Пример #1
0
        public IEnumerable <ComboBoxList> GetProductHelpList(int Id, string term)
        {
            var PurchaseOrder = new PurchaseOrderHeaderService(_unitOfWork).Find(Id);

            var settings = new PurchaseOrderSettingService(_unitOfWork).GetPurchaseOrderSettingForDocument(PurchaseOrder.DocTypeId, PurchaseOrder.DivisionId, PurchaseOrder.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,
            }
                        ).Take(20);

            return(list.ToList());
        }
Пример #2
0
        public IEnumerable <PurchaseIndentLineListViewModel> GetPendingPurchaseIndentHelpList(int Id, string term)
        {
            var PurchaseOrder = new PurchaseOrderHeaderService(_unitOfWork).Find(Id);

            var settings = new PurchaseOrderSettingService(_unitOfWork).GetPurchaseOrderSettingForDocument(PurchaseOrder.DocTypeId, PurchaseOrder.DivisionId, PurchaseOrder.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 PurchaseIndentLineListViewModel
            {
                DocNo = g.Max(m => m.p.PurchaseIndentNo) + " | " + g.Max(m => m.p.DocType.DocumentTypeShortName),
                PurchaseIndentHeaderId = g.Key,

                //    DocumentTypeName=g.Max(p=>p.p.DocumentTypeShortName)
            }
                        ).Take(20);

            return(list.ToList());
        }
Пример #3
0
        public IEnumerable <PurchaseIndentHeaderListViewModel> GetPendingPurchaseIndents(int id, int PurchaseOrderHeaderId)//Product Id
        {
            var PurchaseORder = new PurchaseOrderHeaderService(_unitOfWork).Find(PurchaseOrderHeaderId);

            var Settings = new PurchaseOrderSettingService(_unitOfWork).GetPurchaseOrderSettingForDocument(PurchaseORder.DocTypeId, PurchaseORder.DivisionId, PurchaseORder.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 p in db.ViewPurchaseIndentBalance
                   join t in db.PurchaseIndentLine on p.PurchaseIndentLineId equals t.PurchaseIndentLineId into table from tab in table.DefaultIfEmpty()
                   where p.ProductId == id && 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()))
                   orderby p.PurchaseIndentNo
                   select new PurchaseIndentHeaderListViewModel
            {
                DocNo = p.PurchaseIndentNo,
                PurchaseIndentLineId = p.PurchaseIndentLineId,
                Dimension1Name = tab.Dimension1.Dimension1Name,
                Dimension2Name = tab.Dimension2.Dimension2Name,
            }
                   );
        }
Пример #4
0
        public IEnumerable <PurchaseOrderLineViewModel> GetPurchaseIndentForFilters(PurchaseOrderLineFilterViewModel vm)
        {
            byte?UnitConvForId = new PurchaseOrderHeaderService(_unitOfWork).Find(vm.PurchaseOrderHeaderId).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
                            orderby tab.DocDate, tab.DocNo, tab1.Sr
                            select new PurchaseOrderLineViewModel
                {
                    Dimension1Name = tab1.Dimension1.Dimension1Name,
                    Dimension2Name = tab1.Dimension2.Dimension2Name,
                    Specification = tab1.Specification,
                    IndentBalanceQty = p.BalanceQty,
                    Qty = p.BalanceQty,
                    PurchaseOrderHeaderDocNo = tab.DocNo,
                    ProductName = tab2.ProductName,
                    ProductId = p.ProductId,
                    Rate = vm.Rate,
                    PurchaseOrderHeaderId = vm.PurchaseOrderHeaderId,
                    PurchaseIndentLineId = p.PurchaseIndentLineId,
                    UnitId = tab2.UnitId,
                    PurchaseIndentDocNo = 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
                            orderby tab2.ProductName
                            select new PurchaseOrderLineViewModel
                {
                    Dimension1Name = tab1.Dimension1.Dimension1Name,
                    Dimension2Name = tab1.Dimension2.Dimension2Name,
                    Specification = tab1.Specification,
                    IndentBalanceQty = p.BalanceQty,
                    Qty = p.BalanceQty,
                    PurchaseOrderHeaderDocNo = tab.DocNo,
                    ProductName = tab2.ProductName,
                    ProductId = p.ProductId,
                    Rate = vm.Rate,
                    PurchaseOrderHeaderId = vm.PurchaseOrderHeaderId,
                    PurchaseIndentLineId = p.PurchaseIndentLineId,
                    UnitId = tab2.UnitId,
                    PurchaseIndentDocNo = p.PurchaseIndentNo,
                    DealUnitId = tab2.UnitId,
                    UnitConversionMultiplier = 1,
                    unitDecimalPlaces = tab2.Unit.DecimalPlaces,
                    DealunitDecimalPlaces = tab2.Unit.DecimalPlaces,
                }

                            );
                return(temp);
            }
        }