判断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. Unity Microphone 无限时长录制

    原创文章:转载请标明出处--博客园 Jason_c Unity可以很方便的通过 Microphone.Start()方法来调用麦克风,但是有一个弊端是,必须传入时长,这就很尴尬了,因为大多数时间,我们 ...

  2. CodeVS 1789 最大获利

    1789 最大获利 2006年NOI全国竞赛  时间限制: 2 s  空间限制: 128000 KB  题目等级 : 大师 Master       题目描述 Description 新的技术正冲击着 ...

  3. 【转】Hook钩子C#实例

    [转]Hook钩子C#实例 转过来的文章,出处已经不知道了,但只这篇步骤比较清晰,就贴出来了. 一.写在最前 本文的内容只想以最通俗的语言说明钩子的使用方法,具体到钩子的详细介绍可以参照下面的网址: ...

  4. [Typescript] Promise based delay function using async / await

    Learn how to write a promise based delay function and then use it in async await to see how much it ...

  5. SGU 210 Acdream 1227 Beloved Sons KM

    题目链接:点击打开链接 题意: 给定n个人 每一个人的点权 以下n行i行表示第i个人能够获得哪些数(数字从1-n.且不能反复分配) 若这个人获得了数字则你能够获得他的权值. 要你能获得的权值和最大. ...

  6. hdu2236

    链接:点击打开链接 题意:在一个n*n的矩阵中,找n个数使得这n个数都在不同的行和列里而且要求这n个数中的最大值和最小值的差值最小 代码: #include <iostream> #inc ...

  7. crazyradio焊接和下载固件过程

    非常早之前买过一套crazyradio的器件和空板.可是一直没有时间焊接出来,前天早上六点起来,安静的弄了一把,识别USB.下载crazyradio固件没问题,记录下过程: 1,首先是焊接,寻常的QF ...

  8. java匿名内部类的使用注意事项

    1.首先匿名内部类要继承自抽象基类或者实现基类接口 like this abstract class Seed{ int cnt; public Seed(int x){ cnt=x; } abstr ...

  9. poj_3371

    一道模拟题,写的有点麻烦 #include<iostream> #include<cstring> #include<cstdio> #include<alg ...

  10. ELK搭建(filebeat、elasticsearch、logstash、kibana)

    ELK部署(文章有点儿长,搭建时请到官网将tar包下载好,按步骤可以完成搭建使用) ELK指的是ElasticSearch.LogStash.Kibana三个开源工具 LogStash是负责数据的收集 ...