private void save_data() { if(m_grv_cong_tac.RowCount < 1) { XtraMessageBox.Show("Chưa có dữ liệu để lưu!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if(!check_all_is_ok()) { return; } SplashScreenManager.ShowForm(this, typeof(SplashScreen1), true, true, false); US_GD_CONG_TAC v_us_gd_ct = new US_GD_CONG_TAC(); int v_i_row = 0; try { for(v_i_row = 0; v_i_row < m_grv_cong_tac.RowCount; v_i_row++) { v_us_gd_ct.BeginTransaction(); v_us_gd_ct.ClearAllFields(); var data = m_grv_cong_tac.GetDataRow(v_i_row); grid_to_us_gd_cong_tac(v_us_gd_ct, data); v_us_gd_ct.Insert(); v_us_gd_ct.CommitTransaction(); SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, (int)((decimal)v_i_row / (decimal)m_grv_cong_tac.RowCount * 100)); } //Sau do phai cap nhat lai so ho so, chua biet lam CHRM_BaseMessages.MsgBox_Infor("Đã lưu dữ liệu thành công"); } catch(Exception) { if(v_us_gd_ct.is_having_transaction()) { v_us_gd_ct.Rollback(); } if(v_i_row >= 1) { throw new Exception("Có lỗi xảy ra. Dữ liệu lưu chưa thành công!\nĐã lưu thành công đến dòng thứ " + v_i_row + " với mã nhân viên " + m_grv_cong_tac.GetRowCellValue(v_i_row - 1, ExcelCongTac.MA_NHAN_VIEN).ToString()); } else { throw new Exception("Có lỗi xảy ra. Dữ liệu lưu chưa được lưu!"); } throw; } finally { SplashScreenManager.CloseForm(false); } }
private void save_for_lam_thoi_cong_tac(US_GD_CONG_TAC ip_us_ct_lam_thoi) { try { ip_us_ct_lam_thoi.BeginTransaction(); ip_us_ct_lam_thoi.CapNhatHetHieuLucCongTacChinhThucHoacLamThoi(ip_us_ct_lam_thoi.dcID_NHAN_VIEN, ip_us_ct_lam_thoi.datNGAY_BAT_DAU.AddDays(-1)); ip_us_ct_lam_thoi.Insert(); ip_us_ct_lam_thoi.CommitTransaction(); CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); Close(); } catch(Exception) { if(ip_us_ct_lam_thoi.is_having_transaction()) { ip_us_ct_lam_thoi.Rollback(); } throw; } }
private void save_for_kiem_nhiem_cong_tac(US_GD_CONG_TAC ip_us_ct_lam_thoi) { try { ip_us_ct_lam_thoi.BeginTransaction(); ip_us_ct_lam_thoi.Insert(); ip_us_ct_lam_thoi.CommitTransaction(); CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); Close(); } catch(Exception) { if(ip_us_ct_lam_thoi.is_having_transaction()) { ip_us_ct_lam_thoi.Rollback(); } throw; } }
private void save_for_chuyen_cong_tac(US_GD_CONG_TAC ip_us_ct_hien_tai) { try { if(ip_us_ct_hien_tai.KiemTraNhanVienCoCongTacChua(ip_us_ct_hien_tai.dcID_NHAN_VIEN, ip_us_ct_hien_tai.dcID_DON_VI)) { XtraMessageBox.Show("Nhân viên đang làm việc ở đơn vị này rồi!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ip_us_ct_hien_tai.BeginTransaction(); ip_us_ct_hien_tai.CapNhatHetHieuLucCongTacChinhThucHoacLamThoi(ip_us_ct_hien_tai.dcID_NHAN_VIEN, ip_us_ct_hien_tai.datNGAY_BAT_DAU.AddDays(-1)); ip_us_ct_hien_tai.Insert(); ip_us_ct_hien_tai.CommitTransaction(); CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); Close(); } catch(Exception) { if(ip_us_ct_hien_tai.is_having_transaction()) { ip_us_ct_hien_tai.Rollback(); } throw; } }
private void save_data() { US_GD_CONG_TAC v_us_gd_ct = new US_GD_CONG_TAC(); form_2_us_gd_cong_tac(ref v_us_gd_ct); try { switch(m_e_loai_cap_nhat) { case e_loai_cap_nhat.THEM_MOI_CONG_TAC: v_us_gd_ct.Insert(); CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_LUU_DU_LIEU_THANH_CONG); break; case e_loai_cap_nhat.LAM_THOI_CONG_TAC: save_for_lam_thoi_cong_tac(v_us_gd_ct); break; case e_loai_cap_nhat.KIEM_NHIEM_CONG_TAC: save_for_kiem_nhiem_cong_tac(v_us_gd_ct); break; case e_loai_cap_nhat.CHUYEN_CONG_TAC: save_for_chuyen_cong_tac(v_us_gd_ct); break; case e_loai_cap_nhat.CHAM_DUT_CONG_TAC: save_for_cham_dut_cong_tac(v_us_gd_ct); break; case e_loai_cap_nhat.UPDATE: v_us_gd_ct.Update(); break; default: break; } } catch(Exception v_e) { v_us_gd_ct.Rollback(); CSystemLog_301.ExceptionHandle(v_e); } }
private void save_data() { US_GD_CONG_TAC v_us_gd_ct = new US_GD_CONG_TAC(); form_2_us_gd_cong_tac(v_us_gd_ct); try { switch (m_e_form_mode) { case DataEntryFormMode.InsertDataState: if (m_id_gd_ct != -1) { //Nhan vien da co GD cong tac if (m_loai_ctac_cthuc == true && CIPConvert.ToDecimal(m_sle_chon_loai_cong_tac.EditValue) == CONST_ID_LOAI_CONG_TAC.CHINH_THUC) { cho_gd_ct_da_xoa_Y(); } } v_us_gd_ct.BeginTransaction(); v_us_gd_ct.Insert(); v_us_gd_ct.CommitTransaction(); break; case DataEntryFormMode.UpdateDataState: v_us_gd_ct.BeginTransaction(); v_us_gd_ct.Update(); v_us_gd_ct.CommitTransaction(); break; default: break; } } catch (Exception v_e) { v_us_gd_ct.Rollback(); CSystemLog_301.ExceptionHandle(v_e); } }