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"]; } int?year = null; if (!string.IsNullOrEmpty(context.Request["year"])) { year = Convert.ToInt32(context.Request["year"]); } // select from db var pageResult = PayrollInfoController.GetInsuranceProcessList(_keyWord, null, null, null, null, year, false, 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))); }
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); }