public ActionResult ProductGetByID(int ID)
        {
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }

            var svProduct = new ProductService();

            sqlSelect = @"ProductID,ProductCode,ProductName,ProductImgPath,ShortDescription ,ModifiedDate, CreatedDate,RowFlag,ListNo,
           IsShow,CateLV1,CateLV2,CateLV3,CompID,ProductGroupID,ProductGroupName,CategoryName,ViewCount";
            sqlWhere  = "ProductID=" + ID;
            var Product = svProduct.SelectData <view_Product>(sqlSelect, sqlWhere, null, 0, 0).First();

            Product.ModifiedDate = DataManager.ConvertToDateTime(Product.ModifiedDate);
            Product.CreatedDate  = DataManager.ConvertToDateTime(Product.CreatedDate);

            ViewBag.ProductGetByID = Product;

            var svProductGroup = new ProductGroupService();
            var ProductGroups  = svProductGroup.GetProductGroup(LogonCompID);

            if (ProductGroups.Count() > 0)
            {
                ViewBag.ProductGroups = ProductGroups;
            }
            else
            {
                ViewBag.ProductGroups = null;
            }
            return(PartialView("UC/QuickProductDetail"));
        }
        public ActionResult PrepareAddProduct(string GenCode)
        {
            if (LogonServiceType != 2 && LogonServiceType != 3)
            {
                return(Redirect(res.Pageviews.PvAccessDenied));
            }
            CommonService svCommon       = new CommonService();
            var           svProductGroup = new ProductGroupService();
            var           ProductGroups  = svProductGroup.GetProductGroup(LogonCompID);

            if (ProductGroups.Count() > 0)
            {
                ViewBag.ProductGroups = ProductGroups;
            }
            else
            {
                ViewBag.ProductGroups = null;
            }

            #region FindCateAll
            var svCategory = new CategoryService();
            var data       = svCategory.GetCategoryByLevel(1);
            ViewBag.SelectCateLV1 = data;
            #endregion

            ViewBag.QtyUnits    = svCommon.SelectEnum(CommonService.EnumType.QtyUnits);
            ViewBag.ProductCode = GenCode;
            return(PartialView("UC/AddProduct"));
        }
        public ActionResult GroupProductList()
        {
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }

            var svProductGroup = new ProductGroupService();

            ViewBag.ProductGroups = svProductGroup.GetProductGroup(LogonCompID);
            return(PartialView("UC/GroupProductList"));
        }
        public ActionResult PrepareEditByID(int ID, string GenCode)
        {
            var           svProduct      = new ProductService();
            var           svCategory     = new CategoryService();
            var           svProductGroup = new ProductGroupService();
            var           svProductImage = new ProductImageService();
            CommonService svCommon       = new CommonService();

            #region FindCateAll

            //var sqlwherein = "";
            //switch (res.Common.lblWebsite)
            //{
            //    case "B2BThai": sqlwherein = " AND CategoryType IN (1,2)"; break;
            //    case "AntCart": sqlwherein = " AND CategoryType IN (3)"; break;
            //    case "myOtopThai": sqlwherein = " AND CategoryType IN (5)"; break;
            //    case "AppstoreThai": sqlwherein = " AND CategoryType IN (6)"; break;
            //    default: sqlwherein = ""; break;
            //}

            var sqlSelect = "CategoryID,CategoryName";
            var sqlWhere  = "CategoryLevel=1 AND RowFlag > 0 AND IsDelete=0";
            var data1     = svCategory.GetCategoryByLevel(1);
            //var data2 = svCategory.GetCategoryByLevel(2);
            //var data3 = svCategory.GetCategoryByLevel(3);
            ViewBag.SelectCateLV1 = data1;
            //ViewBag.SelectCateLV2 = data2;
            //ViewBag.SelectCateLV3 = data3;
            #endregion

            ViewBag.QtyUnits = svCommon.SelectEnum(CommonService.EnumType.QtyUnits);

            #region Set Product Group
            var ProductGroups = svProductGroup.GetProductGroup(LogonCompID);
            if (ProductGroups.Count() > 0)
            {
                ViewBag.ProductGroups = ProductGroups;
            }
            else
            {
                ViewBag.ProductGroups = null;
            }
            #endregion
            var Product = svProduct.SelectData <b2bProduct>(" * ", "ProductID=" + ID + " And IsDelete=0", null, 1, 1).First();
            ViewBag.Product = Product;

            sqlSelect = "ProductID,ProductImageID,ImgPath,ListNo";
            sqlWhere  = svProductImage.CreateWhereCause(ID);

            var Images   = svProductImage.SelectData <b2bProductImage>(sqlSelect, sqlWhere, " ListNo ASC");
            var countImg = 0;

            if (svProductImage.TotalRow > 0)
            {
                countImg = Images.Where(m => m.ImgPath == Product.ProductImgPath).Count();
            }

            if (countImg == 0)
            {
                var img = new b2bProductImage();
                img.ProductID = Product.ProductID;
                img.ListNo    = 1;
                img.ImgPath   = Product.ProductImgPath;
                img.ImgDetail = Product.ProductName;
                svProductImage.InsertProductImage(img);

                Images = svProductImage.SelectData <b2bProductImage>(sqlSelect, sqlWhere, " ListNo DESC");
            }

            ViewBag.ProductImg = Images;
            ViewBag.ImgCount   = Images.Count();

            var data2 = new List <b2bCategory>();
            var data3 = new List <b2bCategory>();
            data2 = svCategory.LoadSubCategory(DataManager.ConvertToInteger(Product.CateLV1), 500, 2);
            data3 = svCategory.LoadSubCategory(DataManager.ConvertToInteger(Product.CateLV2), 500, 3);
            ViewBag.SelectCateLV2 = data2;
            ViewBag.SelectCateLV3 = data3;

            var a = svCategory.SearchCategoryByID((int)Product.CateLV3);
            //var a = svCategory.SelectData<b2bCategory>("*", "CategoryID = " + (int)Product.CateLV3, null, 1, 1,);
            ViewBag.Catename    = a;
            ViewBag.ProductCode = GenCode;
            return(PartialView("UC/EditProduct"));
        }