Ejemplo n.º 1
0
        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());
        }
        public IQueryable <ComboBoxResult> GetCustomProducts(int Id, string term)
        {
            var SaleInvoice = new SaleInvoiceHeaderService(_unitOfWork).FindDirectSaleInvoice(Id);

            var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(SaleInvoice.DocTypeId, SaleInvoice.DivisionId, SaleInvoice.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" };
            }

            return(from p in db.Product
                   where (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())) &&
                   (string.IsNullOrEmpty(term) ? 1 == 1 : p.ProductName.ToLower().Contains(term.ToLower()))
                   orderby p.ProductName
                   select new ComboBoxResult
            {
                id = p.ProductId.ToString(),
                text = p.ProductName,
            });
        }
Ejemplo n.º 6
0
        public IQueryable <ComboBoxResult> GetCustomPerson(int Id, string term)
        {
            int DocTypeId  = Id;
            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

            var settings = new SaleInvoiceSettingService(_unitOfWork).GetSaleInvoiceSettingForDocument(DocTypeId, DivisionId, SiteId);

            string[] PersonRoles = null;
            if (!string.IsNullOrEmpty(settings.filterPersonRoles))
            {
                PersonRoles = settings.filterPersonRoles.Split(",".ToCharArray());
            }
            else
            {
                PersonRoles = new string[] { "NA" };
            }

            string DivIdStr  = "|" + DivisionId.ToString() + "|";
            string SiteIdStr = "|" + SiteId.ToString() + "|";

            var list = (from p in db.Persons
                        join bus in db.BusinessEntity on p.PersonID equals bus.PersonID into BusinessEntityTable
                        from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                        join pp in db.PersonProcess on p.PersonID equals pp.PersonId into PersonProcessTable
                        from PersonProcessTab in PersonProcessTable.DefaultIfEmpty()
                        join pr in db.PersonRole on p.PersonID equals pr.PersonId into PersonRoleTable
                        from PersonRoleTab in PersonRoleTable.DefaultIfEmpty()
                        where PersonProcessTab.ProcessId == settings.ProcessId &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : (p.Name.ToLower().Contains(term.ToLower()) || p.Code.ToLower().Contains(term.ToLower()))) &&
                        (string.IsNullOrEmpty(settings.filterPersonRoles) ? 1 == 1 : PersonRoles.Contains(PersonRoleTab.RoleDocTypeId.ToString())) &&
                        BusinessEntityTab.DivisionIds.IndexOf(DivIdStr) != -1 &&
                        BusinessEntityTab.SiteIds.IndexOf(SiteIdStr) != -1 &&
                        (p.IsActive == null ? 1 == 1 : p.IsActive == true)
                        group new { p } by new { p.PersonID } into Result
                        orderby Result.Max(m => m.p.Name)
                        select new ComboBoxResult
            {
                id = Result.Key.PersonID.ToString(),
                text = Result.Max(m => m.p.Name + ", " + m.p.Suffix + " [" + m.p.Code + "]"),
            }
                        );

            return(list);
        }