コード例 #1
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(hdfId.Text))
                {
                    var decision = DecisionController.GetById(Convert.ToInt32(hdfId.Text));
                    if (decision != null)
                    {
                        //delete decrease insurance
                        var insurance = FluctuationInsuranceController.GetByRecordId(decision.RecordId, decision.DecisionDate.Month, decision.DecisionDate.Year);
                        if (insurance != null)
                        {
                            FluctuationInsuranceController.Delete(insurance.Id);
                        }
                    }

                    //delete
                    DecisionController.Delete(Convert.ToInt32(hdfId.Text));
                }

                // reload data
                gpDecision.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            // init params
            _start = Start;
            _limit = Limit;

            // init params
            context.Response.ContentType = "text/plain";

            // start
            if (!string.IsNullOrEmpty(context.Request["start"]))
            {
                _start = int.Parse(context.Request["start"]);
            }

            // limit
            if (!string.IsNullOrEmpty(context.Request["limit"]))
            {
                _limit = int.Parse(context.Request["limit"]);
            }

            if (!string.IsNullOrEmpty(context.Request["query"]))
            {
                _keyWord = context.Request["query"];
            }
            var groupId = !string.IsNullOrEmpty(context.Request["group"])
                ? Convert.ToInt32(context.Request["group"])
                : 0;
            // select from db
            var pageResult = FluctuationInsuranceController.GetPaging(_keyWord, null, null, null, _start, _limit);

            // response
            context.Response.ContentType = "text/json";
            context.Response.Write("{{TotalRecords:{0},Data:{1}}}".FormatWith(pageResult.Total, Ext.Net.JSON.Serialize(pageResult.Data)));
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        private void ProcessInsurance(SalaryDecisionModel model)
        {
            var insuranceModel = new FluctuationInsuranceModel()
            {
                RecordId      = model.RecordId,
                ReasonId      = !string.IsNullOrEmpty(hdfReason.Text) ? Convert.ToInt32(hdfReason.Text) : 0,
                EffectiveDate = model.EffectiveDate,
                CreatedBy     = CurrentUser.User.UserName,
                CreatedDate   = DateTime.Now,
                EditedBy      = "",
                EditedDate    = DateTime.Now
            };

            if (!string.IsNullOrEmpty(hdfInsuranceType.Text))
            {
                insuranceModel.Type = (InsuranceType)Enum.Parse(typeof(InsuranceType), hdfInsuranceType.Text);
            }

            //check exist insurance
            var checkModel = FluctuationInsuranceController.GetByRecordId(model.RecordId, insuranceModel.EffectiveDate.Month, insuranceModel.EffectiveDate.Year);

            if (checkModel != null)
            {
                //update
                insuranceModel.Id         = checkModel.Id;
                insuranceModel.EditedBy   = CurrentUser.User.UserName;
                insuranceModel.EditedDate = DateTime.Now;

                //update
                FluctuationInsuranceController.Update(insuranceModel);
            }
            else
            {
                //create
                FluctuationInsuranceController.Create(insuranceModel);
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        private void InitFormUpdate(int id)
        {
            // get current decision
            var model = SalaryDecisionController.GetById(id);

            if (model != null)
            {
                // get previous decision
                var previousDecision = SalaryDecisionController.GetPrevious(model.RecordId);

                // bind previous data
                if (previousDecision != null)
                {
                    txtCurrName.Text             = previousDecision.Name;
                    txtCurrDecisionNumber.Text   = previousDecision.DecisionNumber;
                    txtCurrDecisionDate.Text     = previousDecision.DecisionDate.ToString("dd/MM/yyyy");
                    txtCurrSignerName.Text       = previousDecision.SignerName;
                    txtCurrSignerPosition.Text   = previousDecision.SignerPosition;
                    txtCurrContractTypeName.Text = previousDecision.ContractTypeName;
                    txtCurrBasicSalary.Text      = previousDecision.BasicSalary.ToString("#,###");
                    txtCurrFactor.Text           = previousDecision.Factor.ToString("#,##0.00");
                    txtCurrGrossSalary.Text      = previousDecision.GrossSalary.ToString("#,###");
                    txtCurrNetSalary.Text        = previousDecision.NetSalary.ToString("#,###");
                    txtCurrContractSalary.Text   = previousDecision.ContractSalary.ToString("#,###");
                    txtCurrInsuranceSalary.Text  = previousDecision.InsuranceSalary.ToString("#,###");
                    txtCurrPercentageLeader.Text = previousDecision.PercentageLeader.ToString("0.00 %");
                }

                // bind current salary decision
                cboEmployee.Text             = model.EmployeeName;
                hdfEmployee.Text             = model.RecordId.ToString();
                txtName.Text                 = model.Name;
                txtDepartmentName.Text       = model.DepartmentName;
                txtPositionName.Text         = model.PositionName;
                txtJobTitleName.Text         = model.JobTitleName;
                cboContractType.Text         = model.ContractTypeName;
                txtDecisionNumber.Text       = model.DecisionNumber;
                dfDecisionDate.SelectedDate  = model.DecisionDate;
                dfEffectiveDate.SelectedDate = model.EditedDate;
                txtSignerName.Text           = model.SignerName;
                hdfPosition.Text             = model.SignerPositionId.ToString();
                cboPosition.Text             = model.SignerPosition;
                txtNote.Text                 = model.Note;
                txtBasicSalary.Text          = model.BasicSalary.ToString("#,###");
                txtFactor.Text               = model.Factor.ToString("#,##0.00");
                txtGrossSalary.Text          = model.GrossSalary.ToString("#,###");
                txtNetSalary.Text            = model.NetSalary.ToString("#,###");
                txtContractSalary.Text       = model.ContractSalary.ToString("#,###");
                txtInsuranceSalary.Text      = model.InsuranceSalary.ToString("#,###");
                txtPercentageSalary.Text     = model.PercentageSalary.ToString("0.00");
                txtPercentageLeader.Text     = model.PercentageLeader.ToString("0.00");
                txtPercentageOverGrade.Text  = model.PercentageOverGrade.ToString("0.00");
                // get file upload
                if (cfAttachFile.Visible)
                {
                    hdfAttachFile.Text = model.AttachFileName;
                    if (!string.IsNullOrEmpty(model.AttachFileName))
                    {
                        hdfAttachFile.Text = model.AttachFileName;
                        fufAttachFile.Text = GetFileName(model.AttachFileName);
                    }
                }
                //insurance
                var insurance = FluctuationInsuranceController.GetByRecordId(model.RecordId, model.EffectiveDate.Month, model.EffectiveDate.Year);

                if (insurance != null)
                {
                    hdfReason.Text        = insurance.ReasonId.ToString();
                    cboReason.Text        = insurance.ReasonName;
                    hdfInsuranceType.Text = ((int)insurance.Type).ToString();
                    if (insurance.Type != 0)
                    {
                        cboInsuranceType.Text = insurance.TypeName;
                    }
                    if (!string.IsNullOrEmpty(hdfInsuranceType.Text))
                    {
                        cboReason.Show();
                    }
                }
                else
                {
                    //reset insurance
                    ResetInsurance();
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// insert or update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            try
            {
                // init entity
                var model = new DecisionModel();

                // check id
                if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
                {
                    var result = DecisionController.GetById(Convert.ToInt32(hdfId.Text));;
                    if (result != null)
                    {
                        model = result;
                    }
                }

                // set new props for entity
                model.Name = txtName.Text;
                if (!string.IsNullOrEmpty(hdfType.Text))
                {
                    model.Type = (DecisionType)Enum.Parse(typeof(DecisionType), hdfType.Text);
                }
                var util = new ConvertUtils();
                if (!util.IsDateNull(dfDecisionDate.SelectedDate))
                {
                    model.DecisionDate = dfDecisionDate.SelectedDate;
                }
                if (!string.IsNullOrEmpty(hdfReason.Text))
                {
                    model.ReasonId = Convert.ToInt32(hdfReason.Text);
                }
                if (!string.IsNullOrEmpty(hdfChooseEmployee.Text))
                {
                    model.RecordId = Convert.ToInt32(hdfChooseEmployee.Text);
                }
                // check entity id
                if (model.Id > 0)
                {
                    model.EditedDate = DateTime.Now;
                    model.EditedBy   = CurrentUser.User.UserName;
                    // update
                    DecisionController.Update(model);
                }
                else
                {
                    model.CreatedBy   = CurrentUser.User.UserName;
                    model.CreatedDate = DateTime.Now;
                    model.EditedDate  = DateTime.Now;
                    model.EditedBy    = "";

                    // insert
                    DecisionController.Create(model);

                    //create decrease insurance
                    if (!string.IsNullOrEmpty(hdfType.Text) &&
                        (hdfType.Text == ((int)DecisionType.Leave).ToString() ||
                         hdfType.Text == ((int)DecisionType.Maternity).ToString()))
                    {
                        var insuranceModel = new FluctuationInsuranceModel()
                        {
                            RecordId      = model.RecordId,
                            Type          = InsuranceType.Decrease,
                            EffectiveDate = model.DecisionDate,
                            ReasonId      = model.ReasonId,
                            CreatedBy     = CurrentUser.User.UserName,
                            CreatedDate   = DateTime.Now,
                            EditedDate    = DateTime.Now,
                            EditedBy      = ""
                        };

                        //create
                        FluctuationInsuranceController.Create(insuranceModel);
                    }
                }


                // hide window
                wdSetting.Hide();

                //reset form
                ResetForm();
                // reload data
                gpDecision.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }