private void save_data() { US_DM_NHAN_VIEN v_us_trans = new US_DM_NHAN_VIEN(); int i = 0; try { SplashScreenManager.ShowForm(typeof(F_wait_form)); v_us_trans.BeginTransaction(); for (i = 0; i < m_grv.RowCount; i++) { US_DM_NHAN_VIEN v_us = new US_DM_NHAN_VIEN(); switch (m_e_form_mode) { case DataEntryFormMode.UpdateDataState: v_us = gan_du_lieu_cho_us_dm_nhan_vien(m_grv.GetDataRow(i)); v_us.UseTransOfUSObject(v_us_trans); v_us.Update(); break; case DataEntryFormMode.InsertDataState: v_us = gan_du_lieu_cho_us_dm_nhan_vien(m_grv.GetDataRow(i)); v_us.Insert(); break; default: break; } } v_us_trans.CommitTransaction(); m_lbl_check.Text = "Đã lưu dữ liệu"; m_lbl_check.ForeColor = Color.Green; CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); } catch (Exception v_e) { XtraMessageBox.Show(i.ToString()); if (v_us_trans.is_having_transaction()) { v_us_trans.Rollback(); } throw; } finally { SplashScreenManager.CloseForm(); } }
void m_cmd_insert_Click(object sender, EventArgs e) { try { if (check_data_is_ok() == false) return; if (CHRM_BaseMessages.MsgBox_Confirm(CONST_ID_MSGBOX.QUESTION_XAC_NHAN_LUU_DU_LIEU) == false) return; if (check_ma_nv_da_ton_tai(m_txt_ma_nv.Text) == true) { US_DM_NHAN_VIEN v_us_nv_4_insert = new US_DM_NHAN_VIEN(); form_2_us_dm_nv(v_us_nv_4_insert); //insert try { v_us_nv_4_insert.BeginTransaction(); v_us_nv_4_insert.Insert(); v_us_nv_4_insert.CommitTransaction(); m_member_is_newbie = 0; } catch (Exception v_e) { v_us_nv_4_insert.Rollback(); throw v_e; } //cho cac control visible false -> true change_visible_of_control(true); //load_data_2_sle_chon_nv load_data_to_all_controls(v_us_nv_4_insert.dcID); load_data_2_ds_v_dm_nv(); m_sle_chon_nhan_vien.EditValue = v_us_nv_4_insert.dcID; CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); } else { if (m_member_is_newbie == 1) { US_DM_NHAN_VIEN v_us_nv_4_insert = new US_DM_NHAN_VIEN(); form_2_us_dm_nv(v_us_nv_4_insert); //insert try { v_us_nv_4_insert.BeginTransaction(); v_us_nv_4_insert.Insert(); v_us_nv_4_insert.CommitTransaction(); m_member_is_newbie = 0; } catch (Exception v_e) { v_us_nv_4_insert.Rollback(); throw v_e; } //cho cac control visible false -> true change_visible_of_control(true); //load_data_2_sle_chon_nv load_data_to_all_controls(v_us_nv_4_insert.dcID); load_data_2_ds_v_dm_nv(); m_sle_chon_nhan_vien.EditValue = v_us_nv_4_insert.dcID; CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); } else { //update US_DM_NHAN_VIEN v_us_nv_4_update = new US_DM_NHAN_VIEN(CIPConvert.ToDecimal(m_sle_chon_nhan_vien.EditValue)); form_2_us_dm_nv(v_us_nv_4_update); v_us_nv_4_update.Update(); CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_DU_LIEU_DA_DUOC_CAP_NHAT); } } change_visible_of_control(true); } catch (Exception v_e) { CSystemLog_301.ExceptionHandle(v_e); } }