コード例 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (m_IsAdd)
         {
             m_AuthorObject = new CAuthorDTO(txtAuthorId.Text, txtAuthorName.Text, txtAuthorAddress.Text);
             m_AuthorExecute.AddAuthorToDatabase(m_AuthorObject);
         }
         else
         {
             m_AuthorObject = new CAuthorDTO(txtAuthorId.Text, txtAuthorName.Text, txtAuthorAddress.Text);
             m_AuthorExecute.UpdateAuthorToDatabase(m_AuthorObject);
             m_AuthorData                    = m_AuthorExecute.getAuthorDataFromDatabase();
             grdListAuthor.DataSource        = m_AuthorData;
             grdvListAuthor.FocusedRowHandle = grdvListAuthor.DataRowCount - 1;
         }
     }
     catch (System.Exception ex)
     {
         XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnSave);
     }
 }
コード例 #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!checkData())
     {
         return;
     }
     try
     {
         if (m_IsAdd)
         {
             m_AuthorObject = new CAuthorDTO("TG000000", txtAuthorName.Text, txtAuthorAddress.Text);
             if (m_AuthorExecute.AddAuthorToDatabase(m_AuthorObject))
             {
                 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_AuthorObject = new CAuthorDTO(txtAuthorId.Text, txtAuthorName.Text, txtAuthorAddress.Text);
             if (m_AuthorExecute.UpdateAuthorToDatabase(m_AuthorObject))
             {
                 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 ex)
     {
         XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnSave);
     }
 }