public ActionResult ProcessingServices() { var list = ServiceReport.ProcessingServices(UserID, Employee.BussinessID); return(Json(new { html = RenderPartialViewToString("ProcessingServices", list) }, JsonRequestBehavior.AllowGet)); }
public static ServiceReport ProcessingServices(int userID, int bussinessID, bool includeFinished = false) { var result = new ServiceReport(); try { using (var con = Repo.DB.SKtimeManagement) { result.Warranties = con.Query <Warranty>(String.Format( @"select w.ID, w.BussinessID, w.EmployeeID, w.WarehouseID, w.ProductID, w.ClientID, w.OrderID, w.Code, w.SubmitDate, w.TransferDate, w.ReceivedDate, w.ProcessedDate, w.ReturnedDate, w.FinishDate, w.ProductState, w.Fee, w.Discount, w.Other, w.Note, wh.Name as [WarehouseName], e.Name as [EmployeeName], c.Name as [ClientName], c.Code as [ClientCode], c.Address as [ClientAddress], c.Phone as [ClientPhone], case when w.OrderID is not null then o.Code else w.OrderCode end as [OrderCode], isnull(sum(t.Amount), 0) as [Paid] from Warranty w join Warehouse wh on w.WarehouseID = wh.ID and w.Status = 'active' and ((select Username from Login where ID = {1}) = 'admin' or wh.ID in (select WarehouseID from LoginWarehouse where LoginID = {1})) join Employee e on w.EmployeeID = e.ID join Product p on p.ID = w.ProductID left join Client c on w.ClientID = c.ID left join [Order] o on w.OrderID = o.ID left join Transactions t on w.ID = t.WarrantyID where w.BussinessID = {0} and w.Status = 'active' {2} group by w.ID, w.BussinessID, w.EmployeeID, w.WarehouseID, w.ProductID, w.ClientID, w.OrderID, w.Code, w.SubmitDate, w.TransferDate, w.ReceivedDate, w.ProcessedDate, w.ReturnedDate, w.FinishDate, w.ProductState, w.Fee, w.Discount, w.Other, w.Note, wh.Name, e.Name, c.Name, c.Code, c.Address, c.Phone, o.Code, w.OrderCode order by w.FinishDate", bussinessID, userID, includeFinished ? "" : String.Format("and (w.ReturnedDate is null or w.FinishDate > {0})", DateTime.Now.DbValue()))).ToList(); result.Repaires = con.Query <Repair>(String.Format( @"select w.ID, w.BussinessID, w.EmployeeID, w.WarehouseID, w.ProductID, w.ClientID, w.Code, w.SubmitDate, w.TransferDate, w.ReceivedDate, w.ProcessedDate, w.ReturnedDate, w.FinishDate, w.ProductState, w.Fee, w.Discount, w.Other, w.Note, wh.Name as [WarehouseName], e.Name as [EmployeeName], c.Name as [ClientName], c.Code as [ClientCode], c.Address as [ClientAddress], c.Phone as [ClientPhone], isnull(sum(t.Amount), 0) as [Paid] from Repair w join Warehouse wh on w.WarehouseID = wh.ID and w.Status = 'active' and ((select Username from Login where ID = {1}) = 'admin' or wh.ID in (select WarehouseID from LoginWarehouse where LoginID = {1})) join Employee e on w.EmployeeID = e.ID join Product p on p.ID = w.ProductID left join Client c on w.ClientID = c.ID left join Transactions t on w.ID = t.RepairID where w.BussinessID = {0} and w.Status = 'active' {2} group by w.ID, w.BussinessID, w.EmployeeID, w.WarehouseID, w.ProductID, w.ClientID, w.Code, w.SubmitDate, w.TransferDate, w.ReceivedDate, w.ProcessedDate, w.ReturnedDate, w.FinishDate, w.ProductState, w.Fee, w.Discount, w.Other, w.Note, wh.Name, e.Name, c.Name, c.Code, c.Address, c.Phone order by w.FinishDate", bussinessID, userID, includeFinished ? "" : String.Format("and (w.ReturnedDate is null or w.FinishDate > {0})", DateTime.Now.DbValue()))).ToList(); } } catch { } return(result); }