Esempio n. 1
0
        /// <summary>
        /// Khởi tạo HTML danh mục biến thể
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Value"></param>
        /// <returns>HTM DropDownList</returns>
        private string _getSelectVariable(string Name, string Value)
        {
            var variableName = VariableController.GetByName(Name);
            var html         = new StringBuilder();

            if (variableName != null)
            {
                html.AppendLine("<select name='ddlVariableValue'");
                html.AppendLine("        class='form-control select2'");
                html.AppendLine("        style='width: 100%'");
                html.AppendLine(String.Format("        data-name-id='{0}'", variableName.ID));
                html.AppendLine(String.Format("        data-name-text='{0}'", variableName.VariableName));
                html.AppendLine("        onchange='onChangeVariationValue($(this))'");
                html.AppendLine(">");
                html.AppendLine("    <option data-sku-text='' value=''>Chọn giá trị</option>");
                var variableValue = VariableValueController.GetByVariableID(variableName.ID);
                foreach (var item in variableValue)
                {
                    var isSelected = item.VariableValue == Value;
                    html.AppendLine(String.Format("    <option data-sku-text='{0}' value='{1}' {2}>{3}</option>", item.SKUText, item.ID, (isSelected ? "selected='selected'" : String.Empty), item.VariableValue));
                }
                html.AppendLine("</select>");
            }
            return(html.ToString());
        }
Esempio n. 2
0
        public static string getSelectVariable(string Name, string Value)
        {
            var    variablename = VariableController.GetByName(Name);
            string html         = "";

            if (variablename != null)
            {
                html += "<select name='ddlVariableValue' id='ddlVariableValue' data-name-id='" + variablename.ID + "' data-name-text='" + variablename.VariableName + "' class='form-control' onchange='changeVariable($(this))'>";
                html += "<option data-sku-text='' value=''>Chọn giá trị</option>";
                var variablevalue = VariableValueController.GetByVariableID(variablename.ID);
                foreach (var p in variablevalue)
                {
                    if (p.VariableValue == Value)
                    {
                        html += "<option data-sku-text='" + p.SKUText + "' selected='selected' value='" + p.ID + "'>" + p.VariableValue + "</option>";
                    }
                    else
                    {
                        html += "<option data-sku-text='" + p.SKUText + "' value='" + p.ID + "'>" + p.VariableValue + "</option>";
                    }
                }
                html += "</select>";
            }
            return(html);
        }
Esempio n. 3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    string phone     = txtCustomerName.Text.ToLower().Trim();
                    var    checkname = VariableController.GetByName(phone);
                    if (checkname != null)
                    {
                        lblError.Text    = "Tên danh mục đã tồn tại vui lòng chọn tên khác.";
                        lblError.Visible = true;
                    }
                    else
                    {
                        lblError.Visible = false;
                        VariableController.Insert(txtCustomerName.Text, "", chkIsHidden.Checked, DateTime.Now, username);
                        PJUtils.ShowMessageBoxSwAlert("Tạo mới thành công", "s", true, Page);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Tải thông tin của biến thể
        /// </summary>
        /// <param name="productID"></param>
        private void _loadProductVariationInfo(int productID)
        {
            var html       = new StringBuilder();
            var variations = ProductVariableController
                             .GetProductID(productID)
                             .OrderByDescending(o => o.ID);
            var index = variations.Count();

            foreach (var item in variations)
            {
                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         = Thumbnail.getURL(item.Image, Thumbnail.Size.Source);
                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))
                {
                    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'"));
                html.AppendLine(String.Format("     data-index='{0}'", index));
                html.AppendLine(String.Format("     data-product-variation-id='{0}'", item.ID));
                html.AppendLine(String.Format("     data-name-id='{0}'", variableID));
                html.AppendLine(String.Format("     data-value-id='{0}'", variableValueID));
                html.AppendLine(String.Format("     data-name-text='{0}'", variableName));
                html.AppendLine(String.Format("     data-value-text='{0}'", variableValueName));
                html.AppendLine(String.Format("     data-name-value='{0}'", dataVariableValue));
                html.AppendLine(String.Format(">"));
                html.AppendLine(String.Format("    <div class='col-md-12'>"));
                html.AppendLine(String.Format("        <div class='col-md-10 variable-label'  onclick='showVariableContent($(this))'>"));
                html.AppendLine(String.Format("            <strong>#{0}</strong> - {1} {2}", index, labelVariableValue, VariableSKU));
                html.AppendLine(String.Format("        </div>"));
                html.AppendLine(String.Format("        <div class='col-md-2 variable-removal'>"));
                html.AppendLine(String.Format("            <a href='javascript:;' onclick='deleteVariableItem($(this))' class='btn primary-btn fw-btn not-fullwidth'>"));
                html.AppendLine(String.Format("                <i class='fa fa-times' aria-hidden='true'></i>"));
                html.AppendLine(String.Format("            </a>"));
                html.AppendLine(String.Format("        </div>"));
                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='onChangeVariationImage(this,$(this));' name='{0}'><img class='imgpreview' onclick='openUploadImage($(this))' data-file-name='{1}' src='{1}'>{2}", VariableSKU, 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}' disabled='disabled' readonly></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='number' 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='number' 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='number' value='{0}'></div>", RetailPrice));
                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>"));

                index--;
            }

            if (variations.Count() > 0)
            {
                ltrVariables.Text = html.ToString();
            }
        }
Esempio n. 5
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();
                    }
                }
            }
        }