Exemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                RefundGoodDetailController.DeleteByRefundGoodsID(_refundGood.RefundGoodsID);
                RefundGoodController.DeleteByID(_refundGood.RefundGoodsID);
                int OrderSaleID = OrderController.DeleteOrderRefund(_refundGood.RefundGoodsID);
                if (OrderSaleID > 0)
                {
                    _refundGood.OrderSaleID = OrderSaleID;
                }

                foreach (var product in _refundGood.RefundDetails)
                {
                    if (!string.IsNullOrEmpty(product.ChildSKU))
                    {
                        var    ProductVariable = ProductVariableValueController.GetByProductVariableSKU(product.ChildSKU);
                        string VariableValue   = "";
                        if (ProductVariable.Count > 0)
                        {
                            foreach (var v in ProductVariable)
                            {
                                VariableValue += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "|";
                            }
                        }
                        product.VariableValue = VariableValue;
                    }

                    if (product.ChangeType != 3) // Change product error
                    {
                        StockManagerController.Insert(new tbl_StockManager()
                        {
                            AgentID           = 1,
                            ProductID         = product.ProductStyle == 1 ? product.ProductID : 0,
                            ProductVariableID = product.ProductVariableID,
                            Quantity          = product.QuantityRefund,
                            QuantityCurrent   = 0,
                            Type        = 1,
                            NoteID      = "Xuất kho do làm lại đơn hàng đổi trả",
                            OrderID     = product.OrderID,
                            Status      = 11,
                            SKU         = product.ProductStyle == 1 ? product.ParentSKU : product.ChildSKU,
                            CreatedDate = DateTime.Now,
                            CreatedBy   = _refundGood.CreateBy,
                            MoveProID   = 0,
                            ParentID    = product.ProductID,
                        });
                    }
                }

                HttpContext.Current.Items.Add("xem-don-hang-doi-tra", JsonConvert.SerializeObject(_refundGood));
                Server.Transfer("tao-don-hang-doi-tra.aspx");
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        private static List <ProductGetOut> _getProductVariation(List <tbl_ProductVariable> variations, tbl_Product product = null)
        {
            var result = new List <ProductGetOut>();

            if (variations == null || variations.Count() == 0)
            {
                return(result);
            }

            if (product == null)
            {
                product = ProductController.GetBySKU(variations.FirstOrDefault().ParentSKU);
            }

            foreach (var variation in variations)
            {
                var attributes = ProductVariableValueController.GetByProductVariableSKU(variation.SKU);

                if (attributes.Count == 0)
                {
                    continue;
                }

                var variable      = String.Empty;
                var variablename  = String.Empty;
                var variablevalue = String.Empty;

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

                var quantity = StockManagerController.getQuantityStock2BySKU(variation.SKU);
                var item     = new ProductGetOut()
                {
                    ID                   = variation.ID,
                    ProductName          = product.ProductTitle,
                    ProductVariable      = variable,
                    ProductVariableName  = variablename,
                    ProductVariableValue = variablevalue,
                    ProductStyle         = 2,
                    ProductImage         = Thumbnail.getURL(variation.Image, Thumbnail.Size.Normal),
                    ProductImageOrigin   = Thumbnail.getURL(variation.Image, Thumbnail.Size.Source),
                    SKU                  = variation.SKU.Trim().ToUpper(),
                    SupplierID           = product.SupplierID.HasValue ? product.SupplierID.Value : 0,
                    SupplierName         = String.IsNullOrEmpty(product.SupplierName) ? String.Empty : product.SupplierName,
                    WarehouseQuantity    = string.Format("{0:N0}", quantity),
                    ParentID             = product.ID,
                    ParentSKU            = product.ProductSKU
                };
                result.Add(item);
            }

            return(result);
        }
Exemplo n.º 3
0
        public static string getProduct(string textsearch)
        {
            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);
                var products = ProductController.GetBySKU(textsearch.Trim().ToUpper());

                if (products != null)
                {
                    var productvariable = ProductVariableController.GetByParentSKU(products.ProductSKU);

                    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.GetByProductVariableSKU(pv.SKU);

                                    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;

                                        var product = ProductController.GetBySKU(pv.ParentSKU);

                                        if (!string.IsNullOrEmpty(pv.Image))
                                        {
                                            p.ProductImage       = "<img src=\"" + pv.Image + "\" />";
                                            p.ProductImageOrigin = pv.Image;
                                        }
                                        else if (!string.IsNullOrEmpty(product.ProductImage))
                                        {
                                            p.ProductImage       = "<img src=\"" + product.ProductImage + "\" />";
                                            p.ProductImageOrigin = product.ProductImage;
                                        }
                                        else
                                        {
                                            p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                            p.ProductImageOrigin = "";
                                        }

                                        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 (!string.IsNullOrEmpty(products.ProductImage))
                                {
                                    p.ProductImage       = "<img src=\"" + products.ProductImage + "\" />";
                                    p.ProductImageOrigin = products.ProductImage;
                                }
                                else if (img != null)
                                {
                                    p.ProductImage       = "<img src=\"" + img.ProductImage + "\" />";
                                    p.ProductImageOrigin = img.ProductImage;
                                }
                                else
                                {
                                    p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                    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.Trim().ToUpper());

                    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.GetByProductVariableSKU(value.SKU);

                                    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.GetBySKU(value.ParentSKU);

                                        if (product != null)
                                        {
                                            p.ProductName = product.ProductTitle;
                                        }
                                        p.ProductVariable      = variable;
                                        p.ProductVariableName  = variablename;
                                        p.ProductVariableValue = variablevalue;
                                        p.ProductType          = 2;

                                        if (!string.IsNullOrEmpty(value.Image))
                                        {
                                            p.ProductImage       = "<img src=\"" + value.Image + "\" />";
                                            p.ProductImageOrigin = value.Image;
                                        }
                                        else if (!string.IsNullOrEmpty(product.ProductImage))
                                        {
                                            p.ProductImage       = "<img src=\"" + product.ProductImage + "\" />";
                                            p.ProductImageOrigin = product.ProductImage;
                                        }
                                        else
                                        {
                                            p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                            p.ProductImageOrigin = "";
                                        }

                                        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));
        }
Exemplo n.º 4
0
        public void LoadData()
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int AgentID = Convert.ToInt32(acc.AgentID);
                int ID      = Request.QueryString["id"].ToInt(0);
                if (ID > 0)
                {
                    ViewState["ID"] = ID;
                    var r = RefundGoodController.GetByIDAndAgentID(ID, AgentID);
                    if (r == null)
                    {
                        PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-tra-hang", Page);
                    }
                    else
                    {
                        if (acc.RoleID != 0)
                        {
                            if (r.CreatedBy != acc.Username)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-tra-hang", Page);
                            }
                        }
                        ltrOrderID.Text     = ID.ToString();
                        ltrCreateBy.Text    = r.CreatedBy;
                        ltrCreateDate.Text  = r.CreatedDate.ToString();
                        ltrOrderStatus.Text = PJUtils.RefundStatus(Convert.ToInt32(r.Status));
                        if (r.OrderSaleID > 0)
                        {
                            ltrOrderSaleID.Text = "<td><a class=\"customer-name-link\" target=\"_blank\" title=\"Bấm vào xem đơn hàng trừ tiền\" href=\"/thong-tin-don-hang?id=" + r.OrderSaleID + "\">" + r.OrderSaleID + " (Xem đơn)</a>";
                        }
                        else
                        {
                            ltrOrderSaleID.Text = "";
                        }
                        ltrOrderQuantity.Text   = r.TotalQuantity.ToString();
                        ltrOrderTotalPrice.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalPrice)));
                        ltrTotalRefundFee.Text  = string.Format("{0:N0}", (Convert.ToDouble(r.TotalRefundFee)));
                        ltrRefundNote.Text      = r.RefundNote;

                        ltrInfo.Text += "<div class=\"row\">";
                        ltrInfo.Text += "<div class=\"col-md-6\">";
                        ltrInfo.Text += "<div class=\"form-group\">";
                        ltrInfo.Text += "<label>Họ tên</label>";
                        ltrInfo.Text += "<span class=\"form-control input-disabled\">" + r.CustomerName + "</span>";
                        ltrInfo.Text += "</div>";
                        ltrInfo.Text += "</div>";
                        ltrInfo.Text += "<div class=\"col-md-6\">";
                        ltrInfo.Text += "<div class=\"form-group\">";
                        ltrInfo.Text += "<label>Điện thoại</label>";
                        ltrInfo.Text += "<span class=\"form-control input-disabled\">" + r.CustomerPhone + "</span>";
                        ltrInfo.Text += "</div>";
                        ltrInfo.Text += "</div>";
                        ltrInfo.Text += "</div>";

                        var cus = CustomerController.GetByID(r.CustomerID.Value);
                        if (cus != null)
                        {
                            ltrInfo.Text += "<div class=\"row\">";
                            ltrInfo.Text += "<div class=\"col-md-6\">";
                            ltrInfo.Text += "<div class=\"form-group\">";
                            ltrInfo.Text += "<label>Nick đặt hàng</label>";
                            ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Nick + "</span>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "<div class=\"col-md-6\">";
                            ltrInfo.Text += "<div class=\"form-group\">";
                            ltrInfo.Text += "<label>Địa chỉ</label>";
                            ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.CustomerAddress + "</span>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";

                            ltrInfo.Text += "<div class=\"row\">";
                            ltrInfo.Text += "<div class=\"col-md-6\">";
                            ltrInfo.Text += "<div class=\"form-group\">";
                            ltrInfo.Text += "<label>Zalo</label>";
                            ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Zalo + "</span>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "<div class=\"col-md-6\">";
                            ltrInfo.Text += "<div class=\"form-group\">";
                            ltrInfo.Text += "<label>Facebook</label>";
                            ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Facebook + "</span>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "</div>";
                            ltrInfo.Text += "<div class=\"row\">";
                            ltrInfo.Text += "    <div class=\"col-md-12 view-detail\">";
                            ltrInfo.Text += "    	<a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"viewCustomerDetail('"+ cus.ID + "')\"><i class=\"fa fa-address-card-o\" aria-hidden=\"true\"></i> Xem chi tiết</a>";
                            ltrInfo.Text += "    </div>";
                            ltrInfo.Text += "</div>";
                        }

                        ltrTotal.Text    = string.Format("{0:N0}", Convert.ToDouble(r.TotalPrice));
                        ltrQuantity.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalQuantity));
                        ltrRefund.Text   = string.Format("{0:N0}", Convert.ToDouble(r.TotalRefundFee));

                        // get info tranfor page tao-don-hang-doi-tra.aspx
                        _refundGood.RefundGoodsID    = ID;
                        _refundGood.CustomerName     = r.CustomerName;
                        _refundGood.CustomerPhone    = r.CustomerPhone;
                        _refundGood.CustomerNick     = cus != null? cus.Nick : String.Empty;
                        _refundGood.CustomerAddress  = cus != null ? cus.CustomerAddress : String.Empty;
                        _refundGood.CustomerZalo     = cus != null ? cus.Zalo : String.Empty;
                        _refundGood.CustomerFacebook = cus != null ? cus.Facebook : String.Empty;
                        _refundGood.RefundDetails    = RefundGoodDetailController.GetInfoShowRefundDetail(ID);
                        _refundGood.TotalPrice       = Convert.ToDouble(r.TotalPrice);
                        _refundGood.TotalQuantity    = Convert.ToDouble(r.TotalQuantity);
                        _refundGood.TotalFreeRefund  = Convert.ToDouble(r.TotalRefundFee);
                        _refundGood.Status           = r.Status.Value;
                        _refundGood.Note             = txtRefundsNote.Text;
                        _refundGood.CreateBy         = r.CreatedBy;

                        var rds = RefundGoodDetailController.GetByRefundGoodsID(ID);

                        var product = _refundGood.RefundDetails
                                      .Join(
                            rds,
                            p1 => new {
                            RefundGoodsID  = p1.RefundGoodsID,
                            RefundDetailID = p1.RefundDetailID
                        },
                            p2 => new {
                            RefundGoodsID  = p2.RefundGoodsID.Value,
                            RefundDetailID = p2.ID
                        },
                            (p1, p2) => new { p1, p2 })
                                      .Select(x => new {
                            SKU                     = x.p2.SKU,
                            OrderID                 = x.p2.OrderID,
                            ProductName             = x.p2.ProductName,
                            ProductType             = x.p2.ProductType,
                            GiavonPerProduct        = x.p2.GiavonPerProduct,
                            SoldPricePerProduct     = x.p2.SoldPricePerProduct,
                            DiscountPricePerProduct = x.p2.DiscountPricePerProduct,
                            Quantity                = x.p2.Quantity,
                            QuantityMax             = x.p2.QuantityMax,
                            RefundType              = x.p2.RefundType,
                            RefundFeePerProduct     = x.p2.RefundFeePerProduct,
                            TotalPriceRow           = x.p2.TotalPriceRow,
                            ProductImage            = x.p1.ProductImage
                        })
                                      .ToList();

                        if (product.Count > 0)
                        {
                            string html = "";
                            int    t    = 0;
                            foreach (var item in product)
                            {
                                var    variables = ProductVariableValueController.GetByProductVariableSKU(item.SKU);
                                string variable  = "";
                                if (variables.Count > 0)
                                {
                                    variable += "<br><br>";
                                    foreach (var v in variables)
                                    {
                                        variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br>";
                                    }
                                }
                                t++;
                                html += "<tr ondblclick=\"clickrow($(this))\" class=\"product-result\" data-sku=\"" + item.SKU + "\" data-orderID=\"" + item.OrderID
                                        + "\" data-ProductName=\"" + item.ProductName
                                        + "\" data-ProductType=\"" + item.ProductType + "\" data-Giagoc=\"" + item.GiavonPerProduct
                                        + "\" data-Giadaban=\"" + item.SoldPricePerProduct
                                        + "\" data-TienGiam=\"" + item.DiscountPricePerProduct
                                        + "\" data-Soluongtoida=\"" + item.QuantityMax + "\" data-RefundFee=\"" + item.RefundFeePerProduct + "\"  >";
                                html += "   <td>" + t + "</td>";
                                html += "   <td><img src='" + item.ProductImage + "'></td>";
                                html += "   <td>" + item.ProductName + variable + "</td>";
                                html += "   <td>" + item.SKU + "</td>";
                                html += "   <td class=\"giagoc\" data-giagoc=\"" + item.GiavonPerProduct + "\">" + string.Format("{0:N0}", Convert.ToDouble(item.GiavonPerProduct)) + "</td>";
                                html += "   <td class=\"giadaban\" data-giadaban=\"" + item.SoldPricePerProduct + "\"><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.SoldPricePerProduct)) + "</strong><br>(CK: " + string.Format("{0:N0}", Convert.ToDouble(item.DiscountPricePerProduct)) + ")</td>";
                                html += "   <td class=\"slcandoi\">" + item.Quantity + "</td>";
                                html += "   <td>";
                                int    refundType     = Convert.ToInt32(item.RefundType);
                                string refuntTypeName = "";
                                if (item.RefundType == 1)
                                {
                                    refuntTypeName = "Đổi size";
                                }
                                else if (item.RefundType == 2)
                                {
                                    refuntTypeName = "Đổi sản phẩm khác";
                                }
                                else
                                {
                                    refuntTypeName = "Đổi hàng lỗi";
                                }
                                html += refuntTypeName;
                                html += "    </td>";
                                html += "   <td class=\"phidoihang\">" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>";
                                html += "   <td class=\"thanhtien\">" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPriceRow)) + "</td>";
                                html += "</tr>";
                            }

                            ddlRefundStatus.SelectedValue = r.Status.ToString();
                            txtRefundsNote.Text           = r.RefundNote;
                            ltrList.Text = html;
                        }
                        ltrPrint.Text  = "<a href=\"/print-invoice-return?id=" + ID + "\" target=\"_blank\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-print\" aria-hidden=\"true\"></i> In hóa đơn</a>";
                        ltrPrint.Text += "<a href=\"/print-return-order-image?id=" + ID + "\" target=\"_blank\" class=\"btn primary-btn fw-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-picture-o\" aria-hidden=\"true\"></i> Lấy ảnh đơn hàng</a>";
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static string getProduct(string textsearch, int gettotal)
        {
            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);
                var product = ProductController.GetBySKU(textsearch.Trim().ToUpper());

                // Kiểm tra sản phẩm có trong table Product không?
                if (product != null) // Nếu sản phẩm có trong table Product thì...
                {
                    var productvariable = ProductVariableController.GetByParentSKU(product.ProductSKU);

                    // Kiểm tra sản phẩm cha là variable hay simple?
                    if (productvariable.Count > 0) // Nếu sản phẩm cha là variable thì...
                    {
                        foreach (var pv in productvariable)
                        {
                            string SKU = pv.SKU.Trim().ToUpper();

                            var variables = ProductVariableValueController.GetByProductVariableSKU(pv.SKU);

                            if (variables.Count > 0)
                            {
                                string variablename  = "";
                                string variablevalue = "";
                                string variable      = "";
                                string variablesave  = "";
                                foreach (var v in variables)
                                {
                                    variable      += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br/>";
                                    variablesave  += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "|";
                                    variablename  += v.VariableName.Trim() + "|";
                                    variablevalue += v.VariableValue.Trim() + "|";
                                }

                                ProductGetOut p = new ProductGetOut();
                                p.ID                   = pv.ID;
                                p.ProductName          = product.ProductTitle;
                                p.ProductVariable      = variable;
                                p.ProductVariableSave  = variablesave;
                                p.ProductVariableName  = variablename;
                                p.ProductVariableValue = variablevalue;
                                p.ProductType          = 2;

                                if (!string.IsNullOrEmpty(pv.Image))
                                {
                                    p.ProductImage       = "<img src=\"" + pv.Image + "\" />";
                                    p.ProductImageOrigin = pv.Image;
                                }
                                else if (!string.IsNullOrEmpty(product.ProductImage))
                                {
                                    p.ProductImage       = "<img src=\"" + product.ProductImage + "\" />";
                                    p.ProductImageOrigin = product.ProductImage;
                                }
                                else
                                {
                                    p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                    p.ProductImageOrigin = "";
                                }

                                if (gettotal == 1)
                                {
                                    double total     = PJUtils.TotalProductQuantityInstock(AgentID, SKU);
                                    var    mainstock = PJUtils.TotalProductQuantityInstock(1, SKU);
                                    p.QuantityMainInstock       = mainstock;
                                    p.QuantityMainInstockString = string.Format("{0:N0}", mainstock);
                                    p.QuantityInstock           = total;
                                    p.QuantityInstockString     = string.Format("{0:N0}", total);
                                }

                                p.SKU            = SKU;
                                p.Giabansi       = Convert.ToDouble(pv.Regular_Price);
                                p.stringGiabansi = string.Format("{0:N0}", pv.Regular_Price);
                                p.Giabanle       = Convert.ToDouble(pv.RetailPrice);
                                p.stringGiabanle = string.Format("{0:N0}", pv.RetailPrice);
                                ps.Add(p);
                            }
                        }
                    }
                    else // Nếu sản phẩm cha là simple thì...
                    {
                        string SKU       = product.ProductSKU.Trim().ToUpper();
                        double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU);

                        ProductGetOut p = new ProductGetOut();
                        p.ID                   = product.ID;
                        p.ProductName          = product.ProductTitle;
                        p.ProductVariable      = "";
                        p.ProductVariableSave  = "";
                        p.ProductVariableName  = "";
                        p.ProductVariableValue = "";
                        p.ProductType          = 1;

                        if (!string.IsNullOrEmpty(product.ProductImage))
                        {
                            p.ProductImage       = "<img src=\"" + product.ProductImage + "\" />";
                            p.ProductImageOrigin = product.ProductImage;
                        }
                        else
                        {
                            p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                            p.ProductImageOrigin = "";
                        }

                        p.SKU = SKU;
                        p.QuantityMainInstock       = mainstock;
                        p.QuantityMainInstockString = string.Format("{0:N0}", mainstock);
                        p.QuantityInstock           = mainstock;
                        p.QuantityInstockString     = string.Format("{0:N0}", mainstock);
                        p.Giabansi       = Convert.ToDouble(product.Regular_Price);
                        p.stringGiabansi = string.Format("{0:N0}", product.Regular_Price);
                        p.Giabanle       = Convert.ToDouble(product.Retail_Price);
                        p.stringGiabanle = string.Format("{0:N0}", product.Retail_Price);
                        ps.Add(p);
                    }
                }
                else // Nếu không nằm trong table Product thì...
                {
                    var productvariable = ProductVariableController.GetBySKU(textsearch.Trim().ToUpper());

                    // Nếu sản phẩm là con (nằm trong table ProductVariable) thì...
                    if (productvariable != null)
                    {
                        string SKU = productvariable.SKU.Trim().ToUpper();

                        var variables = ProductVariableValueController.GetByProductVariableSKU(SKU);

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

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

                            double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU);

                            ProductGetOut p = new ProductGetOut();
                            p.ID = productvariable.ID;

                            var _product = ProductController.GetBySKU(productvariable.ParentSKU);
                            if (_product != null)
                            {
                                p.ProductName = _product.ProductTitle;
                            }

                            p.ProductVariable      = variable;
                            p.ProductVariableSave  = variablesave;
                            p.ProductVariableName  = variablename;
                            p.ProductVariableValue = variablevalue;
                            p.ProductType          = 2;

                            if (!string.IsNullOrEmpty(productvariable.Image))
                            {
                                p.ProductImage       = "<img src=\"" + productvariable.Image + "\" />";
                                p.ProductImageOrigin = productvariable.Image;
                            }
                            else if (_product != null && !string.IsNullOrEmpty(_product.ProductImage))
                            {
                                p.ProductImage       = "<img src=\"" + _product.ProductImage + "\" />";
                                p.ProductImageOrigin = _product.ProductImage;
                            }
                            else
                            {
                                p.ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                p.ProductImageOrigin = "";
                            }

                            p.SKU = SKU;
                            p.QuantityMainInstock       = mainstock;
                            p.QuantityMainInstockString = string.Format("{0:N0}", mainstock);
                            p.QuantityInstock           = mainstock;
                            p.QuantityInstockString     = string.Format("{0:N0}", mainstock);
                            p.Giabansi       = Convert.ToDouble(productvariable.Regular_Price);
                            p.stringGiabansi = string.Format("{0:N0}", productvariable.Regular_Price);
                            p.Giabanle       = Convert.ToDouble(productvariable.Regular_Price);
                            p.stringGiabanle = string.Format("{0:N0}", productvariable.Regular_Price);
                            ps.Add(p);
                        }
                    }
                }
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(ps));
        }
Exemplo n.º 6
0
        public static string getOrder(int ID)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int AgentID = Convert.ToInt32(acc.AgentID);
                var agent   = AgentController.GetByID(AgentID);
                if (agent != null)
                {
                }
                //List<GetOutOrder> go = new List<GetOutOrder>();
                GetOutRefundOrder getOrder = new GetOutRefundOrder();
                var refund = RefundGoodController.GetByID(ID);
                if (refund != null)
                {
                    var refunddetail = RefundGoodDetailController.GetByRefundGoodsID(refund.ID);
                    if (refunddetail != null)
                    {
                        //table 1
                        getOrder.ID            = refund.ID;
                        getOrder.CustomerName  = refund.CustomerName;
                        getOrder.CustomerPhone = refund.CustomerPhone;
                        if (refund.Status == 1)
                        {
                            getOrder.Status = "Chưa trừ tiền";
                        }
                        if (refund.Status == 2)
                        {
                            getOrder.Status = "Đã trừ tiền";
                        }
                        getOrder.CreatedBy  = refund.CreatedBy;
                        getOrder.CreateDate = string.Format("{0:dd/MM/yyyy}", refund.CreatedDate);


                        getOrder.ListAgent += agent.AgentAddress + "|";
                        getOrder.ListAgent += agent.AgentPhone;


                        for (int j = 0; j < refunddetail.Count(); j++)
                        {
                            getOrder.ListProduct += refunddetail[j].SKU + ";" + refunddetail[j].ProductName + ";";
                            var    productvalue = ProductVariableValueController.GetByProductVariableSKU(refunddetail[j].SKU);
                            string value        = "";
                            if (productvalue != null)
                            {
                                foreach (var item in productvalue)
                                {
                                    value += item.VariableName + ":" + item.VariableValue + "|";
                                }
                            }
                            getOrder.ListProduct += value + ";" + refunddetail[j].Quantity + ";" + refunddetail[j].SoldPricePerProduct + ";" + refunddetail[j].RefundFeePerProduct + ";" + refunddetail[j].TotalPriceRow + "*";
                        }

                        getOrder.TotalQuantity    = Convert.ToInt32(refund.TotalQuantity);
                        getOrder.TotalPrice       = Convert.ToInt32(refund.TotalPrice);
                        getOrder.TotalRefundPrice = Convert.ToInt32(refund.TotalRefundFee);
                    }
                }

                return(serializer.Serialize(getOrder));
            }
            return(serializer.Serialize(null));
        }
Exemplo n.º 7
0
        public void LoadData()
        {
            int n;

            if (String.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out n))
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng", "e", true, "/danh-sach-don-tra-hang", Page);
            }

            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int AgentID = Convert.ToInt32(acc.AgentID);
                int ID      = Request.QueryString["id"].ToInt(0);
                if (ID > 0)
                {
                    ViewState["ID"] = ID;
                    var r = RefundGoodController.GetByIDAndAgentID(ID, AgentID);
                    if (r == null)
                    {
                        PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-tra-hang", Page);
                    }
                    else
                    {
                        if (acc.RoleID != 0)
                        {
                            // Kiểm tra nếu đơn hàng này không "chính chủ"
                            if (r.CreatedBy != acc.Username)
                            {
                                // Kiểm tra đơn hàng này có đang được tạo giúp bởi nhân viên khác không?
                                var usernameRequest = HttpContext.Current.Request["username"];
                                if (!String.IsNullOrEmpty(usernameRequest))
                                {
                                    var userRequest = AccountController.GetByUsername(usernameRequest);
                                    if (userRequest == null)
                                    {
                                        PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhân viên " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page);
                                    }
                                    else
                                    {
                                        if (usernameRequest != r.CreatedBy)
                                        {
                                            PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page);
                                        }
                                        else
                                        {
                                            if (r.UserHelp != acc.Username)
                                            {
                                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải do bạn tạo giúp", "e", true, "/danh-sach-don-tra-hang", Page);
                                            }
                                            else
                                            {
                                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này do bạn tạo giúp. Nhấn OK để tiếp tục xử lý!", "i", false, "", Page);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-tra-hang", Page);
                                }
                            }
                        }

                        ltrCreateBy.Text    = r.CreatedBy;
                        ltrCreateDate.Text  = r.CreatedDate.ToString();
                        ltrOrderStatus.Text = PJUtils.RefundStatus(Convert.ToInt32(r.Status));
                        if (r.OrderSaleID > 0)
                        {
                            ltrOrderSaleID.Text = "<td><a class='customer-name-link' target='_blank' title='Bấm vào xem đơn hàng trừ tiền' href='/thong-tin-don-hang?id=" + r.OrderSaleID + "'>" + r.OrderSaleID + " (Xem đơn)</a>";
                        }
                        else
                        {
                            ltrOrderSaleID.Text = "";
                        }
                        ltrOrderQuantity.Text   = r.TotalQuantity.ToString();
                        ltrOrderTotalPrice.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalPrice)));
                        ltrTotalRefundFee.Text  = string.Format("{0:N0}", (Convert.ToDouble(r.TotalRefundFee)));
                        ltrRefundNote.Text      = r.RefundNote;

                        int    cusID    = 0;
                        string zalo     = "";
                        string nick     = "";
                        string address  = "";
                        string facebook = "";
                        var    cus      = CustomerController.GetByID(r.CustomerID.Value);
                        if (cus != null)
                        {
                            cusID    = cus.ID;
                            zalo     = cus.Zalo;
                            nick     = cus.Nick;
                            address  = cus.CustomerAddress;
                            facebook = cus.Facebook;
                            hdfCustomerPhone.Value = cus.CustomerPhone;
                        }

                        // Title
                        this.Title      = String.Format("{0} - Đổi trả", string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase());
                        ltrHeading.Text = "Đơn đổi trả " + ID.ToString() + " - " + (string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase()) + (!string.IsNullOrEmpty(r.UserHelp) ? " (được tạo giúp bởi " + r.UserHelp + ")" : "");

                        ltrInfo.Text += "<div class='row'>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Họ tên</label>";
                        ltrInfo.Text += "            <span class='form-control input-disabled'>" + r.CustomerName + "</span>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Điện thoại</label>";
                        ltrInfo.Text += "            <span class='form-control input-disabled'>" + r.CustomerPhone + "</span>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Nick đặt hàng</label>";
                        ltrInfo.Text += "            <span class='form-control input-disabled'>" + nick + "</span>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Facebook</label>";
                        ltrInfo.Text += "            <span class='form-control input-disabled'>" + facebook + "</span>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "</div> ";
                        ltrInfo.Text += "<div class='row'>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Tỉnh thành</label>";
                        ltrInfo.Text += "            <select id='_ddlProvince' class='form-control' disable='true' readonly='readonly'></select>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Quận huyện</label>";
                        ltrInfo.Text += "            <select id='_ddlDistrict' class='form-control' disable='true' readonly='readonly'></select>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Phường xã</label>";
                        ltrInfo.Text += "            <select id='_ddlWard' class='form-control' disable='true' readonly='readonly'></select>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "    <div class='col-md-3'>";
                        ltrInfo.Text += "        <div class='form-group'>";
                        ltrInfo.Text += "            <label>Địa chỉ</label>";
                        ltrInfo.Text += "            <span class='form-control input-disabled'>" + address + "</span>";
                        ltrInfo.Text += "        </div>";
                        ltrInfo.Text += "    </div>";
                        ltrInfo.Text += "</div>";

                        ltrInfo.Text += "<div class='form-row view-detail'>";
                        ltrInfo.Text += "    <a href='javascript:;' class='btn primary-btn fw-btn not-fullwidth' onclick='viewCustomerDetail(`" + cusID + "`)'><i class='fa fa-address-card-o' aria-hidden='true'></i> Xem</a>";
                        ltrInfo.Text += "</div>";

                        #region Thông tin phí đổi tra
                        double feeRefundDefault = 0;

                        var discount = DiscountCustomerController.getbyCustID(cusID).FirstOrDefault();
                        if (discount != null)
                        {
                            feeRefundDefault = discount.FeeRefund;

                            ltrInfo.Text += "<div class='form-row discount-info'>";
                            ltrInfo.Text += String.Format("    <strong>* Chiết khấu của khách: {0:0,0}/cái. (đơn từ {1:N0} cái)</strong>", discount.DiscountAmount, discount.QuantityProduct);
                            ltrInfo.Text += "</div>";
                        }
                        else
                        {
                            var config = ConfigController.GetByTop1();
                            feeRefundDefault = config.FeeChangeProduct.Value;
                        }

                        var refundPromotion = RefundGoodController.getPromotion(cusID);
                        if (refundPromotion.IsPromotion)
                        {
                            feeRefundDefault = (feeRefundDefault - refundPromotion.DecreasePrice) < 0 ? 0 : feeRefundDefault - refundPromotion.DecreasePrice;
                        }

                        ltrInfo.Text += "<div class='form-row refund-info'>";
                        if (feeRefundDefault == 0)
                        {
                            ltrInfo.Text += "    <strong>* Miễn phí đổi hàng</strong>";
                        }
                        else
                        {
                            ltrInfo.Text += String.Format("    <strong>* Phí đổi trả hàng: {0:0,0}/cái.</strong>", feeRefundDefault);
                        }
                        ltrInfo.Text += "</div>";

                        if (UserController.checkExists(cusID))
                        {
                            ltrInfo.Text += "<div class='form-row refund-info'>";
                            ltrInfo.Text += "    <strong class='font-green'>Đã đăng ký App</strong>";
                            ltrInfo.Text += "</div>";
                        }
                        else
                        {
                            ltrInfo.Text += "<div class='form-row refund-info'>";
                            ltrInfo.Text += "    <strong class='font-red'>Chưa đăng ký App</strong>";
                            ltrInfo.Text += "</div>";
                        }
                        #endregion


                        ltrTotal.Text    = string.Format("{0:N0}", Convert.ToDouble(r.TotalPrice));
                        ltrQuantity.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalQuantity));
                        ltrRefund.Text   = string.Format("{0:N0}", Convert.ToDouble(r.TotalRefundFee));

                        // get info tranfor page tao-don-hang-doi-tra.aspx
                        _refundGood.RefundGoodsID    = ID;
                        _refundGood.CustomerID       = r.CustomerID.Value;
                        _refundGood.CustomerName     = r.CustomerName;
                        _refundGood.CustomerPhone    = r.CustomerPhone;
                        _refundGood.CustomerNick     = cus != null ? cus.Nick : String.Empty;
                        _refundGood.CustomerAddress  = cus != null ? cus.CustomerAddress : String.Empty;
                        _refundGood.CustomerZalo     = cus != null ? cus.Zalo : String.Empty;
                        _refundGood.CustomerFacebook = cus != null ? cus.Facebook : String.Empty;
                        _refundGood.RefundDetails    = RefundGoodDetailController.GetInfoShowRefundDetail(ID, feeRefundDefault);
                        _refundGood.TotalPrice       = Convert.ToDouble(r.TotalPrice);
                        _refundGood.TotalQuantity    = Convert.ToDouble(r.TotalQuantity);
                        _refundGood.TotalFreeRefund  = Convert.ToDouble(r.TotalRefundFee);
                        _refundGood.Status           = r.Status.Value;
                        _refundGood.Note             = txtRefundsNote.Text;
                        _refundGood.CreateBy         = r.CreatedBy;

                        var rds = RefundGoodDetailController.GetByRefundGoodsID(ID);

                        var product = _refundGood.RefundDetails
                                      .Join(
                            rds,
                            p1 => new {
                            RefundGoodsID  = p1.RefundGoodsID,
                            RefundDetailID = p1.RefundDetailID
                        },
                            p2 => new {
                            RefundGoodsID  = p2.RefundGoodsID.Value,
                            RefundDetailID = p2.ID
                        },
                            (p1, p2) => new { p1, p2 })
                                      .Select(x => new {
                            SKU                     = x.p2.SKU,
                            OrderID                 = x.p2.OrderID,
                            ProductName             = x.p2.ProductName,
                            ProductType             = x.p2.ProductType,
                            GiavonPerProduct        = x.p2.GiavonPerProduct,
                            SoldPricePerProduct     = x.p2.SoldPricePerProduct,
                            DiscountPricePerProduct = x.p2.DiscountPricePerProduct,
                            Quantity                = x.p2.Quantity,
                            QuantityMax             = x.p2.QuantityMax,
                            RefundType              = x.p2.RefundType,
                            RefundFeePerProduct     = x.p2.RefundFeePerProduct,
                            TotalPriceRow           = x.p2.TotalPriceRow,
                            ProductImage            = x.p1.ProductImage
                        })
                                      .ToList();

                        if (product.Count > 0)
                        {
                            string html = "";
                            int    t    = 0;
                            foreach (var item in product)
                            {
                                var    variables = ProductVariableValueController.GetByProductVariableSKU(item.SKU);
                                string variable  = "";
                                if (variables.Count > 0)
                                {
                                    variable += "<br><br>";
                                    foreach (var v in variables)
                                    {
                                        variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br>";
                                    }
                                }
                                t++;
                                html += "<tr ondblclick='clickrow($(this))' class='product-result' data-sku='" + item.SKU
                                        + "' data-orderID='" + item.OrderID
                                        + "' data-ProductName='" + item.ProductName
                                        + "' data-ProductType='" + item.ProductType
                                        + "' data-Giagoc='" + item.GiavonPerProduct
                                        + "' data-Giadaban='" + item.SoldPricePerProduct
                                        + "' data-TienGiam='" + item.DiscountPricePerProduct
                                        + "' data-Soluongtoida='" + item.QuantityMax
                                        + "' data-RefundFee='" + item.RefundFeePerProduct
                                        + "'>";
                                html += "   <td>" + t + "</td>";
                                html += "   <td class='image-item'><img src='" + Thumbnail.getURL(item.ProductImage, Thumbnail.Size.Small) + "'></td>";
                                html += "   <td class='name-item'><a href='/xem-san-pham?sku=" + item.SKU + "' target='_blank'>" + item.ProductName + "</a>" + variable + "</td>";
                                html += "   <td class='sku-item'>" + item.SKU + "</td>";
                                html += "   <td class='price-item giagoc' data-giagoc='" + item.GiavonPerProduct + "'>" + string.Format("{0:N0}", Convert.ToDouble(item.GiavonPerProduct)) + "</td>";
                                html += "   <td class='giadaban' data-giadaban='" + item.SoldPricePerProduct + "'><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.SoldPricePerProduct)) + "</strong><br>(CK: " + string.Format("{0:N0}", Convert.ToDouble(item.DiscountPricePerProduct)) + ")</td>";
                                html += "   <td class='slcandoi'>" + item.Quantity + "</td>";
                                html += "   <td>";
                                int    refundType     = Convert.ToInt32(item.RefundType);
                                string refuntTypeName = "";
                                if (item.RefundType == 1)
                                {
                                    refuntTypeName = "Đổi size";
                                }
                                else if (item.RefundType == 2)
                                {
                                    refuntTypeName = "Đổi sản phẩm khác";
                                }
                                else if (item.RefundType == 4)
                                {
                                    refuntTypeName = "Đổi sản phẩm khác (miễn phí)";
                                }
                                else
                                {
                                    refuntTypeName = "Đổi hàng lỗi";
                                }
                                html += refuntTypeName;
                                html += "    </td>";
                                html += "   <td class='phidoihang'>" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>";
                                html += "   <td class='thanhtien'>" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPriceRow)) + "</td>";
                                html += "</tr>";
                            }

                            ddlRefundStatus.SelectedValue = r.Status.ToString();
                            txtRefundsNote.Text           = r.RefundNote;
                            ltrList.Text = html;
                        }

                        ltrPrint.Text  = "<a href='/print-invoice-return?id=" + ID + "' target='_blank' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-print' aria-hidden='true'></i> In hóa đơn</a>";
                        ltrPrint.Text += "<a href='/print-return-order-image?id=" + ID + "' target='_blank' class='btn primary-btn btn-blue fw-btn not-fullwidth print-invoice-merged'><i class='fa fa-picture-o' aria-hidden='true'></i> Lấy ảnh đơn hàng</a>";
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static string getProduct(string textsearch)
        {
            List <ProductGetOut> ps = new List <ProductGetOut>();
            string username         = HttpContext.Current.Request.Cookies["usernameLoginSystem"].Value;
            var    acc = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int AgentID  = Convert.ToInt32(acc.AgentID);
                var products = ProductController.GetBySKU(textsearch.Trim().ToUpper());

                if (products != null)
                {
                    var productvariable = ProductVariableController.GetByParentSKU(products.ProductSKU);

                    if (productvariable.Count > 0)
                    {
                        foreach (var pv in productvariable)
                        {
                            var variables = ProductVariableValueController.GetByProductVariableSKU(pv.SKU);

                            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 onclick='openImage($(this))' src='" + Thumbnail.getURL(pv.Image, Thumbnail.Size.Normal) + "'>";
                                p.ProductImageOrigin = Thumbnail.getURL(pv.Image, Thumbnail.Size.Source);

                                p.SKU = pv.SKU.Trim().ToUpper();

                                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;

                                double total = PJUtils.TotalProductQuantityInstock(AgentID, pv.SKU);
                                p.WarehouseQuantity = string.Format("{0:N0}", total);
                                ps.Add(p);
                            }
                        }
                    }
                    else
                    {
                        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;

                        p.ProductImage       = "<img onclick='openImage($(this))' src='" + Thumbnail.getURL(products.ProductImage, Thumbnail.Size.Normal) + "'>";
                        p.ProductImageOrigin = Thumbnail.getURL(products.ProductImage, Thumbnail.Size.Source);

                        p.SKU = products.ProductSKU.Trim().ToUpper();
                        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;

                        double total = PJUtils.TotalProductQuantityInstock(AgentID, products.ProductSKU);

                        p.WarehouseQuantity = string.Format("{0:N0}", total);
                        ps.Add(p);
                    }
                }
                else
                {
                    var productvariable = ProductVariableController.GetAllBySKU(textsearch.Trim().ToUpper());

                    if (productvariable != null)
                    {
                        foreach (var value in productvariable)
                        {
                            var variables = ProductVariableValueController.GetByProductVariableSKU(value.SKU);

                            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.GetBySKU(value.ParentSKU);
                                if (product != null)
                                {
                                    p.ProductName = product.ProductTitle;
                                }

                                p.ProductVariable      = variable;
                                p.ProductVariableName  = variablename;
                                p.ProductVariableValue = variablevalue;
                                p.ProductType          = 2;

                                p.ProductImage       = "<img onclick='openImage($(this))' src='" + Thumbnail.getURL(value.Image, Thumbnail.Size.Normal) + "'>";
                                p.ProductImageOrigin = Thumbnail.getURL(value.Image, Thumbnail.Size.Source);

                                p.SKU = value.SKU.Trim().ToUpper();
                                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;

                                double total = PJUtils.TotalProductQuantityInstock(AgentID, value.SKU);

                                p.WarehouseQuantity = string.Format("{0:N0}", total);
                                ps.Add(p);
                            }
                        }
                    }
                }
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(ps));
        }