public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term)
        {
            var PurchaseInvoiceReturn = new PurchaseInvoiceReturnHeaderService(_unitOfWork).Find(Id);

            var settings = new PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(PurchaseInvoiceReturn.DocTypeId, PurchaseInvoiceReturn.DivisionId, PurchaseInvoiceReturn.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());
        }
Exemplo n.º 2
0
        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 <PurchaseGoodsReceiptListViewModel> GetPendingPurchaseReceiptHelpList(int Id, string term)
        {
            var GoodsReceipt = new PurchaseInvoiceReturnHeaderService(_unitOfWork).Find(Id);

            var settings = new PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(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.ViewPurchaseInvoiceBalance
                        where (string.IsNullOrEmpty(term) ? 1 == 1 : p.PurchaseGoodsReceiptNo.ToLower().Contains(term.ToLower())) && p.SupplierId == GoodsReceipt.SupplierId && p.BalanceQty > 0 &&
                        (string.IsNullOrEmpty(settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(p.PurchaseInvoiceDocTypeId.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.PurchaseGoodsReceiptHeaderId into g
                        select new PurchaseGoodsReceiptListViewModel
            {
                DocNo = g.Max(m => m.p.PurchaseGoodsReceiptNo),
                PurchaseGoodsReceiptHeaderId = g.Key,
            }
                        ).Take(20);

            return(list.ToList());
        }
        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 PurchaseInvoiceSettingService(_unitOfWork).GetPurchaseInvoiceSettingForDocument(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);
        }