Exemplo n.º 1
0
        public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term)
        {
            var JobReturn = new JobReturnHeaderService(_unitOfWork).Find(Id);

            var settings = new JobReceiveSettingsService(_unitOfWork).GetJobReceiveSettingsForDocument(JobReturn.DocTypeId, JobReturn.DivisionId, JobReturn.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 <JobOrderLineListViewModel> GetPendingJobOrderHelpList(int Id, string term)//JobOrderHeaderId
        {
            var JobInvoice = new JobReturnHeaderService(_unitOfWork).Find(Id);

            var settings = new JobReceiveSettingsService(_unitOfWork).GetJobReceiveSettingsForDocument(JobInvoice.DocTypeId, JobInvoice.DivisionId, JobInvoice.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.ViewJobReceiveBalance
                        where (string.IsNullOrEmpty(term) ? 1 == 1 : p.JobOrderNo.ToLower().Contains(term.ToLower())) && p.BalanceQty > 0 && p.JobWorkerId == JobInvoice.JobWorkerId && p.JobOrderLineId != 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.JobOrderHeaderId == null ? -1 : p.JobOrderHeaderId into g
                        select new JobOrderLineListViewModel
            {
                DocNo = g.Max(m => m.p.JobOrderNo),
                JobOrderHeaderId = g.Key,
            }
                        ).Take(20);

            return(list.ToList());
        }