public IEnumerable <SaleInvoiceListViewModel> GetPendingInvoices(int id, int SaleInvoiceReturnHeaderId) { var SaleInvoiceReturnHeader = new SaleInvoiceReturnHeaderService(_unitOfWork).Find(SaleInvoiceReturnHeaderId); var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(SaleInvoiceReturnHeader.DocTypeId, SaleInvoiceReturnHeader.DivisionId, SaleInvoiceReturnHeader.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.ViewSaleInvoiceBalance join t in db.SaleInvoiceHeader on p.SaleInvoiceHeaderId equals t.SaleInvoiceHeaderId into table from tab in table.DefaultIfEmpty() join t1 in db.SaleDispatchLine on p.SaleDispatchLineId equals t1.SaleDispatchLineId into table1 from tab1 in table1.DefaultIfEmpty() join t2 in db.SaleInvoiceLine on p.SaleDispatchLineId equals t2.SaleDispatchLineId into InvoiceTable from InvTab in InvoiceTable.DefaultIfEmpty() where InvTab.ProductId == id && tab.SaleToBuyerId == SaleInvoiceReturnHeader.BuyerId && p.BalanceQty > 0 && (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 SaleInvoiceListViewModel { SaleInvoiceLineId = p.SaleInvoiceLineId, SaleInvoiceHeaderId = p.SaleInvoiceHeaderId, DocNo = tab.DocNo, Dimension1Name = InvTab.Dimension1.Dimension1Name, Dimension2Name = InvTab.Dimension2.Dimension2Name, } ); }
public IEnumerable <ComboBoxResult> GetSaleInvoiceHelpListForProduct(int Id, string term) { var SaleInvoiceReturnHeader = new SaleInvoiceReturnHeaderService(_unitOfWork).Find(Id); var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(SaleInvoiceReturnHeader.DocTypeId, SaleInvoiceReturnHeader.DivisionId, SaleInvoiceReturnHeader.SiteId); 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 VSib in db.ViewSaleInvoiceBalance join L in db.SaleInvoiceLine on VSib.SaleInvoiceLineId equals L.SaleInvoiceLineId into SaleInvoiceLineTable from SaleInvoiceLineTab in SaleInvoiceLineTable.DefaultIfEmpty() where VSib.BalanceQty > 0 && SaleInvoiceLineTab.SaleInvoiceHeader.SaleToBuyerId == SaleInvoiceReturnHeader.BuyerId && (string.IsNullOrEmpty(settings.filterContraSites) ? VSib.SiteId == CurrentSiteId : contraSites.Contains(VSib.SiteId.ToString())) && (string.IsNullOrEmpty(settings.filterContraDivisions) ? VSib.DivisionId == CurrentDivisionId : contraDivisions.Contains(VSib.DivisionId.ToString())) && (string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.SaleInvoiceHeader.DocNo.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.SaleInvoiceHeader.DocType.DocumentTypeShortName.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.Product.ProductName.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.Dimension1.Dimension1Name.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.Dimension2.Dimension2Name.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.Dimension3.Dimension3Name.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : SaleInvoiceLineTab.Dimension4.Dimension4Name.ToLower().Contains(term.ToLower()) ) select new ComboBoxResult { id = VSib.SaleInvoiceLineId.ToString(), text = SaleInvoiceLineTab.SaleInvoiceHeader.DocType.DocumentTypeShortName + "-" + SaleInvoiceLineTab.SaleInvoiceHeader.DocNo, TextProp1 = "Balance :" + VSib.BalanceQty, TextProp2 = "Date :" + SaleInvoiceLineTab.SaleInvoiceHeader.DocDate, AProp1 = SaleInvoiceLineTab.Product.ProductName, AProp2 = ((SaleInvoiceLineTab.Dimension1.Dimension1Name == null) ? "" : SaleInvoiceLineTab.Dimension1.Dimension1Name) + ((SaleInvoiceLineTab.Dimension2.Dimension2Name == null) ? "" : "," + SaleInvoiceLineTab.Dimension2.Dimension2Name) + ((SaleInvoiceLineTab.Dimension3.Dimension3Name == null) ? "" : "," + SaleInvoiceLineTab.Dimension3.Dimension3Name) + ((SaleInvoiceLineTab.Dimension4.Dimension4Name == null) ? "" : "," + SaleInvoiceLineTab.Dimension4.Dimension4Name) }); }
public IEnumerable <SaleDispatchListViewModel> GetPendingSaleReceiptHelpList(int Id, string term) { var GoodsReceipt = new SaleInvoiceReturnHeaderService(_unitOfWork).Find(Id); var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(GoodsReceipt.DocTypeId, GoodsReceipt.DivisionId, GoodsReceipt.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.ViewSaleInvoiceBalance where (string.IsNullOrEmpty(term) ? 1 == 1 : p.SaleDispatchNo.ToLower().Contains(term.ToLower())) && p.SaleToBuyerId == GoodsReceipt.BuyerId && p.BalanceQty > 0 && (string.IsNullOrEmpty(settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(p.SaleInvoiceDocTypeId.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.SaleDispatchHeaderId into g select new SaleDispatchListViewModel { DocNo = g.Max(m => m.p.SaleDispatchNo), SaleDispatchHeaderId = g.Key, } ).Take(20); return(list.ToList()); }
public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term) { var SaleInvoiceReturn = new SaleInvoiceReturnHeaderService(_unitOfWork).Find(Id); var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(SaleInvoiceReturn.DocTypeId, SaleInvoiceReturn.DivisionId, SaleInvoiceReturn.SiteId); string[] ProductTypes = null; if (!string.IsNullOrEmpty(settings.filterProductTypes)) { ProductTypes = settings.filterProductTypes.Split(",".ToCharArray()); } else { ProductTypes = new string[] { "NA" }; } string[] Products = null; if (!string.IsNullOrEmpty(settings.filterProducts)) { Products = settings.filterProducts.Split(",".ToCharArray()); } else { Products = new string[] { "NA" }; } string[] ProductGroups = null; if (!string.IsNullOrEmpty(settings.filterProductGroups)) { ProductGroups = settings.filterProductGroups.Split(",".ToCharArray()); } else { ProductGroups = 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())) && (string.IsNullOrEmpty(settings.filterProducts) ? 1 == 1 : Products.Contains(p.ProductId.ToString())) && (string.IsNullOrEmpty(settings.filterProductGroups) ? 1 == 1 : ProductGroups.Contains(p.ProductGroupId.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()); }