コード例 #1
0
        // GET: AvailableSpace/Create
        public ActionResult Create(int SeasonID)
        {
            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            SpaceBusinessLayer sbl          = new SpaceBusinessLayer();
            List <Space>       ListOfSpaces = sbl.Spaces.ToList();

            CatBusinessLayer cbl        = new CatBusinessLayer();
            List <Cat>       ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription
            });
            ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")"
            });
            ViewData["ddSpace"] = ListOfSpaces.Select(m => new SelectListItem {
                Value = m.SpaceID.ToString(), Text = m.SpaceDesc + " (" + m.SpaceID.ToString() + ")", Selected = m.SpaceID == 1
            });

            return(View());
        }
コード例 #2
0
        // GET: AvailableSpace/Edit/5
        public ActionResult Edit(string id)
        {
            AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer();
            AvailableSpace sa = sbl.AvailableSpaces.Where(i => i.ID == id).Single();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            SpaceBusinessLayer spbl         = new SpaceBusinessLayer();
            List <Space>       ListOfSpaces = spbl.Spaces.ToList();

            CatBusinessLayer cbl        = new CatBusinessLayer();
            List <Cat>       ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == sa.SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == sa.SpaceGradeID
            });
            ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == sa.CatID
            });
            ViewData["ddSpace"] = ListOfSpaces.Select(m => new SelectListItem {
                Value = m.SpaceID.ToString(), Text = m.SpaceDesc + " (" + m.SpaceID.ToString() + ")", Selected = m.SpaceID == sa.SpaceID
            });

            return(View(sa));
        }
コード例 #3
0
        // GET: Season
        public ActionResult Index()
        {
            SeasonBusinessLayer sbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = sbl.Seasons.OrderBy(i => i.FirstLaunchDate).ToList();

            return(View(ListOfSeasons));
        }
コード例 #4
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Edit";

            try
            {
                SeasonBusinessLayer bl = new SeasonBusinessLayer();
                Season a = bl.Seasons.Where(p => p.SeasonID == id).Single();

                #region Pull from Form Collection
                a.SeasonDesc      = (string)collection["SeasonDesc"];
                a.SeasonActive    = Convert.ToInt32(collection["ddActive"]);
                a.FirstLaunchDate = Convert.ToDateTime(collection["FirstLaunchDate"]);
                a.VAT             = Convert.ToDecimal(collection["VAT"]);
                a.GBPUSD          = Convert.ToDecimal(collection["GBPUSD"]);
                a.GBPEUR          = Convert.ToDecimal(collection["GBPEUR"]);
                #endregion

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Delete";

            try
            {
                SeasonBusinessLayer bl = new SeasonBusinessLayer();
                Season a = bl.Seasons.Where(p => p.SeasonID == id).Single();

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
コード例 #6
0
        // GET: Season/Delete/5
        public ActionResult Delete(int id)
        {
            SeasonBusinessLayer bl = new SeasonBusinessLayer();
            Season o = bl.Seasons.Where(p => p.SeasonID == id).Single();

            ViewBag.ID = id;
            return(View(o));
        }
コード例 #7
0
        // GET: PreArticleSeasonal/Edit/5
        public ActionResult Edit(string id)
        {
            #region StaticData
            SeasonBusinessLayer sbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = sbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

            VendorBusinessLayer vbl           = new VendorBusinessLayer();
            List <Vendor>       ListOfVendors = vbl.Vendors.OrderBy(o => o.VendorID).ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.Where(z => z.PreArticleGrade == 1).OrderBy(o => o.GradeOrder).ToList();

            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.OrderBy(o => o.MerchCatID).ToList();

            SpaceUseBusinessLayer spbl            = new SpaceUseBusinessLayer();
            List <SpaceUse>       ListOfSpaceUses = spbl.SpaceUses.ToList();

            StatusBusinessLayer tbl            = new StatusBusinessLayer();
            List <Status>       ListOfStatuses = tbl.Statuses.ToList();

            #endregion

            PreArticleSeasonalBusinessLayer pbl       = new PreArticleSeasonalBusinessLayer();
            PreArticleSeasonal SomePreArticleSeasonal = pbl.PreArticleSeasonals.Where(i => i.ID == id).Single();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SomePreArticleSeasonal.SeasonID
            });
            ViewData["ddGradeP"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == SomePreArticleSeasonal.ProposedPreArticleGradeID
            });
            ViewData["ddGradeC"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == SomePreArticleSeasonal.ConfirmedPreArticleGradeID
            });
            ViewData["ddMerchCat"] = ListOfMerchCats.Select(m => new SelectListItem {
                Value = m.MerchCatID.ToString(), Text = m.MerchCatDesc + " (" + m.MerchCatID.ToString() + ")", Selected = m.MerchCatID == SomePreArticleSeasonal.MerchCatID
            });
            ViewData["ddVendor"] = ListOfVendors.Select(m => new SelectListItem {
                Value = m.VendorID, Text = m.VendorDesc + " (" + m.VendorID + ")", Selected = m.VendorID == SomePreArticleSeasonal.VendorID
            });
            ViewData["ddSpaceUse"] = ListOfSpaceUses.Select(m => new SelectListItem {
                Value = m.SpaceUseID.ToString(), Text = m.SpaceUseDesc + " (" + m.SpaceUseID.ToString() + ")", Selected = m.SpaceUseID == SomePreArticleSeasonal.VendorID
            });
            ViewData["ddContinue"] = ListOfStatuses.Where(i => i.StatusType == "C").Select(m => new SelectListItem {
                Value = m.StatusID.ToString(), Text = m.StatusDesc + " (" + m.StatusID.ToString() + ")", Selected = m.StatusID == SomePreArticleSeasonal.ConfirmedPreArticleGradeID
            });
            ViewData["ddReplacement"] = ListOfStatuses.Where(i => i.StatusType == "R").Select(m => new SelectListItem {
                Value = m.StatusID.ToString(), Text = m.StatusDesc + " (" + m.StatusID.ToString() + ")", Selected = m.StatusID == SomePreArticleSeasonal.ReplacementStatusID
            });


            ViewBag.SeasonID = SomePreArticleSeasonal.SeasonID;
            return(View(SomePreArticleSeasonal));
        }
コード例 #8
0
        // GET: AttributeValue/Create
        public ActionResult Create(int Sfid = 0, int SeasonID = 0)
        {
            #region StaticDropdowns
            SeasonBusinessLayer sbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = sbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();
            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });

            AttributeBusinessLayer abl = new AttributeBusinessLayer();
            List <BusinessLayerLibrary.Attribute> ListOfAttributes = abl.Attributes.Where(w => w.Calculated == 0).OrderBy(o => o.AttributeOrder).ToList();

            //exclude attributes that already have values
            AttributeValueBusinessLayer           rbl = new AttributeValueBusinessLayer();
            List <AttributeValue>                 ListOfAttributeValues     = rbl.AttributeValues.Where(r => r.SFID == Sfid && r.SeasonID == SeasonID).ToList();
            List <BusinessLayerLibrary.Attribute> ListOfPopulatedAttributes = ListOfAttributeValues.Select(q => new BusinessLayerLibrary.Attribute {
                AttributeID = q.AttributeID
            }).ToList();
            ListOfAttributes = ListOfAttributes.Except(ListOfPopulatedAttributes, new Compare.LambdaComparer <BusinessLayerLibrary.Attribute>((x, y) => x.AttributeID == y.AttributeID)).ToList();

            //include only attributes that the user has write permissions for
            //work out what team the user is in
            int TeamID                       = 0;
            UserBusinessLayer ubl            = new UserBusinessLayer();
            string            ShortNetworkID = User.Identity.Name.Split('\\')[1].ToLower();
            if (ubl.Users.Any(o => o.NetworkID == ShortNetworkID))
            {
                TeamID = ubl.Users.Where(o => o.NetworkID == ShortNetworkID).Single().TeamID;
            }

            //TeamBusinessLayer tbl = new TeamBusinessLayer();
            //List<Team> WhatTeamsAmIIn = tbl.Teams(User.Identity.Name).ToList();
            TeamAttributePermissionBusinessLayer tapbl = new TeamAttributePermissionBusinessLayer();
            //List<TeamAttributePermission> WhatAttributesCanIWriteTo = tapbl.TeamAttributePermissions.Join(WhatTeamsAmIIn,a=> a.TeamID,b=>b.TeamID,(a,b) => new { a, b }).Select(z => z.a).ToList();
            List <TeamAttributePermission> WhatAttributesCanIWriteTo = tapbl.TeamAttributePermissions.Where(a => a.TeamID == TeamID).ToList();

            ListOfAttributes = ListOfAttributes.Join(WhatAttributesCanIWriteTo, a => a.AttributeID, b => b.AttributeID, (a, b) => new { a, b }).Select(z => z.a).ToList();

            ViewData["ddAttribute"] = ListOfAttributes.Select(m => new SelectListItem {
                Value = m.AttributeID.ToString(), Text = m.AttributeDesc + " (" + m.AttributeID.ToString() + ")"
            });

            ViewBag.Sfid     = Sfid;
            ViewBag.SeasonID = SeasonID;

            #endregion

            return(View());
        }
コード例 #9
0
        // GET: PreArticleSeasonal/Create
        public ActionResult Create(int SeasonID = 0)
        {
            SeasonBusinessLayer sbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = sbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

            VendorBusinessLayer vbl           = new VendorBusinessLayer();
            List <Vendor>       ListOfVendors = vbl.Vendors.OrderBy(o => o.VendorID).ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.Where(z => z.PreArticleGrade == 1).OrderBy(o => o.GradeOrder).ToList();

            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.OrderBy(o => o.MerchCatID).ToList();

            SpaceUseBusinessLayer spbl            = new SpaceUseBusinessLayer();
            List <SpaceUse>       ListOfSpaceUses = spbl.SpaceUses.ToList();

            StatusBusinessLayer tbl            = new StatusBusinessLayer();
            List <Status>       ListOfStatuses = tbl.Statuses.ToList();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddSpaceUse"] = ListOfSpaceUses.Select(m => new SelectListItem {
                Value = m.SpaceUseID.ToString(), Text = m.SpaceUseDesc + " (" + m.SpaceUseID.ToString() + ")"
            });
            ViewData["ddGradeP"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription
            });
            ViewData["ddGradeC"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription
            });
            ViewData["ddMerchCat"] = ListOfMerchCats.Select(m => new SelectListItem {
                Value = m.MerchCatID.ToString(), Text = m.MerchCatDesc + " (" + m.MerchCatID.ToString() + ")"
            });
            ViewData["ddVendor"] = ListOfVendors.Select(m => new SelectListItem {
                Value = m.VendorID, Text = m.VendorDesc + " (" + m.VendorID + ")"
            });
            ViewData["ddContinue"] = ListOfStatuses.Where(i => i.StatusType == "C").Select(m => new SelectListItem {
                Value = m.StatusID.ToString(), Text = m.StatusDesc + " (" + m.StatusID.ToString() + ")", Selected = m.Default == 1
            });
            ViewData["ddReplacement"] = ListOfStatuses.Where(i => i.StatusType == "R").Select(m => new SelectListItem {
                Value = m.StatusID.ToString(), Text = m.StatusDesc + " (" + m.StatusID.ToString() + ")", Selected = m.Default == 1
            });

            ViewBag.SeasonID = SeasonID;
            return(View());
        }
コード例 #10
0
        // GET: Season/Edit/5
        public ActionResult Edit(int id)
        {
            SeasonBusinessLayer bl = new SeasonBusinessLayer();
            Season o = bl.Seasons.Where(p => p.SeasonID == id).Single();

            var Items = new HashSet <SelectListItem>();

            Items.Add(new SelectListItem {
                Text = "Yes", Value = "1", Selected = o.SeasonActive == 1
            });
            Items.Add(new SelectListItem {
                Text = "No", Value = "0", Selected = o.SeasonActive == 0
            });
            ViewData["ddActive"] = Items;

            ViewBag.ID = id;
            return(View(o));
        }
コード例 #11
0
        public ActionResult Index(FormCollection collection)
        {
            AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer();

            int SeasonID = Convert.ToInt32(collection["ddSeason"]);
            int GradeID  = Convert.ToInt32(collection["ddGrade"]);
            int CatID    = Convert.ToInt32(collection["ddCat"]);

            string DeptName;
            string CatName = "";


            List <AvailableSpace> ListOfAvailableSpaces = sbl.AvailableSpaces.ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();
            string             GradeName    = ListOfGrades.Where(q => q.GradeID == GradeID).Single().GradeDescription;

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.ToList();

            CatBusinessLayer cbl        = new CatBusinessLayer();
            List <Cat>       ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList();

            int DeptID = ListOfMerchCats.Where(m => m.CatID == CatID).First().DeptID;

            DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

            if (ListOfCats.Count > 0)
            {
                CatName = ListOfCats.Where(c => c.CatID == CatID).Single().CatDesc;
            }

            #region StaticData

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == GradeID
            });
            ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == CatID
            });

            ViewBag.DeptID    = DeptID;
            ViewBag.DeptName  = DeptName;
            ViewBag.CatID     = CatID;
            ViewBag.CatName   = CatName;
            ViewBag.GradeName = GradeName;
            ViewBag.SeasonID  = SeasonID;

            ListOfAvailableSpaces = ListOfAvailableSpaces.Where(z => z.SpaceGradeID == GradeID && z.SeasonID == SeasonID && z.CatID == CatID).OrderBy(w => w.FixtureOrdinal).ToList();
            #endregion

            return(View(ListOfAvailableSpaces));
        }
コード例 #12
0
        // GET: AvailableSpace
        public ActionResult Index(int DeptID = 0, int SeasonID = 0, int GradeID = 0, int CatID = 0)
        {
            string DeptName  = "";
            string CatName   = "";
            string GradeName = "";

            AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer();
            List <AvailableSpace>       ListOfAvailableSpaces = sbl.AvailableSpaces.ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            //no parameters recieved, pick the first ones
            if (GradeID == 0)
            {
                GradeID = ListOfGrades.Where(q => q.PreArticleGrade == 1).First().GradeID;
            }
            GradeName = ListOfGrades.Where(q => q.GradeID == GradeID).Single().GradeDescription;
            if (DeptID == 0)
            {
                DeptID = ListOfDepts.Where(q => q.DeptActive == 1).First().DeptID;
            }
            DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

            if (SeasonID == 0)
            {
                SeasonID = ListOfSeasons.Where(q => q.SeasonActive == 1).First().SeasonID;
            }


            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.Where(w => w.DeptID == DeptID).ToList();

            CatBusinessLayer cbl        = new CatBusinessLayer();
            List <Cat>       ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList();

            if (CatID == 0 && ListOfMerchCats.Any(q => q.MerchCatActive == 1))
            {
                CatID = ListOfMerchCats.Where(q => q.MerchCatActive == 1).First().CatID;
            }
            ListOfCats = ListOfCats.Join(ListOfMerchCats, a => a.CatID, b => b.CatID, (a, b) => new { a, b }).Select(z => z.a).Distinct().ToList();

            if (ListOfCats.Count > 0)
            {
                CatName = ListOfCats.Where(c => c.CatID == CatID).Single().CatDesc;
            }

            ListOfAvailableSpaces = ListOfAvailableSpaces.Where(z => z.SpaceGradeID == GradeID && z.SeasonID == SeasonID && z.CatID == CatID).ToList();

            #region StaticData
            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == GradeID
            });
            //move department selection to department index
            //ViewData["ddDept"] = ListOfDepts.Select(m => new SelectListItem { Value = m.DeptID.ToString(), Text = m.DeptName + " (" + m.DeptID.ToString() + ")", Selected = m.DeptID == DeptID });
            ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == CatID
            });

            ViewBag.DeptID   = DeptID;
            ViewBag.DeptName = DeptName;

            ViewBag.CatID     = CatID;
            ViewBag.CatName   = CatName;
            ViewBag.GradeName = GradeName;
            ViewBag.SeasonID  = SeasonID;

            #endregion

            return(View(ListOfAvailableSpaces));
        }
コード例 #13
0
        public ActionResult Index(FormCollection collection)
        {
            int ViewID   = Convert.ToInt32(collection["ddView"]);
            int SeasonID = Convert.ToInt32(collection["ddSeason"]);
            int DeptID   = Convert.ToInt32(collection["ddDept"]);

            #region StaticDropdowns
            SeasonBusinessLayer rbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = rbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

            PivotViewBusinessLayer tbl = new PivotViewBusinessLayer();
            List <PivotView>       ListOfPivotViews = tbl.PivotViews(User.Identity.Name).OrderBy(o => o.ViewDesc).ToList();

            if (ViewID == 0 && ListOfPivotViews.Count > 0)
            {
                ViewID = ListOfPivotViews.First().ViewID;
            }
            if (SeasonID == 0 && ListOfSeasons.Count > 0)
            {
                SeasonID = ListOfSeasons.First().SeasonID;
            }

            ViewAttributePivotBusinessLayer vapbl     = new ViewAttributePivotBusinessLayer();
            List <ViewAttributePivot>       ListOfVAP = vapbl.ViewAttributePivots.Where(r => r.ViewID == ViewID).OrderBy(s => s.PivotOrder).ToList();

            int  AttributeCount = 1;
            bool ShallWefilter  = true;

            List <WebGridColumn> columns = new List <WebGridColumn>();
            columns.Add(new WebGridColumn()
            {
                ColumnName = "DeptID", Header = "DeptID", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "DeptName", Header = "Dept", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ContinuationStatus", Header = "Continue", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ReplacementStatus", Header = "Replace", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "SapArticleID", Header = "SapArticleID", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "MasterDescription", Header = "MasterDesc", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "CatDesc", Header = "Cat", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "MerchCatDesc", Header = "MerchCat", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "VendorDesc", Header = "Vendor", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ProposedPreArticleGradeDesc", Header = "ProposedGrade", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ConfirmedPreArticleGradeDesc", Header = "ConfirmedGrade", CanSort = ShallWefilter
            });

            foreach (ViewAttributePivot vap in ListOfVAP)
            {
                ViewData["att" + AttributeCount.ToString("00")] = vap.AttributeDescription;
                Object WebGridFormat = "#,##0.00";
                columns.Add(new WebGridColumn()
                {
                    ColumnName = "att" + AttributeCount.ToString("00"), Header = vap.AttributeDescription, CanSort = false
                });
                AttributeCount++;
                if (AttributeCount > 18)
                {
                    break;
                }
            }
            columns.Add(new WebGridColumn()
            {
                ColumnName = "PreArticleSeasonal",
                Header     = "Edit",
                CanSort    = false,
                Format     = (item) => new MvcHtmlString("<a href='" + Url.Action("Edit", "PreArticleSeasonal", new { id = item.ID }, null) + "'>edit</a>")
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "Attr",
                Header     = "Attributes",
                CanSort    = false,
                Format     = (item) => new MvcHtmlString("<a href='" + Url.Action("Index", "AttributeValue", new { SeasonID = item.SeasonID, SfID = item.SFID }, null) + "'>attr</a>")
            });

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();
            string            DeptName    = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;


            #endregion
            AttributeValuePivotBusinessLayer sbl = new AttributeValuePivotBusinessLayer();
            List <AttributeValuePivot>       ListOfAttributeValuePivots = sbl.AttributeValuePivots(DeptID, ViewID, SeasonID).OrderBy(i => i.SFID).ToList();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddView"] = ListOfPivotViews.Select(m => new SelectListItem {
                Value = m.ViewID.ToString(), Text = m.ViewDesc + " (" + m.ViewID.ToString() + ")", Selected = m.ViewID == ViewID
            });
            ViewData["ddDept"] = ListOfDepts.Select(m => new SelectListItem {
                Value = m.DeptID.ToString(), Text = m.DeptName + " (" + m.DeptID.ToString() + ")", Selected = m.DeptID == DeptID
            });

            #region Filter
            string FilterMessage                  = "";
            string DeptName_f                     = (string)(collection["DeptName_f"]);
            string SapArticleID_f                 = (string)(collection["SapArticleID_f"]);
            string ContinuationStatus_f           = (string)(collection["ContinuationStatus_f"]);
            string ReplacementStatus_f            = (string)(collection["ReplacementStatus_f"]);
            string MasterDescription_f            = (string)(collection["MasterDescription_f"]);
            string CatDesc_f                      = (string)(collection["CatDesc_f"]);
            string MerchCatDesc_f                 = (string)(collection["MerchCatDesc_f"]);
            string VendorDesc_f                   = (string)(collection["VendorDesc_f"]);
            string ProposedPreArticleGradeDesc_f  = (string)(collection["ProposedPreArticleGradeDesc_f"]);
            string ConfirmedPreArticleGradeDesc_f = (string)(collection["ConfirmedPreArticleGradeDesc_f"]);

            string[] AttributeFilter = new string[18];
            for (int i = 1; i <= 18; i++)
            {
                AttributeFilter[i - 1] = (string)(collection["Att" + i.ToString("00") + "Fragment"]);
            }
            if (DeptName_f != "")
            {
                int  _DeptID = 0;
                bool parsed  = int.TryParse(DeptName_f, out _DeptID);
                if (parsed)
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.DeptID == _DeptID).ToList();
                    FilterMessage = FilterMessage + " filtered by Dept ID";
                }
                else
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.DeptName.ToLower().Contains(DeptName_f.ToLower())).ToList();
                    FilterMessage = FilterMessage + " filtered by Dept Name";
                }
            }

            if (SapArticleID_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.SapArticleID.Contains(SapArticleID_f)).ToList();
                FilterMessage = " filtered by Sap Article";
            }
            if (MasterDescription_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.MasterDescription.ToLower().Contains(MasterDescription_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Master Description";
            }
            if (CatDesc_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.CatDesc.ToLower().Contains(CatDesc_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Cat Name";
            }
            if (MerchCatDesc_f != "")
            {
                int  MerchCatID = 0;
                bool parsed     = int.TryParse(MerchCatDesc_f, out MerchCatID);
                if (parsed)
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.MerchCatID == MerchCatID).ToList();
                    FilterMessage = FilterMessage + " filtered by MerchCat ID";
                }
                else
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.MerchCatDesc.ToLower().Contains(MerchCatDesc_f)).ToList();
                    FilterMessage = FilterMessage + " filtered by MerchCat Name";
                }
            }
            if (VendorDesc_f != "")
            {
                if (ListOfAttributeValuePivots.Any(a => a.VendorID == VendorDesc_f))
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.VendorID == VendorDesc_f).ToList();
                    FilterMessage = FilterMessage + " filtered by Vendor ID";
                }
                else
                {
                    ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.VendorDesc.ToLower().Contains(VendorDesc_f.ToLower())).ToList();
                    FilterMessage = FilterMessage + " filtered by Vendor Description";
                }
            }
            if (ProposedPreArticleGradeDesc_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ProposedPreArticleGradeDesc.ToLower().Contains(ProposedPreArticleGradeDesc_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Proposed Grade";
            }
            if (ConfirmedPreArticleGradeDesc_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ConfirmedPreArticleGradeDesc.ToLower().Contains(ConfirmedPreArticleGradeDesc_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Confirmed Grade";
            }
            if (ContinuationStatus_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ContinuationStatus.ToLower().Contains(ContinuationStatus_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Continuation Status";
            }
            if (ReplacementStatus_f != "")
            {
                ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ReplacementStatus.ToLower().Contains(ReplacementStatus_f.ToLower())).ToList();
                FilterMessage = FilterMessage + " filtered by Replacement Grade";
            }
            for (int i = 1; i <= 18; i++)
            {
                if (AttributeFilter[i - 1] != "")
                {
                    //ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.Att01.ToString().Contains(AttributeFilter[0])).ToList();
                    ListOfAttributeValuePivots = sbl.AttributeValuePivotWhereQuery(ListOfAttributeValuePivots, "Att" + i.ToString("00"), AttributeFilter[i - 1]).ToList();
                    FilterMessage = FilterMessage + " filtered by attribute " + i.ToString("00");
                }
            }
            #endregion

            ViewBag.DeptID   = DeptID;
            ViewBag.DeptName = DeptName;
            ViewBag.Columns  = columns;

            ViewBag.FilterMessage                  = FilterMessage;
            ViewBag.DeptName_f                     = DeptName_f;
            ViewBag.SapArticleID_f                 = SapArticleID_f;
            ViewBag.MasterDescription_f            = MasterDescription_f;
            ViewBag.CatDesc_f                      = CatDesc_f;
            ViewBag.MerchCatDesc_f                 = MerchCatDesc_f;
            ViewBag.VendorDesc_f                   = VendorDesc_f;
            ViewBag.ProposedPreArticleGradeDesc_f  = ProposedPreArticleGradeDesc_f;
            ViewBag.ConfirmedPreArticleGradeDesc_f = ConfirmedPreArticleGradeDesc_f;
            ViewBag.ContinuationStatus_f           = ContinuationStatus_f;
            ViewBag.ReplacementStatus_f            = ReplacementStatus_f;
            for (int i = 1; i <= 18; i++)
            {
                ViewData["Att" + i.ToString("00") + "Fragment"] = AttributeFilter[i - 1];
            }



            return(View(ListOfAttributeValuePivots));
        }
コード例 #14
0
        //// GET: AttributeValuePivot
        //public ActionResult Index(int ViewID=0,int SeasonID=0,int DeptID=0)
        //{
        //    #region StaticDropdowns
        //    SeasonBusinessLayer rbl = new SeasonBusinessLayer();
        //    List<Season> ListOfSeasons = rbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

        //    PivotViewBusinessLayer tbl = new PivotViewBusinessLayer();
        //    List<PivotView> ListOfPivotViews = tbl.PivotViews(User.Identity.Name).OrderBy(o => o.ViewDesc).ToList();

        //    if (ViewID == 0 && ListOfPivotViews.Count>0)
        //    {
        //        ViewID = ListOfPivotViews.First().ViewID;
        //    }
        //    if (SeasonID == 0 && ListOfSeasons.Count > 0)
        //    {
        //        SeasonID = ListOfSeasons.First().SeasonID;
        //    }

        //    //work out what team the user is in
        //    //int TeamID = 0;
        //    //UserBusinessLayer ubl = new UserBusinessLayer();
        //    //if (ubl.Users.Any(o => o.NetworkID == User.Identity.Name))
        //    //{
        //    //    TeamID = ubl.Users.Where(o => o.NetworkID == User.Identity.Name).Single().TeamID;
        //    //}

        //    ViewAttributePivotBusinessLayer vapbl = new ViewAttributePivotBusinessLayer();
        //    List<ViewAttributePivot> ListOfVAP = vapbl.ViewAttributePivots.Where(r => r.ViewID == ViewID).OrderBy(s=>s.PivotOrder).ToList();

        //    int AttributeCount = 1;

        //    foreach (ViewAttributePivot vap in ListOfVAP)
        //    {
        //        ViewData["att" + AttributeCount.ToString("00")] = vap.AttributeDescription;
        //        AttributeCount++;
        //        if (AttributeCount > 12)
        //        {
        //            break;
        //        }
        //    }

        //    DeptBusinessLayer dbl = new DeptBusinessLayer();
        //    List<Dept> ListOfDepts = dbl.Depts.ToList();
        //    string DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

        //    #endregion

        //    AttributeValuePivotBusinessLayer sbl = new AttributeValuePivotBusinessLayer();
        //    List<AttributeValuePivot> ListOfAttributeValuePivots = sbl.AttributeValuePivots(DeptID, ViewID, SeasonID).OrderBy(i => i.SFID).ToList();

        //    ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem { Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID });
        //    ViewData["ddView"] = ListOfPivotViews.Select(m => new SelectListItem { Value = m.ViewID.ToString(), Text = m.ViewDesc + " (" + m.ViewID.ToString() + ")", Selected = m.ViewID == ViewID });
        //    ViewBag.SeasonID = SeasonID;
        //    ViewBag.DeptID = DeptID;
        //    ViewBag.DeptName = DeptName;
        //    return View(ListOfAttributeValuePivots);
        //}

        //[HttpPost]
        //public ActionResult Index(FormCollection collection,int DeptID=0)
        //{
        //    int ViewID = Convert.ToInt32(collection["ddView"]);
        //    int SeasonID = Convert.ToInt32(collection["ddSeason"]);

        //    #region StaticDropdowns
        //    SeasonBusinessLayer rbl = new SeasonBusinessLayer();
        //    List<Season> ListOfSeasons = rbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

        //    PivotViewBusinessLayer tbl = new PivotViewBusinessLayer();
        //    List<PivotView> ListOfPivotViews = tbl.PivotViews(User.Identity.Name).OrderBy(o => o.ViewDesc).ToList();

        //    if (ViewID == 0 && ListOfPivotViews.Count > 0)
        //    {
        //        ViewID = ListOfPivotViews.First().ViewID;
        //    }
        //    if (SeasonID == 0 && ListOfSeasons.Count > 0)
        //    {
        //        SeasonID = ListOfSeasons.First().SeasonID;
        //    }

        //    ViewAttributePivotBusinessLayer vapbl = new ViewAttributePivotBusinessLayer();
        //    List<ViewAttributePivot> ListOfVAP = vapbl.ViewAttributePivots.Where(r => r.ViewID == ViewID).OrderBy(s => s.PivotOrder).ToList();

        //    int AttributeCount = 1;

        //    foreach (ViewAttributePivot vap in ListOfVAP)
        //    {
        //        ViewData["att" + AttributeCount.ToString("00")] = vap.AttributeDescription;
        //        AttributeCount++;
        //        if (AttributeCount > 12)
        //        {
        //            break;
        //        }
        //    }

        //    DeptBusinessLayer dbl = new DeptBusinessLayer();
        //    List<Dept> ListOfDepts = dbl.Depts.ToList();
        //    string DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;


        //    #endregion
        //    AttributeValuePivotBusinessLayer sbl = new AttributeValuePivotBusinessLayer();
        //    List<AttributeValuePivot> ListOfAttributeValuePivots = sbl.AttributeValuePivots(DeptID,ViewID, SeasonID).OrderBy(i => i.SFID).ToList();

        //    ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem { Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID });
        //    ViewData["ddView"] = ListOfPivotViews.Select(m => new SelectListItem { Value = m.ViewID.ToString(), Text = m.ViewDesc + " (" + m.ViewID.ToString() + ")", Selected = m.ViewID == ViewID });

        //    #region Filter
        //    string FilterMessage = "";
        //    string SapArticleID_f = (string)(collection["SapArticleID_f"]);
        //    string MasterDescription_f = (string)(collection["MasterDescription_f"]);
        //    string CatDesc_f = (string)(collection["CatDesc_f"]);
        //    string MerchCatDesc_f = (string)(collection["MerchCatDesc_f"]);
        //    string VendorDesc_f = (string)(collection["VendorDesc_f"]);
        //    string ProposedPreArticleGradeDesc_f = (string)(collection["ProposedPreArticleGradeDesc_f"]);
        //    string ConfirmedPreArticleGradeDesc_f = (string)(collection["ConfirmedPreArticleGradeDesc_f"]);

        //    string[] AttributeFilter = new string[18];
        //    for(int i = 1; i <= 18; i++)
        //    {
        //        AttributeFilter[i-1]= (string)(collection["Att" + i.ToString("00") + "Fragment"]);
        //    }

        //    if (SapArticleID_f!="")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.SapArticleID.ToString().Contains(SapArticleID_f)).ToList();
        //        FilterMessage = " filtered by Sap Article";
        //    }
        //    if (MasterDescription_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.MasterDescription.ToString().Contains(MasterDescription_f)).ToList();
        //        FilterMessage = FilterMessage + " filtered by Master Description";
        //    }
        //    if (CatDesc_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.CatDesc.ToString().Contains(CatDesc_f)).ToList();
        //        FilterMessage = FilterMessage + " filtered by Cat Name";
        //    }
        //    if (MerchCatDesc_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.MerchCatDesc.ToString().Contains(MerchCatDesc_f)).ToList();
        //        FilterMessage = " filtered by Merch Cat";
        //    }
        //    if (VendorDesc_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.VendorDesc.ToString().Contains(VendorDesc_f)).ToList();
        //        FilterMessage = FilterMessage + " filtered by Vendor Description";
        //    }
        //    if (ProposedPreArticleGradeDesc_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ProposedPreArticleGradeDesc.ToString().Contains(ProposedPreArticleGradeDesc_f)).ToList();
        //        FilterMessage = FilterMessage + " filtered by Proposed Grade";
        //    }
        //    if (ConfirmedPreArticleGradeDesc_f != "")
        //    {
        //        ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.ConfirmedPreArticleGradeDesc.ToString().Contains(ConfirmedPreArticleGradeDesc_f)).ToList();
        //        FilterMessage = FilterMessage + " filtered by Confirmed Grade";
        //    }
        //    for (int i = 1; i <= 18; i++)
        //    {
        //        if (AttributeFilter[i-1] != "")
        //        {
        //            //ListOfAttributeValuePivots = ListOfAttributeValuePivots.Where(a => a.Att01.ToString().Contains(AttributeFilter[0])).ToList();
        //            ListOfAttributeValuePivots = sbl.AttributeValuePivotWhereQuery(ListOfAttributeValuePivots, "Att" + i.ToString("00"), AttributeFilter[i-1]).ToList();
        //            FilterMessage = FilterMessage + " filtered by attribute " + i.ToString("00");
        //        }
        //    }

        //    ViewBag.DeptID = DeptID;
        //    ViewBag.DeptName = DeptName;

        //    ViewBag.FilterMessage = FilterMessage;
        //    ViewBag.SapArticleID_f = SapArticleID_f;
        //    ViewBag.MasterDescription_f = MasterDescription_f;
        //    ViewBag.CatDesc_f = CatDesc_f;
        //    ViewBag.MerchCatDesc_f = MerchCatDesc_f;
        //    ViewBag.VendorDesc_f = VendorDesc_f;
        //    ViewBag.ProposedPreArticleGradeDesc_f = ProposedPreArticleGradeDesc_f;
        //    ViewBag.ConfirmedPreArticleGradeDesc_f = ConfirmedPreArticleGradeDesc_f;
        //    for (int i = 1; i <= 18; i++)
        //    {
        //        ViewData["Att" + i.ToString("00") + "Fragment"] = AttributeFilter[i - 1];
        //    }
        //    #endregion


        //    return View(ListOfAttributeValuePivots);

        //}

        public ActionResult Index(int ViewID = 0, int SeasonID = 0, int DeptID = 0)
        {
            #region StaticDropdowns
            SeasonBusinessLayer rbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = rbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();

            PivotViewBusinessLayer tbl = new PivotViewBusinessLayer();
            List <PivotView>       ListOfPivotViews = tbl.PivotViews(User.Identity.Name).OrderBy(o => o.ViewDesc).ToList();

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();

            if (ViewID == 0 && ListOfPivotViews.Count > 0)
            {
                bool parsed = int.TryParse(ViewBag.ViewID, out ViewID);
                if (!parsed)
                {
                    ViewID = ListOfPivotViews.First().ViewID;
                }
            }
            if (SeasonID == 0 && ListOfSeasons.Count > 0)
            {
                bool parsed = int.TryParse(ViewBag.SeasonID, out SeasonID);
                if (!parsed)
                {
                    SeasonID = ListOfSeasons.First().SeasonID;
                }
            }

            ViewAttributePivotBusinessLayer vapbl     = new ViewAttributePivotBusinessLayer();
            List <ViewAttributePivot>       ListOfVAP = vapbl.ViewAttributePivots.Where(r => r.ViewID == ViewID).OrderBy(s => s.PivotOrder).ToList();

            int  AttributeCount = 1;
            bool ShallWefilter  = true;

            List <WebGridColumn> columns = new List <WebGridColumn>();
            columns.Add(new WebGridColumn()
            {
                ColumnName = "DeptID", Header = "DeptID", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "DeptName", Header = "Dept", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ContinuationStatus", Header = "Continue", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ReplacementStatus", Header = "Replace", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "SapArticleID", Header = "SapArticleID", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "MasterDescription", Header = "MasterDesc", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "CatDesc", Header = "Cat", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "MerchCatDesc", Header = "MerchCat", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "VendorDesc", Header = "Vendor", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ProposedPreArticleGradeDesc", Header = "ProposedGrade", CanSort = ShallWefilter
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "ConfirmedPreArticleGradeDesc", Header = "ConfirmedGrade", CanSort = ShallWefilter
            });

            foreach (ViewAttributePivot vap in ListOfVAP)
            {
                ViewData["att" + AttributeCount.ToString("00")] = vap.AttributeDescription;
                Object WebGridFormat = "#,##0.00";
                columns.Add(new WebGridColumn()
                {
                    ColumnName = "att" + AttributeCount.ToString("00"),
                    Header     = vap.AttributeDescription,

                    CanSort = false
                });
                AttributeCount++;
                if (AttributeCount > 18)
                {
                    break;
                }
            }
            columns.Add(new WebGridColumn()
            {
                ColumnName = "PreArticleSeasonal",
                Header     = "Edit",
                CanSort    = false,
                Format     = (item) => new MvcHtmlString("<a href='" + Url.Action("Edit", "PreArticleSeasonal", new { id = item.ID }, null) + "'>edit</a>")
            });
            columns.Add(new WebGridColumn()
            {
                ColumnName = "Attr",
                Header     = "Attributes",
                CanSort    = false,
                Format     = (item) => new MvcHtmlString("<a href='" + Url.Action("Index", "AttributeValue", new { SeasonID = item.SeasonID, SfID = item.SFID }, null) + "'>attr</a>")
            });

            string DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

            #endregion

            AttributeValuePivotBusinessLayer sbl = new AttributeValuePivotBusinessLayer();
            List <AttributeValuePivot>       ListOfAttributeValuePivots = sbl.AttributeValuePivots(DeptID, ViewID, SeasonID).OrderBy(i => i.SFID).ToList();

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddView"] = ListOfPivotViews.Select(m => new SelectListItem {
                Value = m.ViewID.ToString(), Text = m.ViewDesc + " (" + m.ViewID.ToString() + ")", Selected = m.ViewID == ViewID
            });
            ViewData["ddDept"] = ListOfDepts.Select(m => new SelectListItem {
                Value = m.DeptID.ToString(), Text = m.DeptName + " (" + m.DeptID.ToString() + ")", Selected = m.DeptID == DeptID
            });

            ViewBag.SeasonID = SeasonID;
            ViewBag.DeptID   = DeptID;
            ViewBag.DeptName = DeptName;
            ViewBag.ViewID   = ViewID;
            ViewBag.Columns  = columns;

            return(View(ListOfAttributeValuePivots));
        }
コード例 #15
0
        public ActionResult Index(FormCollection collection, string submitButton, IEnumerable <string> keys, IEnumerable <decimal> amounts)
        {
            SpaceAllocationBusinessLayer sbl = new SpaceAllocationBusinessLayer();

            if (submitButton == "Retazz LocationID" && keys != null)
            {
                //read the values for retazz and attempt to realign
                for (int i = 0; i < keys.Count(); i++)
                {
                    int NewOrder;
                    NewOrder = i + 1000 * Convert.ToInt32(amounts.ElementAt(i));
                    if (sbl.SpaceAllocations.Where(y => y.ID == keys.ElementAt(i) && y.AutoID != 0).Any())
                    {
                        SpaceAllocation LoopSA = sbl.SpaceAllocations.Where(y => y.ID == keys.ElementAt(i) && y.AutoID != 0).Single();
                        LoopSA.OrdinalSequence = NewOrder;
                        StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                        Boolean DidUpdateWork             = spbl.ExecuteStoredProcedure(LoopSA, "Edit", User.Identity.Name);
                        //Boolean DidUpdateWork = sbl.ActionSpaceAllocation(LoopSA, "Edit", User.Identity.Name);
                    }
                }
                Boolean DidRetazzWork = sbl.RetazzSpaceAllocation();
            }
            int DeptID   = Convert.ToInt32(collection["ddDept"]);
            int SeasonID = Convert.ToInt32(collection["ddSeason"]);
            int GradeID  = Convert.ToInt32(collection["ddGrade"]);
            int CatID    = Convert.ToInt32(collection["ddCat"]);
            int FO       = Convert.ToInt32(collection["ddFO"]);

            string DeptName;
            string CatName = "";


            List <SpaceAllocation> ListOfSpaceAllocations = sbl.SpaceAllocations.ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();
            string             GradeName    = ListOfGrades.Where(q => q.GradeID == GradeID).Single().GradeDescription;

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.Where(w => w.DeptID == DeptID).ToList();

            CatBusinessLayer cbl               = new CatBusinessLayer();
            List <Cat>       ListOfCats        = cbl.Cats.Where(w => w.CatActive == 1).ToList();
            List <Cat>       ListOfCatsForDept = ListOfCats.Join(ListOfMerchCats, a => a.CatID, b => b.CatID, (a, b) => new { a, b }).Select(z => z.a).Distinct().ToList();

            if (ListOfCatsForDept.Count == 0)
            {
                CatID = 0;
                FO    = 0;
            }
            else
            {
                if (ListOfCatsForDept.Any(c => c.CatID == CatID) == false)
                {
                    CatID   = ListOfCatsForDept.First().CatID;
                    CatName = ListOfCatsForDept.Where(c => c.CatID == CatID).Single().CatDesc;
                }
            }

            DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

            #region StaticData

            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == GradeID
            });
            ViewData["ddCat"] = ListOfCatsForDept.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == CatID
            });
            ViewData["ddDept"] = ListOfDepts.Select(m => new SelectListItem {
                Value = m.DeptID.ToString(), Text = m.DeptName + " (" + m.DeptID.ToString() + ")", Selected = m.DeptID == DeptID
            });

            ViewBag.DeptID   = DeptID;
            ViewBag.DeptName = DeptName;

            ViewBag.CatID   = CatID;
            ViewBag.CatName = CatName;

            ViewBag.GradeName = GradeName;

            ListOfSpaceAllocations = ListOfSpaceAllocations.Where(z => z.SpaceGradeID == GradeID && z.SeasonID == SeasonID && z.CatID == CatID).OrderBy(w => w.OrdinalSequence).ToList();

            if (FO == 0 && ListOfSpaceAllocations.Count > 0)
            {
                FO = ListOfSpaceAllocations.First().FixtureOrdinal;
            }

            List <SelectListItem> ListofSelects = new List <SelectListItem>();
            ListofSelects = ListOfSpaceAllocations.Select(m => new SelectListItem {
                Value = m.FixtureOrdinal.ToString(), Text = m.FixtureName + " (" + m.FixtureOrdinal.ToString() + ")", Selected = m.FixtureOrdinal == FO
            }).ToList();
            IEnumerable <SelectListItem> ListofSelects2 = ListofSelects;
            ListofSelects = ListofSelects.GroupBy(p => p.Value).Select(g => g.First()).ToList();

            #endregion

            ListOfSpaceAllocations = ListOfSpaceAllocations.Where(z => z.FixtureOrdinal == FO).ToList();
            string FixtureName = "";
            if (ListOfSpaceAllocations.Count > 0)
            {
                FixtureName = ListOfSpaceAllocations.First().FixtureName;
            }

            //fixture ordinals are slightly different to the other drop downs...they are made from the existing data
            ViewData["ddFO"]    = ListofSelects;
            ViewBag.FixtureName = FixtureName;

            return(View(ListOfSpaceAllocations));
        }
コード例 #16
0
        // GET: SpaceAllocation
        public ActionResult Index(int DeptID = 0, int SeasonID = 0, int GradeID = 0, int CatID = 0, int FO = 0)
        {
            string DeptName  = "";
            string CatName   = "";
            string GradeName = "";

            SpaceAllocationBusinessLayer sbl = new SpaceAllocationBusinessLayer();
            List <SpaceAllocation>       ListOfSpaceAllocations = sbl.SpaceAllocations.ToList();

            GradeBusinessLayer gbl          = new GradeBusinessLayer();
            List <Grade>       ListOfGrades = gbl.Grades.ToList();

            DeptBusinessLayer dbl         = new DeptBusinessLayer();
            List <Dept>       ListOfDepts = dbl.Depts.ToList();

            SeasonBusinessLayer ebl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = ebl.Seasons.ToList();

            //no parameters recieved, pick the first ones
            if (GradeID == 0)
            {
                GradeID = ListOfGrades.Where(q => q.PreArticleGrade == 1).First().GradeID;
            }
            GradeName = ListOfGrades.Where(q => q.GradeID == GradeID).Single().GradeDescription;
            if (DeptID == 0)
            {
                DeptID = ListOfDepts.Where(q => q.DeptActive == 1).First().DeptID;
            }
            DeptName = ListOfDepts.Where(q => q.DeptID == DeptID).Single().DeptName;

            if (SeasonID == 0)
            {
                SeasonID = ListOfSeasons.Where(q => q.SeasonActive == 1).First().SeasonID;
            }


            MerchCatBusinessLayer mbl             = new MerchCatBusinessLayer();
            List <MerchCat>       ListOfMerchCats = mbl.MerchCats.Where(w => w.DeptID == DeptID).ToList();

            CatBusinessLayer cbl        = new CatBusinessLayer();
            List <Cat>       ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList();

            if (CatID == 0 && ListOfMerchCats.Any(q => q.MerchCatActive == 1))
            {
                CatID = ListOfMerchCats.Where(q => q.MerchCatActive == 1).First().CatID;
            }
            ListOfCats = ListOfCats.Join(ListOfMerchCats, a => a.CatID, b => b.CatID, (a, b) => new { a, b }).Select(z => z.a).Distinct().ToList();

            if (ListOfCats.Count > 0)
            {
                CatName = ListOfCats.Where(c => c.CatID == CatID).Single().CatDesc;
            }

            //ListOfSpaceAllocations = ListOfSpaceAllocations.Join(ListOfMerchCats, a => a.CatID, b => b.CatID, (a, b) => new { a, b }).Select(z => z.a).ToList();

            ListOfSpaceAllocations = ListOfSpaceAllocations.Where(z => z.SpaceGradeID == GradeID && z.SeasonID == SeasonID && z.CatID == CatID).ToList();

            List <SelectListItem> ListofSelects = new List <SelectListItem>();

            ListofSelects = ListOfSpaceAllocations.Select(m => new SelectListItem {
                Value = m.FixtureOrdinal.ToString(), Text = m.FixtureName + " (" + m.FixtureOrdinal.ToString() + ")", Selected = m.FixtureOrdinal == FO
            }).ToList();
            IEnumerable <SelectListItem> ListofSelects2 = ListofSelects;

            ListofSelects = ListofSelects.GroupBy(p => p.Value).Select(g => g.First()).ToList();

            if (FO == 0 && ListOfSpaceAllocations.Count > 0)
            {
                FO = ListOfSpaceAllocations.Min(a => a.FixtureOrdinal);
            }
            ListOfSpaceAllocations = ListOfSpaceAllocations.Where(z => z.FixtureOrdinal == FO).OrderBy(w => w.OrdinalSequence).ToList();
            string FixtureName = "";

            if (ListOfSpaceAllocations.Count > 0)
            {
                FixtureName = ListOfSpaceAllocations.First().FixtureName;
            }

            #region StaticData
            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });
            ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem {
                Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == GradeID
            });
            ViewData["ddDept"] = ListOfDepts.Select(m => new SelectListItem {
                Value = m.DeptID.ToString(), Text = m.DeptName + " (" + m.DeptID.ToString() + ")", Selected = m.DeptID == DeptID
            });
            ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem {
                Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == CatID
            });

            ViewData["ddFO"] = ListofSelects;

            ViewBag.DeptID   = DeptID;
            ViewBag.DeptName = DeptName;

            ViewBag.CatID       = CatID;
            ViewBag.CatName     = CatName;
            ViewBag.GradeName   = GradeName;
            ViewBag.FixtureName = FixtureName;

            #endregion

            return(View(ListOfSpaceAllocations));
        }