public ActionResult ProductDetail(int?id) { if (RedirectToProduction()) { return(Redirect(UrlProduction)); } GetStatusUser(); svProductImage = new ProductImageService(); svProduct = new ProductService(); svCompany = new CompanyService(); string page = "Product"; int CompID = Convert.ToInt32(Request.Cookies["WebsiteCompID"].Value); DefaultWebsite((int)CompID, page); var Products = svProduct.SelectData <view_Product>("*", "ProductID = " + id, null, 1, 0); ViewBag.Product = Products; if (Products != null) { ViewBag.ProductDetail = Products.First(); string sqlWhere = "CompID = " + CompID + " AND RowFlag > 0 AND IsShow = 1 AND IsJunk = 0"; var ImgProducts = svProduct.SelectData <view_Product>("ProductID,ProductImgPath,ProductName", sqlWhere, null, 1, 0, false); ViewBag.ProductImageAll = ImgProducts; ViewBag.ImageCount = ImgProducts.Count; var ProductImages = svProductImage.SelectData <view_ProductImage>("*", "ProductID = " + id, null, 1, 0, false); ViewBag.ProductImage = ProductImages; var Companies = svCompany.SelectData <view_Company>("*", "CompID = " + CompID, null, 1, 0, false); ViewBag.Company = Companies.First(); var Shipments = svProduct.SelectData <view_ProductShipment>("*", "CompID = " + CompID, null, 1, 0, false); ViewBag.ProductShipment = Shipments; var Payments = svProduct.SelectData <view_ProductPayment>("*", "CompID = " + CompID, null, 1, 0, false); ViewBag.ProductShipment = Payments; ViewBag.CompID = CompID; } ViewBag.ProID = (int)id; return(View()); }
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")); }