Exemplo n.º 1
0
        private bool check_data_is_ok()
        {
            //if (check_trung_ma_quyet_dinh(m_txt_ma_quyet_dinh.Text.Trim()))
            //{
            //    BaseMessages.MsgBox_Error("Đã có mã Quyết định này!");
            //    return false;
            //}
            //return CValidateTextBox.IsValid(m_txt_ma_quyet_dinh, DataType.StringType, allowNull.NO, true) && kiem_tra_ngay_truoc_sau();

            /*if (!check_format_ma_qd())
             * {
             *  BaseMessages.MsgBox_Infor("Mã quyết định chưa đúng định dạng.");
             *  return false;
             * }*/
            if (!CValidateTextBox.IsValid(m_txt_ma_quyet_dinh, DataType.StringType, allowNull.NO, true))
            {
                BaseMessages.MsgBox_Infor("Bạn chưa nhập mã quyết định.");
                return(false);
            }
            string[] v_arstr = m_txt_ma_quyet_dinh.Text.Trim().Split('/');
            if (!CIPConvert.is_valid_number(v_arstr[0].Substring(0, v_arstr[0].Length - 1)))
            {
                BaseMessages.MsgBox_Infor("Mã quyết định không đúng định dạng.");
                return(false);
            }
            return(kiem_tra_ngay_truoc_sau());
        }
        private void form_to_us_object_chi_tiet_chuc_vu()
        {
            m_us_chi_tiet_chuc_vu = new US_GD_CHI_TIET_CHUC_VU();
            if (CIPConvert.is_valid_number(m_txt_ty_le_tham_gia.Text.Trim()))
            {
                m_us_chi_tiet_chuc_vu.dcTY_LE_THAM_GIA = CIPConvert.ToDecimal(m_txt_ty_le_tham_gia.Text.Trim());
            }
            else
            {
                m_us_chi_tiet_chuc_vu.dcTY_LE_THAM_GIA = 0;
            }
            m_us_chi_tiet_chuc_vu.dcID_NHAN_SU = id_nhan_su;
            m_us_chi_tiet_chuc_vu.dcID_CHUC_VU = CIPConvert.ToDecimal(m_cbo_chuc_vu_moi.SelectedValue);

            m_us_chi_tiet_chuc_vu.dcID_LOAI_CV = (m_rdb_cv_chinh.Checked) ? LOAI_CHUC_VU.CHUC_VU_CHINH : LOAI_CHUC_VU.CHUC_VU_KIEM_NHIEM;
            //    m_us_chi_tiet_chuc_vu.dcID_LOAI_CV = CIPConvert.ToDecimal(m_cbo_loai_chuc_vu.SelectedValue);
            m_us_chi_tiet_chuc_vu.dcID_DON_VI = m_us_dm_don_vi.dcID;
            if (m_txt_ma_quyet_dinh.Text != "")
            {
                m_us_chi_tiet_chuc_vu.dcID_QUYET_DINH = m_us_quyet_dinh.dcID;
            }
            m_us_chi_tiet_chuc_vu.SetID_QUYET_DINH_MIEN_NHIEMNull();
            m_us_chi_tiet_chuc_vu.datNGAY_BAT_DAU = m_dat_ngay_bat_dau.Value;
            m_us_chi_tiet_chuc_vu.SetNGAY_KET_THUCNull();
            m_us_chi_tiet_chuc_vu.strTRANG_THAI_CV = "Y";
        }
        public decimal Sum_ty_le_tham_gia(string ip_str_ma_nv, string ip_str_trang_thai_chuc_vu_yn, decimal ip_id_phap_nhan)
        {
            decimal     v_dc_ty_le = 0;
            CStoredProc v_sp       = new CStoredProc("pr_V_GD_QUA_TRINH_LAM_VIEC_Sum_Ty_le_tham_gia");

            v_sp.addNVarcharInputParam("@MA_NV", ip_str_ma_nv);
            v_sp.addDecimalInputParam("@ID_PHAP_NHAN", ip_id_phap_nhan);
            v_sp.addNVarcharInputParam("@TRANG_THAI_CHUC_VU_YN", ip_str_trang_thai_chuc_vu_yn);
            SqlParameter v_pa_ty_le = v_sp.addDecimalOutputParam("@TONG_TY_LE", v_dc_ty_le);

            v_sp.ExecuteCommand(this);
            if (CIPConvert.is_valid_number(v_pa_ty_le.Value) == false)
            {
                return(0);
            }

            return(CIPConvert.ToDecimal(v_pa_ty_le.Value));
        }
        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();
            }
        }