Пример #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (this.textBox4.Text.Trim() != string.Empty && this.textBox5.Text.Trim() != string.Empty && this.textBox6.Text.Trim() != string.Empty && this.comboBox2.Text.Trim() != string.Empty)
     {
         if (this.comboBox2.Text.Trim() == "master")
         {
             Form4 f4 = new Form4();
             f4.Owner = this;
             f4.judge = this.rank;
             f4.ShowDialog();
             if (f4.centect == 1)
             {
                 int           clientnumber = Convert.ToInt32(this.textBox4.Text.Trim());
                 string        clientname   = this.textBox5.Text.Trim();
                 string        clientcode   = this.textBox6.Text.Trim();
                 string        clientpower  = this.comboBox2.Text.Trim();
                 SqlConnection conn;
                 conn = new SqlConnection("Data Source=.;Initial Catalog=商品库存管理;Integrated Security=True");
                 conn.Open();
                 string         find = "insert into[商品库存管理].[dbo].[用户表] values(" + "" + clientnumber + "" + ", '" + clientname + "', '" + clientcode + "', '" + clientpower + "')";
                 SqlDataAdapter code = new SqlDataAdapter(find, conn);
                 DataSet        dt   = new DataSet();
                 code.Fill(dt, "perform");
                 string find2 = "select*"
                                + " from [商品库存管理].[dbo].[用户表]"
                                + " where [商品库存管理].[dbo].[用户表].用户编号=" + "" + clientnumber + "";
                 SqlDataAdapter code5 = new SqlDataAdapter(find2, conn);
                 DataSet        dg    = new DataSet();
                 code5.Fill(dg, "perform");
                 dataGridView1.DataSource = dg.Tables["perform"];
                 MessageBox.Show("插入成功!");
                 conn.Close();
             }
             else
             {
                 MessageBox.Show("重新输入密码");
             }
         }
         else if (this.comboBox2.Text.Trim() == "security" || this.comboBox2.Text.Trim() == "insert" || this.comboBox2.Text.Trim() == "inner" || this.comboBox2.Text.Trim() == "waiter")
         {
             int           clientnumber = Convert.ToInt32(this.textBox4.Text.Trim());
             string        clientname   = this.textBox5.Text.Trim();
             string        clientcode   = this.textBox6.Text.Trim();
             string        clientpower  = this.comboBox2.Text.Trim();
             SqlConnection conn;
             conn = new SqlConnection("Data Source=.;Initial Catalog=商品库存管理;Integrated Security=True");
             conn.Open();
             string         find = "insert into[商品库存管理].[dbo].[用户表] values(" + "" + clientnumber + "" + ", '" + clientname + "', '" + clientcode + "', '" + clientpower + "')";
             SqlDataAdapter code = new SqlDataAdapter(find, conn);
             DataSet        dt   = new DataSet();
             code.Fill(dt, "perform");
             string find2 = "select*"
                            + " from [商品库存管理].[dbo].[用户表]"
                            + " where [商品库存管理].[dbo].[用户表].用户编号=" + "" + clientnumber + "";
             SqlDataAdapter code5 = new SqlDataAdapter(find2, conn);
             DataSet        dg    = new DataSet();
             code5.Fill(dg, "perform");
             dataGridView1.DataSource = dg.Tables["perform"];
             MessageBox.Show("插入成功!");
             conn.Close();
         }
         this.comboBox1.Text = "显示所有";
     }
     else
     {
         MessageBox.Show("请填写满!");
     }
 }
Пример #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (cater == 1)
     {
         Form4 f4 = new Form4();
         f4.Owner = this;
         f4.line  = line;
         f4.judge = this.rank;
         f4.ShowDialog();
         if (f4.centect == 1)
         {
             Form10 account = new Form10();
             account.Owner = this;
             account.ShowDialog();
             name = account.name;
             string code = this.textBox1.Text.Trim();
             if (code != string.Empty)
             {
                 SqlConnection conn;
                 conn = new SqlConnection("Data Source=.;Initial Catalog=商品库存管理;Integrated Security=True");
                 conn.Open();
                 string charge = "update [商品库存管理].[dbo].[用户表]"
                                 + "set [商品库存管理].[dbo].[用户表].用户密码='" + code + "'"
                                 + "where [商品库存管理].[dbo].[用户表].用户名='" + name.Trim() + "'";
                 SqlDataAdapter c1  = new SqlDataAdapter(charge, conn);
                 DataSet        cou = new DataSet();
                 int            i   = c1.Fill(cou);
                 if (i != 0)
                 {
                     MessageBox.Show("成功修改密码");
                 }
                 else
                 {
                     MessageBox.Show("成功修改密码");
                 }
                 conn.Close();
             }
             else
             {
             }
             string getname = this.textBox2.Text.Trim();
             if (getname != string.Empty)
             {
                 SqlConnection conn;
                 conn = new SqlConnection("Data Source=.;Initial Catalog=商品库存管理;Integrated Security=True");
                 conn.Open();
                 string save = "update [商品库存管理].[dbo].[用户表]"
                               + "set [商品库存管理].[dbo].[用户表].用户名='" + getname + "'"
                               + "where [商品库存管理].[dbo].[用户表].用户名='" + name + "'";
                 SqlDataAdapter c2   = new SqlDataAdapter(save, conn);
                 DataSet        cou2 = new DataSet();
                 int            i    = c2.Fill(cou2);
                 if (i != 0)
                 {
                     MessageBox.Show("成功修改用户名");
                 }
                 else
                 {
                     MessageBox.Show("成功修改用户名");
                 }
                 conn.Close();
             }
             else
             {
             }
         }
         else
         {
         }
     }
     else
     {
         MessageBox.Show("输入要更改的东西");
     }
 }