Beispiel #1
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     if (ValidateForm())
     {
         char Sex;
         if (rbMale.Checked == true)
         {
             Sex = 'M';
         }
         else
         {
             Sex = 'F';
         }
         Model_Role     role  = (Model_Role)cbxRole.SelectedItem;
         Model_Employee model = new Model_Employee(textBoxFirstName.Text,
                                                   Sex, dateTimePicker1.Value.Date,
                                                   textBoxPhoneNumber.Text,
                                                   textBoxAddress.Text,
                                                   role);
         try
         {
             GlobalConfig.Connection.InsertNewEmployee(model);
         }
         catch
         {
             MessageBox.Show("Lỗi Thêm Nhân viên vào Database Liên hệ Thảo để fix :)", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         MessageBox.Show("Thêm nhân viên Thành công", "Thông Báo", MessageBoxButtons.OK);
         this.Dispose();
     }
 }
Beispiel #2
0
 public Model_Role CreateNew_Role(Model_Role model)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnectionString("Clothes")))
     {
         var p = new DynamicParameters();
         p.Add("@Name", model.Name);
         p.Add("@id", 0, DbType.Int32, direction: ParameterDirection.Output);
         connection.Execute("dbo.NewRole", p, commandType: CommandType.StoredProcedure);
         model.ID = p.Get <int>("@id");
         return(model);
     }
 }
Beispiel #3
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (Validation())
     {
         Model_Employee em   = new Model_Employee();
         Model_Role     role = new Model_Role();
         em.ID          = textBoxID.Text;
         em.Name        = textBoxName.Text;
         em.DateOfBirth = dateOfbirth.Value;
         em.Address     = textBoxAddress.Text;
         em.PhoneNumber = textBoxPhoneNumber.Text;
         role           = (Model_Role)comboBoxRole.SelectedItem;
         em.Role        = role;
         if (radioButtonNam.Checked == true)
         {
             em.Sex = 'M';
         }
         else
         {
             em.Sex = 'F';
         }
         try
         {
             GlobalConfig.Connection.UpdateEmployee(em);
             WireData();
         }
         catch (Exception t)
         {
             MessageBox.Show($"Lỗi không update được  {t}");
         }
         finally
         {
             DeActiveBtn();
         }
     }
 }
Beispiel #4
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     if (textbox_Input.Text != "")
     {
         //Category
         if (Type == 1)
         {
             Model_Category model = new Model_Category();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Category(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm loại Sản Phẩm  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Color
         else if (Type == 2)
         {
             Model_Color model = new Model_Color();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Color(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Màu Sắc  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Manufactured
         else if (Type == 3)
         {
             Model_Manufactured model = new Model_Manufactured();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Manufactured(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Nhà Sản Xuất  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Material
         else if (Type == 4)
         {
             Model_RawMaterial model = new Model_RawMaterial();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_RawMaterial(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Nguyên Liệu  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Object
         else if (Type == 5)
         {
             Model_Object model = new Model_Object();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Object(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Đối Tượng  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Season
         else if (Type == 6)
         {
             Model_Season model = new Model_Season();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Season(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Mùa  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Size
         else if (Type == 7)
         {
             Model_Size model = new Model_Size();
             model.Size = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Size(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Kích cỡ :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         //Role
         else if (Type == 8)
         {
             Model_Role model = new Model_Role();
             model.Name = textbox_Input.Text;
             try
             {
                 GlobalConfig.Connection.CreateNew_Role(model);
             }
             catch
             {
                 MessageBox.Show("Lỗi Câu lệnh SQL Thêm Chức Vụ  :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK);
                 return;
             }
         }
         MessageBox.Show("Nhập Thông tin Thành Công ", "Thông Báo", MessageBoxButtons.OK);
         this.Dispose();
     }
     else
     {
         MessageBox.Show("Xin hãy kiểm tra lại thông tin ", "Thông Báo", MessageBoxButtons.OK);
     }
 }