public ActionResult _CreateList(SalaryMasterModel smModel) { ViewBag.PayDate = DateTime.Now.ToString("yyyy-MM-dd"); ViewBag.FromDate = smModel.FromDate; ViewBag.ToDate = smModel.ToDate; //Get thông tin nhân viên //var emp = _context.EmployeeModel.Where(p => p.Actived == true && p.EmployeeId != 10001).ToList(); //foreach(var item in emp) //{ // detail.Add(new SalaryDetailViewModel() // { // EmployeeId = item.EmployeeId, // EmployeeName = item.FullName // }); //} if (smModel.FromDate == null && smModel.ToDate == null) { var query = (from emp in _context.EmployeeModel join dco in _context.Daily_ChicCut_OrderModel on emp.EmployeeId equals dco.StaffId into ret1 from ret2 in ret1.DefaultIfEmpty() where emp.Actived == true && emp.EmployeeId != 10001 orderby emp.EmployeeId group ret2 by new { ret2.StaffId, emp.FullName } into g select new SalaryDetailViewModel() { EmployeeName = g.Key.FullName, }); return(PartialView(query.ToList())); } else { var result = (from emp in _context.EmployeeModel join dco in _context.Daily_ChicCut_OrderModel on emp.EmployeeId equals dco.StaffId into ret1 from ret2 in ret1.DefaultIfEmpty() where emp.Actived == true && emp.EmployeeId != 10001 && ret2.CashierDate >= smModel.FromDate && ret2.CashierDate <= smModel.ToDate orderby emp.EmployeeId group ret2 by new { ret2.StaffId, emp.FullName } into g select new SalaryDetailViewModel() { EmployeeName = g.Key.FullName, Tip = g.Sum(p => p.Tip), Commission = g.Sum(p => p.Commission), }); return(PartialView(result.ToList())); } }
public ActionResult CreateNew(DateTime?FromDate, DateTime?ToDate) { SalaryMasterModel smModel = new SalaryMasterModel(); if (FromDate == null && ToDate == null) { return(Json("Vui lòng nhập thông tin có dấu (*)!", JsonRequestBehavior.AllowGet)); } else { smModel.FromDate = FromDate; ViewBag.FromDate = smModel.FromDate; smModel.ToDate = ToDate; ViewBag.ToDate = smModel.ToDate; return(PartialView()); } }