public void GetProductImageByProductID(int ProductID, string username, string password)
        {
            var rs = new ResponseClass();

            if (Login(username, password))
            {
                var ProductImage = ProductImageController.GetByProductID(ProductID);
                if (ProductImage.Count > 0)
                {
                    rs.Code         = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS);
                    rs.Status       = APIUtils.ResponseMessage.Success.ToString();
                    rs.ProductImage = ProductImage;
                }
                else
                {
                    rs.Code    = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound);
                    rs.Status  = APIUtils.ResponseMessage.Error.ToString();
                    rs.Message = APIUtils.OBJ_DNTEXIST;
                }
            }
            else
            {
                rs.Code   = APIUtils.GetResponseCode(APIUtils.ResponseCode.FAILED);
                rs.Status = APIUtils.ResponseMessage.Fail.ToString();
            }
            Context.Response.ContentType = "application/json";
            Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented));
            Context.Response.Flush();
            Context.Response.End();
        }
Exemple #2
0
        /// <summary>
        /// Tải tập hình ảnh của sản phẩm
        /// </summary>
        /// <param name="productID"></param>
        private void _loadImageGallery(int productID)
        {
            var images = ProductImageController.GetByProductID(productID);

            imageGallery.Text = "<ul class='image-gallery'>";
            foreach (var img in images)
            {
                imageGallery.Text += "<li><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "'><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class='fa fa-times' aria-hidden='true'></i> Xóa hình</a></li>";
            }
            imageGallery.Text += "</ul>";
        }
        public void GetProductByCategory(int CategoryID, int limit, string username, string password, int showHomePage, int minQuantity, int changeProductName)
        {
            var rs = new ResponseClass();

            if (Login(username, password))
            {
                var Product = ProductController.GetProductAPI(CategoryID, limit, showHomePage, minQuantity, changeProductName);

                if (Product.Count > 0)
                {
                    rs.Code   = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS);
                    rs.Status = APIUtils.ResponseMessage.Success.ToString();

                    foreach (var item in Product)
                    {
                        if (!string.IsNullOrEmpty(item.ProductImage))
                        {
                            item.ProductContent += String.Format("<p><img src='/wp-content/uploads/{0}' alt='{1}'/></p>", item.ProductImage.Split('/')[3], item.ProductTitle);
                        }

                        var productImage = ProductImageController.GetByProductID(item.ID);

                        if (productImage.Count() > 0)
                        {
                            foreach (var image in productImage)
                            {
                                item.ProductImage   += "|" + image.ProductImage;
                                item.ProductContent += String.Format("<p><img src='/wp-content/uploads/{0}' alt='{1}'/></p>", image.ProductImage.Split('/')[3], item.ProductTitle);
                            }
                        }
                    }
                    rs.Product = Product;
                }
                else
                {
                    rs.Code    = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound);
                    rs.Status  = APIUtils.ResponseMessage.Error.ToString();
                    rs.Message = APIUtils.OBJ_DNTEXIST;
                }
            }
            else
            {
                rs.Code   = APIUtils.GetResponseCode(APIUtils.ResponseCode.FAILED);
                rs.Status = APIUtils.ResponseMessage.Fail.ToString();
            }

            Context.Response.ContentType = "application/json";
            Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented));
            Context.Response.Flush();
            Context.Response.End();
        }
        public static string getAllProductImage(string sku)
        {
            var product = ProductController.GetBySKU(sku);
            List<string> images = new List<string>();
            if (product != null)
            {
                images.Add(product.ProductImage);

                // lấy ảnh sản phẩm từ thư viện

                var imageProduct = ProductImageController.GetByProductID(product.ID);

                if(imageProduct != null)
                {
                    foreach (var img in imageProduct)
                    {
                        images.Add(img.ProductImage);
                    }
                }
                

                // lấy ảnh sản phẩm từ biến thể

                var variable = ProductVariableController.GetByParentSKU(product.ProductSKU);

                if(variable != null)
                {
                    foreach (var v in variable)
                    {
                        images.Add(v.Image);
                    }
                }

            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(images.Distinct().ToList());
        }
        public void LoadData()
        {
            string s = "";

            if (Request.QueryString["s"] != null)
            {
                s = Request.QueryString["s"];
            }
            List <tbl_ProductImage> a = new List <tbl_ProductImage>();
            int productID             = Request.QueryString["id"].ToInt(0);

            if (productID > 0)
            {
                var product = ProductController.GetByID(productID);
                if (product != null)
                {
                    var cate = CategoryController.GetByID(Convert.ToInt32(product.CategoryID));
                    lblCategoryName.Text = product.ProductTitle;
                    ltrAddnew.Text       = "<a href=\"/them-anh-san-pham?productid=" + productID + "\" class=\"h45-btn primary-btn btn\">Thêm mới</a>";
                }
                a = ProductImageController.GetByProductID(productID);
                pagingall(a);
            }
        }
Exemple #6
0
        public static string getAllCategoryImage(double productPrice = 0)
        {
            List <string> result = new List <string>();

            string rootPath          = HostingEnvironment.ApplicationPhysicalPath;
            string uploadsImagesPath = rootPath + "/uploads/images/";

            using (var dbe = new inventorymanagementEntities())
            {
                var products = dbe.tbl_Product.Where(p => p.CategoryID == 44).OrderByDescending(o => o.ID).ToList();
                if (productPrice > 0)
                {
                    products = products.Where(p => p.Regular_Price == productPrice).ToList();
                }
                else if (productPrice == -1)
                {
                    products = products.Where(p => p.Regular_Price != 30000 && p.Regular_Price != 35000 && p.Regular_Price != 49000 && p.Regular_Price != 135000).ToList();
                }

                if (products != null)
                {
                    List <string> images = new List <string>();

                    foreach (var item in products)
                    {
                        var    stock    = StockManagerController.getStock(item.ID, 0);
                        double quantity = 0;
                        if (stock.Count > 0)
                        {
                            quantity = stock
                                       .Select(s => s.Type == 2 ? (s.QuantityCurrent.Value - s.Quantity.Value) : (s.QuantityCurrent.Value + s.Quantity.Value))
                                       .Sum(s => s);
                        }

                        // Chỉ lấy ảnh sản phẩm còn hàng
                        if (quantity >= 3)
                        {
                            // lấy ảnh đại diện
                            string imgAdd = item.ProductImage;
                            if (File.Exists(uploadsImagesPath + imgAdd))
                            {
                                images.Add(imgAdd);
                            }

                            // lấy ảnh sản phẩm từ thư viện
                            var imageProduct = ProductImageController.GetByProductID(item.ID);
                            if (imageProduct != null)
                            {
                                foreach (var img in imageProduct)
                                {
                                    imgAdd = img.ProductImage;
                                    if (File.Exists(uploadsImagesPath + imgAdd))
                                    {
                                        images.Add(imgAdd);
                                    }
                                }
                            }

                            // lấy ảnh sản phẩm từ biến thể
                            var variable = ProductVariableController.GetByParentSKU(item.ProductSKU);
                            if (variable != null)
                            {
                                foreach (var v in variable)
                                {
                                    if (!String.IsNullOrEmpty(v.Image))
                                    {
                                        imgAdd = v.Image;
                                        if (File.Exists(uploadsImagesPath + imgAdd))
                                        {
                                            images.Add(imgAdd);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    images = images.Distinct().ToList();

                    if (images.Count() > 0)
                    {
                        // lấy hình gốc
                        for (int i = 0; i < images.Count; i++)
                        {
                            result.Add(Thumbnail.getURL(images[i], Thumbnail.Size.Source));
                        }
                    }
                }
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(result.ToList()));
        }
Exemple #7
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = ProductController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page);
                }
                else
                {
                    ViewState["ID"]      = id;
                    ViewState["cateID"]  = p.CategoryID;
                    ViewState["SKU"]     = p.ProductSKU;
                    hdfParentID.Value    = p.CategoryID.ToString();
                    hdfsetStyle.Value    = p.ProductStyle.ToString();
                    ltrBack.Text         = "<a href=\"/xem-san-pham?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>";
                    txtProductTitle.Text = p.ProductTitle;
                    pContent.Content     = p.ProductContent;
                    txtProductSKU.Text   = p.ProductSKU;

                    pRegular_Price.Text         = p.Regular_Price.ToString();
                    pCostOfGood.Text            = p.CostOfGood.ToString();
                    pRetailPrice.Text           = p.Retail_Price.ToString();
                    chkIsHidden.Checked         = Convert.ToBoolean(p.IsHidden);
                    ddlSupplier.SelectedValue   = p.SupplierID.ToString();
                    ddlCategory.SelectedValue   = p.CategoryID.ToString();
                    txtMaterials.Text           = p.Materials;
                    pMinimumInventoryLevel.Text = p.MinimumInventoryLevel.ToString();
                    pMaximumInventoryLevel.Text = p.MaximumInventoryLevel.ToString();
                    if (p.ProductImage != null)
                    {
                        ListProductThumbnail.Value = p.ProductImage;
                        ProductThumbnail.ImageUrl  = p.ProductImage;
                    }

                    var image = ProductImageController.GetByProductID(id);
                    imageGallery.Text = "<ul class=\"image-gallery\">";
                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            imageGallery.Text += "<li><img src='" + img.ProductImage + "' /><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a></li>";
                        }
                    }
                    imageGallery.Text += "</ul>";

                    // Lấy tất cả biến thể ra

                    List <tbl_ProductVariable> a = new List <tbl_ProductVariable>();
                    a = ProductVariableController.GetProductID(p.ID);

                    if (a.Count > 0)
                    {
                        StringBuilder html = new StringBuilder();
                        int           t    = 1;
                        foreach (var item in a)
                        {
                            string VariableSKU           = item.SKU;
                            double RegularPrice          = Convert.ToDouble(item.Regular_Price);
                            double RetailPrice           = Convert.ToDouble(item.RetailPrice);
                            double CostOfGood            = Convert.ToDouble(item.CostOfGood);
                            int    MinimumInventoryLevel = Convert.ToInt32(item.MinimumInventoryLevel);
                            int    MaximumInventoryLevel = Convert.ToInt32(item.MaximumInventoryLevel);
                            string VariableImage         = "/App_Themes/Ann/image/placeholder.png";
                            string deleteVariableImage   = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete hide'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a>";
                            if (!string.IsNullOrEmpty(item.Image))
                            {
                                VariableImage       = item.Image;
                                deleteVariableImage = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a>";
                            }

                            var    value              = ProductVariableValueController.GetByProductVariableID(item.ID);
                            string selectVariable     = "";
                            string variableID         = "";
                            string variableName       = "";
                            string variableValueID    = "";
                            string variableValueName  = "";
                            string dataVariableValue  = "";
                            string labelVariableValue = "";
                            if (value != null)
                            {
                                foreach (var temp in value)
                                {
                                    selectVariable     += "<div class='row margin-bottom-15'><div class='col-md-5'>" + temp.VariableName + "</div><div class='col-md-7'>" + getSelectVariable(temp.VariableName, temp.VariableValue) + "</div></div>";
                                    variableID         += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + "|";
                                    variableName       += temp.VariableName.ToString() + "|";
                                    variableValueID    += temp.VariableValueID.ToString() + "|";
                                    variableValueName  += temp.VariableValue.ToString() + "|";
                                    dataVariableValue  += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + ":" + temp.VariableValueID.ToString() + "|";
                                    labelVariableValue += temp.VariableName.ToString() + ": " + temp.VariableValue.ToString() + " - ";
                                }
                            }

                            html.AppendLine(String.Format("<div class='item-var-gen' data-name-id='{0}' data-value-id='{1}' data-name-text='{2}' data-value-text='{3}' data-name-value='{4}'>", variableID, variableValueID, variableName, variableValueName, dataVariableValue));
                            html.AppendLine(String.Format("    <div class='col-md-12 variable-label' onclick='showVariableContent($(this))'>"));
                            html.AppendLine(String.Format("    	<strong>#{0}</strong> - {1} {2}", t, labelVariableValue, VariableSKU));
                            html.AppendLine(String.Format("    </div>"));
                            html.AppendLine(String.Format("    <div class='col-md-12 variable-content'>"));
                            html.AppendLine(String.Format("    	<div class='row'>"));
                            html.AppendLine(String.Format("		    <div class='col-md-2'>"));
                            html.AppendLine(String.Format("		    	<input type='file' class='productVariableImage upload-btn' onchange='imagepreview(this,$(this));' name='{0}'><img class='imgpreview' onclick='openUploadImage($(this))' data-file-name='{1}' src='{1}'>{2}", dataVariableValue, VariableImage, deleteVariableImage));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    <div class='col-md-5'>"));
                            html.AppendLine(String.Format("		    	{0}", selectVariable));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Mã sản phẩm</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input type='text' disabled class='form-control productvariablesku sku-input' value='{0}'></div>", VariableSKU));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    </div>"));
                            html.AppendLine(String.Format("		    <div class='col-md-5'>"));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Giá sỉ</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input class='form-control regularprice' type='text' value='{0}'> </div>", RegularPrice));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15 cost-of-goods'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Giá vốn</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input class='form-control costofgood cost-price' type='text' value='{0}'></div>", CostOfGood));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Giá bán lẻ</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input class='form-control retailprice' type='text' value='{0}'></div>", RetailPrice));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Tồn kho ít nhất</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input class='form-control minimum' type='text' value='{0}'></div>", MinimumInventoryLevel));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("		    	<div class='row margin-bottom-15'>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-5'>Tồn kho nhiều nhất</div>"));
                            html.AppendLine(String.Format("		    	    <div class='col-md-7'><input class='form-control maximum' type='text' value='{0}'></div>", MaximumInventoryLevel));
                            html.AppendLine(String.Format("		    	</div>"));
                            html.AppendLine(String.Format("			</div>"));
                            html.AppendLine(String.Format("		</div>"));
                            html.AppendLine(String.Format("	</div>"));
                            html.AppendLine(String.Format("</div>"));

                            t++;
                        }

                        ltrVariables.Text = html.ToString();
                    }
                }
            }
        }
Exemple #8
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = ProductController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/sp", Page);
                }
                else
                {
                    this.Title = String.Format("{0} - {1}", p.ProductTitle.ToTitleCase(), p.ProductSKU);

                    ViewState["ID"]     = id;
                    ViewState["cateID"] = p.CategoryID;
                    ViewState["SKU"]    = p.ProductSKU;

                    ltrProductName.Text = p.ProductSKU + " - " + p.ProductTitle;
                    // Create order fileter
                    var filter = new ProductFilterModel()
                    {
                        search = p.ProductSKU
                    };
                    // Create pagination
                    var page = new PaginationMetadataModel();
                    var a    = ProductController.GetAllSql(filter, ref page);
                    if (page.totalCount > 0)
                    {
                        foreach (var item in a)
                        {
                            string StockStatus = "";
                            if (item.StockStatus == 1)
                            {
                                StockStatus = "Còn hàng";
                            }
                            else
                            {
                                StockStatus = "Hết hàng";
                            }
                            ltrProductStock.Text = "<p><strong>✱ Kho</strong>: " + StockStatus + " (" + item.TotalProductInstockQuantityLeft.ToString() + " cái)</p>";
                        }
                    }
                    else
                    {
                        ltrProductStock.Text = "<p><strong>✱ Kho</strong>: Đang nhập hàng</p>";
                    }

                    ltrRegularPrice.Text = "<p><strong>📌 Giá sỉ</strong>: " + (p.Regular_Price / 1000).ToString() + "k</p>";

                    ltrRetailPrice.Text = "<p><strong>📌 Giá lẻ</strong>: " + ((p.Retail_Price + 20000) / 1000).ToString() + "k</p>";

                    if (!string.IsNullOrEmpty(p.Materials))
                    {
                        ltrMaterials.Text = "<p><strong>🔖 Chất liệu</strong>: " + p.Materials + "</p>";
                    }

                    if (!string.IsNullOrEmpty(p.ProductContent))
                    {
                        string content = Regex.Replace(p.ProductContent, @"<img\s[^>]*>(?:\s*?</img>)?", "").ToString();
                        ltrContent.Text = "<p><strong>🔖 Mô tả</strong>: " + content + "</p>";
                    }

                    if (p.ProductImage != null)
                    {
                        ProductThumbnail.Text = "<p><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Large) + "'><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                    }

                    var image = ProductImageController.GetByProductID(id);

                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            if (img.ProductImage != p.ProductImage)
                            {
                                imageGallery.Text += "<p><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Large) + "'><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                            }
                        }
                    }

                    var    v   = ProductVariableController.SearchProductID(id, "");
                    string css = "col-xs-6";
                    if (v.Count > 0)
                    {
                        css = "col-xs-4";
                    }

                    StringBuilder htmlButton = new StringBuilder();
                    htmlButton.Append("<div class='" + css + "'>");
                    htmlButton.Append("    <div class='row'>");
                    htmlButton.Append("        <p><a href='javascript:;' class='btn primary-btn copy-btn h45-btn' onclick='copyProduct(`" + p.ID + "`);'><i class='fa fa-files-o' aria-hidden='true'></i> Copy</a></p>");
                    htmlButton.Append("    </div>");
                    htmlButton.Append("</div>");

                    if (v.Count > 0)
                    {
                        htmlButton.Append("<div class='" + css + "'>");
                        htmlButton.Append("    <div class='row'>");
                        htmlButton.Append("        <p><a href='#variableTable' class='btn download-btn h45-btn'><i class='fa fa-list-ul' aria-hidden='true'></i> Biến thể</a></p>");
                        htmlButton.Append("    </div>");
                        htmlButton.Append("</div>");

                        ltrVariableList.Text = "<h3><i class='fa fa-list-ul' aria-hidden='true'></i> Danh sách biến thể</h3>";
                        pagingall(v);
                    }

                    htmlButton.Append("<div class='" + css + "'>");
                    htmlButton.Append("    <div class='row'>");
                    htmlButton.Append("        <a href='javascript:;' class='btn primary-btn h45-btn' onclick='getAllProductImage(`" + p.ProductSKU + "`);'><i class='fa fa-cloud-download' aria-hidden='true'></i> Tải hình</a>");
                    htmlButton.Append("    </div>");
                    htmlButton.Append("</div>");

                    ltrButton.Text = htmlButton.ToString();
                }
            }
        }
Exemple #9
0
        public void LoadData()
        {
            string username = HttpContext.Current.Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            int    id  = Request.QueryString["id"].ToInt(0);
            string sku = Request.QueryString["sku"];

            var p = new tbl_Product();

            if (id > 0)
            {
                p = ProductController.GetByID(id);
            }
            else if (id == 0)
            {
                int variableid = Request.QueryString["variableid"].ToInt(0);
                if (variableid != 0)
                {
                    p = ProductController.GetByVariableID(variableid);
                }
                else
                {
                    if (sku != "")
                    {
                        p = ProductController.GetBySKU(sku);
                        if (p == null)
                        {
                            p = ProductController.GetByVariableSKU(sku);
                        }
                    }
                }
            }

            if (p == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page);
            }
            else
            {
                this.Title = String.Format("{0} - Sản phẩm", p.ProductSKU.ToTitleCase());

                ViewState["ID"]     = id;
                ViewState["cateID"] = p.CategoryID;
                ViewState["SKU"]    = p.ProductSKU;

                ltrEdit1.Text = "";
                if (acc.RoleID == 0 || acc.RoleID == 1 || acc.Username == "nhom_zalo502")
                {
                    ltrEdit1.Text += "<a href='/thong-tin-san-pham?id=" + p.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-pencil-square-o' aria-hidden='true'></i> Chỉnh sửa</a>";
                    ltrEdit1.Text += "<a href='/tao-san-pham' class='btn primary-btn fw-btn not-fullwidth print-invoice-merged'><i class='fa fa-file-text-o' aria-hidden='true'></i> Thêm mới</a>";
                    if (p.ShowHomePage == 1)
                    {
                        ltrEdit1.Text += "<a href='javascript:;' onclick='showProductSyncModal(`" + p.ProductSKU + "`, " + p.ID + ", " + p.CategoryID + ");' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-upload' aria-hidden='true'></i> Đồng bộ</a>";
                    }
                }
                ltrEdit1.Text += "<a href='javascript:;' onclick='copyProductInfo(" + p.ID + ")' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-files-o'></i> Copy thông tin</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='getAllProductImage(`" + p.ProductSKU + "`);' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-cloud-download'></i> Tải tất cả hình ảnh</a>";

                if (acc.RoleID == 0 || acc.Username == "nhom_zalo502")
                {
                    ltrEdit1.Text += "<a href='javascript:;' onclick='deleteProduct(" + p.ID + ");' class='btn primary-btn not-fullwidth print-invoice-merged btn-red'><i class='fa fa-times'></i> Xóa sản phẩm</a>";
                    ltrEdit1.Text += "<a href='javascript:;' data-toggle='modal' data-target='#modalUpdateProductSKU' data-backdrop='static' data-keyboard='false' class='btn primary-btn not-fullwidth print-invoice-merged btn-blue'><i class='fa fa-times'></i> Sửa mã sản phẩm</a>";
                }

                ltrEdit2.Text = ltrEdit1.Text;

                lbProductTitle.Text = p.ProductTitle;
                pContent.Text       = p.ProductContent;
                lblSKU.Text         = p.ProductSKU;
                txtOldSKU.Text      = p.ProductSKU;

                // Create order fileter
                var filter = new ProductFilterModel()
                {
                    search = p.ProductSKU
                };
                // Create pagination
                var page = new PaginationMetadataModel();
                var a    = ProductController.GetAllSql(filter, ref page);
                if (page.totalCount > 0)
                {
                    foreach (var item in a)
                    {
                        lbProductStock.Text          = item.TotalProductInstockQuantityLeft.ToString();
                        ddlStockStatus.SelectedValue = item.StockStatus.ToString();
                    }
                }
                else
                {
                    lbProductStock.Text = "0";
                }

                lbOldPrice.Text     = string.Format("{0:N0}", p.Old_Price);
                lbRegularPrice.Text = string.Format("{0:N0}", p.Regular_Price);

                ltrCostOfGood.Text = "";
                if (acc.RoleID == 0)
                {
                    ltrCostOfGood.Text += "<div class='form-row'>";
                    ltrCostOfGood.Text += "    <div class='row-left'>";
                    ltrCostOfGood.Text += "        Giá vốn";
                    ltrCostOfGood.Text += "    </div>";
                    ltrCostOfGood.Text += "    <div class='row-right'>";
                    ltrCostOfGood.Text += "        <span class='form-control'>" + string.Format("{0:N0}", p.CostOfGood) + "</span>";
                    ltrCostOfGood.Text += "    </div>";
                    ltrCostOfGood.Text += "</div>";
                }

                lbRetailPrice.Text        = string.Format("{0:N0}", p.Retail_Price);
                ddlSupplier.SelectedValue = p.SupplierID.ToString();
                ddlCategory.SelectedValue = p.CategoryID.ToString();
                lbMaterials.Text          = p.Materials;
                lbColor.Text = p.Color;

                // Hàng order
                ddlPreOrder.SelectedValue = p.PreOrder ? "1" : "0";

                // thư viện ảnh
                var image = ProductImageController.GetByProductID(id);
                imageGallery.Text  = "<ul class='image-gallery'>";
                imageGallery.Text += "<li><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Normal) + "'><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                if (image != null)
                {
                    foreach (var img in image)
                    {
                        if (img.ProductImage != p.ProductImage)
                        {
                            imageGallery.Text += "<li><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Normal) + "'><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                        }
                    }
                }
                imageGallery.Text += "</ul>";


                hdfTable.Value = p.ProductStyle.ToString();

                // Init Tag
                var tagIDList = ProductTagController.get(p.ID, 0)
                                .Select(x => x.name)
                                .ToList();
                hdfTags.Value = String.Join(",", tagIDList);

                List <tbl_ProductVariable> b = new List <tbl_ProductVariable>();

                b = ProductVariableController.SearchProductID(p.ID, "");
                if (b != null)
                {
                    pagingall(b, Convert.ToInt32(acc.RoleID));
                }
            }
        }
Exemple #10
0
        public static string getAllProductImage1MB(string sku)
        {
            List <string> result = new List <string>();

            string rootPath          = HostingEnvironment.ApplicationPhysicalPath;
            string uploadsImagesPath = rootPath + "/uploads/images/";
            var    product           = ProductController.GetBySKU(sku);

            if (product != null)
            {
                List <string> images = new List <string>();

                // lấy ảnh đại diện
                string imgAdd = product.ProductImage;
                if (File.Exists(uploadsImagesPath + imgAdd))
                {
                    images.Add(imgAdd);
                }

                // lấy ảnh sản phẩm từ thư viện
                var imageProduct = ProductImageController.GetByProductID(product.ID);
                if (imageProduct != null)
                {
                    foreach (var img in imageProduct)
                    {
                        imgAdd = img.ProductImage;
                        if (File.Exists(uploadsImagesPath + imgAdd))
                        {
                            images.Add(imgAdd);
                        }
                    }
                }

                // lấy ảnh sản phẩm từ biến thể
                var variable = ProductVariableController.GetByParentSKU(product.ProductSKU);
                if (variable != null)
                {
                    foreach (var v in variable)
                    {
                        if (!String.IsNullOrEmpty(v.Image))
                        {
                            imgAdd = v.Image;
                            if (File.Exists(uploadsImagesPath + imgAdd))
                            {
                                images.Add(imgAdd);
                            }
                        }
                    }
                }

                // lọc hình trùng lặp
                images = images.Distinct().ToList();

                if (images.Count() > 0)
                {
                    for (int i = 0; i < images.Count - 1; i++)
                    {
                        for (int y = i + 1; y < images.Count; y++)
                        {
                            string img1 = Thumbnail.getURL(images[i], Thumbnail.Size.Micro);
                            string img2 = Thumbnail.getURL(images[y], Thumbnail.Size.Micro);

                            // so sánh 2 hình và lọc hình trùng lặp
                            Bitmap bmp1 = (Bitmap)Bitmap.FromFile(rootPath + img1);
                            Bitmap bmp2 = (Bitmap)Bitmap.FromFile(rootPath + img2);
                            if (CompareBitmapsLazy(bmp1, bmp2))
                            {
                                images.RemoveAt(y);
                                y--;
                            }
                        }
                    }
                }

                // lấy hình dưới 1MB
                for (int i = 0; i < images.Count; i++)
                {
                    string item = uploadsImagesPath + images[i];
                    var    size = new System.IO.FileInfo(item).Length;
                    if (size > 1000000)
                    {
                        // kiểm tra size hình rộng 600px
                        item = uploadsImagesPath + "600/" + images[i];
                        if (File.Exists(item))
                        {
                            size = new System.IO.FileInfo(item).Length;
                            if (size > 1000000)
                            {
                                result.Add(Thumbnail.getURL(images[i], Thumbnail.Size.Large));
                            }
                            else
                            {
                                result.Add(Thumbnail.getURL(images[i], Thumbnail.Size.XLarge));
                            }
                        }
                        else
                        {
                            result.Add(Thumbnail.getURL(images[i], Thumbnail.Size.Large));
                        }
                    }
                    else
                    {
                        result.Add(Thumbnail.getURL(images[i], Thumbnail.Size.Source));
                    }
                }
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(result.ToList()));
        }
        public void LoadData(int userRole)
        {
            int id = Request.QueryString["id"].ToInt(0);

            var p = new tbl_Product();

            if (id > 0)
            {
                p = ProductController.GetByID(id);
            }
            else if (id == 0)
            {
                int variableid = Request.QueryString["variableid"].ToInt(0);
                p = ProductController.GetByVariableID(variableid);
            }

            if (p == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page);
            }
            else
            {
                ViewState["ID"]     = id;
                ViewState["cateID"] = p.CategoryID;
                ViewState["SKU"]    = p.ProductSKU;

                ltrEdit1.Text = "";
                if (Convert.ToInt32(ViewState["role"]) == 0 || Convert.ToInt32(ViewState["role"]) == 1)
                {
                    ltrEdit1.Text += "<a href=\"/thong-tin-san-pham?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>";
                    ltrEdit1.Text += "<a href=\"/tao-san-pham\" class=\"btn primary-btn fw-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i> Thêm mới</a>";
                    ltrEdit1.Text += "<a href=\"javascript:;\" onclick=\"ShowUpProductToWeb('" + p.ProductSKU + "', '" + p.ID + "', 'false', 'false');\" class=\"up-product-" + p.ID + " btn primary-btn not-fullwidth print-invoice-merged " + (p.ShowHomePage == 1 ? "" : "hide") + "\"><i class=\"fa fa-upload\" aria-hidden=\"true\"></i> Đồng bộ</a>";
                }
                ltrEdit1.Text += "<a href=\"javascript:;\" onclick=\"copyProductInfo(" + p.ID + ")\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-files-o\"></i> Copy thông tin</a>";
                ltrEdit1.Text += "<a href=\"javascript:;\" onclick=\"getAllProductImage('" + p.ProductSKU + "');\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-cloud-download\"></i> Tải tất cả hình ảnh</a>";
                ltrEdit2.Text  = ltrEdit1.Text;

                lbProductTitle.Text = p.ProductTitle;
                pContent.Text       = p.ProductContent;
                lblSKU.Text         = p.ProductSKU;
                var a = ProductController.GetAllSql(0, p.ProductSKU);
                if (a.Count() > 0)
                {
                    foreach (var item in a)
                    {
                        lbProductStock.Text          = item.TotalProductInstockQuantityLeft.ToString();
                        ddlStockStatus.SelectedValue = item.StockStatus.ToString();
                    }
                }
                else
                {
                    lbProductStock.Text = "0";
                }

                lbRegularPrice.Text = string.Format("{0:N0}", p.Regular_Price);

                ltrCostOfGood.Text = "";
                if (userRole == 0)
                {
                    ltrCostOfGood.Text += "<div class='form-row'>";
                    ltrCostOfGood.Text += "    <div class='row-left'>";
                    ltrCostOfGood.Text += "        Giá vốn";
                    ltrCostOfGood.Text += "    </div>";
                    ltrCostOfGood.Text += "    <div class='row-right'>";
                    ltrCostOfGood.Text += "        <span class='form-control'>" + string.Format("{0:N0}", p.CostOfGood) + "</span>";
                    ltrCostOfGood.Text += "    </div>";
                    ltrCostOfGood.Text += "</div>";
                }

                lbRetailPrice.Text        = string.Format("{0:N0}", p.Retail_Price);
                ddlSupplier.SelectedValue = p.SupplierID.ToString();
                ddlCategory.SelectedValue = p.CategoryID.ToString();
                lbMaterials.Text          = p.Materials;

                // thư viện ảnh
                var image = ProductImageController.GetByProductID(id);
                imageGallery.Text  = "<ul class=\"image-gallery\">";
                imageGallery.Text += "<li><img src=\"" + p.ProductImage + "\" /><a href='" + p.ProductImage + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                if (image != null)
                {
                    foreach (var img in image)
                    {
                        if (img.ProductImage != p.ProductImage)
                        {
                            imageGallery.Text += "<li><img src=\"" + img.ProductImage + "\" /><a href='" + img.ProductImage + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                        }
                    }
                }
                imageGallery.Text += "</ul>";


                hdfTable.Value = p.ProductStyle.ToString();
            }

            List <tbl_ProductVariable> b = new List <tbl_ProductVariable>();

            b = ProductVariableController.SearchProductID(p.ID, "");
            pagingall(b, userRole);
        }
Exemple #12
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = ProductController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/sp", Page);
                }
                else
                {
                    ViewState["ID"]     = id;
                    ViewState["cateID"] = p.CategoryID;
                    ViewState["SKU"]    = p.ProductSKU;

                    ltrProductName.Text = p.ProductSKU + " - " + p.ProductTitle;
                    var a = ProductController.GetAllSql(0, p.ProductSKU);
                    if (a.Count() > 0)
                    {
                        foreach (var item in a)
                        {
                            string StockStatus = "";
                            if (item.StockStatus == 1)
                            {
                                StockStatus = "Còn hàng";
                            }
                            else
                            {
                                StockStatus = "Hết hàng";
                            }
                            ltrProductStock.Text = "<p><strong>✱ Kho</strong>: " + StockStatus + " (" + item.TotalProductInstockQuantityLeft.ToString() + " cái)</p>";
                        }
                    }
                    else
                    {
                        ltrProductStock.Text = "<p><strong>✱ Kho</strong>: Đang nhập hàng</p>";
                    }

                    ltrRegularPrice.Text = "<p><strong>📌 Giá sỉ</strong>: " + (p.Regular_Price / 1000).ToString() + "k</p>";

                    ltrRetailPrice.Text = "<p><strong>📌 Giá lẻ</strong>: " + ((p.Retail_Price + 20000) / 1000).ToString() + "k</p>";

                    if (!string.IsNullOrEmpty(p.Materials))
                    {
                        ltrMaterials.Text = "<p><strong>🔖 Chất liệu</strong>: " + p.Materials + "</p>";
                    }

                    if (!string.IsNullOrEmpty(p.ProductContent))
                    {
                        ltrContent.Text = "<p><strong>🔖 Mô tả</strong>: " + p.ProductContent + "</p>";
                    }

                    if (p.ProductImage != null)
                    {
                        ProductThumbnail.Text = "<p><img src=\"" + p.ProductImage + "\" /><a href='" + p.ProductImage + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                    }

                    var image = ProductImageController.GetByProductID(id);

                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            if (img.ProductImage != p.ProductImage)
                            {
                                imageGallery.Text += "<p><img src=\"" + img.ProductImage + "\" /><a href='" + img.ProductImage + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                            }
                        }
                    }

                    ltrCopyProductInfoButton.Text      = "<p><a href=\"javascript:;\" class=\"btn primary-btn copy-btn h45-btn\" onclick=\"copyProduct(" + p.ID + ")\"><i class=\"fa fa-files-o\" aria-hidden=\"true\"></i> Copy</a></p>";
                    ltrDownloadProductImageButton.Text = "<a href =\"javascript:;\" class=\"btn primary-btn h45-btn\" onclick=\"getAllProductImage('" + p.ProductSKU + "');\"><i class=\"fa fa-cloud-download\" aria-hidden=\"true\"></i> Tải hình</a>";

                    var v = ProductVariableController.SearchProductID(id, "");

                    if (v.Count > 0)
                    {
                        ltrViewVariableListButton.Text = "<p><a href='#variableTable' class='btn download-btn h45-btn'><i class='fa fa-list-ul' aria-hidden='true'></i> Biến thể</a></p>";
                        ltrVariableList.Text           = "<h3><i class='fa fa-list-ul' aria-hidden='true'></i> Danh sách biến thể</h3>";

                        pagingall(v);
                    }
                }
            }
        }
Exemple #13
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = ProductController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm", "e", true, "/", Page);
                }
                else
                {
                    if (p.CategoryID != 44)
                    {
                        PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm", "e", true, "/", Page);
                    }

                    this.Title = String.Format("{0} - {1}", p.ProductTitle.ToTitleCase(), p.ProductSKU);

                    ViewState["ID"]     = id;
                    ViewState["cateID"] = p.CategoryID;
                    ViewState["SKU"]    = p.ProductSKU;

                    ltrProductName.Text  = p.ProductSKU + " - " + p.ProductTitle;
                    ltrRegularPrice.Text = "<p><strong>📌 Giá sỉ</strong>: " + (p.Regular_Price / 1000).ToString() + "k</p>";
                    ltrRetailPrice.Text  = "<p><strong>📌 Giá lẻ</strong>: " + (p.Retail_Price / 1000).ToString() + "k</p>";

                    if (!string.IsNullOrEmpty(p.Materials))
                    {
                        ltrContent.Text += "<p>" + p.Materials + "</p>";
                    }

                    if (!string.IsNullOrEmpty(p.ProductContent))
                    {
                        string content = Regex.Replace(p.ProductContent, @"<img\s[^>]*>(?:\s*?</img>)?", "").ToString();
                        ltrContent.Text += "<p>" + content + "</p>";
                    }

                    if (p.ProductImage != null)
                    {
                        ProductThumbnail.Text = "<p><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "'><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                    }

                    var image = ProductImageController.GetByProductID(id);

                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            if (img.ProductImage != p.ProductImage)
                            {
                                imageGallery.Text += "<p><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "'><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>";
                            }
                        }
                    }

                    var    v   = ProductVariableController.SearchProductID(id, "");
                    string css = "col-xs-6";
                    if (v.Count > 0)
                    {
                        css = "col-xs-4";
                    }

                    StringBuilder htmlButton = new StringBuilder();
                    htmlButton.Append("<div class='" + css + "'>");
                    htmlButton.Append("    <div class='row'>");
                    htmlButton.Append("        <p><a href='javascript:;' class='btn primary-btn copy-btn h45-btn' onclick='copyProduct(`" + p.ID + "`);'><i class='fa fa-files-o' aria-hidden='true'></i> Copy mô tả</a></p>");
                    htmlButton.Append("    </div>");
                    htmlButton.Append("</div>");

                    if (v.Count > 0)
                    {
                        htmlButton.Append("<div class='" + css + "'>");
                        htmlButton.Append("    <div class='row'>");
                        htmlButton.Append("        <p><a href='#variableTable' class='btn download-btn h45-btn'><i class='fa fa-list-ul' aria-hidden='true'></i> Biến thể</a></p>");
                        htmlButton.Append("    </div>");
                        htmlButton.Append("</div>");

                        ltrVariableList.Text = "<h3><i class='fa fa-list-ul' aria-hidden='true'></i> Danh sách biến thể</h3>";
                        pagingall(v);
                    }

                    htmlButton.Append("<div class='" + css + "'>");
                    htmlButton.Append("    <div class='row'>");
                    htmlButton.Append("        <a href='javascript:;' class='btn primary-btn h45-btn' onclick='getAllProductImage(`" + p.ProductSKU + "`);'><i class='fa fa-cloud-download' aria-hidden='true'></i> Tải hình</a>");
                    htmlButton.Append("    </div>");
                    htmlButton.Append("</div>");

                    ltrButton.Text = htmlButton.ToString();
                }
            }
        }
Exemple #14
0
        public void LoadData(int userRole)
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = ProductController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page);
                }
                else
                {
                    ViewState["ID"]     = id;
                    ViewState["cateID"] = p.CategoryID;
                    ViewState["SKU"]    = p.ProductSKU;

                    if (Convert.ToInt32(ViewState["role"]) == 0 || Convert.ToInt32(ViewState["role"]) == 1)
                    {
                        ltrEdit1.Text = "<a href=\"/thong-tin-san-pham.aspx?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Chỉnh sửa</a>";
                        ltrEdit2.Text = "<a href=\"/thong-tin-san-pham.aspx?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Chỉnh sửa</a>";
                    }

                    lbProductTitle.Text = p.ProductTitle;
                    pContent.Text       = p.ProductContent;
                    lblSKU.Text         = p.ProductSKU;
                    var a = ProductController.GetAllSql(0, p.ProductSKU);
                    if (a.Count() > 0)
                    {
                        foreach (var item in a)
                        {
                            lbProductStock.Text          = item.TotalProductInstockQuantityLeft.ToString();
                            ddlStockStatus.SelectedValue = item.StockStatus.ToString();
                        }
                    }
                    else
                    {
                        lbProductStock.Text = "0";
                    }

                    lbRegularPrice.Text = string.Format("{0:N0}", p.Regular_Price);

                    ltrCostOfGood.Text = "";
                    if (userRole == 0)
                    {
                        ltrCostOfGood.Text += "<div class='form-row'>";
                        ltrCostOfGood.Text += "    <div class='row-left'>";
                        ltrCostOfGood.Text += "        Giá vốn";
                        ltrCostOfGood.Text += "    </div>";
                        ltrCostOfGood.Text += "    <div class='row-right'>";
                        ltrCostOfGood.Text += "        <span class='form-control'>" + string.Format("{0:N0}", p.CostOfGood) + "</span>";
                        ltrCostOfGood.Text += "    </div>";
                        ltrCostOfGood.Text += "</div>";
                    }

                    lbRetailPrice.Text            = string.Format("{0:N0}", p.Retail_Price);
                    ddlSupplier.SelectedValue     = p.SupplierID.ToString();
                    ddlCategory.SelectedValue     = p.CategoryID.ToString();
                    lbMaterials.Text              = p.Materials;
                    lbpMinimumInventoryLevel.Text = p.MinimumInventoryLevel.ToString();
                    lbpMaximumInventoryLevel.Text = p.MaximumInventoryLevel.ToString();

                    var image = ProductImageController.GetByProductID(id);

                    imageGallery.Text = "<ul class=\"image-gallery\">";
                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            imageGallery.Text += "<li><img src=\"" + img.ProductImage + "\" /></li>";
                        }
                    }
                    imageGallery.Text += "</ul>";

                    if (p.ProductImage != null)
                    {
                        ProductThumbnail.ImageUrl = p.ProductImage;
                    }

                    hdfTable.Value = p.ProductStyle.ToString();
                    var ka = ProductVariableController.SearchProductID(p.ID, "");
                    if (ka != null)
                    {
                        //var value = ProductVariableValueController.GetByProductVariableID(a.ID);
                    }
                }

                List <tbl_ProductVariable> b = new List <tbl_ProductVariable>();

                b = ProductVariableController.SearchProductID(id, "");
                pagingall(b, userRole);
            }
        }
        public void LoadData()
        {
            int    id  = Request.QueryString["id"].ToInt(0);
            string sku = Request.QueryString["sku"];

            var p = new tbl_Product();

            if (id > 0)
            {
                p = ProductController.GetByID(id);
            }
            else if (id == 0)
            {
                int variableid = Request.QueryString["variableid"].ToInt(0);
                if (variableid != 0)
                {
                    p = ProductController.GetByVariableID(variableid);
                }
                else
                {
                    if (sku != "")
                    {
                        p = ProductController.GetBySKU(sku);
                        if (p == null)
                        {
                            p = ProductController.GetByVariableSKU(sku);
                        }
                    }
                }
            }

            if (p == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/san-pham", Page);
            }
            else
            {
                this.Title = String.Format("{0} - Sản phẩm", p.ProductSKU);

                ltrEdit1.Text  = "";
                ltrEdit1.Text += "<a href='javascript:;' onclick='copyProductInfo(" + p.ID + ")' class='btn primary-btn margin-right-15px'><i class='fa fa-files-o'></i> Copy</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='getAllProductImage(`" + p.ProductSKU + "`)' class='btn primary-btn margin-right-15px'><i class='fa fa-download'></i> Tải hình</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='postProductKiotViet(`" + p.ProductSKU + "`)' class='btn primary-btn margin-right-15px'><i class='fa fa-arrow-up'></i> Đăng Kiot</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='postProductZaloShop(`" + p.ProductSKU + "`)' class='btn primary-btn margin-right-15px'><i class='fa fa-arrow-up'></i> Đăng Zalo</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='downloadProductZaloShop(`" + p.ProductSKU + "`)' class='btn primary-btn btn-blue margin-right-15px'><i class='fa fa-download'></i> Tải Zalo</a>";
                ltrEdit1.Text += "<a href='javascript:;' onclick='deleteProductZaloShop(`" + p.ProductSKU + "`)' class='btn primary-btn btn-red margin-right-15px'><i class='fa fa-times' aria-hidden='true'></i> Xóa Zalo</a>";
                if (p.ProductType == 2)
                {
                    ltrEdit1.Text += "<a href='#variantList' class='btn primary-btn margin-right-15px'><i class='fa fa-th-list'></i> Thuộc tính</a>";
                }
                ltrProductName.Text = p.ProductSKU + " - " + p.ProductTitle;
                var categoryName = CategoryController.GetByID(p.CategoryID.Value);
                ltrCategory.Text     = categoryName.CategoryName;
                ltrMaterials.Text    = p.Materials;
                pContent.Text        = p.ProductContent;
                ltrSKU.Text          = p.ProductSKU;
                ltrRegularPrice.Text = string.Format("{0:N0}", p.Regular_Price);
                ltrRetailPrice.Text  = string.Format("{0:N0}", p.Retail_Price);

                // Create order fileter
                var filter = new ProductFilterModel()
                {
                    search = p.ProductSKU
                };
                // Create pagination
                var page = new PaginationMetadataModel();
                var a    = ProductController.GetAllSql(filter, ref page);
                if (page.totalCount > 0)
                {
                    foreach (var item in a)
                    {
                        ltrStock.Text = item.TotalProductInstockQuantityLeft.ToString();
                        if (item.StockStatus == 1)
                        {
                            ltrStockStatus.Text = "còn hàng";
                        }
                        else if (item.StockStatus == 2)
                        {
                            ltrStockStatus.Text = "hết hàng";
                        }
                        else
                        {
                            ltrStockStatus.Text = "đang nhập hàng";
                        }
                    }
                }
                else
                {
                    ltrStock.Text = "0";
                }

                // thư viện ảnh
                var image = ProductImageController.GetByProductID(id);
                imageGallery.Text  = "<ul class='image-gallery'>";
                imageGallery.Text += "<li><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' target='_blank'><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "'></a><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình</a></li>";
                if (image != null)
                {
                    foreach (var img in image)
                    {
                        if (img.ProductImage != p.ProductImage)
                        {
                            imageGallery.Text += "<li><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' target='_blank'><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "'></a><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình</a></li>";
                        }
                    }
                }
                imageGallery.Text += "</ul>";


                hdfTable.Value = p.ProductStyle.ToString();
                List <tbl_ProductVariable> b = new List <tbl_ProductVariable>();
                b = ProductVariableController.SearchProductID(p.ID, "");
                if (b != null)
                {
                    pagingall(b);
                }
            }
        }