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

            if (Login(username, password))
            {
                var ProductVariableValue = ProductVariableValueController.GetByProductVariableID(ProductVariableID);
                if (ProductVariableValue.Count > 0)
                {
                    rs.Code   = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS);
                    rs.Status = APIUtils.ResponseMessage.Success.ToString();
                    rs.ProductVariableValue = ProductVariableValue;
                }
                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
        public void pagingall(List <tbl_ProductVariable> acs)
        {
            int           PageSize = 30;
            StringBuilder html     = new StringBuilder();

            html.Append("<div class='row'>");
            if (acs.Count > 0)
            {
                int TotalItems = acs.Count;
                if (TotalItems % PageSize == 0)
                {
                    PageCount = TotalItems / PageSize;
                }
                else
                {
                    PageCount = TotalItems / PageSize + 1;
                }

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }

                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item = acs[i];
                    html.Append("<div class='col-md-3 product-item'>");

                    html.Append("   <div><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Large) + "'></div>");
                    if (!string.IsNullOrEmpty(item.Image))
                    {
                        html.Append("   <div><a href='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Source) + "' download class='btn download-btn h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></div>");
                    }

                    var value = ProductVariableValueController.GetByProductVariableID(item.ID);
                    if (value != null)
                    {
                        foreach (var temp in value)
                        {
                            html.Append("<h3>" + temp.VariableName + ": " + temp.VariableValue + "</h3>");
                        }
                    }

                    html.Append("   <p>Mã: " + item.SKU + "</p>");
                    html.Append("   <p>Giá sỉ: " + string.Format("{0:N0}", item.Regular_Price) + "</p>");
                    html.Append("   <p>Kho: " + PJUtils.StockStatusBySKU(1, item.SKU) + " (" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + " cái)</p>");
                    html.Append("</div>");
                }
            }
            ltrList.Text = html.ToString();
        }
        public void LoadData()
        {
            List <tbl_ProductVariableValue> a = new List <tbl_ProductVariableValue>();
            int productvariableid             = Request.QueryString["productvariableid"].ToInt(0);

            if (productvariableid > 0)
            {
                var pv = ProductVariableController.GetByID(productvariableid);
                if (pv != null)
                {
                    ltrBack.Text         = "<a href=\"/thuoc-tinh-san-pham?id=" + pv.ProductID + "\" class=\"btn primary-btn h45-btn\">Trở về</a>";
                    lblCategoryName.Text = "Giá trị thuộc tính sản phẩm";
                    ltrAddnew.Text       = "<a href=\"/them-gia-tri-thuoc-tinh?productvariableid=" + productvariableid + "\" class=\"h45-btn btn\" style=\"background-color: #ff3f4c\">Thêm mới</a>";
                }
                a = ProductVariableValueController.GetByProductVariableID(productvariableid);
                pagingall(a);
            }
        }
Exemple #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            int      AgentID     = 0;
            string   username    = Request.Cookies["usernameLoginSystem"].Value;

            if (!string.IsNullOrEmpty(username))
            {
                var a = AccountController.GetByUsername(username);
                if (a != null)
                {
                    AgentID = Convert.ToInt32(a.AgentID);
                    string phone = hdfPhone.Value;
                    if (!string.IsNullOrEmpty(phone))
                    {
                        var cust = CustomerController.GetByPhone(phone);
                        if (cust != null)
                        {
                            #region Tạo đơn hàng đổi tra
                            int    custID        = cust.ID;
                            string totalprice    = hdfTotalPrice.Value;
                            string totalquantity = hdfTotalQuantity.Value;
                            string totalrefund   = hdfTotalRefund.Value;
                            var    agent         = AgentController.GetByID(AgentID);
                            string agentName     = "";
                            if (agent != null)
                            {
                                agentName = agent.AgentName;
                            }
                            //insert ddlstatus, refundnote
                            int    status      = ddlRefundStatus.SelectedValue.ToInt();
                            string RefundsNote = txtRefundsNote.Text;
                            int    rID         = RefundGoodController.Insert(AgentID, totalprice, status, custID, Convert.ToInt32(totalquantity),
                                                                             totalrefund, agentName, cust.CustomerName, cust.CustomerPhone, currentDate, username, RefundsNote);
                            #endregion

                            if (rID > 0)
                            {
                                string   listString = hdfListProduct.Value;
                                string[] items      = listString.Split('|');
                                if (items.Length - 1 > 0)
                                {
                                    for (int i = 0; i < items.Length - 1; i++)
                                    {
                                        #region Tạo chi tiết đơn hàng đổi tra
                                        string[] element                 = items[i].Split(';');
                                        var      sku                     = element[0];
                                        var      orderID                 = element[1].ToInt(0);
                                        var      orderDetailID           = element[2];
                                        var      ProductName             = element[3];
                                        var      GiavonPerProduct        = Convert.ToDouble(element[5]);
                                        var      SoldPricePerProduct     = Convert.ToDouble(element[6]);
                                        var      DiscountPricePerProduct = Convert.ToDouble(element[7]);
                                        var      quantity                = Convert.ToDouble(element[10]);
                                        var      quantityMax             = Convert.ToDouble(element[8]);
                                        var      ProductType             = element[4].ToInt(1);
                                        var      RefundType              = element[9].ToInt(1);
                                        var      RefundFeePerProduct     = Convert.ToDouble(element[11]);
                                        var      TotalPriceRow           = element[12];
                                        var      PriceNotFeeRefund       = SoldPricePerProduct * quantity;
                                        var      rdTotalRefundFee        = RefundFeePerProduct * quantity;

                                        int rdID = RefundGoodDetailController.Insert(rID, AgentID, orderID, ProductName, custID, sku, quantity,
                                                                                     quantityMax, PriceNotFeeRefund.ToString(), ProductType, true, RefundType, RefundFeePerProduct.ToString(),
                                                                                     rdTotalRefundFee.ToString(), GiavonPerProduct.ToString(), DiscountPricePerProduct.ToString(), SoldPricePerProduct.ToString(),
                                                                                     TotalPriceRow, currentDate, username);
                                        #endregion

                                        #region Cập nhật stock
                                        if (rdID > 0)
                                        {
                                            if (RefundType < 3)
                                            {
                                                int    typeRe = 0;
                                                string note   = "";
                                                if (RefundType == 1)
                                                {
                                                    note   = "Đổi size";
                                                    typeRe = 8;
                                                }
                                                else if (RefundType == 2)
                                                {
                                                    note   = "Đổi sản phẩm";
                                                    typeRe = 9;
                                                }
                                                if (ProductType == 1)
                                                {
                                                    var product = ProductController.GetBySKU(sku);
                                                    if (product != null)
                                                    {
                                                        int    productID          = product.ID;
                                                        string ProductImageOrigin = "";
                                                        var    ProductImage       = ProductImageController.GetFirstByProductID(product.ID);
                                                        if (ProductImage != null)
                                                        {
                                                            ProductImageOrigin = ProductImage.ProductImage;
                                                        }
                                                        StockManagerController.Insert(
                                                            new tbl_StockManager {
                                                            AgentID           = AgentID,
                                                            ProductID         = productID,
                                                            ProductVariableID = 0,
                                                            Quantity          = quantity,
                                                            QuantityCurrent   = 0,
                                                            Type        = 1,
                                                            NoteID      = note,
                                                            OrderID     = orderID,
                                                            Status      = typeRe,
                                                            SKU         = sku,
                                                            CreatedDate = currentDate,
                                                            CreatedBy   = username,
                                                            MoveProID   = 0,
                                                            ParentID    = productID,
                                                        });
                                                    }
                                                }
                                                else
                                                {
                                                    string ProductVariableName  = "";
                                                    string ProductVariableValue = "";
                                                    string ProductVariable      = "";
                                                    int    parentID             = 0;
                                                    string parentSKU            = "";
                                                    string ProductImageOrigin   = "";
                                                    int    ID = 0;

                                                    var productvariable = ProductVariableController.GetBySKU(sku);
                                                    if (productvariable != null)
                                                    {
                                                        ID = productvariable.ID;
                                                        ProductImageOrigin = productvariable.Image;
                                                        parentSKU          = productvariable.ParentSKU;
                                                        var variables = ProductVariableValueController.GetByProductVariableID(productvariable.ID);
                                                        if (variables.Count > 0)
                                                        {
                                                            foreach (var v in variables)
                                                            {
                                                                ProductVariable      += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|";
                                                                ProductVariableName  += v.VariableName + "|";
                                                                ProductVariableValue += v.VariableValue + "|";
                                                            }
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty(parentSKU))
                                                    {
                                                        var product = ProductController.GetBySKU(parentSKU);
                                                        if (product != null)
                                                        {
                                                            parentID = product.ID;
                                                        }
                                                    }


                                                    StockManagerController.Insert(
                                                        new tbl_StockManager {
                                                        AgentID           = AgentID,
                                                        ProductID         = 0,
                                                        ProductVariableID = ID,
                                                        Quantity          = quantity,
                                                        QuantityCurrent   = 0,
                                                        Type        = 1,
                                                        NoteID      = note,
                                                        OrderID     = orderID,
                                                        Status      = typeRe,
                                                        SKU         = sku,
                                                        CreatedDate = currentDate,
                                                        CreatedBy   = username,
                                                        MoveProID   = 0,
                                                        ParentID    = parentID,
                                                    });
                                                }
                                            }
                                        }
                                        #endregion
                                    }

                                    RefundGoodController.updateQuantityCOGS(rID);

                                    PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo đơn hàng đổi trả thành công", "s", true, "redirectTo(" + rID + ")", Page);
                                }
                            }
                        }
                    }
                }
            }
        }
        public static string getProduct(string textsearch, int typeinout)
        {
            List <ProductGetOut> ps = new List <ProductGetOut>();
            string username         = HttpContext.Current.Request.Cookies["userLoginSystem"].Value;
            var    acc = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int AgentID = Convert.ToInt32(acc.AgentID);
                if (typeinout == 1)
                {
                    var products = ProductController.GetByTextSearchIsHidden(textsearch.Trim(), false);
                    if (products.Count > 0)
                    {
                        foreach (var item in products)
                        {
                            var productvariable = ProductVariableController.GetProductID(item.ID);
                            if (productvariable.Count > 0)
                            {
                                foreach (var pv in productvariable)
                                {
                                    string SKU   = pv.SKU.Trim().ToUpper();
                                    var    check = StockManagerController.GetBySKU(AgentID, SKU);
                                    if (check.Count > 0)
                                    {
                                        double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU);
                                        if (total > 0)
                                        {
                                            var variables = ProductVariableValueController.GetByProductVariableID(pv.ID);
                                            if (variables.Count > 0)
                                            {
                                                string variablename  = "";
                                                string variablevalue = "";
                                                string variable      = "";

                                                foreach (var v in variables)
                                                {
                                                    variable      += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|";
                                                    variablename  += v.VariableName.Trim() + "|";
                                                    variablevalue += v.VariableValue.Trim() + "|";
                                                }

                                                ProductGetOut p = new ProductGetOut();
                                                p.ID                    = pv.ID;
                                                p.ProductName           = item.ProductTitle;
                                                p.ProductVariable       = variable;
                                                p.ProductVariableName   = variablename;
                                                p.ProductVariableValue  = variablevalue;
                                                p.ProductType           = 2;
                                                p.ProductImage          = "<img src=\"" + pv.Image + "\" alt=\"\" style=\"width: 50px\" />";
                                                p.ProductImageOrigin    = pv.Image;
                                                p.QuantityInstock       = total;
                                                p.QuantityInstockString = string.Format("{0:N0}", total);
                                                p.SKU                   = SKU;
                                                int supplierID = 0;
                                                if (pv.SupplierID != null)
                                                {
                                                    supplierID = pv.SupplierID.ToString().ToInt(0);
                                                }
                                                p.SupplierID = supplierID;
                                                string supplierName = "";
                                                if (!string.IsNullOrEmpty(pv.SupplierName))
                                                {
                                                    supplierName = pv.SupplierName;
                                                }
                                                p.SupplierName = supplierName;
                                                ps.Add(p);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                string SKU   = item.ProductSKU.Trim().ToUpper();
                                var    check = StockManagerController.GetBySKU(AgentID, SKU);
                                if (check.Count > 0)
                                {
                                    double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU);
                                    if (total > 0)
                                    {
                                        string variablename  = "";
                                        string variablevalue = "";
                                        string variable      = "";

                                        ProductGetOut p = new ProductGetOut();
                                        p.ID                   = item.ID;
                                        p.ProductName          = item.ProductTitle;
                                        p.ProductVariable      = variable;
                                        p.ProductVariableName  = variablename;
                                        p.ProductVariableValue = variablevalue;
                                        p.ProductType          = 1;
                                        var img = ProductImageController.GetFirstByProductID(item.ID);
                                        if (img != null)
                                        {
                                            p.ProductImage       = "<img src=\"" + img.ProductImage + "\" alt=\"\" style=\"width: 50px\"  />";
                                            p.ProductImageOrigin = img.ProductImage;
                                        }
                                        else
                                        {
                                            p.ProductImage       = "";
                                            p.ProductImageOrigin = "";
                                        }
                                        p.QuantityInstock       = total;
                                        p.QuantityInstockString = string.Format("{0:N0}", total);
                                        p.SKU = SKU;
                                        int supplierID = 0;
                                        if (item.SupplierID != null)
                                        {
                                            supplierID = item.SupplierID.ToString().ToInt(0);
                                        }
                                        p.SupplierID = supplierID;
                                        string supplierName = "";
                                        if (!string.IsNullOrEmpty(item.SupplierName))
                                        {
                                            supplierName = item.SupplierName;
                                        }
                                        p.SupplierName = supplierName;
                                        ps.Add(p);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    var products = ProductController.GetBySKU(textsearch);
                    if (products != null)
                    {
                        var productvariable = ProductVariableController.GetProductID(products.ID);
                        if (productvariable.Count > 0)
                        {
                            foreach (var pv in productvariable)
                            {
                                string SKU   = pv.SKU.Trim().ToUpper();
                                var    check = StockManagerController.GetBySKU(AgentID, SKU);
                                if (check.Count > 0)
                                {
                                    double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU);

                                    if (total > 0)
                                    {
                                        var variables = ProductVariableValueController.GetByProductVariableID(pv.ID);
                                        if (variables.Count > 0)
                                        {
                                            string variablename  = "";
                                            string variablevalue = "";
                                            string variable      = "";

                                            foreach (var v in variables)
                                            {
                                                variable      += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|";
                                                variablename  += v.VariableName.Trim() + "|";
                                                variablevalue += v.VariableValue.Trim() + "|";
                                            }

                                            ProductGetOut p = new ProductGetOut();
                                            p.ID                    = pv.ID;
                                            p.ProductName           = products.ProductTitle;
                                            p.ProductVariable       = variable;
                                            p.ProductVariableName   = variablename;
                                            p.ProductVariableValue  = variablevalue;
                                            p.ProductType           = 2;
                                            p.ProductImage          = "<img src=\"" + pv.Image + "\" alt=\"\" style=\"width: 50px\"  />";
                                            p.ProductImageOrigin    = pv.Image;
                                            p.QuantityInstock       = total;
                                            p.QuantityInstockString = string.Format("{0:N0}", total);
                                            p.SKU                   = SKU;
                                            int supplierID = 0;
                                            if (pv.SupplierID != null)
                                            {
                                                supplierID = pv.SupplierID.ToString().ToInt(0);
                                            }
                                            p.SupplierID = supplierID;
                                            string supplierName = "";
                                            if (!string.IsNullOrEmpty(pv.SupplierName))
                                            {
                                                supplierName = pv.SupplierName;
                                            }
                                            p.SupplierName = supplierName;
                                            ps.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            string SKU   = products.ProductSKU.Trim().ToUpper();
                            var    check = StockManagerController.GetBySKU(AgentID, SKU);
                            if (check.Count > 0)
                            {
                                double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU);
                                if (total > 0)
                                {
                                    string variablename  = "";
                                    string variablevalue = "";
                                    string variable      = "";

                                    ProductGetOut p = new ProductGetOut();
                                    p.ID                   = products.ID;
                                    p.ProductName          = products.ProductTitle;
                                    p.ProductVariable      = variable;
                                    p.ProductVariableName  = variablename;
                                    p.ProductVariableValue = variablevalue;
                                    p.ProductType          = 1;
                                    var img = ProductImageController.GetFirstByProductID(products.ID);
                                    if (img != null)
                                    {
                                        p.ProductImage       = "<img src=\"" + img.ProductImage + "\" alt=\"\" style=\"width: 50px\"  />";
                                        p.ProductImageOrigin = img.ProductImage;
                                    }
                                    else
                                    {
                                        p.ProductImage       = "";
                                        p.ProductImageOrigin = "";
                                    }
                                    p.SKU                   = SKU;
                                    p.QuantityInstock       = total;
                                    p.QuantityInstockString = string.Format("{0:N0}", total);
                                    int supplierID = 0;
                                    if (products.SupplierID != null)
                                    {
                                        supplierID = products.SupplierID.ToString().ToInt(0);
                                    }
                                    p.SupplierID = supplierID;
                                    string supplierName = "";
                                    if (!string.IsNullOrEmpty(products.SupplierName))
                                    {
                                        supplierName = products.SupplierName;
                                    }
                                    p.SupplierName = supplierName;
                                    ps.Add(p);
                                }
                            }
                        }
                    }
                    else
                    {
                        var productvariable = ProductVariableController.GetAllBySKU(textsearch);
                        if (productvariable != null)
                        {
                            foreach (var value in productvariable)
                            {
                                string SKU   = value.SKU.Trim().ToUpper();
                                var    check = StockManagerController.GetBySKU(AgentID, SKU);
                                if (check.Count > 0)
                                {
                                    double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU);
                                    if (total > 0)
                                    {
                                        var variables = ProductVariableValueController.GetByProductVariableID(value.ID);

                                        if (variables.Count > 0)
                                        {
                                            string variablename  = "";
                                            string variablevalue = "";
                                            string variable      = "";

                                            foreach (var v in variables)
                                            {
                                                variable      += v.VariableName + ":" + v.VariableValue + "|";
                                                variablename  += v.VariableName + "|";
                                                variablevalue += v.VariableValue + "|";
                                            }

                                            ProductGetOut p = new ProductGetOut();
                                            p.ID = value.ID;
                                            var product = ProductController.GetByID(Convert.ToInt32(value.ProductID));
                                            if (product != null)
                                            {
                                                p.ProductName = product.ProductTitle;
                                            }
                                            p.ProductVariable      = variable;
                                            p.ProductVariableName  = variablename;
                                            p.ProductVariableValue = variablevalue;
                                            p.ProductType          = 2;
                                            p.ProductImage         = "<img src=\"" + value.Image + "\" alt=\"\" style=\"width:50px;\" />";
                                            p.ProductImageOrigin   = value.Image;
                                            p.SKU                   = value.SKU.Trim().ToUpper();
                                            p.QuantityInstock       = total;
                                            p.QuantityInstockString = string.Format("{0:N0}", total);
                                            int supplierID = 0;
                                            if (value.SupplierID != null)
                                            {
                                                supplierID = value.SupplierID.ToString().ToInt(0);
                                            }
                                            p.SupplierID = supplierID;
                                            string supplierName = "";
                                            if (!string.IsNullOrEmpty(value.SupplierName))
                                            {
                                                supplierName = value.SupplierName;
                                            }
                                            p.SupplierName = supplierName;
                                            ps.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(ps));
        }
Exemple #6
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();
            }
        }
        public void pagingall(List <tbl_ProductVariable> acs)
        {
            string        productname = ViewState["ProductName"].ToString();
            int           PageSize    = 15;
            StringBuilder html        = new StringBuilder();

            if (acs.Count > 0)
            {
                int TotalItems = acs.Count;
                if (TotalItems % PageSize == 0)
                {
                    PageCount = TotalItems / PageSize;
                }
                else
                {
                    PageCount = TotalItems / PageSize + 1;
                }

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }
                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item = acs[i];
                    html.Append("<tr>");
                    if (!string.IsNullOrEmpty(item.Image))
                    {
                        html.Append("   <td><img src=\"" + item.Image + "\"/></td>");
                    }
                    else
                    {
                        html.Append("   <td><img src=\"/App_Themes/Ann/image/placeholder.png\"/></td>");
                    }

                    string date     = string.Format("{0:dd/MM/yyyy}", item.CreatedDate);
                    string ishidden = "";
                    if (item.IsHidden != null)
                    {
                        bool IsHidden = Convert.ToBoolean(item.IsHidden);
                        ishidden = PJUtils.IsHiddenStatus(IsHidden);
                    }
                    else
                    {
                        ishidden = PJUtils.IsHiddenStatus(false);
                    }

                    var value = ProductVariableValueController.GetByProductVariableID(item.ID);
                    if (value != null)
                    {
                        html.Append("   <td>");
                        string list = "";
                        foreach (var temp in value)
                        {
                            html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + "");
                            list += temp.VariableName + "|";
                        }
                        html.Append("</td>");
                        hdfSearch.Value = list;
                    }

                    html.Append("   <td>" + item.SKU + "</td>");

                    html.Append("   <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>");

                    int k = Convert.ToInt32(ViewState["role"]);
                    if (k == 0)
                    {
                        html.Append("   <td>" + string.Format("{0:N0}", item.CostOfGood) + "</td>");
                    }

                    html.Append("   <td>" + string.Format("{0:N0}", item.RetailPrice) + "</td>");

                    html.Append("   <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>");
                    html.Append("   <td>" + PJUtils.StockStatusBySKU(1, item.SKU) + "</td>");

                    html.Append("   <td>" + date + "</td>");
                    html.Append("   <td>" + ishidden + "</td>");
                    html.Append("   <td>");
                    html.Append("       <a href=\"/thong-tin-thuoc-tinh-san-pham.aspx?id=" + item.ID + "\" title=\"Xem chi tiết\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>");
                    html.Append("       <a href=\"/gia-tri-thuoc-tinh-san-pham.aspx?productvariableid=" + item.ID + "\" title=\"Xem thuộc tính\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i></a>");
                    html.Append("   </td>");
                    html.Append("</tr>");
                }
            }
            ltrList.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, "/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 #9
0
        public void pagingall(List <tbl_ProductVariable> acs, int userRole)
        {
            int           PageSize = 40;
            StringBuilder html     = new StringBuilder();

            if (acs.Count > 0)
            {
                int TotalItems = acs.Count;
                if (TotalItems % PageSize == 0)
                {
                    PageCount = TotalItems / PageSize;
                }
                else
                {
                    PageCount = TotalItems / PageSize + 1;
                }

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }
                html.Append("<tr>");
                html.Append("    <th class='image-column'>Ảnh</th>");
                html.Append("    <th class='variable-column'>Thuộc tính</th>");
                html.Append("    <th class='sku-column'>Mã</th>");
                html.Append("    <th class='wholesale-price-column'>Giá sỉ</th>");
                if (userRole == 0)
                {
                    html.Append("    <th class='cost-price-column'>Giá vốn</th>");
                }
                html.Append("    <th class='retail-price-column'>Giá lẻ</th>");
                html.Append("    <th class='stock-column'>Kho</th>");
                html.Append("    <th class='stock-status-column'>Trạng thái</th>");
                html.Append("    <th class='date-column'>Ngày tạo</th>");
                html.Append("    <th class='hide-column'>Ẩn</th>");
                html.Append("    <th class='action-column'>Thao tác</th>");
                html.Append("</tr>");
                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item   = acs[i];
                    var stock2 = StockManagerController.getQuantityStock2BySKU(item.SKU);
                    html.Append("<tr>");
                    html.Append("   <td><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Small) + "'></td>");

                    string date     = string.Format("{0:dd/MM/yyyy}", item.CreatedDate);
                    string ishidden = "";
                    if (item.IsHidden != null)
                    {
                        bool IsHidden = Convert.ToBoolean(item.IsHidden);
                        ishidden = PJUtils.IsHiddenStatus(IsHidden);
                    }
                    else
                    {
                        ishidden = PJUtils.IsHiddenStatus(false);
                    }

                    var value = ProductVariableValueController.GetByProductVariableID(item.ID);
                    if (value != null)
                    {
                        html.Append("   <td>");
                        string list = "";
                        foreach (var temp in value)
                        {
                            html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + "");
                            list += temp.VariableName + "|";
                        }
                        html.Append("</td>");
                    }

                    html.Append("   <td>" + item.SKU + "</td>");

                    html.Append("   <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>");

                    if (userRole == 0)
                    {
                        html.Append("   <td>" + string.Format("{0:N0}", item.CostOfGood) + "</td>");
                    }

                    html.Append("   <td>" + string.Format("{0:N0}", item.RetailPrice) + "</td>");

                    if (stock2.HasValue)
                    {
                        html.Append(String.Format("   <td>{0:N0}<br>(Kho 2: {1:N0})</td>", PJUtils.TotalProductQuantityInstock(1, item.SKU), stock2.Value));
                    }
                    else
                    {
                        html.Append("   <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>");
                    }
                    html.Append("   <td>" + PJUtils.StockStatusBySKU(1, item.SKU) + "</td>");

                    html.Append("   <td>" + date + "</td>");
                    html.Append("   <td>" + ishidden + "</td>");
                    html.Append("   <td>");
                    html.Append("       <a href=\"/thong-tin-thuoc-tinh-san-pham?id=" + item.ID + "\" title=\"Xem chi tiết\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>");
                    html.Append("       <a href=\"/gia-tri-thuoc-tinh-san-pham?productvariableid=" + item.ID + "\" title=\"Xem thuộc tính\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i></a>");
                    html.Append("   </td>");
                    html.Append("</tr>");
                }
            }
            ltrList.Text = html.ToString();
        }
        public void pagingall(List <tbl_ProductVariable> acs)
        {
            int           PageSize = 40;
            StringBuilder html     = new StringBuilder();

            if (acs.Count > 0)
            {
                int TotalItems = acs.Count;
                if (TotalItems % PageSize == 0)
                {
                    PageCount = TotalItems / PageSize;
                }
                else
                {
                    PageCount = TotalItems / PageSize + 1;
                }

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }
                html.Append("<tr>");
                html.Append("    <th class='image-column'>Ảnh</th>");
                html.Append("    <th class='variable-column'>Thuộc tính</th>");
                html.Append("    <th class='wholesale-price-column'>Giá sỉ</th>");
                html.Append("    <th class='stock-column'>Kho</th>");
                html.Append("</tr>");
                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item = acs[i];
                    html.Append("<tr>");
                    html.Append("   <td><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Small) + "'></td>");
                    html.Append("<td>");
                    html.Append("<strong>" + item.SKU + "</strong><br><br>");
                    var value = ProductVariableValueController.GetByProductVariableID(item.ID);
                    if (value != null)
                    {
                        string list = "";
                        foreach (var temp in value)
                        {
                            html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + "");
                            list += temp.VariableName + "|";
                        }
                        html.Append("<br>" + PJUtils.StockStatusBySKU(1, item.SKU));
                    }
                    html.Append("</td>");
                    html.Append("   <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>");
                    html.Append("   <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>");
                    html.Append("</tr>");
                }
            }
            ltrList.Text = html.ToString();
        }