public async Task <JsonResult> Create(FormCollection fc) { Salaryadjustment o = SalaryadjustmentHelper.GetObject(null, fc); Dictionary <string, object> err = null; ISession se = NHibernateHelper.CurrentSession; err = o.IsValid(); if (err == null) { await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(o); tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Salary Adjustment was successfully added." } }, JsonRequestBehavior.AllowGet)); } else { return(Json(err, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> List() { string staff_id = CommonHelper.GetValue(Request["staff_id"]); int month = CommonHelper.GetValue <int>(Request["month"], 0); int year = CommonHelper.GetValue <int>(Request["year"], 0); int pgnum = CommonHelper.GetValue <int>(Request["pgnum"], 1); int pgsize = CommonHelper.GetValue <int>(Request["pgsize"], 0); string sortcolumn = CommonHelper.GetValue(Request["sortcolumn"], SalaryadjustmentHelper.DEFAULT_SORT_COLUMN); string sortdir = CommonHelper.GetValue(Request["sortdir"], SalaryadjustmentHelper.DEFAULT_SORT_DIR); Sort sort = new Sort(sortcolumn, sortdir); Dictionary <string, object> filters = new Dictionary <string, object> { { "staff_id", staff_id }, { "month", month }, { "year", year } }; ListModel <Salaryadjustment> l = null; if (string.IsNullOrEmpty(staff_id) && month == 0 && year == 0) { l = await SalaryadjustmentHelper.GetAll(pgnum, pgsize, sort); } else { l = await SalaryadjustmentHelper.GetFilterBy(filters, pgnum, pgsize, sort); } return(View("_list", l)); }
// // GET: /Admin/SalaryAdjustment/ public async Task <ActionResult> Index() { ListModel <Salaryadjustment> l = null; l = await SalaryadjustmentHelper.GetAll(); return(View(l)); }
public async Task <JsonResult> Delete(FormCollection fc) { string staff_id = CommonHelper.GetValue(Request["staff_id"]); int month = CommonHelper.GetValue <int>(Request["month"], 0); int year = CommonHelper.GetValue <int>(Request["year"], 0); int pgnum = CommonHelper.GetValue <int>(Request["pgnum"], 1); int pgsize = CommonHelper.GetValue <int>(Request["pgsize"], 0); string ids = fc.Get("id[]"); string[] idlist = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string itemscount = null; Dictionary <string, object> filters = new Dictionary <string, object> { { "staff_id", staff_id }, { "month", month }, { "year", year } }; ISession se = NHibernateHelper.CurrentSession; await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.CreateQuery("delete from Salaryadjustment where id in (:idlist)") .SetParameterList("idlist", idlist) .ExecuteUpdate(); tx.Commit(); } }); if (string.IsNullOrEmpty(staff_id) && month == 0 && year == 0) { itemscount = await SalaryadjustmentHelper.GetItemMessage(null, pgnum, pgsize); } else { itemscount = await SalaryadjustmentHelper.GetItemMessage(filters, pgnum, pgsize); } return(Json(new Dictionary <string, object> { { "success", 1 }, { "itemscount", itemscount }, { "message", string.Format("{0} salary adjustment(s) was successfully deleted.", idlist.Length) } }, JsonRequestBehavior.AllowGet)); }
// // GET: /User/Salary/ public async Task <ActionResult> Index() { ISession se = NHibernateHelper.CurrentSession; SalaryView o = new SalaryView(); object id = Session["employee_id"]; Employee employee = se.Get <Employee>(id); o.Employeesalary = EmployeesalaryHelper.Find(id); double adjustment = await SalaryadjustmentHelper.GetSalaryAdjustment(new Dictionary <string, object> { { "staff_id", employee.Staffid }, { "year", DateTime.Now.Year } }); o.BasicPay = o.Employeesalary.Salary + adjustment; return(View(o)); }
public async Task <ActionResult> Payslip(int month, int year) { ISession se = NHibernateHelper.CurrentSession; object id = Session["employee_id"]; Employee employee = se.Get <Employee>(id); Employeesalary employee_salary = employee.Employeesalary; PayslipModel o = new PayslipModel(); o.Period = string.Format("{0}-{1}", CommonHelper.GetMonthName(month), year); o.Employee = employee; o.EmployeeSalary = employee_salary; if (employee_salary == null) { o.EmployeeSalary = new Employeesalary(); return(View("payslip_monthly", o)); } else { if (employee_salary.Paytype == 1) { Dictionary <string, object> filters = new Dictionary <string, object> { { "year", year }, { "month", month }, { "staff_id", employee.Staffid } }; o.TotalOvertime = await PayslipHelper.GetTotalOvertime(filters); o.TotalOvertimeEarnings = await PayslipHelper.GetTotalOvertimeEarnings(filters, o.TotalOvertime); o.Adjustment = await SalaryadjustmentHelper.GetSalaryAdjustment(filters); o.TotalEarnings = PayslipHelper.GetTotalEarnings(employee_salary, o.Adjustment, o.TotalOvertimeEarnings); o.TotalDeduct = PayslipHelper.GetTotalDeductions(employee_salary); o.NettSalary = PayslipHelper.GetNettSalary(o.TotalEarnings, o.TotalDeduct); o.BasicPay = employee_salary.Salary + o.Adjustment; return(View("payslip_monthly", o)); } else { Dictionary <string, object> filters = new Dictionary <string, object> { { "year", year }, { "month", month }, { "staff_id", employee.Staffid } }; double[] x = await PayslipHelper.GetTotalEarningsHourly(employee_salary, filters); o.TotalEarnings = x[0]; o.TotalHours = x[1]; o.HourlyPayRate = x[2]; o.TotalDeduct = PayslipHelper.GetTotalDeductions(employee_salary); o.NettSalary = PayslipHelper.GetNettSalaryHourly(o.TotalEarnings, o.TotalDeduct); return(View("payslip_hourly", o)); } } }