Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (button1.Text.Equals("Lưu lại"))
     {
         if (txtDeptID.Text.Equals(""))
         {
             Alert.Show("Bạn phải nhập mã", Color.Red);
             return;
         }
         //cmbCate.SelectedIndex = 0;
         DataRowView item = (DataRowView)cmbCate.SelectedItem;
         DataTable   tmp  = get_service.GetAllDepartmentsByDeptId(txtDeptID.Text, StaticClass.storeId);
         DataTable   tmp1 = get_service.GetInventoryByItemNum(StaticClass.storeId, txtDeptID.Text);
         if (tmp.Rows.Count > 0 || tmp1.Rows.Count > 0)
         {
             Alert.Show("Mã đã tồn tại", Color.Red);
             return;
         }
         int function = 0;
         get_service.CreateDepartment(txtDeptID.Text, StaticClass.storeId, item.Row[0].ToString(),
                                      txtDeptDesc.Text, getType(), checkBox1.Checked, textBox1.Text,
                                      checkBox2.Checked, checkBox3.Checked, checkBox4.Checked,
                                      Convert.ToDouble(creTextBox1.Text), Convert.ToInt32(creTextBox2.Text),
                                      StaticClass.stationId, "", function, "", StaticClass.BackColorDept,
                                      StaticClass.ForeColor);
         departs = get_service.GetAllDepartments2(StaticClass.storeId);
         limit   = departs.Rows.Count - 1;
     }
     if (sender.Equals(button4))
     {
         AddState(0);
     }
     else
     {
         AddState(1);
     }
 }