예제 #1
0
 public ThGoodsInfoForm(string EmpID) : this()
 {
     txtEmpID.Text  = EmpID;
     thGoodsInfo    = new tb_ThGoodsInfo();
     thGoodsMenthod = new tb_ThGoodsMenthod();
     thGoodsMenthod.Find(dataGridView1);
 }
예제 #2
0
 //保存按钮
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (IsComplete())
     {
         if (count == 1)  //添加操作
         {
             if (thGoodsMenthod.Add(thGoodsInfo))
             {
                 if (num == txtThGoodsNum.Text)   //置对应的销售记录删除标志为1
                 {
                     string        sqlcmd = "update tb_SellGoods set SellFlag=1 where SellID='" + txtSellID.Text + "'";
                     SqlConnection conn   = (new GetSqlConnection()).GetCon();
                     SqlCommand    cmd    = new SqlCommand(sqlcmd, conn);
                     cmd.ExecuteNonQuery();
                     conn.Dispose();
                 }
                 MessageBox.Show("添加成功");
                 Clear();
                 ChangeToolsStatus();
                 count = 0;
                 thGoodsMenthod.Find(dataGridView1);   //返回操作后的数据库
                 button1.Enabled = false;
                 Ban();
             }
             else
             {
                 MessageBox.Show("添加失败");
                 Clear();
                 ChangeToolsStatus();
                 count           = 0;
                 button1.Enabled = false;
                 Ban();
             }
         }
         if (count == 2)  //修改操作
         {
             if (thGoodsMenthod.Update(thGoodsInfo, this.dataGridView1[3, this.dataGridView1.CurrentCell.RowIndex].Value.ToString()))
             {
                 if (num == txtThGoodsNum.Text)   //置对应的销售记录删除标志为1
                 {
                     string        sqlcmd = "update tb_SellGoods set SellFlag=1 where SellID='" + txtSellID.Text + "'";
                     SqlConnection conn   = (new GetSqlConnection()).GetCon();
                     SqlCommand    cmd    = new SqlCommand(sqlcmd, conn);
                     cmd.ExecuteNonQuery();
                     conn.Dispose();
                 }
                 MessageBox.Show("修改成功");
                 Clear();
                 ChangeToolsStatus();
                 count = 0;
                 thGoodsMenthod.Find(dataGridView1);   //返回操作后的数据库
                 Ban();
             }
             else
             {
                 MessageBox.Show("修改失败");
                 Clear();
                 ChangeToolsStatus();
                 count = 0;
                 Ban();
             }
         }
         if (count == 3)  //删除操作
         {
             if (thGoodsMenthod.Delete(thGoodsInfo.strThGoodsID))
             {
                 MessageBox.Show("删除成功");
                 Clear();
                 ChangeToolsStatus();
                 count = 0;
                 thGoodsMenthod.Find(dataGridView1);   //返回操作后的数据库
             }
             else
             {
                 MessageBox.Show("删除失败");
                 Clear();
                 ChangeToolsStatus();
                 count = 0;
             }
         }
     }
 }