public ActionResult ProductDataEdit(int?ID, bool error = false)
        {
            if (!ID.HasValue)
            {
                return(RedirectToAction("ProductList"));
            }
            ListModuleService       module = ListFactoryService.Create(ListMethodType.PRODUCT);
            ProductDetailsDataModel model  = (module.DoGetDetailsByID((int)ID) as ProductDetailsDataModel);

            if (model == null)
            {
                return(RedirectToAction("Login", "SignIn"));
            }
            //取圖檔
            ImgModule imgModule = new ImgModule();

            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            ProductKindModule typeModule = new ProductKindModule();
            SelectList        typeList   = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);

            ViewBag.TypeList = typeList;
            if (error)
            {
                TempData["ERROR"] = "此分類已被停用,若要顯示前台請先將分類啟用";
            }
            return(View(model));
        }
        public ActionResult ProductDataAdd()
        {
            ProductKindModule typeModule = new ProductKindModule();
            //產品分類下拉選單
            SelectList typeList = typeModule.CreateProductKindDropList(null, false);

            ViewBag.TypeList = typeList;
            return(View(new ProductDetailsDataModel()));
        }
        /// 代理語言產品資料
        public ActionResult ProductList(int?page, string qry, string sort, int?type, string status, string lang)
        {
            Language             language = PublicMethodRepository.CurrentLanguageEnum;
            ProductListViewModel model    = new ProductListViewModel();

            model.Filter.CurrentPage = page ?? 1;
            model.Filter.QueryString = qry ?? string.Empty;
            model.Filter.SortColumn  = sort ?? string.Empty;
            model.Filter.TypeID      = type;
            model.Filter.Status      = status ?? string.Empty;
            ListModuleService module = ListFactoryService.Create(Enums.ListMethodType.PRODUCT);

            model.Result = (module.DoGetList(model.Filter, language) as ProductListResultModel);
            ProductKindModule typeModule = new ProductKindModule();

            //產品分類下拉選單
            ViewBag.TypeList = typeModule.CreateProductKindDropList(model.Filter.TypeID);
            return(View(model));
        }
        public ActionResult ProductDataEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string            langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?              ID         = Convert.ToInt32(form["ProductID"]);
            ProductKindModule typeModule = new ProductKindModule();

            #region 判斷狀態是否已被停用 被停用 不得啟用前台顯示
            if (ID.HasValue)
            {
                int chkTypeID = Convert.ToInt16(form["type"]);
                ProductKindDetailsDataModel tModel = (typeModule.DoGetDetailsByID(chkTypeID) as ProductKindDetailsDataModel);
                bool tpStatus  = tModel.Status == "Y" ? true : false;
                bool setStatus = form["fSt"] == null ? false : true;
                if ((!tpStatus) && (setStatus))
                {
                    var redirectErrorUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = ID, error = true });
                    return(Json(new { Url = redirectErrorUrl }));
                }
            }

            #endregion
            ListModuleService module      = ListFactoryService.Create(ListMethodType.PRODUCT);
            int identityId                = module.DoSaveData(form, language, ID, image, images);
            ProductDetailsDataModel model = (module.DoGetDetailsByID((int)identityId) as ProductDetailsDataModel);
            //取圖檔
            ImgModule imgModule = new ImgModule();
            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            SelectList typeList = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);
            ViewBag.TypeList = typeList;

            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = identityId });
            return(Json(new { Url = redirectUrl }));
        }