public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term) { var PurchaseGoodsReturn = new PurchaseGoodsReturnHeaderService(_unitOfWork).Find(Id); var settings = new PurchaseGoodsReceiptSettingService(_unitOfWork).GetPurchaseGoodsReceiptSettingForDocument(PurchaseGoodsReturn.DocTypeId, PurchaseGoodsReturn.DivisionId, PurchaseGoodsReturn.SiteId); string[] ProductTypes = null; if (!string.IsNullOrEmpty(settings.filterProductTypes)) { ProductTypes = settings.filterProductTypes.Split(",".ToCharArray()); } else { ProductTypes = new string[] { "NA" }; } var list = (from p in db.Product where (string.IsNullOrEmpty(term) ? 1 == 1 : p.ProductName.ToLower().Contains(term.ToLower())) && (string.IsNullOrEmpty(settings.filterProductTypes) ? 1 == 1 : ProductTypes.Contains(p.ProductGroup.ProductTypeId.ToString())) group new { p } by p.ProductId into g select new ComboBoxList { PropFirst = g.Max(m => m.p.ProductName), Id = g.Key, // DocumentTypeName=g.Max(p=>p.p.DocumentTypeShortName) } ).Take(20); return(list.ToList()); }
public IEnumerable <PurchaseGoodsReceiptListViewModel> GetPendingReceipts(int id, int PurchaseGoodsReturnHeaderId) { var PurchaseGoodsReturn = new PurchaseGoodsReturnHeaderService(_unitOfWork).Find(PurchaseGoodsReturnHeaderId); var settings = new PurchaseGoodsReceiptSettingService(_unitOfWork).GetPurchaseGoodsReceiptSettingForDocument(PurchaseGoodsReturn.DocTypeId, PurchaseGoodsReturn.DivisionId, PurchaseGoodsReturn.SiteId); string[] contraDocTypes = null; if (!string.IsNullOrEmpty(settings.filterContraDocTypes)) { contraDocTypes = settings.filterContraDocTypes.Split(",".ToCharArray()); } else { contraDocTypes = new string[] { "NA" }; } string[] contraSites = null; if (!string.IsNullOrEmpty(settings.filterContraSites)) { contraSites = settings.filterContraSites.Split(",".ToCharArray()); } else { contraSites = new string[] { "NA" }; } string[] contraDivisions = null; if (!string.IsNullOrEmpty(settings.filterContraDivisions)) { contraDivisions = settings.filterContraDivisions.Split(",".ToCharArray()); } else { contraDivisions = new string[] { "NA" }; } int CurrentSiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; return(from p in db.ViewPurchaseGoodsReceiptBalance join t in db.PurchaseGoodsReceiptHeader on p.PurchaseGoodsReceiptHeaderId equals t.PurchaseGoodsReceiptHeaderId into table from tab in table.DefaultIfEmpty() join t1 in db.PurchaseOrderLine on p.PurchaseOrderLineId equals t1.PurchaseOrderLineId into table1 from tab1 in table1.DefaultIfEmpty() where p.ProductId == id && tab.SupplierId == PurchaseGoodsReturn.SupplierId && p.BalanceQty > 0 && (string.IsNullOrEmpty(settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(p.DocTypeId.ToString())) && (string.IsNullOrEmpty(settings.filterContraSites) ? p.SiteId == CurrentSiteId : contraSites.Contains(p.SiteId.ToString())) && (string.IsNullOrEmpty(settings.filterContraDivisions) ? p.DivisionId == CurrentDivisionId : contraDivisions.Contains(p.DivisionId.ToString())) select new PurchaseGoodsReceiptListViewModel { PurchaseGoodsReceiptLineId = p.PurchaseGoodsReceiptLineId, PurchaseGoodsReceiptHeaderId = p.PurchaseGoodsReceiptHeaderId, DocNo = tab.DocNo, Dimension1Name = tab1.Dimension1.Dimension1Name, Dimension2Name = tab1.Dimension2.Dimension2Name, } ); }
public IEnumerable <PurchaseOrderLineListViewModel> GetPendingPurchaseOrderHelpList(int Id, string term)//PurchaseOrderHeaderId { var PurchaseInvoice = new PurchaseGoodsReturnHeaderService(_unitOfWork).Find(Id); var settings = new PurchaseGoodsReceiptSettingService(_unitOfWork).GetPurchaseGoodsReceiptSettingForDocument(PurchaseInvoice.DocTypeId, PurchaseInvoice.DivisionId, PurchaseInvoice.SiteId); string[] contraDocTypes = null; if (!string.IsNullOrEmpty(settings.filterContraDocTypes)) { contraDocTypes = settings.filterContraDocTypes.Split(",".ToCharArray()); } else { contraDocTypes = new string[] { "NA" }; } string[] contraSites = null; if (!string.IsNullOrEmpty(settings.filterContraSites)) { contraSites = settings.filterContraSites.Split(",".ToCharArray()); } else { contraSites = new string[] { "NA" }; } string[] contraDivisions = null; if (!string.IsNullOrEmpty(settings.filterContraDivisions)) { contraDivisions = settings.filterContraDivisions.Split(",".ToCharArray()); } else { contraDivisions = new string[] { "NA" }; } int CurrentSiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var list = (from p in db.ViewPurchaseGoodsReceiptBalance where (string.IsNullOrEmpty(term) ? 1 == 1 : p.PurchaseOrderNo.ToLower().Contains(term.ToLower())) && p.BalanceQty > 0 && p.SupplierId == PurchaseInvoice.SupplierId && p.PurchaseOrderLineId != null && (string.IsNullOrEmpty(settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(p.DocTypeId.ToString())) && (string.IsNullOrEmpty(settings.filterContraSites) ? p.SiteId == CurrentSiteId : contraSites.Contains(p.SiteId.ToString())) && (string.IsNullOrEmpty(settings.filterContraDivisions) ? p.DivisionId == CurrentDivisionId : contraDivisions.Contains(p.DivisionId.ToString())) group new { p } by p.PurchaseOrderHeaderId == null ? -1 : p.PurchaseOrderHeaderId into g select new PurchaseOrderLineListViewModel { DocNo = g.Max(m => m.p.PurchaseOrderNo), PurchaseOrderHeaderId = g.Key, } ).Take(20); return(list.ToList()); }