Exemple #1
0
        protected override string uc_Save()
        {
            string str;

            if (MyRule.Get(MyLogin.RoleId, "bbiContract") != "OK")
            {
                str = "";
            }
            else if (!MyRule.AllowAdd)
            {
                MyRule.Notify();
                str = "";
            }
            else if ((this.txtContractCode.ErrorText != string.Empty ? false : !(this.glkEmployeeCode.ErrorText != string.Empty)))
            {
                // SYS_LOG.Insert("Hợp Đồng Lao Động", "Thêm", this.txtContractCode.Text);

                Cursor.Current = Cursors.WaitCursor;
                HRM_CONTRACT hRMCONTRACT  = new HRM_CONTRACT();
                HRM_CONTRACT hRMCONTRACT1 = this.InitClass();
                hRMCONTRACT = hRMCONTRACT1;
                if (hRMCONTRACT1 != null)
                {
                    base.SetWaitDialogCaption("Đang lưu dữ liệu...");
                    string str1 = hRMCONTRACT.Insert();
                    if (str1 == "OK")
                    {
                        this.RaiseSuccessEventHander(hRMCONTRACT);
                    }
                    Cursor.Current = Cursors.Default;
                    if (!(str1 != "OK"))
                    {
                        HRM_EMPLOYEE hRMEMPLOYEE = new HRM_EMPLOYEE();
                        hRMEMPLOYEE.Get(this.glkEmployeeCode.EditValue.ToString());
                        HRM_PROCESS_SALARY hRMPROCESSSALARY = new HRM_PROCESS_SALARY()
                        {
                            SalaryID             = Guid.NewGuid(),
                            EmployeeCode         = hRMEMPLOYEE.EmployeeCode,
                            OldPayForm           = hRMEMPLOYEE.PayForm,
                            OldPayMoney          = hRMEMPLOYEE.PayMoney,
                            OldRankSalary        = hRMEMPLOYEE.RankSalary,
                            OldStepSalary        = hRMEMPLOYEE.StepSalary,
                            OldCoefficientSalary = hRMEMPLOYEE.CoefficientSalary,
                            OldMinimumSalary     = hRMEMPLOYEE.MinimumSalary,
                            OldBasicSalary       = hRMEMPLOYEE.BasicSalary,
                            OldInsuranceSalary   = hRMEMPLOYEE.InsuranceSalary,
                            NewPayForm           = 1,
                            NewPayMoney          = decimal.Parse(this.calBasicSalary.EditValue.ToString()),
                            NewRankSalary        = hRMEMPLOYEE.RankSalary,
                            NewStepSalary        = hRMEMPLOYEE.StepSalary,
                            NewCoefficientSalary = hRMEMPLOYEE.CoefficientSalary,
                            NewMinimumSalary     = hRMEMPLOYEE.MinimumSalary,
                            NewBasicSalary       = decimal.Parse(this.calBasicSalary.EditValue.ToString()),
                            NewInsuranceSalary   = decimal.Parse(this.calBasicSalary.EditValue.ToString()),
                            Date   = this.dtSignDate.DateTime,
                            Reason = "Ký mới hợp đồng lao động",
                            Person = this.txtSigner.Text
                        };
                        hRMPROCESSSALARY.Insert();
                        hRMEMPLOYEE.ContractCode     = this.txtContractCode.Text;
                        hRMEMPLOYEE.ContractType     = this.cboContractType.Text;
                        hRMEMPLOYEE.ContractSignDate = this.dtFromDate.DateTime;
                        hRMEMPLOYEE.ContractFromDate = this.dtFromDate.DateTime;
                        if (this.cboContractType.SelectedIndex != 1)
                        {
                            hRMEMPLOYEE.ContractToDate = this.dtToDate.DateTime;
                        }
                        else
                        {
                            SqlDateTime maxValue = SqlDateTime.MaxValue;
                            hRMEMPLOYEE.ContractToDate = Convert.ToDateTime(maxValue.ToString());
                        }
                        if (hRMEMPLOYEE.PayForm == 1)
                        {
                            hRMEMPLOYEE.PayMoney        = decimal.Parse(this.calBasicSalary.EditValue.ToString());
                            hRMEMPLOYEE.BasicSalary     = hRMEMPLOYEE.PayMoney;
                            hRMEMPLOYEE.InsuranceSalary = hRMEMPLOYEE.PayMoney;
                            hRMEMPLOYEE.DateSalary      = this.dtSignDate.DateTime;
                        }
                        hRMEMPLOYEE.Update();
                    }
                    else
                    {
                        XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    this.DoHide();
                    str = str1;
                }
                else
                {
                    str = "FALSE";
                }
            }
            else
            {
                MessageBox.Show("Mã hợp đồng hoặc mã nhân viên không được trùng!", "Cảnh Báo");
                str = "";
            }
            return(str);
        }