判断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. 记录python之递归函数

    函数move(n,a,b,c)的定义是将n个圆盘从a借助b移动到c. def move(n,a,b,c): if n==1: print a,'-->',c move (n-1,a,c,b) p ...

  2. 调用Windows属性窗口

    简述 在Windows系统下.可以通过:右键 -> 属性,来查看文件/文件夹对应的属性信息,包括:常规.安全.详细信息等. 简述 共有类型 共有类型 首先,需要包含头文件: #include & ...

  3. [Transducer] Create a Sequence Helper to Transduce Without Changing Collection Types

    A frequent use case when transducing is to apply a transformation to items without changing the type ...

  4. Maven配置Spring+SpringMVC+MyBatis(3.2.2)Pom 以及 IntelliJ IDEA 怎样打开依赖视图

    Maven配置Spring+SpringMVC+MyBatis(3.2.2)Pom 配置原则: 利用依赖,将所需的jar包加载到project中. 先依赖主要jar包 Spring + Spring ...

  5. 关于Android制作.9.png图片

    第一个问题,.9格式的图片与我们之前的一般图片有什么问题呢? 这是安卓开发里面的一种特殊的图片. 这样的格式的图片在android 环境下具有自适应调节大小的能力. (1)同意开发者定义可扩展区域,当 ...

  6. RISC设计原则及基本技术

    CISC的特点: 指令系统庞大,指令功能复杂,指令寻址方式多,指令格式多 绝大多数指令须要多个机器周期完毕 各种指令都能够訪问存储器 採用微程序控制 有专用寄存器,少量 难以用优化编译技术生成高效的目 ...

  7. 安卓实训第四天--基于HttpClient来完毕数据在server和设备间的交互。

    上午:老师首先回想了昨天作业. 首先在安卓project中的TOOLS文件里,解析字节流那里,不用改变.而是把server端的编码方式变为UTF-8,然后将在安卓project的LoginActivi ...

  8. CUDA学习笔记(三)

    近期对CUDA的理解,是对库的利用. 1 nvcc.exe是CUDA C编译器. 2 cudart.dll是CUDA运行时API动态链接库. 3 在Sdk目录下,\lib有CUTIL.CUDPP等函数 ...

  9. SVN: repository browser 库浏览器

    SVN: repository browser  库浏览器 -----如果不想全部下载,可以通过repository browser  库浏览器 从库中选择要下载的文件夹内容下载(svn针对性下载)

  10. T_SQL 日期函数

    日期函数基数表达式的日期和时间或者是从时间间隔中返回值. GETDATE(),返回当前系统的日期和时间.例: SELECT GETDATE();  结果为:2010-05-18 15:53:08.92 ...