예제 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     m_CustomerObject = new CCustomerDTO(txtCustomerId.Text, txtCustomerName.Text, cmbCustomerGender.Text,
                                         dateBirthDay.DateTime, txtCustomerAddress.Text, txtCustomerPhone.Text, txtCustomerEmail.Text, 0);
     m_CustomerExecute.AddCustomerToDatabase(m_CustomerObject);
     m_CustomerData             = m_CustomerExecute.getCustomerDataFromDatabase();
     grdListCustomer.DataSource = m_CustomerData;
     //
     btnDelete.Enabled = true;
     btnUpdate.Enabled = true;
     btnCancel.Visible = false;
 }
예제 #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!checkData())
     {
         return;
     }
     try
     {
         if (m_IsAdd)
         {
             m_CustomerObject = new CCustomerDTO("KH0000000", txtCustomerName.Text, cmbCustomerGender.Text,
                                                 dateBirthDay.DateTime, txtCustomerAddress.Text,
                                                 txtCustomerPhone.Text, txtCustomerEmail.Text, 0);
             if (m_CustomerExecute.AddCustomerToDatabase(m_CustomerObject))
             {
                 XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true);
             }
             else
             {
                 XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true);
             }
         }
         else
         {
             m_CustomerObject = new CCustomerDTO(txtCustomerId.Text, txtCustomerName.Text, cmbCustomerGender.Text,
                                                 dateBirthDay.DateTime, txtCustomerAddress.Text, txtCustomerPhone.Text,
                                                 txtCustomerEmail.Text, (int)spCustomerDebit.Value);
             if (m_CustomerExecute.UpdateCustomerToDatabase(m_CustomerObject))
             {
                 XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true);
             }
             else
             {
                 XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true);
             }
         }
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnSave);
     }
 }