判断1.ds不能为空 2.ds的表数量必须大于0 3.判断ds的第一个表中的行数必须有
if (ds.Tables.Count > 0 && ds != null && ds.Tables[0].Rows.Count > 0)
首先ds不能为空,然后ds大集合里的table要有(数量>0)ds.tables.count>0 ds.tables[0].Rows.Count>0
窗体位于屏幕中心 strtposition
form前提下 acceptbutton canclebutton
Tabindex table键 不需要的设为0
MaximizeBox--false 最大框禁用

panle radiobutton 年级GropDownList
groupBox 容器 panl 面板 radiobutton放在Panle中,实现单选互斥
菜单项 toolstrip menustrip
menustrip一用于左上角,如文件,编辑...之类的;
ContextMenuStrip是你单击出来修改,删除,这样之类的

!!!!!!!!!!!!!!!ToolStrip 介个控件很实用,很实用!!!!!!!!!!!!!!!!!!!

strvalue = comboBox1.SelectedValue.ToString();~~~~~~~~~~~~~~~~~~~~~~~~~~SelectedValue=DisplayMember+ValueMember

登录的时候要想密码和账号都匹配 就需要在select语句时:
select * from UserLogin where LoginName='" + username + "' and Loginpwd='" + userpwd + "'
传参数username userpwd

当重置按钮的时候,要给用户名获得焦点: txtUsername.Focus();
txtUsername.Text = ""; txtpwd.Text = "";

登录事件都是点击提交的时候进行事件的运行,所以主代码都要写到btn_Sumit中

为什么要进行异常处理:
代码错误 资源不可用 公共语言运行库遇到意外 ....多种原因

Exception是异常的基类
IOException SQLException Exception 开发人员
try{可能出现的异常} catch(Exception ex){异常处理} ----consoele.writeLine();
try
{s
File.Delete("C:/test/aa.txt");//第一段异常
//第二顿异常
SqlConnection conn = new SqlConnection("server=.;database=student;integrated security=true");
conn.Open();
conn.Close();
//异常代码
int i = 100;
int j = 0;
int k = i / j;

}

catch (IOException h)
{
Console.WriteLine("出现IO异常:" + h.ToString());
throw h;错误在其他信息中
}
catch (SqlException ex)
{
Console.WriteLine("出现IO异常:" + ex.ToString());
Console.WriteLine("错误信息是"+ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("出现其他异常:"+ ex.ToString());

}
Console.ReadKey();

要更改控件属性头名字:
DataTable dt = new System.Data.DataTable();
dt = SaleBLL.BuyInGoodsListBLL.BuyInGoodsList(); 先绑定数据源先绑定数据源先绑定数据源先绑定数据源先绑定数据源先绑定数据源
dataGridView1.DataSource = dt;
dataGridView1.Columns[0].HeaderText = "ID编号";
dataGridView1.Columns[1].HeaderText = "学生编号";
dataGridView1.Columns[2].HeaderText = "学生姓名";
dataGridView1.Columns[3].HeaderText = "性别";

DataTable dt = NewsBLL.GetNewsType();
DropDownList1.DataValueField = "NewID";
DropDownList1.DataTextField = "NewName";
DropDownList1.DataSource = dt;
DropDownList1.DataBind();

public void GetGrade()
{
Grade Gd=new Grade();
GrideList.ValueMember="ID"; DataValueFiled="ID";
GrideList.DisplayMember="name"; DataTextField="name";

selectText=name
selectvalue=ID

}

this.txtUser.text.trim()=="";
this.txtUser.text.trim().Equals(string.Empty)性能更好,更优化,空间的开辟

MessageBox.Show("你好", "取消", MessageBoxButtons.OK, MessageBoxIcon.Error);

dataDataReader返回的是TRUE false 结束后必须关闭数据库

string.Empty 不占用空间 "" 占用空间
DialogResult 对话框

DataTable dt = TransBLL.ComBoxBLL.GetProList();
comboBox1.DataSource = dt;
DataRow dr = dt.NewRow();
dr["ProvinceName"] = "请选择";
dt.Rows.InsertAt(dr, 0);
comboBox1.ValueMember = "ProvinceName";
comboBox1.SelectedIndex = 0;

——————————————————————@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@————————————————————————————————
窗体之间的跳转就是将目标窗体在本窗体代码中实例化一下,然后showDilog一下

给DataGrview添加事件
selectionMode的值变成FullRowSelect
private void dataGridView1_Click(object sender, EventArgs e)
{
this.tBoxName.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
this.tBoxGoodsStyle.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
。。。。。。
}

将winform窗体中获取的修改的值传递给model中的值
Modeltb_Goods GG = new Modeltb_Goods();
GG.BarCode = bar;
GG.GoodsName = name;
GG.GoodsSize = size;
GG.GoodsTypeID = ConvertType(style);//要写一个装换的方法
GG.JinPrice = jin;
GG.PiFaPrice = PiFa;
GG.LingPrice = Ling;
GG.CurrentNum = currNum;
GG.GoodsNote = Note;
GG.GoodsProduct = Pro;

//获取点击行的ID
int ID =Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
GG.GoodsID = ID;
int result = SaleBLL.GoodsMangerBLL.Update(GG);/

————————————@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@—————————————————————
要想出现那个删除的按钮,就是在控件中添加contextMenuStrip控件
!!!!!!!!!!!!在datadriview中有一个contextMenuStrip属性,值指向contextMenuStrip1
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{}

由主窗体跳转到子窗体的时候,主窗体有一个ISMdiContainer属性设置为TRUE;!!!!!!!!!!!!!!!!!!
private void 添加货物ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!ShowChildrenForm("AddGoods"))
{
AddGoods AG = new AddGoods();//将要打开的窗体实例化
AG.MdiParent = this;//要子窗体的父窗体设置为当前窗体
AG.Show();
}
}
/// <summary>
/// 防止子窗体重复出现
/// </summary>
/// <param name="ChildFormName">把子窗体的name传递过来</param>
/// <returns></returns>
private bool ShowChildrenForm(string ChildFormName)
{
int i;
for (i = 0; i < this.MdiChildren.Length; i++)
{
//判断子窗体是否已经打开
if (this.MdiChildren[i].Name == ChildFormName)
{
//如果子窗体已经打开,设置子窗体位焦点
this.MdiChildren[i].Activate();
return true;
}
}
return false;

}
------------@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@———————————————————
弹出框的确定 取消
DialogResult dr=MessageBox.Show("确定要删除吗?","删除",MessageBoxButtons.YesNoCancel);
if (dr == DialogResult.Yes){}
else{return;}

int ID =Convert.ToInt32( dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

---------------------------------@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@______________________-----------
/// <summary>
///选择dataGriview里的一行,传到修改里去,前提dataGriview的selectMode属性变成一行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_Click(object sender, EventArgs e)
{
this.tBoxBar.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
this.tBoxName.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
this.tBoxSize.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
this.CmbStyle.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
this.tBoxBuyIn.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
this.tBoxPiFa.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
this.tBoxLPrice.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
this.tBoxCurNum.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
this.tBoxNote.Text= dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
this.tBoxProduct.Text = dataGridView1.SelectedRows[0].Cells[10].Value.ToString();

}
----------------------------------------------------字符串分割----------------------------------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
//循环输出所有字符
string txtinput = textBox1.Text.Trim();
foreach (char item in txtinput)
{
//MessageBox.Show(item.ToString());
}
for (int i = 0; i < txtinput.Length; i++)
{
MessageBox.Show(txtinput[i].ToString());
}
}

private void button1_Click(object sender, EventArgs e)
{
string txtinput = textBox1.Text.Trim();
string[] str = txtinput.Split(',');//按照特定的符号进行分割
foreach (string item in str)
{
// MessageBox.Show(item.ToString());
}
for (int i = 0; i < str.Length; i++)
{
MessageBox.Show(str[i]);
}
}
------------------------------------------------------------------------------------------------------------------------------------------
从登录页面传登录类型,以便frm_main 页面的显示情况
string s_LoginName = "";
string s_Role = "";
public Frm_main(string strLoginName,string strRole)
{
InitializeComponent();
s_LoginName = strLoginName;
s_Role = strRole;
if(s_Role=="普通人")
{
管理员系统ToolStripMenuItem.Visible = false;
管理员列表ToolStripMenuItem.Visible = false;
购物管理ToolStripMenuItem.Visible = false;
添加货物ToolStripMenuItem.Visible = false;
}
}
------------------------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// 检查数据库中是否存在用户
/// </summary>
/// <param name="MM"></param>
/// <returns></returns>
public static int CheckUsers(ModelManger MM)
{
SqlConnection conn = new SqlConnection("server=.;initial Catalog=GoodsManger;integrated security=true;");
conn.Open();
string strsql = "select Adminion from Manger where Adminion=@Admin";
SqlParameter sps = new SqlParameter("@Admin",MM.Adminion);
object obj = sqlhelper.GetExecuteScalar(strsql, sps);
if (obj != null && obj.ToString() != "")
{
return 1;
}
else
{
return 0;
}
}
---------------------------------------------------------------------------------------------------------------
/// <summary>
/// 查看登录人的权限是否正确
/// </summary>
/// <param name="MM"></param>
/// <returns></returns>
public static string Match(ModelManger MM)
{
SqlConnection conn = new SqlConnection("server=.;initial Catalog=GoodsManger;integrated security=true;");
conn.Open();
string strsql = "select LimiterName from Manger where Adminion=@Admin";
SqlParameter sps = new SqlParameter("@Admin", MM.Adminion);
return sqlhelper.GetExecuteScalar(strsql, sps).ToString();//ToString() 是将数据库中相对应的名字取出来
}
------------------------------------------------------------------------------------------------------------------------
Frm_main Fm = new Frm_main(name, sss);传递窗体用户名
Fm.Show();
string s_LoginName = "";
string s_Role = "";
public Frm_main(string strLoginName,string strRole)
{
InitializeComponent();
s_LoginName = strLoginName;
s_Role = strRole;
if(s_Role=="普通人")
{
管理员系统ToolStripMenuItem.Visible = false;
管理员列表ToolStripMenuItem.Visible = false;
购物管理ToolStripMenuItem.Visible = false;
添加货物ToolStripMenuItem.Visible = false;

}
toolStripStatusLabel2.Text = s_LoginName;
}

Win form碎知识点的更多相关文章

  1. Win Form程序线程点点

    消息循环 Win32窗体程序基于消息驱动的,程序的模型就是一个用户触发事件消息->系统分发事件消息->程序处理事件的循环过程. .NET Win Form程序对消息循环进行了封装,可以看到 ...

  2. WPF / Win Form:多线程去修改或访问UI线程数据的方法( winform 跨线程访问UI控件 )

    WPF:谈谈各种多线程去修改或访问UI线程数据的方法http://www.cnblogs.com/mgen/archive/2012/03/10/2389509.html 子线程非法访问UI线程的数据 ...

  3. WPF调用Win Form

    WPF是win form的下一代版本,现在越来越多的公司使用WPF.如何兼容已有的使用win form开发的应用程序呢?下面有三种方式来在WPF中调用win form. 使用WPF中的WindowsF ...

  4. vue散碎知识点学习

    1. vue散碎知识点学习 1.1. 特点 数据渲染/数据同步 组件化/模块化 其他功能路由,ajax,数据流 1.2. Vue.js学习资源 vuejs中文官网:http://cn.vuejs.or ...

  5. js的form基础知识点

    在HTML 中,表单是由<form>元素来表示的,而在JavaScript 中,表单对应的则是HTMLForm-Element 类型.HTMLFormElement 继承了HTMLElem ...

  6. JS一些碎知识点

    一些js基本知识点 Doctype 浏览器渲染模式 渲染模式发展历史 在多年以前(IE6诞生以前),各浏览器都处于各自比较封闭的发展中(基本没有兼容性可谈).随着WEB的发展,兼容性问题的解决越来越显 ...

  7. c# win form 显示支付宝二维码图片

    System.Net.WebClient web = new System.Net.WebClient(); byte[] buffer = web.DownloadData(网络图片的地址); we ...

  8. Win Form不能响应键盘事件

    在窗体属性中,将KeyPreview设置为true

  9. .NET(C#) win Form窗体的常用属性以及事件

    使用.Net编写Windows程序,对于窗体控制常见项目 属性:1.让窗体在启动时在指定位置出现 form1.StartPosition Manual CenterScreen WindowsDefa ...

随机推荐

  1. jsp页面跳转的路径问题

    <form class="box login" action="/graduation_system/BServlet" method="pos ...

  2. 对于树的序列化,用了stream,很好

    https://leetcode.com/problems/serialize-and-deserialize-binary-tree/?tab=Description 下面这个解法里面的C++部分很 ...

  3. Effective C++ 11-17

    11.为须要动态分配内存的类声明一个拷贝构造函数和一个赋值操作符. 显然,由于动态内存分配,绝对会有深浅拷贝的问题,要重写拷贝构造函数.使其为深拷贝,才干实现真正意义上的拷贝.这是我理解的关于要声明拷 ...

  4. ios开发经常使用到的第三方库

    由于iOS SDK相对照较底层,所以开发人员就得受累多做一些体力活.只是幸运的是,有非常多第三方的类库能够用来简化非常多不必要的工作.经过作者团队的谨慎讨论.他们 评选出了10款可以极大提高iOS开发 ...

  5. JavaScript编程随笔

    尽管说用JS非常多年了,可是却一直停留在肤浅的阶段,对JS的机制原理依旧是一知半解,比如:闭包.尽管能说出一二.却不能说出三四,确实羞愧.近期恶补一番.并将比較与大家分享,希望对大家有些帮助. 闭包 ...

  6. delphi网络函数大全

    {=========================================================================功 能: 网络函数库时 间: 2002/10/02版 ...

  7. 面向对象(OOP)五大基本原则

    书单 <Object-Oriented Analysis & Design with Application>:Grady Booch, 下载地址:object-oriented- ...

  8. 6. MongoDB——Java操作(增删改查)

    转自:https://blog.csdn.net/kai402458953/article/details/79626148 import java.net.UnknownHostException; ...

  9. Hive框架基础(一)

    * Hive框架基础(一) 一句话:学习Hive有毛用? 那么解释一下 毛用: * 操作接口采用类SQL语法,提供快速开发的能力(不会Java也可以玩运算) * 避免了去写MapReduce,减少开发 ...

  10. codeforces 400 C Inna and Huge Candy Matrix【模拟】

    题意:给出一个矩形的三种操作,顺时针旋转,逆时针旋转,对称,给出原始坐标,再给出操作数,问最后得到的坐标 画一下模拟一下操作就可以找到规律了 #include<iostream> #inc ...