i = cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception ) { conn.Close(); } } return i; } } } 登录窗体Form1的代码: using System; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; namespace chaoshiguanlixitong { public partial class Form1 : Form { public static string yhm; public Form1() { InitializeComponent();} private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == \ { label3.Text = \账号或密码不能为空!\ else { string m = \密码 from denglu where 账号='\+ textBox1.Text + \ string g = \管理员 from denglu where 账号='\+ textBox1.Text + \ Sjk d = new Sjk(); if (d.cx(m).Trim() == textBox2.Text) { yhm = textBox1.Text; if (d.cx(g).Trim() == \ { Form2 f2 = new Form2(); f2.Show(); } else { Form3 f3 = new Form3(); f3.Show(); } this.Hide(); } else { label3.Text = \账号或密码错误,请重新输入!\ } } } } 管理员窗口Form2的代码: using System; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; namespace chaoshiguanlixitong { public partial class Form2 : Form { Sjk shujuku = new Sjk(); //定义一个数据库的对象 public static string hh, hl;//想xinhuo窗体传递参数 public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“csglDataSet1.xsb”中。您可以根据需要移动或删除它。 // TODO: 这行代码将数据加载到表“csglDataSet1.spxx”中。您可以根据需要移动或删除它。 // TODO: 这行代码将数据加载到表“csglDataSet.denglu”中。您可以根据需要移动或删除它。 // TODO: 这行代码将数据加载到表“csglDataSet.spxx”中。您可以根据需要移动或删除它。 string h= \用户名 from denglu where 账号='\+ \ label2.Text = Form1.yhm ; this.Text = shujuku .cx(h)+ \(管理员用户)\ } private void button1_Click(object sender, EventArgs e) { DialogResult k1 = MessageBox.Show(\你确定要退出当前用户切换到另一用户?\ if (k1 == DialogResult.Yes) { this.Close(); Form1 f1 = new Form1(); f1.Show(); } } private void button2_Click(object sender, EventArgs e) { DialogResult k1 = MessageBox.Show(\你确定要退出当前用户?\\MessageBoxButtons.YesNo); if (k1 == DialogResult.Yes) { Application.Exit();} } private void button3_Click(object sender, EventArgs e) { int sl=0; if (jhspbh.Text == \ { MessageBox.Show(\商品编号或数量不能为空!\ else { try //判断输入的进货数量是否为数字 { sl = int.Parse(jhsl.Text); } catch { MessageBox.Show(\请输入正确的商品数量!(商品数量必须为大于0的数字)\ jhsl.Text = \ } if (sl > 0) { string sql = \数量=数量+\\商品编号='\ int i=shujuku.xg(sql); if (i>=0) { if (i == 0) { hh = jhspbh.Text; hl = jhsl.Text; xinhuo xh = new xinhuo(); xh.Show(); xh.Visible = false; if (xh.ShowDialog() == DialogResult.OK) { } } MessageBox.Show(\商品添加成功!\ jhspbh.Text = \ jhsl.Text = \ } else { MessageBox.Show(\打开数据库失败,请重试!\ } } } private void button4_Click(object sender, EventArgs e) //商品查询中的“查询”按钮 { if(spcx.Text ==\ { MessageBox.Show(\你还没输入要查询的商品编号呢!\ else { string sql = \* from spxx where 商品编号='\+ spcx.Text + \ string[] j = shujuku.cx(sql, 7).Split(','); label12 . Text = j[0].ToString(); label13 . Text = j[1].ToString(); label15 . Text = j[2].ToString(); label17 . Text = j[3].ToString(); label19 . Text = j[4].ToString(); label21 . Text = j[5].ToString(); label23 . Text = j[6].ToString(); sql = \出售数量 from xsb where 商品编号='\+ spcx.Text + \ label25.Text = shujuku.qh(sql).ToString(); } } private void button7_Click(object sender, EventArgs e) //人员管理中的删除按钮 { if(ryglxm.Text ==\ { MessageBox.Show(\你还没输入要删除的账号呢,不能删除!\ else { if (ryglxm.Text == label2.Text) ///判断要删除的是不是当前登陆用户
相关推荐: