コード例 #1
0
 public void LoadImageVariabe()
 {
     using (WebClient client = new WebClient())
     {
         var link = ProductVariableController.GetAll("");
         if (link.Count > 0)
         {
             foreach (var l in link)
             {
                 if (!string.IsNullOrEmpty(l.Image))
                 {
                     string li    = l.Image;
                     string fname = li.Replace("https://ann.com.vn/wp-content/uploads/", "");
                     try
                     {
                         client.DownloadFile(new Uri(li), Server.MapPath("~/uploads/" + fname + ""));
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        public static string getProduct(string textsearch)
        {
            List <ProductGetOut> result = 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 product = ProductController.GetBySKU(textsearch.Trim().ToUpper());

                if (product != null)
                {
                    if (product.ProductStyle == 1)
                    {
                        result.Add(_getProduct(product));
                    }
                    else
                    {
                        var productvariable = ProductVariableController.GetByParentSKU(product.ProductSKU);
                        result.AddRange(_getProductVariation(productvariable, product));
                    }
                }
                else
                {
                    var productvariable = ProductVariableController.GetAllBySKU(textsearch.Trim().ToUpper());
                    result.AddRange(_getProductVariation(productvariable));
                }
            }

            return(JsonConvert.SerializeObject(result));
        }
コード例 #3
0
        public void LoadData()
        {
            string s = "";

            if (Request.QueryString["s"] != null)
            {
                s = Request.QueryString["s"];
            }

            List <tbl_ProductVariable> a = new List <tbl_ProductVariable>();
            int productID = Request.QueryString["id"].ToInt(0);

            if (productID > 0)
            {
                ViewState["ID"] = productID;
                var product = ProductController.GetByID(productID);
                if (product != null)
                {
                    ViewState["ProductName"] = product.ProductTitle;
                    var cate = CategoryController.GetByID(Convert.ToInt32(product.CategoryID));
                    lblCategoryName.Text = product.ProductTitle;
                    ltrAddnew.Text       = "<a href=\"/them-thuoc-tinh-san-pham?productid=" + productID + "\" class=\"h45-btn primary-btn btn\">Thêm mới</a>";
                }
                a = ProductVariableController.SearchProductID(productID, s);
                pagingall(a);
            }
        }
コード例 #4
0
        public static int getCategory(string SKU, int ProductType)
        {
            int categoryID = 0;

            if (ProductType == 1)
            {
                var product = ProductController.GetBySKU(SKU);
                if (product != null)
                {
                    categoryID = Convert.ToInt32(product.CategoryID);
                }
            }
            else
            {
                var productvariable = ProductVariableController.GetBySKU(SKU);
                if (productvariable != null)
                {
                    var product1 = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID));
                    if (product1 != null)
                    {
                        categoryID = Convert.ToInt32(product1.CategoryID);
                    }
                }
            }
            return(categoryID);
        }
コード例 #5
0
        public void GetStockVariable(string username, string password)
        {
            if (Login(username, password))
            {
                var StockManager = StockManagerController.GetStockAll();

                if (StockManager.Count > 0)
                {
                    var dataToExportToCSV = StockManager.Select(x =>
                    {
                        var quantityCurrent = 0D;

                        if (x.Type == 1)
                        {
                            quantityCurrent = x.QuantityCurrent.Value + x.Quantity.Value;
                        }
                        else
                        {
                            quantityCurrent = x.QuantityCurrent.Value - x.Quantity.Value;
                        }

                        return(new StockManager()
                        {
                            SKU = x.SKU,
                            Quantity = quantityCurrent,
                        });
                    }).ToList();

                    string attachment = String.Format("attachment; filename={0}_stock-variable.csv", DateTime.Now.ToString("yyyyMMddHHmmss"));
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.ClearHeaders();
                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.AddHeader("content-disposition", attachment);
                    HttpContext.Current.Response.ContentType = "text/csv";
                    HttpContext.Current.Response.AddHeader("Pragma", "public");
                    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

                    var sb = new StringBuilder();
                    sb.AppendLine("parent_sku, sku, stock, stock_status, manage_stock");
                    foreach (var line in dataToExportToCSV)
                    {
                        var    parentProduct = ProductVariableController.GetBySKU(line.SKU);
                        string parentSKU     = "";
                        if (parentProduct != null)
                        {
                            parentSKU = parentProduct.ParentSKU;
                            sb.AppendLine(String.Format("{0}, {1}, {2}, {3}, {4}", parentSKU, line.SKU, line.Quantity, line.Quantity > 0 ? "instock" : "outofstock", "yes"));
                        }
                    }

                    HttpContext.Current.Response.Write(sb.ToString());
                }
            }
        }
コード例 #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["usernameLoginSystem"].Value;
            int      id          = Convert.ToInt32(ViewState["ID"]);
            var      pv          = ProductVariableController.GetByID(id);

            if (pv != null)
            {
                string parentSKU = ViewState["productsku"].ToString();
                int    productID = ViewState["productid"].ToString().ToInt(0);

                bool   isHidden      = chkIsHidden.Checked;
                string SKU           = ViewState["SKU"].ToString();
                double Stock         = Convert.ToDouble(pv.Stock);
                double Regular_Price = Convert.ToDouble(pRegular_Price.Text);
                double CostOfGood    = Convert.ToDouble(pCostOfGood.Text);
                double RetailPrice   = Convert.ToDouble(pRetailPrice.Text);
                int    StockStatus   = Convert.ToInt32(pv.StockStatus);
                bool   ManageStock   = true;

                //Phần thêm ảnh đại diện sản phẩm
                string path         = "/uploads/images/";
                string ProductImage = ListProductThumbnail.Value;
                if (ProductThumbnailImage.UploadedFiles.Count > 0)
                {
                    foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles)
                    {
                        var o = path + productID + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true);
                        try
                        {
                            f.SaveAs(Server.MapPath(o));
                            ProductImage = o;
                        }
                        catch { }
                    }
                }

                if (ProductImage != ListProductThumbnail.Value)
                {
                    if (File.Exists(Server.MapPath(ListProductThumbnail.Value)))
                    {
                        File.Delete(Server.MapPath(ListProductThumbnail.Value));
                    }
                }

                ProductVariableController.Update(id, productID, parentSKU, SKU, Stock, StockStatus, Regular_Price,
                                                 CostOfGood, RetailPrice, ProductImage, ManageStock, isHidden, currentDate, username, Convert.ToInt32(pv.SupplierID),
                                                 pv.SupplierName, Convert.ToDouble(pMinimumInventoryLevel.Text),
                                                 Convert.ToDouble(pMaximumInventoryLevel.Text));
                PJUtils.ShowMessageBoxSwAlert("Cập nhật thuộc tính thành công", "s", true, Page);
            }
        }
コード例 #7
0
        public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print)
        {
            var orderdetails = RefundGoodDetailController.GetByRefundGoodsID(ID);

            if (orderdetails.Count > 0)
            {
                foreach (var item in orderdetails)
                {
                    TotalQuantity += Convert.ToDouble(item.Quantity);

                    int    ProductType = Convert.ToInt32(item.ProductType);
                    double ItemPrice   = Convert.ToDouble(item.SoldPricePerProduct);
                    string SKU         = item.SKU;
                    string ProductName = "";
                    int    SubTotal    = (Convert.ToInt32(ItemPrice) - Convert.ToInt32(item.RefundFeePerProduct)) * Convert.ToInt32(item.Quantity);

                    Print += "<tr>";
                    if (ProductType == 1)
                    {
                        var product = ProductController.GetBySKU(SKU);
                        if (product != null)
                        {
                            ProductName = product.ProductTitle;
                            Print      += "<td colspan='4'><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 27) + "</td>";
                        }
                    }
                    else
                    {
                        var productvariable = ProductVariableController.GetBySKU(SKU);
                        if (productvariable != null)
                        {
                            var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID));
                            if (parent_product != null)
                            {
                                ProductName = parent_product.ProductTitle;
                            }
                            Print += "<td colspan='4'><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 27) + "</td>";
                        }
                    }
                    Print += "</tr>";
                    Print += "<tr>";
                    Print += "<td>" + item.Quantity + "</td>";
                    Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>";
                    Print += "<td>" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>";
                    Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>";
                    Print += "</tr>";

                    TotalOrder += SubTotal;
                }
            }
        }
コード例 #8
0
        public void LoadData()
        {
            int productvariableid = Request.QueryString["productvariableid"].ToInt(0);

            if (productvariableid > 0)
            {
                var pv = ProductVariableController.GetByID(productvariableid);
                if (pv != null)
                {
                    ViewState["productvariableid"]  = productvariableid;
                    ViewState["ProductvariableSKU"] = pv.SKU;
                    ltrBack.Text = "<a href=\"/gia-tri-thuoc-tinh-san-pham.aspx?productvariableid=" + productvariableid + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>";
                }
            }
        }
コード例 #9
0
        public void GetProductVariableByProductID(int ProductID, string username, string password)
        {
            var rs = new ResponseClass();

            if (Login(username, password))
            {
                var ProductVariable = ProductVariableController.GetProductID(ProductID);
                if (ProductVariable.Count > 0)
                {
                    rs.Code   = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS);
                    rs.Status = APIUtils.ResponseMessage.Success.ToString();

                    foreach (var item in ProductVariable)
                    {
                        item.Stock = PJUtils.GetSotckProduct(1, item.SKU);

                        if (item.Stock > 0)
                        {
                            item.StockStatus = 1;
                        }
                        else if (item.Stock == 0)
                        {
                            item.StockStatus = 2;
                        }
                        else if (item.StockStatus < 0)
                        {
                            item.StockStatus = 3;
                        }
                    }
                    rs.ProductVariable = ProductVariable;
                }
                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();
        }
コード例 #10
0
        public void UpdateProductID()
        {
            DateTime currentDate = DateTime.Now;
            var      product     = ProductVariableController.GetAll("");

            foreach (var p in product)
            {
                var pr = ProductController.GetBySKU(p.ParentSKU);
                if (pr != null)
                {
                    ProductVariableController.UpdateProductID(p.ID, pr.ID);
                }
                string color = "";
                string size  = "";
                if (!string.IsNullOrEmpty(p.color))
                {
                    color = p.color;
                }
                if (!string.IsNullOrEmpty(p.size))
                {
                    size = p.size;
                }

                if (!string.IsNullOrEmpty(color))
                {
                    var vcolor = VariableValueController.GetByVariableID(1);
                    foreach (var c in vcolor)
                    {
                        if (color == c.VariableValueText)
                        {
                            ProductVariableValueController.Insert(p.ID, p.SKU, c.ID, c.VariableName, c.VariableValue, false, currentDate, "admin");
                        }
                    }
                }
                if (!string.IsNullOrEmpty(size))
                {
                    var vsize = VariableValueController.GetByVariableID(2);
                    foreach (var s in vsize)
                    {
                        if (size == s.VariableValueText)
                        {
                            ProductVariableValueController.Insert(p.ID, p.SKU, s.ID, s.VariableName, s.VariableValue, false, currentDate, "admin");
                        }
                    }
                }
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var pvv = ProductVariableValueController.GetByID(id);
                if (pvv != null)
                {
                    ViewState["ID"] = id;
                    int productvariableid = Convert.ToInt32(pvv.ProductVariableID);
                    if (productvariableid > 0)
                    {
                        int variableID    = 0;
                        var variablevalue = VariableValueController.GetByID(Convert.ToInt32(pvv.VariableValueID));
                        if (variablevalue != null)
                        {
                            variableID = Convert.ToInt32(variablevalue.VariableID);
                        }
                        ddlVariable.SelectedValue = variableID.ToString();

                        var vv = VariableValueController.GetByVariableIDIsHidden(Convert.ToInt32(variableID), false);
                        ddlVariableValue.Items.Clear();
                        ddlVariableValue.Items.Insert(0, new ListItem("-- Chọn --", "0"));
                        ddlVariableValue.DataSource = vv;
                        ddlVariableValue.DataBind();

                        ddlVariableValue.SelectedValue = pvv.VariableValueID.ToString();
                        chkIsHidden.Checked            = Convert.ToBoolean(pvv.IsHidden);

                        var pv = ProductVariableController.GetByID(productvariableid);
                        if (pv != null)
                        {
                            ViewState["productvariableid"]  = productvariableid;
                            ViewState["ProductvariableSKU"] = pv.SKU;
                            ltrBack.Text = "<a href=\"/gia-tri-thuoc-tinh-san-pham?productvariableid=" + productvariableid + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>";
                        }
                    }
                }
            }
        }
コード例 #13
0
        public static string getAllProductImage(string sku)
        {
            var product = ProductController.GetBySKU(sku);
            List<string> images = new List<string>();
            if (product != null)
            {
                images.Add(product.ProductImage);

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

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

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

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

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

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

            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(images.Distinct().ToList());
        }
コード例 #14
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var pv = ProductVariableController.GetByID(id);
                if (pv != null)
                {
                    ViewState["ID"]             = id;
                    ViewState["SKU"]            = pv.SKU;
                    chkIsHidden.Checked         = Convert.ToBoolean(pv.IsHidden);
                    lblSKU.Text                 = pv.SKU;
                    pRegular_Price.Text         = pv.Regular_Price.ToString();
                    pCostOfGood.Text            = pv.CostOfGood.ToString();
                    pRetailPrice.Text           = pv.RetailPrice.ToString();
                    pMinimumInventoryLevel.Text = pv.MinimumInventoryLevel.ToString();
                    pMaximumInventoryLevel.Text = pv.MaximumInventoryLevel.ToString();
                    if (pv.Image != null)
                    {
                        ListProductThumbnail.Value = pv.Image;
                        ProductThumbnail.ImageUrl  = pv.Image;
                    }
                    int productid = Convert.ToInt32(pv.ProductID);
                    if (productid > 0)
                    {
                        var product = ProductController.GetByID(productid);
                        if (product != null)
                        {
                            ViewState["productid"]  = productid;
                            ViewState["productsku"] = product.ProductSKU;
                            ltrBack.Text            = "<a href=\"/thuoc-tinh-san-pham?id=" + product.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>";
                        }
                    }
                }
            }
        }
コード例 #15
0
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["userLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0 || acc.RoleID == 2)
                {
                    // Change user
                    string OrderNote = "";
                    if (username != hdfUsernameCurrent.Value)
                    {
                        OrderNote = "Được tính tiền giúp bởi " + username;
                        username  = hdfUsernameCurrent.Value;
                    }

                    int    AgentID     = Convert.ToInt32(acc.AgentID);
                    int    OrderType   = hdfOrderType.Value.ToInt();
                    string AdditionFee = "0";
                    string DisCount    = "0";
                    int    CustomerID  = 0;

                    string CustomerPhone   = txtPhone.Text.Trim().Replace(" ", "");
                    string CustomerName    = txtFullname.Text.Trim();
                    string Nick            = txtNick.Text.Trim();
                    string CustomerEmail   = "";
                    string CustomerAddress = txtAddress.Text.Trim();

                    var checkCustomer = CustomerController.GetByPhone(CustomerPhone);

                    if (checkCustomer != null)
                    {
                        CustomerID = checkCustomer.ID;
                        string kq = CustomerController.Update(CustomerID, CustomerName, checkCustomer.CustomerPhone, CustomerAddress, "", Convert.ToInt32(checkCustomer.CustomerLevelID), Convert.ToInt32(checkCustomer.Status), checkCustomer.CreatedBy, currentDate, username, false, checkCustomer.Zalo, checkCustomer.Facebook, checkCustomer.Note, checkCustomer.ProvinceID.ToString(), Nick, checkCustomer.Avatar, Convert.ToInt32(checkCustomer.ShippingType), Convert.ToInt32(checkCustomer.PaymentType), Convert.ToInt32(checkCustomer.TransportCompanyID), Convert.ToInt32(checkCustomer.TransportCompanySubID), checkCustomer.CustomerPhone2);
                    }
                    else
                    {
                        string kq = CustomerController.Insert(CustomerName, CustomerPhone, CustomerAddress, CustomerEmail, 0, 0, currentDate, username, false, "", "", "", "", Nick);
                        if (kq.ToInt(0) > 0)
                        {
                            CustomerID = kq.ToInt(0);
                        }
                    }

                    string totalPrice            = hdfTotalPrice.Value.ToString();
                    string totalPriceNotDiscount = hdfTotalPriceNotDiscount.Value;
                    int    PaymentStatus         = 3;
                    int    ExcuteStatus          = 2;
                    int    PaymentType           = 1;
                    int    ShippingType          = 1;
                    bool   IsHidden = false;
                    int    WayIn    = 1;

                    double DiscountPerProduct = Convert.ToDouble(pDiscount.Value);

                    double TotalDiscount = Convert.ToDouble(pDiscount.Value) * Convert.ToDouble(hdfTotalQuantity.Value);
                    string FeeShipping   = pFeeShip.Value.ToString();
                    double GuestPaid     = Convert.ToDouble(pGuestPaid.Value);
                    double GuestChange   = Convert.ToDouble(totalPrice) - GuestPaid;
                    string OtherFeeName  = txtOtherFeeName.Text;
                    double OtherFeeValue = Convert.ToDouble(pOtherFee.Value);

                    var ret = OrderController.InsertOnSystem(AgentID, OrderType, AdditionFee, DisCount, CustomerID, CustomerName, CustomerPhone, CustomerAddress,
                                                             CustomerEmail, totalPrice, totalPriceNotDiscount, PaymentStatus, ExcuteStatus, IsHidden, WayIn, currentDate, username, DiscountPerProduct,
                                                             TotalDiscount, FeeShipping, GuestPaid, GuestChange, PaymentType, ShippingType, OrderNote, DateTime.Now, OtherFeeName, OtherFeeValue, 1);
                    int OrderID = ret.ID;

                    if (OrderID > 0)
                    {
                        ProductPOS              POS          = JsonConvert.DeserializeObject <ProductPOS>(hdfListProduct.Value);
                        List <tbl_OrderDetail>  orderDetails = new List <tbl_OrderDetail>();
                        List <tbl_StockManager> stockManager = new List <tbl_StockManager>();

                        foreach (ProductGetOut item in POS.productPOS)
                        {
                            orderDetails.Add(
                                new tbl_OrderDetail()
                            {
                                AgentID                   = AgentID,
                                OrderID                   = OrderID,
                                SKU                       = item.SKU,
                                ProductID                 = item.ProductType == 1 ? item.ProductID : 0,
                                ProductVariableID         = item.ProductType == 1 ? 0 : item.ProductVariableID,
                                ProductVariableDescrition = item.ProductVariableSave,
                                Quantity                  = item.QuantityInstock,
                                Price                     = item.Giabanle,
                                Status                    = 1,
                                DiscountPrice             = 0,
                                ProductType               = item.ProductType,
                                CreatedDate               = currentDate,
                                CreatedBy                 = username,
                                IsCount                   = true
                            }
                                );

                            int parentID = item.ProductID;
                            var variable = ProductVariableController.GetByID(item.ProductVariableID);
                            if (variable != null)
                            {
                                parentID = Convert.ToInt32(variable.ProductID);
                            }

                            stockManager.Add(
                                new tbl_StockManager()
                            {
                                AgentID           = AgentID,
                                ProductID         = item.ProductType == 1 ? item.ProductID : 0,
                                ProductVariableID = item.ProductType == 1 ? 0 : item.ProductVariableID,
                                Quantity          = item.QuantityInstock,
                                QuantityCurrent   = 0,
                                Type        = 2,
                                NoteID      = "Xuất kho bán POS",
                                OrderID     = OrderID,
                                Status      = 3,
                                SKU         = item.SKU,
                                CreatedDate = currentDate,
                                CreatedBy   = username,
                                MoveProID   = 0,
                                ParentID    = parentID
                            }
                                );
                        }

                        OrderDetailController.Insert(orderDetails);
                        StockManagerController.Insert(stockManager);

                        string refund = Request.Cookies["refund"].Value;
                        if (refund != "1")
                        {
                            string[] RefundID = refund.Split('|');
                            var      update   = RefundGoodController.UpdateStatus(RefundID[0].ToInt(), username, 2, OrderID);
                            var      updateor = OrderController.UpdateRefund(OrderID, RefundID[0].ToInt(), username);
                        }

                        Response.Cookies["refund"].Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(Response.Cookies["refund"]);

                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { printInvoice(" + OrderID + ") });", true);
                    }
                }
            }
        }
コード例 #16
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));
        }
コード例 #17
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();
            }
        }
コード例 #18
0
        public static string getAllCategoryImage(double productPrice = 0)
        {
            List <string> result = new List <string>();

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

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

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

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

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

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

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

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

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

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(result.ToList()));
        }
コード例 #19
0
        private void _updateProductVariation(tbl_Account acc)
        {
            if (String.IsNullOrEmpty(hdfVariableListInsert.Value))
            {
                var strFunction = "";
                strFunction = "HoldOn.close();";
                strFunction = "swal({title: 'Lỗi', text: 'Quá trình cập nhật biến thể đã xảy ra lỗi', type: 'error'});";

                JavaScript.BeforePageLoad(Page).ExecuteCustomScript(strFunction);
                return;
            }

            var productID    = ViewState["ID"].ToString().ToInt(0);
            var productSKU   = ViewState["SKU"].ToString();
            var uploadPath   = "/uploads/images/";
            var imageDefault = "/App_Themes/Ann/image/placeholder.png";

            #region Xóa biến thể
            var variationRemovalList = JsonConvert.DeserializeObject <List <string> >(hdfVariationRemovalList.Value);

            foreach (var sku in variationRemovalList)
            {
                ProductVariableController.removeByVariationSKU(sku);
            }
            #endregion

            #region Cập nhật biến thể
            var productVariationUpdateList = JsonConvert.DeserializeObject <List <ProductVariationUpdateModel> >(hdfVariableListInsert.Value);

            if (uploadVariationImage.HasFiles)
            {
                foreach (var file in uploadVariationImage.PostedFiles)
                {
                    var fileName  = file.FileName;
                    var imageName = _uploadImage(productID, file);

                    productVariationUpdateList
                    .Where(x => x.image == uploadPath + fileName)
                    .Select(x =>
                    {
                        x.image = uploadPath + imageName;

                        return(x);
                    });
                }
            }

            foreach (var item in productVariationUpdateList)
            {
                var now = DateTime.Now;
                // Kiểm tra sản phẩm biến thể có tồn tại hay không để thực hiện insert hoặc update
                var productVariation = ProductVariableController.GetByID(item.productVariationID);
                var image            = String.Empty;

                if (item.image != imageDefault)
                {
                    image = item.image.Replace(uploadPath, String.Empty);
                }

                if (productVariation != null)
                {
                    // Thực hiện update biến thể
                    var productVariationID = ProductVariableController.Update(
                        ID: productVariation.ID,
                        ProductID: productID,
                        ParentSKU: productSKU,
                        SKU: item.sku,
                        Stock: Convert.ToDouble(productVariation.Stock),
                        StockStatus: Convert.ToInt32(productVariation.StockStatus),
                        Regular_Price: item.regularPrice,
                        CostOfGood: item.costOfGood,
                        RetailPrice: item.retailPrice,
                        Image: image,
                        ManageStock: true,
                        IsHidden: false,
                        ModifiedDate: now,
                        ModifiedBy: acc.Username,
                        SupplierID: Convert.ToInt32(productVariation.SupplierID),
                        SupplierName: productVariation.SupplierName,
                        MinimumInventoryLevel: item.minimumInventoryLevel,
                        MaximumInventoryLevel: item.maximumInventoryLevel
                        );

                    // Xóa tất cả giá trị của biến thể để cập nhật lại
                    ProductVariableValueController.DeleteByProductVariableID(productVariation.ID);

                    // Khởi tạo biến thể cho sản phẩm con
                    _createVariationValue(new VariationValueUpdateModel()
                    {
                        productVariationID  = Convert.ToInt32(productVariationID),
                        productVariationSKU = item.sku,
                        variationValueID    = item.variationValueID,
                        variationName       = item.variationName,
                        variationValueName  = item.variationValueName,
                        isHidden            = false,
                        createdDate         = now,
                        createdBy           = acc.Username
                    });
                }
                else
                {
                    // Tạo sản phẩm biến thể mới
                    var productVariationID = ProductVariableController.Insert(
                        ProductID: productID,
                        ParentSKU: productSKU,
                        SKU: item.sku,
                        Stock: 0,
                        StockStatus: item.stockStatus,
                        Regular_Price: item.regularPrice,
                        CostOfGood: item.costOfGood,
                        RetailPrice: item.retailPrice,
                        Image: image,
                        ManageStock: true,
                        IsHidden: false,
                        CreatedDate: now,
                        CreatedBy: acc.Username,
                        SupplierID: ddlSupplier.SelectedValue.ToInt(0),
                        SupplierName: ddlSupplier.SelectedItem.ToString(),
                        MinimumInventoryLevel: item.minimumInventoryLevel,
                        MaximumInventoryLevel: item.maximumInventoryLevel);

                    // Khởi tạo biến thể cho sản phẩm con
                    _createVariationValue(new VariationValueUpdateModel()
                    {
                        productVariationID  = Convert.ToInt32(productVariationID),
                        productVariationSKU = item.sku,
                        variationValueID    = item.variationValueID,
                        variationName       = item.variationName,
                        variationValueName  = item.variationValueName,
                        isHidden            = false,
                        createdDate         = now,
                        createdBy           = acc.Username
                    });
                }
            }
            #endregion
        }
コード例 #20
0
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["userLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0 || acc.RoleID == 2)
                {
                    int OrderID = ViewState["ID"].ToString().ToInt(0);
                    if (OrderID > 0)
                    {
                        var order = OrderController.GetByID(OrderID);

                        if (order != null)
                        {
                            int ExcuteStatusOld = Convert.ToInt32(order.ExcuteStatus);

                            string OrderNote = txtOrderNote.Text;

                            // Xử lý nhập kho khi chuyển hoàn
                            if (ExcuteStatusOld != 4)
                            {
                                var orderDetails = OrderDetailController.GetByOrderID(order.ID);

                                foreach (tbl_OrderDetail product in orderDetails)
                                {
                                    int parentID = 0;

                                    if (product.ProductID != 0)
                                    {
                                        parentID = product.ProductID.Value;
                                    }
                                    else
                                    {
                                        parentID = ProductVariableController.GetByID(product.ProductVariableID.Value).ProductID.Value;
                                    }

                                    StockManagerController.Insert(
                                        new tbl_StockManager
                                    {
                                        AgentID           = product.AgentID,
                                        ProductID         = product.ProductID,
                                        ProductVariableID = product.ProductVariableID,
                                        Quantity          = product.Quantity,
                                        QuantityCurrent   = 0,
                                        Type        = 1,
                                        NoteID      = "Nhập kho do chuyển hoàn đơn " + product.OrderID,
                                        OrderID     = product.OrderID,
                                        Status      = 13,
                                        SKU         = product.SKU,
                                        CreatedDate = currentDate,
                                        CreatedBy   = product.CreatedBy,
                                        MoveProID   = 0,
                                        ParentID    = parentID
                                    });
                                }
                            }

                            bool updateOrder = OrderController.UpdateExcuteStatus4(order.ID, username, OrderNote);

                            if (updateOrder == true)
                            {
                                Response.Redirect("/thong-tin-don-hang-chuyen-hoan?id=" + order.ID);
                            }
                            else
                            {
                                PJUtils.ShowMessageBoxSwAlertCallFunction("Đã xảy ra lỗi", "s", true, "payAllClicked()", Page);
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
        public void LoadData()
        {
            int ID = Request.QueryString["id"].ToInt(0);

            if (ID > 0)
            {
                var order = OrderController.GetByID(ID);
                if (order == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                }
                else
                {
                    hdfOrderID.Value = order.ID.ToString();
                    string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value;
                    var    acc      = AccountController.GetByUsername(username);

                    // check order condition
                    if (acc.RoleID != 0)
                    {
                        if (order.ExcuteStatus == 4)
                        {
                            PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page);
                        }
                        else
                        {
                            if (order.CreatedBy != acc.Username)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }

                            if (order.ExcuteStatus == 1)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }

                            if (order.ExcuteStatus == 3)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }

                            if (order.ShippingType == 1)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }
                        }
                    }
                    else
                    {
                        if (order.ExcuteStatus == 4)
                        {
                            PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page);
                        }
                        else
                        {
                            if (order.ExcuteStatus == 1)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }

                            if (order.ExcuteStatus == 3)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }

                            if (order.ShippingType == 1)
                            {
                                PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page);
                            }
                        }
                    }

                    ViewState["ID"] = ID;

                    Response.Cookies["odid"].Value = ID.ToString();

                    int AgentID = Convert.ToInt32(order.AgentID);
                    txtPhone.Text    = order.CustomerPhone;
                    txtFullname.Text = order.CustomerName;
                    txtAddress.Text  = order.CustomerAddress;
                    var cus = CustomerController.GetByID(order.CustomerID.Value);
                    if (cus != null)
                    {
                        txtNick.Text = cus.Nick;

                        txtZalo.Text = cus.Zalo;

                        txtFacebook.Text = cus.Facebook;
                        if (!string.IsNullOrEmpty(cus.Facebook))
                        {
                            ltrFb.Text += "<a href =\"" + cus.Facebook + "\" class=\"btn primary-btn fw-btn not-fullwidth\" target=\"_blank\">Xem</a>";
                        }
                    }
                    int customerID = Convert.ToInt32(order.CustomerID);
                    ltrViewDetail.Text  = "<a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"viewCustomerDetail('" + customerID + "')\"><i class=\"fa fa-address-card-o\" aria-hidden=\"true\"></i> Xem chi tiết</a>";
                    ltrViewDetail.Text += "<a href=\"chi-tiet-khach-hang?id=" + customerID + "\" class=\"btn primary-btn fw-btn not-fullwidth edit-customer-btn\" target=\"_blank\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>";

                    var d = DiscountCustomerController.getbyCustID(customerID);
                    if (d.Count > 0)
                    {
                        var da = d[0].DiscountAmount;
                        hdfIsDiscount.Value     = "1";
                        hdfDiscountAmount.Value = da.ToString();
                        ltrDiscountInfo.Text    = "<strong>Khách hàng được chiết khấu: " + string.Format("{0:N0}", Convert.ToDouble(da)) + " vnđ/sản phẩm.</strong>";
                    }
                    else
                    {
                        hdfIsDiscount.Value     = "0";
                        hdfDiscountAmount.Value = "0";
                    }

                    int customerType = Convert.ToInt32(order.OrderType);
                    ltrCustomerType.Text  = "";
                    ltrCustomerType.Text += "<select disabled class=\"form-control customer-type\" onchange=\"getProductPrice($(this))\">";
                    if (customerType == 1)
                    {
                        ltrCustomerType.Text += "<option value=\"2\">Khách mua sỉ</option>";
                        ltrCustomerType.Text += "<option value=\"1\" selected>Khách mua lẻ</option>";
                    }
                    else
                    {
                        ltrCustomerType.Text += "<option value=\"2\" selected>Khách mua sỉ</option>";
                        ltrCustomerType.Text += "<option value=\"1\">Khách mua lẻ</option>";
                    }
                    ltrCustomerType.Text += "</select>";


                    double ProductQuantity       = 0;
                    double totalPrice            = Convert.ToDouble(order.TotalPrice);
                    double totalPriceNotDiscount = Convert.ToDouble(order.TotalPriceNotDiscount);

                    hdfcheckR.Value = "";

                    int totalrefund = 0;
                    if (order.RefundsGoodsID > 0)
                    {
                        var re = RefundGoodController.GetByID(order.RefundsGoodsID.Value);
                        if (re != null)
                        {
                            totalrefund     = Convert.ToInt32(re.TotalPrice);
                            hdfcheckR.Value = order.RefundsGoodsID.ToString() + "," + re.TotalPrice;
                        }

                        ltrtotalpricedetail.Text = string.Format("{0:N0}", totalPrice - totalrefund);

                        ltrTotalPriceRefund.Text = string.Format("{0:N0}", totalrefund);
                    }

                    hdfDiscountInOrder.Value = "";

                    if (order.DiscountPerProduct > 0)
                    {
                        hdfDiscountInOrder.Value = order.DiscountPerProduct.ToString();
                    }

                    int paymentStatus         = Convert.ToInt32(order.PaymentStatus);
                    int excuteStatus          = Convert.ToInt32(order.ExcuteStatus);
                    int shipping              = Convert.ToInt32(order.ShippingType);
                    int TransportCompanyID    = Convert.ToInt32(order.TransportCompanyID);
                    int TransportCompanySubID = Convert.ToInt32(order.TransportCompanySubID);
                    int PostalDeliveryType    = Convert.ToInt32(order.PostalDeliveryType);
                    int paymenttype           = Convert.ToInt32(order.PaymentType);
                    #region Lấy danh sách sản phẩm
                    var    orderdetails = OrderDetailController.GetByOrderID(ID);
                    string html         = "";
                    string Print        = "";
                    if (orderdetails.Count > 0)
                    {
                        int t         = 0;
                        int orderitem = 0;
                        foreach (var item in orderdetails)
                        {
                            ProductQuantity += Convert.ToDouble(item.Quantity);

                            int    ProductType       = Convert.ToInt32(item.ProductType);
                            int    ProductID         = Convert.ToInt32(item.ProductID);
                            int    ProductVariableID = Convert.ToInt32(item.ProductVariableID);
                            double ItemPrice         = Convert.ToDouble(item.Price);
                            string SKU                        = item.SKU;
                            double Giabansi                   = 0;
                            double Giabanle                   = 0;
                            string stringGiabansi             = "";
                            string stringGiabanle             = "";
                            double QuantityInstock            = 0;
                            string ProductImageOrigin         = "";
                            string ProductVariable            = "";
                            string ProductName                = "";
                            int    PID                        = 0;
                            string ProductVariableName        = "";
                            string ProductVariableValue       = "";
                            string ProductVariableSave        = "";
                            double QuantityMainInstock        = 0;
                            string ProductImage               = "";
                            string QuantityMainInstockString  = "";
                            string QuantityInstockString      = "";
                            string productVariableDescription = item.ProductVariableDescrition;

                            if (ProductType == 1)
                            {
                                PID = ProductID;
                                var product = ProductController.GetBySKU(SKU);
                                if (product != null)
                                {
                                    double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU);

                                    if (customerType == 1)
                                    {
                                        Giabansi = Convert.ToDouble(product.Regular_Price);
                                        Giabanle = ItemPrice;
                                    }
                                    else
                                    {
                                        Giabansi = ItemPrice;
                                        Giabanle = Convert.ToDouble(product.Retail_Price);
                                    }
                                    stringGiabansi = string.Format("{0:N0}", Giabansi);
                                    stringGiabanle = string.Format("{0:N0}", Giabanle);
                                    string variablename  = "";
                                    string variablevalue = "";
                                    string variable      = "";



                                    QuantityInstock       = mainstock;
                                    QuantityInstockString = string.Format("{0:N0}", mainstock);

                                    var img = ProductImageController.GetFirstByProductID(product.ID);
                                    if (!string.IsNullOrEmpty(product.ProductImage))
                                    {
                                        ProductImage       = "<img src=\"" + product.ProductImage + "\" />";
                                        ProductImageOrigin = product.ProductImage;
                                    }
                                    else if (img != null)
                                    {
                                        ProductImage       = "<img src=\"" + img.ProductImage + "\" />";
                                        ProductImageOrigin = img.ProductImage;
                                    }
                                    else
                                    {
                                        ProductImage       = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />";
                                        ProductImageOrigin = "";
                                    }
                                    ProductVariable = variable;
                                    ProductName     = product.ProductTitle;

                                    QuantityMainInstock       = mainstock;
                                    QuantityMainInstockString = string.Format("{0:N0}", mainstock);
                                    ProductVariableSave       = item.ProductVariableDescrition;

                                    ProductVariableName  = variablename;
                                    ProductVariableValue = variablevalue;
                                }
                            }
                            else
                            {
                                PID = ProductVariableID;
                                var productvariable = ProductVariableController.GetBySKU(SKU);
                                if (productvariable != null)
                                {
                                    SKU = productvariable.SKU.Trim().ToUpper();

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

                                    if (customerType == 1)
                                    {
                                        Giabansi = Convert.ToDouble(productvariable.Regular_Price);
                                        Giabanle = ItemPrice;
                                    }
                                    else
                                    {
                                        Giabansi = ItemPrice;
                                        Giabanle = Convert.ToDouble(productvariable.RetailPrice);
                                    }
                                    stringGiabansi = string.Format("{0:N0}", Giabansi);
                                    stringGiabanle = string.Format("{0:N0}", Giabanle);


                                    string variablename  = "";
                                    string variablevalue = "";
                                    string variable      = "";

                                    string[] vs = productVariableDescription.Split('|');
                                    if (vs.Length - 1 > 0)
                                    {
                                        for (int i = 0; i < vs.Length - 1; i++)
                                        {
                                            string[] items = vs[i].Split(':');
                                            variable      += items[0] + ":" + items[1] + "<br/>";
                                            variablename  += items[0] + "|";
                                            variablevalue += items[1] + "|";
                                        }
                                    }

                                    QuantityInstock       = mainstock;
                                    QuantityInstockString = string.Format("{0:N0}", mainstock);

                                    var _product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID));

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

                                    ProductVariable = variable;

                                    if (_product != null)
                                    {
                                        ProductName = _product.ProductTitle;
                                    }

                                    QuantityMainInstock       = mainstock;
                                    QuantityMainInstockString = string.Format("{0:N0}", mainstock);
                                    ProductVariableSave       = item.ProductVariableDescrition;

                                    ProductVariableName  = variablename;
                                    ProductVariableValue = variablevalue;
                                }
                            }
                            orderitem++;
                            html += "<tr class=\"product-result\" data-orderdetailid=\"" + item.ID + "\" data-giabansi=\"" + Giabansi + "\" data-giabanle=\"" + Giabanle + "\" " +
                                    "data-quantityinstock=\"" + QuantityInstock + "\" data-productimageorigin=\"" + ProductImageOrigin + "\" " +
                                    "data-productvariable=\"" + ProductVariable + "\" data-productname=\"" + ProductName + "\" " +
                                    "data-sku=\"" + SKU + "\" data-producttype=\"" + ProductType + "\" data-id=\"" + PID + "\" " +
                                    "data-productnariablename=\"" + ProductVariableName + "\" " +
                                    "data-productvariablevalue =\"" + ProductVariableValue + "\" " +
                                    "data-productvariablesave =\"" + ProductVariableSave + "\" " +
                                    "data-quantitymaininstock=\"" + QuantityMainInstock + "\">";
                            html += "   <td class=\"order-item\">" + orderitem + "";
                            html += "   <td class=\"image-item\">" + ProductImage + "";
                            html += "   <td class=\"name-item\">" + ProductName + "</td>";
                            html += "   <td class=\"sku-item\">" + SKU + "</td>";
                            html += "   <td class=\"variable-item\">" + ProductVariable + "</td>";
                            html += "   <td class=\"price-item gia-san-pham\" data-price=\"" + ItemPrice + "\">" + string.Format("{0:N0}", ItemPrice) + "</td>";
                            html += "   <td class=\"quantity-item soluong\">" + QuantityInstockString + "</td>";
                            html += "   <td class=\"quantity-item\"><input disabled data-quantity=\"" + item.Quantity + "\" value=\"" + item.Quantity + "\" type=\"text\" class=\"form-control in-quanlity\" value=\"1\" onblur=\"checkQuantiy($(this))\" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>";
                            int k = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity);
                            html += "<td class=\"total-item totalprice-view\">" + string.Format("{0:N0}", k) + "</td>";
                            html += "   <td class=\"trash-item\"><a href=\"javascript:;\" class=\"link-btn\"><i class=\"fa fa-trash\"></i></a>    </td>";

                            html += "</tr>";


                            Print += " <tr>";
                            t++;
                            Print += "<td>" + t + "</td>";
                            Print += "<td>" + SKU + " - " + ProductName + " - " + ProductVariableSave.Replace("|", ", ") + "</td> ";
                            Print += "<td>" + item.Quantity + "</td>";
                            Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>";

                            Print += "<td> " + string.Format("{0:N0}", k) + "</td>";

                            Print += "</tr>";
                        }
                        ltrProducts.Text = html;
                    }
                    #endregion
                    ddlPaymentStatus.SelectedValue      = paymentStatus.ToString();
                    ddlExcuteStatus.SelectedValue       = excuteStatus.ToString();
                    ddlPaymentType.SelectedValue        = paymenttype.ToString();
                    ddlShippingType.SelectedValue       = shipping.ToString();
                    ddlPostalDeliveryType.SelectedValue = PostalDeliveryType.ToString();

                    LoadTransportCompanySubID(TransportCompanyID);
                    ddlTransportCompanyID.SelectedValue    = TransportCompanyID.ToString();
                    ddlTransportCompanySubID.SelectedValue = TransportCompanySubID.ToString();

                    txtShippingCode.Text = order.ShippingCode;
                    txtOrderNote.Text    = order.OrderNote;

                    ltrProductQuantity.Text  = string.Format("{0:N0}", ProductQuantity) + " sản phẩm";
                    ltrTotalNotDiscount.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPriceNotDiscount));
                    ltrTotalprice.Text       = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice));
                    pDiscount.Value          = order.DiscountPerProduct;
                    pFeeShip.Value           = Convert.ToDouble(order.FeeShipping);

                    ltrOtherFeeName.Text = order.OtherFeeName;
                    txtOtherFeeName.Text = order.OtherFeeName;
                    pOtherFee.Value      = Convert.ToDouble(order.OtherFeeValue);

                    ltrTotalAfterCK.Text = string.Format("{0:N0}", (Convert.ToDouble(order.TotalPriceNotDiscount) - Convert.ToDouble(order.TotalDiscount)));
                    ltrOrderID.Text      = ID.ToString();
                    ltrCreateBy.Text     = order.CreatedBy;
                    ltrCreateDate.Text   = order.CreatedDate.ToString();
                    ltrDateDone.Text     = "Chưa hoàn tất";
                    if (order.DateDone != null)
                    {
                        ltrDateDone.Text = order.DateDone.ToString();
                    }
                    ltrOrderNote.Text       = order.OrderNote;
                    ltrOrderQuantity.Text   = ProductQuantity.ToString();
                    ltrOrderTotalPrice.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice));
                    ltrOrderStatus.Text     = PJUtils.OrderExcuteStatus(Convert.ToInt32(order.ExcuteStatus));

                    ltrOrderType.Text = PJUtils.OrderType(Convert.ToInt32(order.OrderType));
                }
            }
        }
コード例 #22
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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #23
0
        public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print)
        {
            var orderdetails = OrderDetailController.GetByOrderID(ID);

            if (orderdetails.Count > 0)
            {
                int t     = 0;
                int print = 1;
                foreach (var item in orderdetails)
                {
                    TotalQuantity += Convert.ToDouble(item.Quantity);

                    int    ProductType  = Convert.ToInt32(item.ProductType);
                    double ItemPrice    = Convert.ToDouble(item.Price);
                    string SKU          = item.SKU;
                    string ProductName  = "";
                    string ProductImage = "/App_Themes/Ann/image/placeholder.png";
                    int    SubTotal     = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity);

                    t++;
                    Print += "<tr>";
                    Print += "<td>" + t + "</td>";

                    if (ProductType == 1)
                    {
                        var product = ProductController.GetBySKU(SKU);
                        if (product != null)
                        {
                            ProductName = product.ProductTitle;
                            if (!string.IsNullOrEmpty(product.ProductImage))
                            {
                                ProductImage = product.ProductImage;
                            }
                            Print += "<td><image src=\"" + ProductImage + "\" /></td> ";
                            Print += "<td><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 30) + "</td> ";
                        }
                    }
                    else
                    {
                        var productvariable = ProductVariableController.GetBySKU(SKU);
                        if (productvariable != null)
                        {
                            var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID));
                            if (parent_product != null)
                            {
                                ProductName = parent_product.ProductTitle;

                                if (string.IsNullOrEmpty(productvariable.Image))
                                {
                                    ProductImage = parent_product.ProductImage;
                                }
                                else
                                {
                                    ProductImage = productvariable.Image;
                                }
                            }

                            Print += "<td><image src=\"" + ProductImage + "\" /></td>";
                            Print += "<td><p><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 30) + "</p><p class=\"variable\">" + item.ProductVariableDescrition.Replace("|", ". ") + "</p></td> ";
                        }
                    }

                    Print += "<td>" + item.Quantity + "</td>";
                    Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>";
                    Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>";
                    Print += "</tr>";

                    TotalOrder += SubTotal;

                    if (t % 10 == 0)
                    {
                        if (t == print * 10)
                        {
                            continue;
                        }
                        Print += "</tbody>";
                        Print += "</table>";
                        Print += "</div>";
                        Print += "</div>";
                        Print += "</div>";
                        Print += "</div>";

                        Print += "<div class=\"print-order-image\">";
                        Print += "<div class=\"all print print-" + print + "\">";
                        Print += "<div class=\"body\">";
                        Print += "<div class=\"table-2\">";
                        Print += "<table>";
                        Print += "<colgroup>";
                        Print += "<col class=\"order-item\" />";
                        Print += "<col class=\"image\" />";
                        Print += "<col class=\"name\" />";
                        Print += "<col class=\"quantity\" />";
                        Print += "<col class=\"price\" />";
                        Print += "<col class=\"subtotal\"/>";
                        Print += "</colgroup>";
                        Print += "<thead>";
                        Print += "<th>#</th>";
                        Print += "<th>Hình ảnh</th>";
                        Print += "<th>Sản phẩm</th>";
                        Print += "<th>SL</th>";
                        Print += "<th>Giá</th>";
                        Print += "<th>Tổng</th>";
                        Print += "</thead>";
                        Print += "<tbody>";
                        print++;
                    }
                }
            }
        }
コード例 #24
0
        public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print, ref double TotalFee)
        {
            var orderdetails = RefundGoodDetailController.GetByRefundGoodsID(ID);

            if (orderdetails.Count > 0)
            {
                int t     = 0;
                int print = 1;
                foreach (var item in orderdetails)
                {
                    TotalQuantity += Convert.ToDouble(item.Quantity);

                    int    ProductType  = Convert.ToInt32(item.ProductType);
                    double ItemPrice    = Convert.ToDouble(item.GiavonPerProduct);
                    double SoldPrice    = Convert.ToDouble(item.SoldPricePerProduct);
                    double RefundFee    = Convert.ToDouble(item.RefundFeePerProduct);
                    string SKU          = item.SKU;
                    string ProductName  = "";
                    string ProductImage = "/App_Themes/Ann/image/placeholder.png";
                    int    SubTotal     = (Convert.ToInt32(SoldPrice) - Convert.ToInt32(item.RefundFeePerProduct)) * Convert.ToInt32(item.Quantity);

                    t++;
                    Print += "<tr>";
                    Print += "<td>" + t + "</td>";

                    if (ProductType == 1)
                    {
                        var product = ProductController.GetBySKU(SKU);
                        if (product != null)
                        {
                            ProductName = product.ProductTitle;
                            if (!string.IsNullOrEmpty(product.ProductImage))
                            {
                                ProductImage = product.ProductImage;
                            }
                            Print += "<td><image src=\"" + ProductImage + "\" /></td> ";
                            Print += "<td><strong>" + SKU + "</strong> - " + ProductName + "</td> ";
                        }
                    }
                    else
                    {
                        var productvariable = ProductVariableController.GetBySKU(SKU);
                        if (productvariable != null)
                        {
                            var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID));
                            if (parent_product != null)
                            {
                                ProductName = parent_product.ProductTitle;

                                if (string.IsNullOrEmpty(productvariable.Image))
                                {
                                    ProductImage = parent_product.ProductImage;
                                }
                                else
                                {
                                    ProductImage = productvariable.Image;
                                }
                            }

                            Print += "<td><image src=\"" + ProductImage + "\" /></td>";
                            Print += "<td><p><strong>" + SKU + "</strong> - " + ProductName + "</p></td> ";
                        }
                    }

                    Print      += "<td>" + item.Quantity + "</td>";
                    Print      += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>";
                    Print      += "<td>" + string.Format("{0:N0}", SoldPrice) + "</td>";
                    Print      += "<td>" + string.Format("{0:N0}", RefundFee) + "</td>";
                    Print      += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>";
                    Print      += "</tr>";
                    TotalFee   += Convert.ToInt32(item.RefundFeePerProduct) * Convert.ToInt32(item.Quantity);
                    TotalOrder += SubTotal;

                    if (t % 10 == 0)
                    {
                        if (t == print * 10)
                        {
                            continue;
                        }
                        Print += "</tbody>";
                        Print += "</table>";
                        Print += "</div>";
                        Print += "</div>";
                        Print += "</div>";
                        Print += "</div>";

                        Print += "<div class=\"print-order-image\">";
                        Print += "<div class=\"all print print-" + print + "\">";
                        Print += "<div class=\"body\">";
                        Print += "<div class=\"table-2\">";
                        Print += "<table>";
                        Print += "<colgroup>";
                        Print += "<col class=\"order-item\" />";
                        Print += "<col class=\"image\" />";
                        Print += "<col class=\"name\" />";
                        Print += "<col class=\"quantity\" />";
                        Print += "<col class=\"price\" />";
                        Print += "<col class=\"sold-price\" />";
                        Print += "<col class=\"fee\" />";
                        Print += "<col class=\"subtotal\"/>";
                        Print += "</colgroup>";
                        Print += "<thead>";
                        Print += "<th>#</th>";
                        Print += "<th>Hình ảnh</th>";
                        Print += "<th>Sản phẩm</th>";
                        Print += "<th>SL</th>";
                        Print += "<th>Giá niêm yết</th>";
                        Print += "<th>Giá đã bán</th>";
                        Print += "<th>Phí đổi hàng</th>";
                        Print += "<th>Tổng</th>";
                        Print += "</thead>";
                        Print += "<tbody>";
                        print++;
                    }
                }
            }
        }
コード例 #25
0
ファイル: tao-san-pham.aspx.cs プロジェクト: war-man/ANNsys
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string   username    = Request.Cookies["usernameLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);
            DateTime currentDate = DateTime.Now;

            if (acc != null)
            {
                if (acc.RoleID == 0 || acc.RoleID == 1 || acc.Username == "nhom_zalo502")
                {
                    int cateID = hdfParentID.Value.ToInt();
                    if (cateID > 0)
                    {
                        string ProductSKU   = txtProductSKU.Text.Trim().ToUpper();
                        var    check        = true;
                        var    productcheck = ProductController.GetBySKU(ProductSKU);
                        if (productcheck != null)
                        {
                            check = false;
                        }
                        else
                        {
                            var productvariable = ProductVariableController.GetBySKU(ProductSKU);
                            if (productvariable != null)
                            {
                                check = false;
                            }
                        }

                        if (check == false)
                        {
                            PJUtils.ShowMessageBoxSwAlert("Mã sản phẩm đã tồn tại, hãy kiểm tra lại", "e", false, Page);
                        }
                        else
                        {
                            string ProductTitle   = Regex.Replace(txtProductTitle.Text.Trim(), @"\s*\,\s*|\s*\;\s*", " - ");
                            string ProductContent = pContent.Content.ToString();

                            double ProductStock  = 0;
                            int    StockStatus   = 3;
                            double Regular_Price = Convert.ToDouble(pRegular_Price.Text);
                            double CostOfGood    = Convert.ToDouble(pCostOfGood.Text);
                            double Retail_Price  = Convert.ToDouble(pRetailPrice.Text);
                            int    supplierID    = ddlSupplier.SelectedValue.ToInt(0);
                            string supplierName  = ddlSupplier.SelectedItem.ToString();
                            string mainColor     = ddlColor.SelectedValue.Trim();
                            int    a             = 1;
                            var    preOrder      = ddlPreOrder.SelectedValue == "1" ? true : false;
                            double Old_Price     = String.IsNullOrEmpty(pOld_Price.Text) ? 0 : Convert.ToDouble(pOld_Price.Text);

                            double MinimumInventoryLevel = pMinimumInventoryLevel.Text.ToInt(0);
                            double MaximumInventoryLevel = pMaximumInventoryLevel.Text.ToInt(0);

                            if (hdfsetStyle.Value == "2")
                            {
                                MinimumInventoryLevel = 0;
                                MaximumInventoryLevel = 0;
                                a = hdfsetStyle.Value.ToInt();
                            }

                            int ShowHomePage = ddlShowHomePage.SelectedValue.ToInt(0);

                            var prodNew = new tbl_Product()
                            {
                                CategoryID            = cateID,
                                ProductOldID          = 0,
                                ProductTitle          = ProductTitle,
                                ProductContent        = ProductContent,
                                ProductSKU            = ProductSKU,
                                ProductStock          = ProductStock,
                                StockStatus           = StockStatus,
                                ManageStock           = true,
                                Regular_Price         = Regular_Price,
                                CostOfGood            = CostOfGood,
                                Retail_Price          = Retail_Price,
                                ProductImage          = String.Empty,
                                ProductType           = a,
                                IsHidden              = false,
                                CreatedDate           = currentDate,
                                CreatedBy             = username,
                                SupplierID            = supplierID,
                                SupplierName          = supplierName,
                                Materials             = txtMaterials.Text,
                                MinimumInventoryLevel = MinimumInventoryLevel,
                                MaximumInventoryLevel = MaximumInventoryLevel,
                                ProductStyle          = a,
                                ShowHomePage          = ShowHomePage,
                                Color     = mainColor,
                                PreOrder  = preOrder,
                                Old_Price = Old_Price
                            };

                            string kq = ProductController.Insert(prodNew);
                            prodNew.ID = Convert.ToInt32(kq);

                            if (!String.IsNullOrEmpty(hdfTags.Value))
                            {
                                var tagList = JsonConvert.DeserializeObject <List <TagModel> >(hdfTags.Value);

                                if (tagList.Count > 0)
                                {
                                    // Get tag new
                                    var tagNew = TagController.insert(tagList, acc);

                                    var productTag = tagList
                                                     .GroupJoin(
                                        tagNew,
                                        t => t.name.ToLower(),
                                        n => n.Name.ToLower(),
                                        (t, n) => new { t, n }
                                        )
                                                     .SelectMany(
                                        x => x.n.DefaultIfEmpty(),
                                        (parent, child) => new ProductTag
                                    {
                                        TagID             = child != null ? child.ID : parent.t.id,
                                        ProductID         = prodNew.ID,
                                        ProductVariableID = 0,
                                        SKU         = prodNew.ProductSKU,
                                        CreatedBy   = acc.ID,
                                        CreatedDate = currentDate
                                    }
                                        )
                                                     .ToList();

                                    ProductTagController.insert(productTag);
                                }
                            }

                            //Phần thêm ảnh đại diện sản phẩm
                            string path         = "/uploads/images/";
                            string ProductImage = "";
                            if (ProductThumbnailImage.UploadedFiles.Count > 0)
                            {
                                foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles)
                                {
                                    var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true);
                                    if (!File.Exists(Server.MapPath(o)))
                                    {
                                        f.SaveAs(Server.MapPath(o));
                                        // Thumbnail
                                        Thumbnail.create(Server.MapPath(o), 85, 113);
                                        Thumbnail.create(Server.MapPath(o), 159, 212);
                                        Thumbnail.create(Server.MapPath(o), 240, 320);
                                        Thumbnail.create(Server.MapPath(o), 350, 467);
                                        Thumbnail.create(Server.MapPath(o), 600, 0);
                                    }

                                    ProductImage = Path.GetFileName(Server.MapPath(o));
                                }
                            }
                            string updateImage = ProductController.UpdateImage(kq.ToInt(), ProductImage);

                            //Phần thêm ảnh đại diện sản phẩm sạch không có đóng dấu
                            string ProductImageClean = "";
                            if (ProductThumbnailImageClean.UploadedFiles.Count > 0)
                            {
                                foreach (UploadedFile f in ProductThumbnailImageClean.UploadedFiles)
                                {
                                    var o = path + kq + "-clean-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true);
                                    if (!File.Exists(Server.MapPath(o)))
                                    {
                                        f.SaveAs(Server.MapPath(o));
                                        // Thumbnail
                                        Thumbnail.create(Server.MapPath(o), 85, 113);
                                        Thumbnail.create(Server.MapPath(o), 159, 212);
                                        Thumbnail.create(Server.MapPath(o), 240, 320);
                                        Thumbnail.create(Server.MapPath(o), 350, 467);
                                        Thumbnail.create(Server.MapPath(o), 600, 0);
                                    }

                                    ProductImageClean = Path.GetFileName(Server.MapPath(o));
                                }
                            }
                            string updateImageClean = ProductController.UpdateImageClean(kq.ToInt(), ProductImageClean);

                            //Phần thêm thư viện ảnh sản phẩm
                            string IMG = "";
                            if (hinhDaiDien.UploadedFiles.Count > 0)
                            {
                                foreach (UploadedFile f in hinhDaiDien.UploadedFiles)
                                {
                                    var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true);
                                    if (!File.Exists(Server.MapPath(o)))
                                    {
                                        f.SaveAs(Server.MapPath(o));
                                        // Thumbnail
                                        Thumbnail.create(Server.MapPath(o), 85, 113);
                                        Thumbnail.create(Server.MapPath(o), 159, 212);
                                        Thumbnail.create(Server.MapPath(o), 240, 320);
                                        Thumbnail.create(Server.MapPath(o), 350, 467);
                                        Thumbnail.create(Server.MapPath(o), 600, 0);
                                    }

                                    IMG = Path.GetFileName(Server.MapPath(o));
                                    ProductImageController.Insert(kq.ToInt(), IMG, false, currentDate, username);
                                }
                            }


                            if (kq.ToInt(0) > 0)
                            {
                                int ProductID = kq.ToInt(0);

                                string variable = hdfVariableListInsert.Value;
                                if (!string.IsNullOrEmpty(variable))
                                {
                                    string[] items = variable.Split(',');
                                    for (int i = 0; i < items.Length - 1; i++)
                                    {
                                        string   item        = items[i];
                                        string[] itemElement = item.Split(';');

                                        string   datanameid             = itemElement[0];
                                        string[] datavalueid            = itemElement[1].Split('|');
                                        string   datanametext           = itemElement[2];
                                        string   datavaluetext          = itemElement[3];
                                        string   productvariablesku     = itemElement[4].Trim().ToUpper();
                                        string   regularprice           = itemElement[5];
                                        string   costofgood             = itemElement[6];
                                        string   retailprice            = itemElement[7];
                                        string[] datanamevalue          = itemElement[8].Split('|');
                                        string   imageUpload            = itemElement[4];
                                        int      _MaximumInventoryLevel = itemElement[9].ToInt(0);
                                        int      _MinimumInventoryLevel = itemElement[10].ToInt(0);

                                        int stockstatus = itemElement[11].ToInt();

                                        HttpPostedFile postedFile = Request.Files["" + imageUpload + ""];
                                        string         image      = "";
                                        if (postedFile != null && postedFile.ContentLength > 0)
                                        {
                                            var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(postedFile.FileName), isFile: true);
                                            if (!File.Exists(Server.MapPath(o)))
                                            {
                                                postedFile.SaveAs(Server.MapPath(o));
                                                // Thumbnail
                                                Thumbnail.create(Server.MapPath(o), 85, 113);
                                                Thumbnail.create(Server.MapPath(o), 159, 212);
                                                Thumbnail.create(Server.MapPath(o), 240, 320);
                                                Thumbnail.create(Server.MapPath(o), 350, 467);
                                                Thumbnail.create(Server.MapPath(o), 600, 0);
                                            }

                                            image = Path.GetFileName(Server.MapPath(o));
                                        }

                                        string kq1 = ProductVariableController.Insert(ProductID, ProductSKU, productvariablesku, 0, stockstatus, Convert.ToDouble(regularprice),
                                                                                      Convert.ToDouble(costofgood), Convert.ToDouble(retailprice), image, true, false, currentDate, username,
                                                                                      supplierID, supplierName, _MinimumInventoryLevel, _MaximumInventoryLevel);

                                        string color             = "";
                                        string size              = "";
                                        int    ProductVariableID = 0;

                                        if (kq1.ToInt(0) > 0)
                                        {
                                            ProductVariableID = kq1.ToInt(0);
                                            color             = datavalueid[0];
                                            size = datavalueid[1];
                                            string[] Data      = datanametext.Split('|');
                                            string[] DataValue = datavaluetext.Split('|');
                                            for (int k = 0; k < Data.Length - 2; k++)
                                            {
                                                int    variablevalueID   = datavalueid[k].ToInt();
                                                string variableName      = Data[k];
                                                string variableValueName = DataValue[k];
                                                ProductVariableValueController.Insert(ProductVariableID, productvariablesku, variablevalueID,
                                                                                      variableName, variableValueName, false, currentDate, username);
                                            }
                                        }
                                        ProductVariableController.UpdateColorSize(ProductVariableID, color, size);
                                    }
                                }

                                PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo sản phẩm thành công", "s", true, "redirectTo(" + kq + ")", Page);
                            }
                        }
                    }
                }
            }
        }
コード例 #26
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["userLoginSystem"].Value;

            bool   check        = true;
            string SKU          = txtProductSKU.Text.Trim().ToUpper();
            var    productcheck = ProductController.GetBySKU(SKU);

            if (productcheck != null)
            {
                check = false;
            }
            else
            {
                var productvariable = ProductVariableController.GetBySKU(SKU);
                if (productvariable != null)
                {
                    check = false;
                }
            }
            if (check == false)
            {
                PJUtils.ShowMessageBoxSwAlert("Trùng mã sản phẩm vui lòng kiểm tra lại", "e", false, Page);
            }
            else
            {
                int parentID = ViewState["productid"].ToString().ToInt(0);

                var parentProduct = ProductController.GetByID(parentID);

                bool isHidden = false;

                double Stock         = 0;
                double Regular_Price = Convert.ToDouble(pRegular_Price.Text);
                double CostOfGood    = Convert.ToDouble(pCostOfGood.Text);
                double RetailPrice   = Convert.ToDouble(pRetailPrice.Text);
                int    StockStatus   = 1;
                bool   ManageStock   = true;

                //Phần thêm ảnh đại diện sản phẩm
                string path         = "/uploads/images/";
                string ProductImage = "";
                if (ProductThumbnailImage.UploadedFiles.Count > 0)
                {
                    foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles)
                    {
                        var o = path + parentID.ToString() + '-' + convertToSlug(Path.GetFileName(f.FileName));
                        try
                        {
                            f.SaveAs(Server.MapPath(o));
                            ProductImage = o;
                        }
                        catch { }
                    }
                }
                ProductVariableController.Insert(parentProduct.ID, parentProduct.ProductSKU, SKU, Stock, StockStatus, Regular_Price,
                                                 CostOfGood, RetailPrice, ProductImage, ManageStock, isHidden, currentDate, username, Convert.ToInt32(parentProduct.SupplierID),
                                                 parentProduct.SupplierName, Convert.ToDouble(pMinimumInventoryLevel.Text),
                                                 Convert.ToDouble(pMaximumInventoryLevel.Text));

                PJUtils.ShowMessageBoxSwAlert("Thêm biến thể sản phẩm thành công", "s", true, Page);
            }
        }
コード例 #27
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["userLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0 || acc.RoleID == 1)
                {
                    int    AgentID = Convert.ToInt32(acc.AgentID);
                    string list    = hdfvalue.Value;
                    string note    = "Xuất kho bằng chức năng xuất kho";
                    if (hdfNote.Value != "")
                    {
                        note = hdfNote.Value;
                    }
                    string[] items = list.Split(';');
                    if (items.Length - 1 > 0)
                    {
                        int SessionInOutID = SessionInOutController.Insert(currentDate, note, AgentID, 2, currentDate, username).ToInt(0);
                        if (SessionInOutID > 0)
                        {
                            for (int i = 0; i < items.Length - 1; i++)
                            {
                                var      item                 = items[i];
                                string[] itemValue            = item.Split(',');
                                int      ID                   = itemValue[0].ToInt();
                                string   SKU                  = itemValue[1];
                                int      producttype          = itemValue[2].ToInt();
                                string   ProductVariableName  = itemValue[3];
                                string   ProductVariableValue = itemValue[4];
                                double   Quantity             = Convert.ToDouble(itemValue[5]);
                                string   ProductName          = itemValue[6];
                                string   ProductImageOrigin   = itemValue[7];
                                string   ProductVariable      = itemValue[8];
                                if (producttype == 1)
                                {
                                    StockManagerController.Insert(
                                        new tbl_StockManager {
                                        AgentID           = AgentID,
                                        ProductID         = ID,
                                        ProductVariableID = 0,
                                        Quantity          = Quantity,
                                        QuantityCurrent   = 0,
                                        Type        = 2,
                                        NoteID      = note,
                                        OrderID     = 0,
                                        Status      = 2,
                                        SKU         = SKU,
                                        CreatedDate = currentDate,
                                        CreatedBy   = username,
                                        MoveProID   = 0,
                                        ParentID    = ID,
                                    });
                                }
                                else
                                {
                                    int    parentID  = 0;
                                    string parentSKU = "";
                                    var    productV  = ProductVariableController.GetByID(ID);
                                    if (productV != null)
                                    {
                                        parentSKU = productV.ParentSKU;
                                    }
                                    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        = 2,
                                        NoteID      = note,
                                        OrderID     = 0,
                                        Status      = 2,
                                        SKU         = SKU,
                                        CreatedDate = currentDate,
                                        CreatedBy   = username,
                                        MoveProID   = 0,
                                        ParentID    = parentID,
                                    });
                                }
                            }
                            PJUtils.ShowMessageBoxSwAlert("Xuất kho thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: kiem-kho.aspx.cs プロジェクト: ANN-Project/ann-shop
        protected void btnImport_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["userLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0 || acc.RoleID == 1)
                {
                    int      AgentID = Convert.ToInt32(acc.AgentID);
                    string   list    = hdfvalue.Value;
                    string   note    = hdfNote.Value;
                    string[] items   = list.Split(';');
                    if (items.Length - 1 > 0)
                    {
                        int SessionInOutID = SessionInOutController.Insert(currentDate, note, AgentID, 2, currentDate, username).ToInt(0);
                        if (SessionInOutID > 0)
                        {
                            for (int i = 0; i < items.Length - 1; i++)
                            {
                                //list += id + "," + sku + "," + producttype + "," + productnariablename + "," + productvariablevalue + "," + quantity + "|";
                                var      item                 = items[i];
                                string[] itemValue            = item.Split(',');
                                int      ID                   = itemValue[0].ToInt();
                                string   SKU                  = itemValue[1];
                                int      producttype          = itemValue[2].ToInt();
                                string   ProductVariableName  = itemValue[3];
                                string   ProductVariableValue = itemValue[4];
                                double   Quantity             = Convert.ToDouble(itemValue[5]);
                                string   ProductName          = itemValue[6];
                                string   ProductImageOrigin   = itemValue[7];
                                string   ProductVariable      = itemValue[8];

                                string noteeach        = itemValue[9];
                                double QuantityInStock = Convert.ToDouble(itemValue[10]);

                                if (!string.IsNullOrEmpty(noteeach))
                                {
                                    noteeach = "Cập nhật số lượng sản phẩm khi kiểm kho ngày: " + string.Format("0:dd/MM/yyyy", currentDate);
                                }


                                if (Quantity > QuantityInStock)
                                {
                                    double slIn = Quantity - QuantityInStock;
                                    if (producttype == 1)
                                    {
                                        StockManagerController.Insert(
                                            new tbl_StockManager {
                                            AgentID           = AgentID,
                                            ProductID         = ID,
                                            ProductVariableID = 0,
                                            Quantity          = slIn,
                                            QuantityCurrent   = 0,
                                            Type        = 1,
                                            NoteID      = note,
                                            OrderID     = 0,
                                            Status      = 1,
                                            SKU         = SKU,
                                            CreatedDate = currentDate,
                                            CreatedBy   = username,
                                            MoveProID   = 0,
                                            ParentID    = ID
                                        });
                                    }
                                    else
                                    {
                                        int    parentID  = 0;
                                        string parentSKU = "";
                                        var    productV  = ProductVariableController.GetByID(ID);
                                        if (productV != null)
                                        {
                                            parentSKU = productV.ParentSKU;
                                        }
                                        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          = slIn,
                                            QuantityCurrent   = 0,
                                            Type        = 1,
                                            NoteID      = note,
                                            OrderID     = 0,
                                            Status      = 1,
                                            SKU         = SKU,
                                            CreatedDate = currentDate,
                                            CreatedBy   = username,
                                            MoveProID   = 0,
                                            ParentID    = parentID
                                        });
                                    }
                                }
                                else if (Quantity < QuantityInStock)
                                {
                                    double slOut = QuantityInStock - Quantity;
                                    if (producttype == 1)
                                    {
                                        StockManagerController.Insert(
                                            new tbl_StockManager {
                                            AgentID           = AgentID,
                                            ProductID         = ID,
                                            ProductVariableID = 0,
                                            Quantity          = slOut,
                                            QuantityCurrent   = 0,
                                            Type        = 2,
                                            NoteID      = noteeach,
                                            OrderID     = 0,
                                            Status      = 2,
                                            SKU         = SKU,
                                            CreatedDate = currentDate,
                                            CreatedBy   = username,
                                            MoveProID   = 0,
                                            ParentID    = ID
                                        });
                                    }
                                    else
                                    {
                                        int    parentID  = 0;
                                        string parentSKU = "";
                                        var    productV  = ProductVariableController.GetByID(ID);
                                        if (productV != null)
                                        {
                                            parentSKU = productV.ParentSKU;
                                        }
                                        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          = slOut,
                                            QuantityCurrent   = 0,
                                            Type        = 2,
                                            NoteID      = noteeach,
                                            OrderID     = 0,
                                            Status      = 2,
                                            SKU         = SKU,
                                            CreatedDate = currentDate,
                                            CreatedBy   = username,
                                            MoveProID   = 0,
                                            ParentID    = parentID
                                        });
                                    }
                                }
                            }
                            PJUtils.ShowMessageBoxSwAlert("Kiểm kho thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
コード例 #29
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));
        }
コード例 #30
0
        public static string copyProductInfo(int id)
        {
            var product = ProductController.GetByID(id);
            StringBuilder html = new StringBuilder();
            if (product != null)
            {
                html.Append("<p>" + product.ProductSKU + " - Sỉ " + (product.Regular_Price / 1000).ToString() + "k - " + product.ProductTitle + "</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>📌 Giá sỉ: " + (product.Regular_Price / 1000).ToString() + "k</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>📌 Giá lẻ: " + ((product.Retail_Price + 25000) / 1000).ToString() + "k</p>\r\n");
                html.Append("<p></p>\r\n");

                if (!string.IsNullOrEmpty(product.Materials))
                {
                    html.Append("<p>🔖 Chất liệu: " + product.Materials + "</p>\r\n");
                    html.Append("<p></p>\r\n");
                }

                if (!string.IsNullOrEmpty(product.ProductContent))
                {
                    html.Append("<p>🔖 Mô tả: " + product.ProductContent + "</p>\r\n");
                    html.Append("<p></p>\r\n");
                }

                // liệt kê thuộc tính sản phẩm

                List<ProductVariable> variableTemp = new List<ProductVariable>();

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

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

                string Variable = "";
                if (v.Count > 0)
                {
                    for (int i = 0; i < v.Count; i++)
                    {
                        var item = v[i];
                        var value = ProductVariableValueController.GetByProductVariableIDSortByName(item.ID);
                        if (value != null)
                        {
                            for (int j = 0; j < value.Count; j++)
                            {
                                variableTemp.Add(new ProductVariable() { VariableName = value[j].VariableName, VariableValue = value[j].VariableValue });

                            }
                        }
                    }
                    var vari = variableTemp.GroupBy(x => new { x.VariableName, x.VariableValue }).Select(x => new { VariableName = x.Key.VariableName, VariableValue = x.Key.VariableValue }).OrderBy(x => x.VariableName).ToList();

                    string stringVariable = vari[0].VariableName;

                    Variable = "<p><strong>📚 " + vari[0].VariableName + "</strong>: ";

                    for (int y = 0; y < vari.Count; y++)
                    {
                        if (stringVariable == vari[y].VariableName)
                        {
                            Variable += vari[y].VariableValue + "; ";
                        }
                        else
                        {
                            Variable += "</p>\r\n";
                            Variable += "<p></p>\r\n";
                            Variable += "<p><strong>📐 " + vari[y].VariableName + "</strong>: " + vari[y].VariableValue + "; ";
                            stringVariable = vari[y].VariableName;
                        }
                    }

                    html.Append(Variable);
                }

                // thông tin liên hệ
                html.Append("<p></p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>-----------------------------------------------------------</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⚡⚡ Hàng có sẵn tại KHO HÀNG SỈ ANN ⚡⚡</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>🏭 68 Đường C12, P.13, Tân Bình, TP.HCM</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Web: ANN.COM.VN</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Zalo đặt hàng: 0936786404 - 0913268406 - 0918567409</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Facebook: https://facebook.com/bosiquanao.net </p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Zalo xem Quần Áo Nam: 0977399405 (Zalo này không trả lời tin nhắn)</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Zalo xem Đồ Bộ Nữ: 0975442402 (Zalo này không trả lời tin nhắn)</p>\r\n");
                html.Append("<p></p>\r\n");
                html.Append("<p>⭐ Zalo xem Váy Đầm - Áo Nữ - Quần Nữ: 0987409403 (Zalo này không trả lời tin nhắn)</p>\r\n");
                html.Append("<p></p>\r\n");

            }

            return html.ToString();
        }