示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request["payrollId"]))
            {
                _payrollId = int.Parse(context.Request["payrollId"]);
            }
            if (!string.IsNullOrEmpty(context.Request["keyword"]))
            {
                _keyword = context.Request["keyword"];
            }

            var result = PayrollController.GetPayrollDetail(_keyword, _payrollId, null, null);

            context.Response.Write("{{TotalRecords:{0},Data:{1}}}".FormatWith(result.Rows.Count, Ext.Net.JSON.Serialize(result)));
        }
示例#2
0
        public void SaveData(string json)
        {
            // get payroll
            _payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (_payroll == null)
            {
                return;
            }

            // save data
            _payroll.Data = json;

            var table = PayrollController.GetPayrollDetail(null, _payroll.Id, null, null);

            if (table.Rows.Count > 0)
            {
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    //save payrollInfo
                    var payrollInfo = new PayrollInfoModel()
                    {
                        SalaryBoardId = _payroll.Id,
                        RecordId      = table.Rows[i]["RecordId"] != null?Convert.ToInt32(table.Rows[i]["RecordId"].ToString()) : 0,
                                            TotalIncome      = 0,
                                            IndividualTax    = 0,
                                            EnterpriseSocial = 0,
                                            LaborerSocial    = 0,
                                            ActualSalary     = 0,
                                            Month            = _payroll.Month,
                                            Year             = _payroll.Year,
                                            CreatedBy        = "admin",
                                            CreatedDate      = DateTime.Now,
                                            EditedBy         = "",
                                            EditedDate       = DateTime.Now,
                                            IsDeleted        = false
                    };

                    //check exist column
                    if (table.Columns.Contains("{0}".FormatWith(Constant.IndividualTax)))
                    {
                        payrollInfo.IndividualTax = table.Rows[i]["IndividualTax"] != null
                            ? Convert.ToDecimal(table.Rows[i]["IndividualTax"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.TotalIncome)))
                    {
                        payrollInfo.TotalIncome = table.Rows[i]["TotalIncome"] != null
                            ? Convert.ToInt32(table.Rows[i]["TotalIncome"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.EnterpriseSocialInsurance)))
                    {
                        payrollInfo.EnterpriseSocial = table.Rows[i]["EnterpriseSocialInsurance"] != null
                            ? Convert.ToInt32(table.Rows[i]["EnterpriseSocialInsurance"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.LaborerSocialInsurance)))
                    {
                        payrollInfo.LaborerSocial = table.Rows[i]["LaborerSocialInsurance"] != null
                            ? Convert.ToInt32(table.Rows[i]["LaborerSocialInsurance"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.ActualSalary)))
                    {
                        payrollInfo.ActualSalary = table.Rows[i]["ActualSalary"] != null
                            ? Convert.ToInt32(table.Rows[i]["ActualSalary"].ToString())
                            : 0;
                    }

                    var checkExistModel = PayrollInfoController.GetUnique(payrollInfo.SalaryBoardId, payrollInfo.RecordId, payrollInfo.Month, payrollInfo.Year);
                    if (checkExistModel != null)
                    {
                        payrollInfo.Id         = checkExistModel.Id;
                        payrollInfo.EditedDate = DateTime.Now;
                        payrollInfo.EditedBy   = CurrentUser.User.UserName;
                        //update
                        PayrollInfoController.Update(payrollInfo);
                    }
                    else
                    {
                        //create
                        PayrollInfoController.Create(payrollInfo);
                    }
                }
            }

            // update payroll
            PayrollController.Update(_payroll);
        }