コード例 #1
0
        private void delete_v_gd_quyet_dinh()
        {
            if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg))
            {
                return;
            }
            if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, m_fg.Row))
            {
                return;
            }
            if (BaseMessages.askUser_DataCouldBeDeleted(8) != BaseMessages.IsDataCouldBeDeleted.CouldBeDeleted)
            {
                return;
            }
            US_V_GD_QUYET_DINH         v_us       = new US_V_GD_QUYET_DINH();
            US_GD_QUYET_DINH_PHAP_NHAN v_us_qd_pn = new US_GD_QUYET_DINH_PHAP_NHAN();
            DS_GD_QUYET_DINH_PHAP_NHAN v_ds_qd_pn = new DS_GD_QUYET_DINH_PHAP_NHAN();

            grid2us_object(v_us, m_fg.Row);
            try
            {
                v_us.BeginTransaction();
                // Xoá Quyết định - Pháp nhân
                v_us_qd_pn.FillDatasetByIdQuyetDinh(v_ds_qd_pn, v_us.dcID);
                v_us_qd_pn.DeleteByID(v_us.dcID);

                // Xoá Pháp nhân
                v_us.delete_by_id(v_us.dcID);
                v_us.CommitTransaction();
                m_fg.Rows.Remove(m_fg.Row);
            }
            catch (Exception v_e)
            {
                v_us.Rollback();
                CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e,
                                                                              new CDBClientDBExceptionInterpret());
                v_objErrHandler.showErrorMessage();
            }
        }
コード例 #2
0
        private void save_quyet_dinh()
        {
            if (check_data_is_ok() == false)
            {
                return;
            }

            try
            {
                m_us_v_gd_cong_tac.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_2_us_object_quyet_dinh();
                switch (m_e_form_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_v_gd_cong_tac.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.");
                            m_txt_ma_quyet_dinh.Focus();
                            return;
                        }
                    }
                    m_us_v_gd_cong_tac.Update();
                    break;
                }
                #endregion

                #region Xử lý nhân sự
                US_GD_CONG_TAC v_us_gd_cong_tac = new US_GD_CONG_TAC();
                v_us_gd_cong_tac.UseTransOfUSObject(m_us_v_gd_cong_tac);

                form_to_us_cong_tac(v_us_gd_cong_tac, m_us_v_gd_cong_tac);
                v_us_gd_cong_tac.DeleteByID(m_us_dm_quyet_dinh.dcID);

                for (int i = m_fg.Rows.Fixed; i < m_fg.Rows.Count - 1; i++)
                {
                    v_us_gd_cong_tac.dcID_NHAN_SU       = CIPConvert.ToDecimal(m_fg[i, (int)e_col_Number.ID_NHAN_SU]);
                    v_us_gd_cong_tac.datNGAY_DI         = DateTime.Parse(m_fg[i, (int)e_col_Number.NGAY_DI].ToString());
                    v_us_gd_cong_tac.datNGAY_VE         = DateTime.Parse(m_fg[i, (int)e_col_Number.NGAY_VE].ToString());
                    v_us_gd_cong_tac.strDIA_DIEM        = m_fg[i, (int)e_col_Number.DIA_DIEM].ToString();
                    v_us_gd_cong_tac.strMO_TA_CONG_VIEC = m_fg[i, (int)e_col_Number.MO_TA_CONG_VIEC].ToString();
                    v_us_gd_cong_tac.Insert();
                }
                #endregion

                #region Xử lý Quyết định - Pháp nhân
                US_GD_QUYET_DINH_PHAP_NHAN v_us_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();
                v_us_quyet_dinh_phap_nhan.UseTransOfUSObject(m_us_v_gd_cong_tac);
                form_to_us_quyet_dinh_phap_nhan(v_us_quyet_dinh_phap_nhan, m_us_v_gd_cong_tac);

                if (m_e_form_mode == DataEntryFormMode.InsertDataState)
                {
                    v_us_quyet_dinh_phap_nhan.Insert();
                }
                #endregion

                m_us_v_gd_cong_tac.CommitTransaction();
                BaseMessages.MsgBox_Infor("Lưu dữ liệu thành công.");
                this.Close();
            }
            catch (Exception)
            {
                if (m_us_v_gd_cong_tac.is_having_transaction())
                {
                    m_us_v_gd_cong_tac.Rollback();
                }
                throw;
            }
        }
コード例 #3
0
 private void form_to_us_quyet_dinh_phap_nhan(US_GD_QUYET_DINH_PHAP_NHAN op_us, US_V_GD_CONG_TAC ip_us)
 {
     op_us.dcID_PHAP_NHAN  = CAppContext_201.getCurrentIDPhapnhan();
     op_us.dcID_QUYET_DINH = ip_us.dcID;
 }
コード例 #4
0
        private void save_data()
        {
            US_GD_QUYET_DINH_PHAP_NHAN v_us_gd_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();

            if (confirm_save_data() && check_validate_data_is_ok())
            {
                #region Xử lý file đính kèm
                // 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
                decimal v_dc_ty_le = 0;
                if (CIPConvert.is_valid_number(m_txt_ty_le_tham_gia.Text.Trim()))
                {
                    v_dc_ty_le = CIPConvert.ToDecimal(m_txt_ty_le_tham_gia.Text.Trim());
                }
                if (m_us_v_qua_trinh_lam_viec.Sum_ty_le_tham_gia(m_us_v_qua_trinh_lam_viec.strMA_NV, m_us_v_qua_trinh_lam_viec.strTRANG_THAI_CHUC_VU_YN, CAppContext_201.getCurrentIDPhapnhan()) + v_dc_ty_le > 100)
                {
                    BaseMessages.MsgBox_Infor("Tỷ lệ tham gia đã đã vượt quá 100%.");
                    return;
                }
                if (check_validate_data_is_ok() == false)
                {
                    return;
                }
                else
                {
                    if (m_txt_ma_quyet_dinh.Text != "")
                    {
                        form_to_us_object_quyet_dinh();
                        if (m_b_check_quyet_dinh_save)
                        {
                            m_us_quyet_dinh.Insert();
                            v_us_gd_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();
                            v_us_gd_quyet_dinh_phap_nhan.dcID_QUYET_DINH = m_us_quyet_dinh.dcID;
                            v_us_gd_quyet_dinh_phap_nhan.dcID_PHAP_NHAN  = CAppContext_201.getCurrentIDPhapnhan();
                            v_us_gd_quyet_dinh_phap_nhan.Insert();
                        }
                        else
                        {
                            m_us_quyet_dinh.Update();
                        }
                    }
                    form_to_us_object_chi_tiet_chuc_vu();
                    m_us_chi_tiet_chuc_vu.Insert();
                }
                BaseMessages.MsgBox_Infor("Dữ liệu đã được cập nhât!");
                this.Close();
            }
        }
コード例 #5
0
        private void save_data()
        {
            if (confirm_save_data() && check_validate_data_is_ok())
            {
                US_GD_QUYET_DINH_PHAP_NHAN v_us_gd_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();
                #region Xử lý file đính kèm
                // 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
                switch (m_e_form_mode)
                {
                case DataEntryFormMode.UpdateDataState:
                    if (check_validate_data_is_ok() == false)
                    {
                        return;
                    }

                    else
                    {
                        if (!check_trang_thai_hien_tai_phap_nhan())
                        {
                            BaseMessages.MsgBox_Infor("Tại thời điểm hiện tại, ứng với 1 pháp nhân, mỗi nhân viên chỉ có thể có 1 trạng thái chính thức.");
                            return;
                        }
                        form_to_us_object_quyet_dinh();
                        if (m_b_check_quyet_dinh_save)
                        {
                            if (m_b_check_quyet_dinh_null && check_quyet_dinh(m_txt_ma_quyet_dinh.Text.Trim()))
                            {
                                if (m_txt_ma_quyet_dinh.Text != "")
                                {
                                    m_us_quyet_dinh.Insert();
                                    v_us_gd_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();
                                    v_us_gd_quyet_dinh_phap_nhan.dcID_QUYET_DINH = m_us_quyet_dinh.dcID;
                                    v_us_gd_quyet_dinh_phap_nhan.dcID_PHAP_NHAN  = CAppContext_201.getCurrentIDPhapnhan();
                                    v_us_gd_quyet_dinh_phap_nhan.Insert();
                                    form_to_us_object_trang_thai_ld();
                                }
                                else
                                {
                                    form_to_us_object_trang_thai_ld();
                                    switch ((int)CAppContext_201.getCurrentIDPhapnhan())
                                    {
                                    case (int)PHAP_NHAN.TU:
                                        m_us_trang_thai_ld.dcID_QUYET_DINH = 1515;
                                        break;

                                    case (int)PHAP_NHAN.TE:
                                        m_us_trang_thai_ld.dcID_QUYET_DINH = 1517;
                                        break;

                                    case (int)PHAP_NHAN.TEG:
                                        m_us_trang_thai_ld.dcID_QUYET_DINH = 1516;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            form_to_us_object_trang_thai_ld();
                            if (m_txt_ma_quyet_dinh.Text == "")
                            {
                                switch ((int)CAppContext_201.getCurrentIDPhapnhan())
                                {
                                case (int)PHAP_NHAN.TU:
                                    m_us_trang_thai_ld.dcID_QUYET_DINH = 1515;
                                    break;

                                case (int)PHAP_NHAN.TE:
                                    m_us_trang_thai_ld.dcID_QUYET_DINH = 1517;
                                    break;

                                case (int)PHAP_NHAN.TEG:
                                    m_us_trang_thai_ld.dcID_QUYET_DINH = 1516;
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                        m_us_trang_thai_ld.Update();
                    }

                    break;

                case DataEntryFormMode.InsertDataState:

                    if (check_validate_data_is_ok() == false)
                    {
                        return;
                    }
                    else
                    {
                        if (m_b_check_quyet_dinh_save)
                        {
                            if (m_b_check_quyet_dinh_null && check_quyet_dinh(m_txt_ma_quyet_dinh.Text.Trim()))
                            {
                                if (m_txt_ma_quyet_dinh.Text != "")
                                {
                                    form_to_us_object_quyet_dinh();
                                    m_us_quyet_dinh.Insert();
                                    v_us_gd_quyet_dinh_phap_nhan = new US_GD_QUYET_DINH_PHAP_NHAN();
                                    v_us_gd_quyet_dinh_phap_nhan.dcID_QUYET_DINH = m_us_quyet_dinh.dcID;
                                    v_us_gd_quyet_dinh_phap_nhan.dcID_PHAP_NHAN  = CAppContext_201.getCurrentIDPhapnhan();
                                    v_us_gd_quyet_dinh_phap_nhan.Insert();
                                }
                                else
                                {
                                    BaseMessages.MsgBox_Infor("Mã quyết định trống");
                                    return;
                                }
                                form_to_us_object_v_trang_thai_ld();
                                if (m_us_v_trang_thai_ld.dcID_QUYET_DINH == 0)
                                {
                                    switch ((int)CAppContext_201.getCurrentIDPhapnhan())
                                    {
                                    case (int)PHAP_NHAN.TU:
                                        m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1515;
                                        break;

                                    case (int)PHAP_NHAN.TE:
                                        m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1517;
                                        break;

                                    case (int)PHAP_NHAN.TEG:
                                        m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1516;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                                m_us_v_trang_thai_ld.Insert();
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            form_to_us_object_v_trang_thai_ld();
                            if (m_us_v_trang_thai_ld.dcID_QUYET_DINH == 0)
                            {
                                switch ((int)CAppContext_201.getCurrentIDPhapnhan())
                                {
                                case (int)PHAP_NHAN.TU:
                                    m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1515;
                                    break;

                                case (int)PHAP_NHAN.TE:
                                    m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1517;
                                    break;

                                case (int)PHAP_NHAN.TEG:
                                    m_us_v_trang_thai_ld.dcID_QUYET_DINH = 1516;
                                    break;

                                default:
                                    break;
                                }
                            }
                            m_us_v_trang_thai_ld.Insert();
                        }
                    }
                    break;

                default:
                    break;
                }
                BaseMessages.MsgBox_Infor("Dữ liệu đã được cập nhât!");
                this.Close();
            }
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        /// <summary>
        /// Insert/Update vào Table DM_QUYET_DINH trước, nếu thành công thì tiếp tục với GD_LUONG_THEO_QD.
        /// Nếu GD_LUONG_THEO_QD gặp exception thì Rollback() bản ghi DM_QUYET_DINH đã Insert/Update trước đó.
        /// </summary>
        /// <returns>Trả về True nếu thành công</returns>
        private bool save_data()
        {
            US_GD_QUYET_DINH_PHAP_NHAN v_us_qd_pn;

            try
            {
                #region Validate Data
                // Nếu validate có vấn đề
                if (!validate_data())
                {
                    return(false);
                }
                #endregion

                // Chưa hiểu rõ về xử lý file lắm
                #region Xử lý file đính kèm
                // 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(false);
                    }

                    // 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_previous_link != m_lbl_file_name.Text && 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(false);
                        }

                        // Xóa file cũ
                        if (FileExplorer.IsExistedFile(m_str_directory_to + m_str_previous_link))
                        {
                            FileExplorer.DeleteFile(m_str_directory_to + m_str_previous_link);
                        }

                        // 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_previous_link) == false)
                    {
                        BaseMessages.MsgBox_Infor("File không tồn tại!");
                        return(false);
                    }
                    FileExplorer.DeleteFile(m_str_directory_to + m_str_previous_link);
                    break;
                }
                #endregion

                m_us_v_gd_luong_theo_qd.BeginTransaction();

                #region Prepare for update

                // Bởi vì ở đây ta cần Update bảng DM_QUYET_DINH nhưng mà nó lại relate với GD_LUONG_THEO_QD theo MA_QD chứ không phải ID
                // Do đó ở đây ta cần Update cột MA_QD trong GD_LUONG_THEO_QD thành NULL để có thể Update ở DM_QUYET_DINH

                if (m_e_form_mode == DataEntryFormMode.UpdateDataState)
                {
                    load_data_2_us_gd_luong_theo_qd();
                    m_us_v_gd_luong_theo_qd.strMA_QD = String.Empty;

                    m_us_v_gd_luong_theo_qd.Update();
                }

                #endregion

                #region Save Quyết định
                load_data_2_us_qd();

                // Commit trans thông qua US m_us_gd_luong_theo_qd.
                // Việc này giúp Rollback() - ngừng connection tới DB nếu xảy ra lỗi.
                m_us_dm_quyet_dinh.UseTransOfUSObject(m_us_v_gd_luong_theo_qd);

                switch (m_e_form_mode)
                {
                case DataEntryFormMode.InsertDataState:
                    m_us_dm_quyet_dinh.Insert();     // Trực tiếp thêm vào DataBase thành công ở bước này.

                    // throw new Exception("DucVT: DEBUG");
                    // Đã Test OK. Nếu giả sử ở bước này xảy ra lỗi thì sẽ catch exception gọi RollBack() và
                    // Xóa đi bản ghi vừa được m_us_dm_quyet_dinh.Insert() khỏi DataBase ở dòng trên đây.

                    #region Save Gd quyết định, pháp nhân
                    v_us_qd_pn = new US_GD_QUYET_DINH_PHAP_NHAN();
                    v_us_qd_pn.dcID_PHAP_NHAN = CAppContext_201.getCurrentIDPhapnhan();

                    // Lấy Id của bản ghi quyết định vừa được Insert ở trên vào Table DM_QUYET_DINH
                    v_us_qd_pn.dcID_QUYET_DINH = CUtils.get_current_auto_id("DM_QUYET_DINH");

                    // Commit trans thông qua US m_us_gd_luong_theo_qd.
                    v_us_qd_pn.UseTransOfUSObject(m_us_v_gd_luong_theo_qd);

                    // Insert gd quyết định, pháp nhân
                    v_us_qd_pn.Insert();
                    #endregion

                    break;

                case DataEntryFormMode.SelectDataState:
                    break;

                case DataEntryFormMode.UpdateDataState:
                    m_us_dm_quyet_dinh.Update();
                    break;

                case DataEntryFormMode.ViewDataState:
                    break;

                default:
                    break;
                }

                #endregion

                #region Save Gd lương theo quyết định
                load_data_2_us_gd_luong_theo_qd();

                switch (m_e_form_mode)
                {
                case DataEntryFormMode.InsertDataState:
                    m_us_v_gd_luong_theo_qd.Insert();
                    // Refresh mới lại form để insert bản ghi mới
                    CUtils.show_success_message("Thêm thành công Lương theo quyết định mới");
                    reset_form();
                    break;

                case DataEntryFormMode.SelectDataState:
                    break;

                case DataEntryFormMode.UpdateDataState:
                    m_us_v_gd_luong_theo_qd.Update();
                    this.Close();
                    break;

                case DataEntryFormMode.ViewDataState:
                    break;

                default:
                    break;
                }

                #endregion

                m_us_v_gd_luong_theo_qd.CommitTransaction();

                if (m_e_form_mode == DataEntryFormMode.UpdateDataState)
                {
                    this.Close();
                }
            }
            catch (Exception v_e)
            {
                if (m_us_v_gd_luong_theo_qd.is_having_transaction())
                {
                    m_us_v_gd_luong_theo_qd.Rollback();
                }

                CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e,
                                                                              new CDBClientDBExceptionInterpret());
                v_objErrHandler.showErrorMessage();
                return(false);
            }

            return(true);
        }