Exemplo n.º 1
0
        public ActionResult Filter(AdSearchViewModel collection, string id = "")
        {
            WorksSearchModel value = new WorksSearchModel()
            {
                Budget         = collection.Budget,
                MaxDeep        = collection.MaxDeep,
                MaxHeight      = collection.MaxHeight,
                MaxLength      = collection.MaxLength,
                MaxPrice       = collection.Price_U,
                MaxTimeLength  = collection.MaxTimeLength,
                MaxWidth       = collection.MaxWidth,
                MineDeep       = collection.MineDeep,
                MineHeight     = collection.MineHeight,
                MineLength     = collection.MineLength,
                MinePrice      = collection.Price_L,
                MineTimeLength = collection.MineTimeLength,
                MineWidth      = collection.MineWidth,
                WorksName      = collection.WorksName,
                StyleNoList    = collection.StyleNoList,
                AuthorNoList   = collection.AuthorNoList,
                GenreNoList    = collection.GenreNoList,
                GradedNoList   = collection.GradedNoList,
                OrderbyType    = MenuModel.WorkOrderbyTypeEnum.稱姓名小至大
            };
            PackagesModel pm = new PackagesModel();

            if (string.IsNullOrEmpty(id))
            {
                pm.PackagesName = "未命名" + DateTime.Now.ToString("yyMMddHHmmss");
                short d = 1;
                Int16.TryParse(SystemGeneralModel.GetConfigure(SystemGeneralModel.ConfigureClassEnum.OpenDays.ToString()).ConfigureContent, out d);
                pm.EndDate = DateTime.Now.AddDays(d);
                pm.Create();
                id = pm.PackagesNo;
            }
            pm = PackagesModel.GetPackageDetail(id);
            pm.PackagesName = "";
            // 將搜尋結果加入PackagesModel 的WorksNos
            var model = value.Search();

            for (int i = 0; i < model.Count; i++)
            {
                pm.PackageItems.Add(new PackagesModel.PackageItemModel()
                {
                    WorksNo = model[i].WorksNo,
                    IsJoin  = "N"
                });
            }
            pm.SearchJson = JsonConvert.SerializeObject(value);
            pm.Budget     = collection.Budget;
            pm.Update();

            //儲存篩選條件
            return(RedirectToAction("Edit_WorksList", new { id = pm.PackagesNo }));
        }
Exemplo n.º 2
0
        // GET: Works
        public ActionResult Index(int p = 0, string artlist = "", string name = "", string mip = "", string mxp = "", string sort = "")
        {
            List <WorksViewModel> model = new List <WorksViewModel>();

            ViewBag.OrderbyType  = "";
            ViewBag.WorksName    = "";
            ViewBag.AuthorNoList = "";
            ViewBag.MinePrice    = "";
            ViewBag.MaxPrice     = "";
            WorksSearchModel value = new WorksSearchModel();

            value.OrderbyType = MenuModel.WorkOrderbyTypeEnum.作品起始年代大至小;
            if (!string.IsNullOrEmpty(artlist))
            {
                value.AuthorNoList   = artlist.Split(',').ToList();
                ViewBag.AuthorNoList = artlist;
            }
            if (!string.IsNullOrEmpty(name))
            {
                value.WorksName   = name;
                ViewBag.WorksName = name;
            }
            if (!string.IsNullOrEmpty(mip))
            {
                value.MinePrice   = Convert.ToInt32(mip);
                ViewBag.MinePrice = mip;
            }
            if (!string.IsNullOrEmpty(mxp))
            {
                value.MaxPrice   = Convert.ToInt32(mxp);
                ViewBag.MaxPrice = mxp;
            }
            if (!string.IsNullOrEmpty(sort))
            {
                MenuModel.WorkOrderbyTypeEnum _MeunOrderbyTypeEnum = (MenuModel.WorkOrderbyTypeEnum)Enum.Parse(typeof(MenuModel.WorkOrderbyTypeEnum), sort, true);
                value.OrderbyType   = _MeunOrderbyTypeEnum;
                ViewBag.OrderbyType = sort;
            }
            var _value = value.Search(p + 1, take);

            //多取一,若有表示有下一頁
            if (_value.Count == (take + 1))
            {
                ViewBag.pn = p + 1;
                _value.RemoveAt(take);
            }
            else
            {
                ViewBag.pn = 0;
            }
            ViewBag.pi = p;
            for (int i = 0; i < _value.Count; i++)
            {
                model.Add(new WorksViewModel()
                {
                    WorksNo     = _value[i].WorksNo,
                    WorksName   = _value[i].WorksName,
                    AuthorsName = _value[i].AuthorsName,
                    YearStart   = _value[i].YearStart,
                    YearEnd     = _value[i].YearEnd,
                    Cost        = _value[i].Cost,
                    Price       = _value[i].Price,
                    CreateUser  = _value[i].CreateUser,
                    Material    = _value[i].MaterialsName
                });
            }

            MenuModel             mm           = new MenuModel();
            List <SelectListItem> WorksAuthors = new List <SelectListItem>();
            var _WorksAuthors = AuthorsModel.GetAuthorList();

            for (int i = 0; i < _WorksAuthors.Count; i++)
            {
                WorksAuthors.Add(new SelectListItem()
                {
                    Text  = _WorksAuthors[i].AuthorsCName,
                    Value = _WorksAuthors[i].AuthorsNo.ToString()
                });
            }
            ViewBag.WorksAuthors = WorksAuthors;
            var MeunOrderList = new Dictionary <string, string>();

            foreach (var item in Enum.GetValues(typeof(MenuModel.WorkOrderbyTypeEnum)))
            {
                MeunOrderList.Add(item.ToString(), item.ToString());
            }
            ViewBag.MeunOrderList = new SelectList(MeunOrderList, "Key", "Value", ViewBag.OrderbyType);
            ViewBag.pt            = take.ToString();
            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Index(FormCollection collection, int p = 0)
        {
            List <WorksViewModel> model = new List <WorksViewModel>();

            MenuModel.WorkOrderbyTypeEnum _MeunOrderbyTypeEnum = (MenuModel.WorkOrderbyTypeEnum)Enum.Parse(typeof(MenuModel.WorkOrderbyTypeEnum), collection["Sort"], true);
            WorksSearchModel value = new WorksSearchModel()
            {
                WorksName   = collection["WorksName"],
                OrderbyType = _MeunOrderbyTypeEnum
            };

            ViewBag.OrderbyType = "";
            if (!string.IsNullOrEmpty(collection["Sort"]))
            {
                ViewBag.OrderbyType = collection["Sort"];
            }

            ViewBag.WorksName = "";
            if (!string.IsNullOrEmpty(collection["WorksName"]))
            {
                ViewBag.WorksName = collection["WorksName"].ToString();
            }
            ViewBag.AuthorNoList = "";
            if (!string.IsNullOrEmpty(collection["AuthorNoList"]))
            {
                value.AuthorNoList   = collection["AuthorNoList"].Split(',').ToList();
                ViewBag.AuthorNoList = collection["AuthorNoList"].ToString();
            }
            ViewBag.MinePrice = "";
            if (!string.IsNullOrEmpty(collection["MinePrice"]))
            {
                value.MinePrice   = Convert.ToInt32(collection["MinePrice"]);
                ViewBag.MinePrice = value.MinePrice.ToString();
            }
            ViewBag.MaxPrice = "";
            if (!string.IsNullOrEmpty(collection["MaxPrice"]))
            {
                value.MaxPrice   = Convert.ToInt32(collection["MaxPrice"]);
                ViewBag.MaxPrice = value.MaxPrice.ToString();
            }

            var _value = value.Search(1, take);

            //多取一,若有表示有下一頁
            if (_value.Count == (take + 1))
            {
                ViewBag.pn = 1;
                _value.RemoveAt(take);
            }
            else
            {
                ViewBag.pn = 0;
            }
            ViewBag.pi = 0;
            for (int i = 0; i < _value.Count; i++)
            {
                model.Add(new WorksViewModel()
                {
                    WorksNo     = _value[i].WorksNo,
                    WorksName   = _value[i].WorksName,
                    AuthorsName = _value[i].AuthorsName,
                    YearStart   = _value[i].YearStart,
                    YearEnd     = _value[i].YearEnd,
                    Cost        = _value[i].Cost,
                    Price       = _value[i].Price,
                    Material    = _value[i].MaterialsName
                });
            }


            MenuModel             mm           = new MenuModel();
            List <SelectListItem> WorksAuthors = new List <SelectListItem>();
            var _WorksAuthors = AuthorsModel.GetAuthorList();

            for (int i = 0; i < _WorksAuthors.Count; i++)
            {
                WorksAuthors.Add(new SelectListItem()
                {
                    Text  = _WorksAuthors[i].AuthorsCName,
                    Value = _WorksAuthors[i].AuthorsNo.ToString()
                });
            }
            ViewBag.WorksAuthors = WorksAuthors;

            var MeunOrderList = new Dictionary <string, string>();

            foreach (var item in Enum.GetValues(typeof(MenuModel.WorkOrderbyTypeEnum)))
            {
                MeunOrderList.Add(item.ToString(), item.ToString());
            }
            ViewBag.MeunOrderList = new SelectList(MeunOrderList, "Key", "Value", ViewBag.OrderbyType);

            //setSortDropDown(_MeunOrderbyTypeEnum);
            ViewBag.pt = take.ToString();
            return(View(model));
        }