public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term) { var PurchaseInvoice = new PurchaseInvoiceHeaderService(_unitOfWork).Find(Id); var settings = new PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(PurchaseInvoice.DocTypeId, PurchaseInvoice.DivisionId, PurchaseInvoice.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 <PurchaseIndentLineListViewModel> GetPendingIndentsForInvoice(int id, int PurchaseInvoiceHeaderId) { var PurchaseInvoiceHeader = new PurchaseInvoiceHeaderService(_unitOfWork).Find(PurchaseInvoiceHeaderId); var settings = new PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(PurchaseInvoiceHeader.DocTypeId, PurchaseInvoiceHeader.DivisionId, PurchaseInvoiceHeader.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.ViewPurchaseIndentBalance join t1 in db.PurchaseIndentLine on p.PurchaseIndentLineId equals t1.PurchaseIndentLineId into table1 from tab1 in table1.DefaultIfEmpty() where p.ProductId == id && 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 PurchaseIndentLineListViewModel { PurchaseIndentLineId = p.PurchaseIndentLineId, PurchaseIndentHeaderId = p.PurchaseIndentHeaderId, DocNo = p.PurchaseIndentNo, Dimension1Name = tab1.Dimension1.Dimension1Name, Dimension2Name = tab1.Dimension2.Dimension2Name, } ); }
public IEnumerable <PurchaseOrderLineListViewModel> GetPendingPurchaseIndentHelpList(int Id, string term) { var PurchaseInvoice = new PurchaseInvoiceHeaderService(_unitOfWork).Find(Id); var settings = new PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(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.ViewPurchaseIndentBalance where (string.IsNullOrEmpty(term) ? 1 == 1 : p.PurchaseIndentNo.ToLower().Contains(term.ToLower())) && 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())) group new { p } by p.PurchaseIndentHeaderId into g select new PurchaseOrderLineListViewModel { DocNo = g.Max(m => m.p.PurchaseIndentNo), PurchaseIndentHeaderId = g.Key, } ).Take(20); return(list.ToList()); }
public IEnumerable <PurchaseInvoiceLineViewModel> GetPurchaseIndentForFilters(PurchaseInvoiceLineFilterViewModel vm) { byte?UnitConvForId = new PurchaseInvoiceHeaderService(_unitOfWork).Find(vm.PurchaseInvoiceHeaderId).UnitConversionForId; string[] ProductIdArr = null; if (!string.IsNullOrEmpty(vm.ProductId)) { ProductIdArr = vm.ProductId.Split(",".ToCharArray()); } else { ProductIdArr = new string[] { "NA" }; } string[] SaleOrderIdArr = null; if (!string.IsNullOrEmpty(vm.PurchaseIndentHeaderId)) { SaleOrderIdArr = vm.PurchaseIndentHeaderId.Split(",".ToCharArray()); } else { SaleOrderIdArr = new string[] { "NA" }; } string[] ProductGroupIdArr = null; if (!string.IsNullOrEmpty(vm.ProductGroupId)) { ProductGroupIdArr = vm.ProductGroupId.Split(",".ToCharArray()); } else { ProductGroupIdArr = new string[] { "NA" }; } if (!string.IsNullOrEmpty(vm.DealUnitId)) { Unit Dealunit = new UnitService(_unitOfWork).Find(vm.DealUnitId); var temp = (from p in db.ViewPurchaseIndentBalance join t in db.PurchaseIndentHeader on p.PurchaseIndentHeaderId equals t.PurchaseIndentHeaderId into table from tab in table.DefaultIfEmpty() join product in db.Product on p.ProductId equals product.ProductId into table2 join t1 in db.PurchaseIndentLine on p.PurchaseIndentLineId equals t1.PurchaseIndentLineId into table1 from tab1 in table1.DefaultIfEmpty() from tab2 in table2.DefaultIfEmpty() join t3 in db.UnitConversion on new { p1 = p.ProductId, DU1 = vm.DealUnitId, U1 = UnitConvForId ?? 0 } equals new { p1 = t3.ProductId ?? 0, DU1 = t3.ToUnitId, U1 = t3.UnitConversionForId } into table3 from tab3 in table3.DefaultIfEmpty() where (string.IsNullOrEmpty(vm.ProductId) ? 1 == 1 : ProductIdArr.Contains(p.ProductId.ToString())) && (string.IsNullOrEmpty(vm.PurchaseIndentHeaderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.PurchaseIndentHeaderId.ToString())) && (string.IsNullOrEmpty(vm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) && p.BalanceQty > 0 select new PurchaseInvoiceLineViewModel { Dimension1Name = tab1.Dimension1.Dimension1Name, Dimension2Name = tab1.Dimension2.Dimension2Name, Dimension1Id = tab1.Dimension1Id, Dimension2Id = tab1.Dimension2Id, Specification = tab1.Specification, IndentBalQty = p.BalanceQty, Qty = p.BalanceQty, Rate = vm.Rate, ProductName = tab2.ProductName, ProductId = p.ProductId, PurchaseInvoiceHeaderId = vm.PurchaseInvoiceHeaderId, PurchaseIndentLineId = p.PurchaseIndentLineId, UnitId = tab2.UnitId, PurchaseIndentHeaderDocNo = p.PurchaseIndentNo, DealUnitId = (tab3 == null ? tab2.UnitId : vm.DealUnitId), UnitConversionMultiplier = (tab3 == null ? 1 : tab3.ToQty / tab3.FromQty), UnitConversionException = tab3 == null ? true : false, unitDecimalPlaces = tab2.Unit.DecimalPlaces, DealunitDecimalPlaces = (tab3 == null ? tab2.Unit.DecimalPlaces : Dealunit.DecimalPlaces), } ); return(temp); } else { var temp = (from p in db.ViewPurchaseIndentBalance join t in db.PurchaseIndentHeader on p.PurchaseIndentHeaderId equals t.PurchaseIndentHeaderId into table from tab in table.DefaultIfEmpty() join product in db.Product on p.ProductId equals product.ProductId into table2 join t1 in db.PurchaseIndentLine on p.PurchaseIndentLineId equals t1.PurchaseIndentLineId into table1 from tab1 in table1.DefaultIfEmpty() from tab2 in table2.DefaultIfEmpty() where (string.IsNullOrEmpty(vm.ProductId) ? 1 == 1 : ProductIdArr.Contains(p.ProductId.ToString())) && (string.IsNullOrEmpty(vm.PurchaseIndentHeaderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.PurchaseIndentHeaderId.ToString())) && (string.IsNullOrEmpty(vm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) && p.BalanceQty > 0 select new PurchaseInvoiceLineViewModel { Dimension1Name = tab1.Dimension1.Dimension1Name, Dimension1Id = tab1.Dimension1Id, Dimension2Name = tab1.Dimension2.Dimension2Name, Dimension2Id = tab1.Dimension2Id, Specification = tab1.Specification, IndentBalQty = p.BalanceQty, Qty = p.BalanceQty, Rate = vm.Rate, PurchaseIndentHeaderDocNo = tab.DocNo, ProductName = tab2.ProductName, ProductId = p.ProductId, PurchaseInvoiceHeaderId = vm.PurchaseInvoiceHeaderId, PurchaseIndentLineId = p.PurchaseIndentLineId, UnitId = tab2.UnitId, DealUnitId = tab2.UnitId, UnitConversionMultiplier = 1, unitDecimalPlaces = tab2.Unit.DecimalPlaces, DealunitDecimalPlaces = tab2.Unit.DecimalPlaces, } ); return(temp); } }