Exemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         m_Charge = new CChargeDTO(txtChargeId.Text, txtChargeName.Text);
         m_ChargeBus.AddChargeToDatabase(m_Charge);
         m_ChargeData                    = m_ChargeBus.getChargeDataFromDatabase();
         grdListCharge.DataSource        = m_ChargeData;
         grdvListCharge.FocusedRowHandle = grdvListCharge.DataRowCount - 1;
     }
     catch (System.Exception ex)
     {
         XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!CheckInformationEntered.checkDataInput(txtChargeName, "Không thể để trống dữ liệu!", ref dxErrorProvider))
     {
         return;
     }
     try
     {
         if (m_IsAdd)
         {
             m_Charge = new CChargeDTO("CV0000000", txtChargeName.Text);
             if (m_ChargeBus.AddChargeToDatabase(m_Charge))
             {
                 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_Charge          = new CChargeDTO(txtChargeId.Text, txtChargeName.Text);
             m_Charge.maChucVu = txtChargeId.Text;
             if (m_ChargeBus.UpdateChargeToDatabase(m_Charge))
             {
                 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 thất bại", "Lỗi", true);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnSave);
     }
 }