private bool is_exist_quyet_dinh(string ip_str_ma_quyet_dinh) { US_DM_QUYET_DINH v_us = new US_DM_QUYET_DINH(); DS_DM_QUYET_DINH v_ds = new DS_DM_QUYET_DINH(); v_us.FillDataset_By_Ma_qd(v_ds, ip_str_ma_quyet_dinh); if (v_ds.DM_QUYET_DINH.Rows.Count > 0) { return(true); } return(false); }
private bool check_is_trung_ma_quyet_dinh() { DS_DM_QUYET_DINH v_ds = new DS_DM_QUYET_DINH(); US_DM_QUYET_DINH v_us = new US_DM_QUYET_DINH(); v_us.FillDataset_By_Ma_qd(v_ds, m_txt_ma_quyet_dinh.Text); if (m_b_check_quyet_dinh_save) { switch (m_e_form_mode) { case DataEntryFormMode.InsertDataState: if (v_ds.DM_QUYET_DINH.Count > 0) { return(true); } break; case DataEntryFormMode.SelectDataState: if (v_ds.DM_QUYET_DINH.Count > 0 && m_txt_ma_quyet_dinh.Text != m_us_v_gd_cong_tac.strMA_QUYET_DINH) { return(true); } break; case DataEntryFormMode.UpdateDataState: break; case DataEntryFormMode.ViewDataState: break; default: break; } } return(false); }
private void us_object_to_form() { m_txt_ma_nv.Text = m_us_v_trang_thai_ld.strMA_NV; m_txt_ho_ten.Text = m_us_v_trang_thai_ld.strHO_DEM + " " + m_us_v_trang_thai_ld.strTEN; m_txt_ma_nv.BackColor = SystemColors.Info; m_txt_ma_nv.ReadOnly = true; m_txt_ho_ten.BackColor = SystemColors.Info; m_txt_ho_ten.ReadOnly = true; m_us_v_trang_thai_ld.FillDatasetByManhanvien_trang_thai_hien_tai(m_ds_v_trang_thai_ld, m_us_v_trang_thai_ld.strMA_NV, CAppContext_201.getCurrentIDPhapnhan()); switch (m_e_form_mode) { case DataEntryFormMode.InsertDataState: if (m_ds_v_trang_thai_ld.V_GD_TRANG_THAI_LAO_DONG.Select("MA_NV is not null").Length > 0) { m_us_v_trang_thai_ld.DataRow2Me((DataRow)m_ds_v_trang_thai_ld.V_GD_TRANG_THAI_LAO_DONG.Rows[0]); m_txt_trang_thai_hien_tai.Text = m_us_v_trang_thai_ld.strTRANG_THAI_LAO_DONG; m_cbo_trang_thai_moi.SelectedValue = m_us_v_trang_thai_ld.dcID_TRANG_LAO_DONG; } else { m_txt_trang_thai_hien_tai.Text = ""; } m_txt_trang_thai_hien_tai.BackColor = SystemColors.Info; m_txt_trang_thai_hien_tai.ReadOnly = true; if (m_us_v_trang_thai_ld.dcID_QUYET_DINH != 0) { US_DM_QUYET_DINH v_us_quyet_dinh = new US_DM_QUYET_DINH(m_us_v_trang_thai_ld.dcID_QUYET_DINH); m_str_link_old = v_us_quyet_dinh.strLINK; if (v_us_quyet_dinh.strLINK == "") { return; } m_lbl_file_name.Text = v_us_quyet_dinh.strLINK; } break; case DataEntryFormMode.UpdateDataState: m_cbo_trang_thai_moi.SelectedValue = m_us_v_trang_thai_ld.dcID_TRANG_LAO_DONG; if (m_us_v_trang_thai_ld.datNGAY_CO_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_co_hieu_luc.Value = m_us_v_trang_thai_ld.datNGAY_CO_HIEU_LUC; } // else // m_dat_ngay_co_hieu_luc.Checked = false; if (m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC != null && m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_het_hieu_luc.Checked = true; m_dat_ngay_het_hieu_luc.Value = m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC; } else { m_dat_ngay_het_hieu_luc.Checked = false; } m_us_quyet_dinh.FillDataset_By_Ma_qd(m_ds_quyet_dinh, m_us_v_trang_thai_ld.strMA_QUYET_DINH); if (m_ds_quyet_dinh.DM_QUYET_DINH.Select("MA_QUYET_DINH is not null").Length > 0) { US_DM_QUYET_DINH v_us_qd = new US_DM_QUYET_DINH(); v_us_qd = new US_DM_QUYET_DINH(m_us_v_trang_thai_ld.dcID_QUYET_DINH); // string[] v_arstr = v_us_qd.strMA_QUYET_DINH.Trim().Split('/'); // m_txt_ma_quyet_dinh.Text = v_arstr[0]; // BKI_HRM.US.US_CM_DM_TU_DIEN v_us = new BKI_HRM.US.US_CM_DM_TU_DIEN(); // BKI_HRM.DS.DS_CM_DM_TU_DIEN v_ds = new BKI_HRM.DS.DS_CM_DM_TU_DIEN(); // decimal v_dc_id = 0; // v_us.FillDatasetByName(v_ds, v_arstr[v_arstr.Length - 1], ref v_dc_id); // m_cbo_ma_quyet_dinh.SelectedValue = v_dc_id; m_txt_ma_quyet_dinh.Text = v_us_qd.strMA_QUYET_DINH; m_us_quyet_dinh.DataRow2Me((DataRow)m_ds_quyet_dinh.DM_QUYET_DINH.Rows[0]); m_cbo_loai_quyet_dinh.SelectedValue = m_us_quyet_dinh.dcID_LOAI_QD; m_dat_ngay_ky.Value = m_us_quyet_dinh.datNGAY_KY; if (m_us_quyet_dinh.datNGAY_CO_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_co_hieu_luc_qd.Value = m_us_quyet_dinh.datNGAY_CO_HIEU_LUC; } // else // m_dat_ngay_co_hieu_luc_qd.Checked = false; if (m_us_quyet_dinh.datNGAY_HET_HIEU_LUC != null && m_us_quyet_dinh.datNGAY_HET_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_het_hieu_luc_qd.Checked = true; m_dat_ngay_het_hieu_luc_qd.Value = m_us_quyet_dinh.datNGAY_HET_HIEU_LUC; } else { m_dat_ngay_het_hieu_luc_qd.Checked = false; } m_lbl_file_name.Text = v_us_qd.strLINK; m_txt_noi_dung.Text = m_us_quyet_dinh.strNOI_DUNG; m_ofd_chon_file.FileName = m_us_quyet_dinh.strLINK; } else { m_txt_ma_quyet_dinh.Text = ""; m_cbo_loai_quyet_dinh.SelectedIndex = 0; m_dat_ngay_ky.Checked = false; m_dat_ngay_co_hieu_luc_qd.Checked = false; m_dat_ngay_het_hieu_luc_qd.Checked = false; m_txt_noi_dung.Text = ""; m_ofd_chon_file.FileName = ""; } if (m_us_v_trang_thai_ld.strTRANG_THAI_HIEN_TAI_YN == "Y") { m_ckb_trang_thai_hien_tai_yn.Checked = true; } else { m_ckb_trang_thai_hien_tai_yn.Checked = false; } break; case DataEntryFormMode.ViewDataState: if (m_us_v_trang_thai_ld.datNGAY_CO_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_co_hieu_luc.Value = m_us_v_trang_thai_ld.datNGAY_CO_HIEU_LUC; } else { m_dat_ngay_co_hieu_luc.Checked = false; } if (m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC != null && m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_het_hieu_luc.Checked = true; m_dat_ngay_het_hieu_luc.Value = m_us_v_trang_thai_ld.datNGAY_HET_HIEU_LUC; } else { m_dat_ngay_het_hieu_luc.Checked = false; } m_us_quyet_dinh.FillDataset_By_Ma_qd(m_ds_quyet_dinh, m_us_v_trang_thai_ld.strMA_QUYET_DINH); if (m_ds_quyet_dinh.DM_QUYET_DINH.Select("MA_QUYET_DINH is not null").Length > 0) { m_txt_ma_quyet_dinh.Text = m_us_v_trang_thai_ld.strMA_QUYET_DINH; m_us_quyet_dinh.DataRow2Me((DataRow)m_ds_quyet_dinh.DM_QUYET_DINH.Rows[0]); m_cbo_loai_quyet_dinh.SelectedValue = m_us_quyet_dinh.dcID_LOAI_QD; m_dat_ngay_ky.Value = m_us_quyet_dinh.datNGAY_KY; if (m_us_quyet_dinh.datNGAY_CO_HIEU_LUC > DateTime.Parse("01/01/1900")) { m_dat_ngay_co_hieu_luc_qd.Value = m_us_quyet_dinh.datNGAY_CO_HIEU_LUC; } else { m_dat_ngay_co_hieu_luc_qd.Checked = false; } if (m_us_quyet_dinh.datNGAY_HET_HIEU_LUC != null) { m_dat_ngay_het_hieu_luc_qd.Value = m_us_quyet_dinh.datNGAY_HET_HIEU_LUC; } else { m_dat_ngay_het_hieu_luc_qd.Checked = false; } m_txt_noi_dung.Text = m_us_quyet_dinh.strNOI_DUNG; m_ofd_chon_file.FileName = m_us_quyet_dinh.strLINK; } else { m_txt_ma_quyet_dinh.Text = ""; m_cbo_loai_quyet_dinh.SelectedIndex = 0; m_dat_ngay_ky.Checked = false; m_dat_ngay_co_hieu_luc_qd.Checked = false; m_dat_ngay_het_hieu_luc_qd.Checked = false; m_txt_noi_dung.Text = ""; m_ofd_chon_file.FileName = ""; } m_txt_noi_dung.ReadOnly = true; m_txt_noi_dung.BackColor = SystemColors.Info; m_txt_ma_quyet_dinh.ReadOnly = true; m_txt_ma_quyet_dinh.BackColor = SystemColors.Info; m_txt_trang_thai_hien_tai.ReadOnly = true; m_txt_trang_thai_hien_tai.BackColor = SystemColors.Info; m_cbo_loai_quyet_dinh.Enabled = false; m_cbo_trang_thai_moi.Visible = false; m_lbl_trang_thai_moi.Visible = false; m_dat_ngay_co_hieu_luc.Enabled = false; m_dat_ngay_co_hieu_luc_qd.Enabled = false; m_dat_ngay_co_hieu_luc.Enabled = false; m_dat_ngay_ky.Enabled = false; break; default: break; } }
private void save_data() { if (check_data_is_ok() == false) { return; } try { m_us.BeginTransaction(); #region Xử lý file đính kèm switch (m_e_file_mode) { case DataEntryFileMode.UploadFile: // Kiểm tra file đã tồn tại trên server hay chưa if (FileExplorer.IsExistedFile(m_str_directory_to + FileExplorer.fileName)) { BaseMessages.MsgBox_Infor("Tên file đã tồn tại. Vui lòng đổi tên khác"); return; } // Nếu đã chọn file if (m_lbl_file_name.Text != "") { // Upload server có sử dụng user và pass if (m_str_user_name != "") { FileExplorer.UploadFile(m_str_domain, m_str_directory_to, m_str_user_name, m_str_password); } // Upload không sử dụng user và pass else { FileExplorer.UploadFile(m_str_domain, m_str_directory_to); } } break; case DataEntryFileMode.EditFile: // Nếu ko up lên file mới sẽ bỏ qua bước này if (m_str_link_old != m_lbl_file_name.Text) { // Kiểm tra file vừa upload đã tồn tại hay chưa if (FileExplorer.IsExistedFile(m_str_directory_to + FileExplorer.fileName)) { BaseMessages.MsgBox_Infor("Tên file đã tồn tại. Vui lòng đổi tên khác"); return; } // Xóa file cũ if (FileExplorer.IsExistedFile(m_str_directory_to + m_str_link_old)) { FileExplorer.DeleteFile(m_str_directory_to + m_str_link_old); } // Upload file mới lên if (m_str_user_name != "") { FileExplorer.UploadFile(m_str_domain, m_str_directory_to, m_str_user_name, m_str_password); } else { FileExplorer.UploadFile(m_str_domain, m_str_directory_to); } } break; case DataEntryFileMode.DeleteFile: // Kiểm tra file có tồn tại hay không if (FileExplorer.IsExistedFile(m_str_directory_to + m_str_link_old) == false) { BaseMessages.MsgBox_Infor("File không tồn tại!"); return; } FileExplorer.DeleteFile(m_str_directory_to + m_str_link_old); break; } #endregion #region Xử lý quyết định form_to_us_quyet_dinh(); switch (m_e_quyet_dinh_mode) { case DataEntryFormMode.InsertDataState: if (is_exist_quyet_dinh(m_txt_ma_quyet_dinh.Text)) { BaseMessages.MsgBox_Error("Mã quyết định đã tồn tại."); m_txt_ma_quyet_dinh.Focus(); return; } m_us.Insert(); break; case DataEntryFormMode.UpdateDataState: if (!m_txt_ma_quyet_dinh.Text.Equals(m_str_ma_quyet_dinh_old)) { if (is_exist_quyet_dinh(m_txt_ma_quyet_dinh.Text)) { BaseMessages.MsgBox_Error("Mã quyết định đã tồn tại hoặc đang được dùng cho dự án khác."); m_txt_ma_quyet_dinh.Focus(); return; } } m_us.Update(); break; } #endregion m_us.CommitTransaction(); } catch (Exception) { if (m_us.is_having_transaction()) { m_us.Rollback(); } } form_2_us_nhan_vien(); US_DM_QUYET_DINH v_us_qd = new US_DM_QUYET_DINH(); DS_DM_QUYET_DINH v_ds_qd = new DS_DM_QUYET_DINH(); switch (m_e_form_mode) { case DataEntryFormMode.InsertDataState: // Insert nhân sự chuyen_trang_thai_ve_no(m_us.dcID_NHAN_SU); m_us.strTRANG_THAI_HIEN_TAI = "Y"; // Quyết định if (m_b_check_quyet_dinh_save) { form_to_us_quyet_dinh(); if (m_b_check_quyet_dinh_null) { m_us_quyet_dinh.Insert(); US_DM_QUYET_DINH v_us = new US_DM_QUYET_DINH(); DS_DM_QUYET_DINH v_ds = new DS_DM_QUYET_DINH(); v_us.FillDataset_By_Ma_qd(v_ds, m_us_quyet_dinh.strMA_QUYET_DINH); if (v_ds.DM_QUYET_DINH.Rows.Count != 0) { US_GD_QUYET_DINH_PHAP_NHAN v_us_qd_pn = new US_GD_QUYET_DINH_PHAP_NHAN(); v_us_qd_pn.dcID_PHAP_NHAN = CAppContext_201.getCurrentIDPhapnhan(); v_us_qd_pn.dcID_QUYET_DINH = CIPConvert.ToDecimal(v_ds_qd.Tables[0].Rows[0]["ID"]); v_us_qd_pn.Insert(); } } else { m_us_quyet_dinh.Update(); } v_us_qd.FillDataset_By_Ma_qd(v_ds_qd, m_us_quyet_dinh.strMA_QUYET_DINH); if (v_ds_qd.Tables[0].Rows.Count != 0) { m_us.dcID_QUYET_DINH = CIPConvert.ToDecimal(v_ds_qd.Tables[0].Rows[0]["ID"]); } } m_us.Insert(); break; case DataEntryFormMode.UpdateDataState: if (m_txt_ma_quyet_dinh.Text != "") { form_to_us_quyet_dinh(); if (m_b_check_quyet_dinh_save) { m_us_quyet_dinh.Insert(); } else { m_us_quyet_dinh.Update(); } v_us_qd.FillDataset_By_Ma_qd(v_ds_qd, m_us_quyet_dinh.strMA_QUYET_DINH); if (v_ds_qd.Tables[0].Rows.Count != 0) { m_us.dcID_QUYET_DINH = CIPConvert.ToDecimal(v_ds_qd.Tables[0].Rows[0]["ID"]); } } m_us.Update(); break; } BaseMessages.MsgBox_Infor("Dữ liệu đã được cập nhật"); this.Close(); }