public ActionResult ProductPart(ProductFilter filter) { var model = ProductPartReport.Get(UserID, Employee.BussinessID, filter); if (Request.IsAjaxRequest()) { return(Json(new { html = RenderPartialViewToString(Views.ProductPartPartial, model) }, JsonRequestBehavior.AllowGet)); } return(View(Views.ProductPart, model)); }
public ActionResult ProductPart() { var model = new ProductPartReport(); if (Request.IsAjaxRequest()) { return(Json(new { html = RenderPartialViewToString(Views.ProductPartPartial, model) }, JsonRequestBehavior.AllowGet)); } return(View(Views.ProductPart, model)); }
public static ProductPartReport Get(int userID, int bussinessID, ProductFilter filter = null) { var result = new ProductPartReport(filter); try { var conditions = new List <string>(); if (filter != null) { if (!String.IsNullOrEmpty(filter.Code)) { conditions.Add(String.Format("and p.Code like N'%{0}%'", filter.Code)); } if (!String.IsNullOrEmpty(filter.Name)) { conditions.Add(String.Format("and p.Name like N'%{0}%'", filter.Name)); } } var query = String.Format( @"select p.*, t.ID as [TagID], t.Name as [TagName], s.Name as [SupplierName], (select isnull(sum(ep.Quantity), 0) from ExportProduct ep join Export e on ep.ExportID = e.ID join Warranty r on ep.WarrantyID = r.ID and r.Status = 'active' {3} {4} where ep.ProductID = p.ID and ep.WarrantyID is not null and ((select Username from Login where ID = {2}) = 'admin' or e.WarehouseID in (select WarehouseID from LoginWarehouse where LoginID = {2}))) + (select isnull(sum(ep.Quantity), 0) from ExportProduct ep join Export e on ep.ExportID = e.ID join Repair r on ep.RepairID = r.ID and r.Status = 'active' {3} {4} where ep.ProductID = p.ID and ep.RepairID is not null and ((select Username from Login where ID = {2}) = 'admin' or e.WarehouseID in (select WarehouseID from LoginWarehouse where LoginID = {2}))) as [Quantity] from Product p left join Supplier s on p.SupplierID = s.ID join ProductTag pt on p.ID = pt.ProductID and pt.TagID = (select top 1 TagID from ProductTag where ProductID = p.ID order by TagID desc) join Tag t on pt.TagID = t.ID and t.Status = 'active' and t.ForRepair = 1 where p.Status = 'active' and p.BussinessID = {0} {1} order by Name", bussinessID, String.Join(" ", conditions), userID, filter != null && filter.From.HasValue ? String.Format(" and r.SubmitDate >= {0}", filter.From.DbValue()) : "", filter != null && filter.To.HasValue ? String.Format(" and r.SubmitDate <= {0}", filter.To.DbValue()) : ""); using (var con = Repo.DB.SKtimeManagement) { result.Data = con.Query <ProductInfo>(query).ToList(); } } catch { } return(result); }