Пример #1
0
        private void _loadData()
        {
            var productID = 0;

            // Lấy product id từ query parameter
            if (!String.IsNullOrEmpty(Request.QueryString["id"]))
            {
                productID = Convert.ToInt32(Request.QueryString["id"]);
            }

            // Kiểm tra product id có tồn tại hoặc đúng yêu cầu không
            if (productID <= 0)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm", "e", true, "/tat-ca-san-pham", Page);
                return;
            }

            // Kiểm tra xem có tồn tại sản phẩm với mã ID trong query param không
            var product = ProductController.GetByID(productID);

            if (product == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + productID, "e", true, "/tat-ca-san-pham", Page);
                return;
            }

            // Cài đặt title page
            this.Title = String.Format("{0} - Sửa sản phẩm", product.ProductSKU.ToTitleCase());
            // Cài đặt dữ liệu cho page
            ViewState["ID"]     = productID;
            ViewState["cateID"] = product.CategoryID;
            _productSKU         = product.ProductSKU.ToUpper();
            ViewState["SKU"]    = product.ProductSKU;
            hdfParentID.Value   = product.CategoryID.ToString();
            hdfsetStyle.Value   = product.ProductStyle.ToString();
            ltrBack.Text        = "<a href='/xem-san-pham?id=" + product.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-arrow-left' aria-hidden='true'></i> Trở về</a>";
            ltrBack2.Text       = ltrBack.Text;
            // Thông tin product
            _loadProductInfo(product);

            // Thông tin biến thể
            if (product.ProductStyle.HasValue && product.ProductStyle.Value == 2)
            {
                _loadProductVariationInfo(product.ID);
            }

            // Thông tin chú thích
            _loadNote(product);
        }
Пример #2
0
 public static string UpdatePassword(int ID, string Password)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         var a = dbe.tbl_Account.Where(ac => ac.ID == ID).SingleOrDefault();
         if (a != null)
         {
             a.Password = PJUtils.Encrypt("userpass", Password);
             dbe.Configuration.ValidateOnSaveEnabled = false;
             int kq = dbe.SaveChanges();
             return(kq.ToString());
         }
         return(null);
     }
 }
Пример #3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DateTime currentDate       = DateTime.Now;
            string   username          = Request.Cookies["userLoginSystem"].Value;
            int      productvariableid = ViewState["productvariableid"].ToString().ToInt(0);
            string   SKU             = ViewState["ProductvariableSKU"].ToString();
            int      VariableValueID = ddlVariableValue.SelectedValue.ToInt();
            string   VariableName    = ddlVariable.SelectedItem.ToString();
            string   VariableValue   = ddlVariableValue.SelectedItem.ToString();
            bool     isHidden        = chkIsHidden.Checked;

            ProductVariableValueController.Insert(productvariableid, SKU, VariableValueID, VariableName, VariableValue, isHidden,
                                                  currentDate, username);
            PJUtils.ShowMessageBoxSwAlert("Thêm giá trị thành công", "s", true, Page);
        }
Пример #4
0
 public static string UpdateSecurityCode(string SecurityCode)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         var a = dbe.tbl_Config.Where(ac => ac.ID == 1).SingleOrDefault();
         if (a != null)
         {
             a.SecurityCode = PJUtils.Encrypt("scode", SecurityCode);
             dbe.Configuration.ValidateOnSaveEnabled = false;
             int kq = dbe.SaveChanges();
             return(kq.ToString());
         }
         return(null);
     }
 }
        public void pagingall(List <tbl_MovePro> acs)
        {
            int           PageSize = 15;
            StringBuilder html     = new StringBuilder();

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

                Int32 Page = GetIntFromQueryString("Page");

                if (Page == -1)
                {
                    Page = 1;
                }
                int FromRow = (Page - 1) * PageSize;
                int ToRow   = Page * PageSize - 1;
                if (ToRow >= TotalItems)
                {
                    ToRow = TotalItems - 1;
                }
                for (int i = FromRow; i < ToRow + 1; i++)
                {
                    var item = acs[i];
                    html.Append("<tr>");
                    html.Append("   <td>" + item.ID + "</td>");
                    html.Append("   <td>" + item.AgentNameSend + "</td>");
                    html.Append("   <td>" + item.AgentNameReceive + "</td>");
                    int status = Convert.ToInt32(item.Status);
                    html.Append("   <td>" + PJUtils.ReturnStatusMovePro(status) + "</td>");
                    string date = string.Format("{0:dd/MM/yyyy}", item.CreatedDate);
                    html.Append("   <td>" + date + "</td>");
                    html.Append("   <td>");
                    html.Append("       <a href=\"/chi-tiet-chuyen-hang?id=" + item.ID + "\" class=\"btn primary-btn h45-btn\">Chi tiết</a>");
                    html.Append("   </td>");
                    html.Append("</tr>");
                }
            }
            ltrList.Text = html.ToString();
        }
Пример #6
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = NotifyController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-thong-bao", Page);
                }
                else
                {
                    this.Title = String.Format("{0} - Sửa thông báo", p.Title.ToTitleCase());

                    ViewState["ID"]     = id;
                    ViewState["cateID"] = p.CategoryID;
                    hdfParentID.Value   = p.CategoryID.ToString();
                    ltrBack.Text        = "<a href='/xem-thong-bao?id=" + p.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-arrow-left' aria-hidden='true'></i> Trở về</a>";
                    ltrBack2.Text       = ltrBack.Text;
                    txtTitle.Text       = p.Title;
                    if (p.Action == "show_web")
                    {
                        txtLink.Text = p.ActionValue;
                    }
                    else if (p.Action == "view_more")
                    {
                        txtSlug.Text = p.ActionValue;
                    }
                    ddlCategory.SelectedValue = p.CategoryID.ToString();
                    ddlAction.SelectedValue   = p.Action.ToString();
                    hdfAction.Value           = p.Action.ToString();
                    ddlAtHome.SelectedValue   = p.AtHome.ToString();
                    pSummary.Content          = p.Summary;
                    pContent.Content          = p.Content;
                    if (p.Thumbnail != null)
                    {
                        ListPostPublicThumbnail.Value = p.Thumbnail;
                        PostPublicThumbnail.ImageUrl  = p.Thumbnail;
                    }
                    string PostInfo = "<p><strong>Ngày tạo</strong>: " + p.CreatedDate + "</p>";
                    PostInfo        += "<p><strong>Người viết</strong>: " + p.CreatedBy + "</p>";
                    PostInfo        += "<p><strong>Ngày cập nhật</strong>: " + p.ModifiedDate + "</p>";
                    PostInfo        += "<p><strong>Người cập nhật</strong>: " + p.ModifiedBy + "</p>";
                    ltrPostInfo.Text = PostInfo;
                }
            }
        }
Пример #7
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();
        }
Пример #8
0
 public static tbl_Account LoginEmail(string Email, string Password)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         Password = PJUtils.Encrypt("userpass", Password);
         tbl_Account acc = dbe.tbl_Account.Where(a => a.Email == Email && a.Password == Password).FirstOrDefault();
         if (acc != null)
         {
             return(acc);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #9
0
        public void LoadData(int userRole)
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = PostController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page);
                }
                else
                {
                    ViewState["ID"] = id;

                    ltrEdit.Text = "";
                    if (Convert.ToInt32(ViewState["role"]) == 0 || Convert.ToInt32(ViewState["role"]) == 1)
                    {
                        ltrEdit.Text += "<a href=\"/sua-bai-viet?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>";
                        ltrEdit.Text += "<a href=\"/tao-bai-viet\" class=\"btn primary-btn fw-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i> Thêm mới</a>";
                    }
                    ltrEdit.Text += "<a href=\"javascript:;\" onclick=\"copyPostInfo(" + p.ID + ")\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-files-o\"></i> Copy nội dung</a>";
                    ltrEdit.Text += "<a href=\"javascript:;\" onclick=\"getAllPostImage('" + p.ID + "');\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-cloud-download\"></i> Tải tất cả hình ảnh</a>";

                    ltrTitle.Text   = p.Title;
                    ltrContent.Text = p.Content;


                    // thư viện ảnh
                    var image = PostImageController.GetByPostID(id);
                    imageGallery.Text  = "<ul class=\"image-gallery\">";
                    imageGallery.Text += "<li><img src=\"" + p.Image + "\" /><a href='" + p.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            if (img.Image != p.Image)
                            {
                                imageGallery.Text += "<li><img src=\"" + img.Image + "\" /><a href='" + img.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>";
                            }
                        }
                    }
                    imageGallery.Text += "</ul>";
                }
            }
        }
Пример #10
0
        public static string CheckSecurityCode(string code)
        {
            string SecurityCode = PJUtils.Encrypt("scode", code);

            var p = ConfigController.GetByTop1();

            if (SecurityCode == p.SecurityCode)
            {
                HttpContext.Current.Response.Cookies["securityCode"].Value   = SecurityCode;
                HttpContext.Current.Response.Cookies["securityCode"].Expires = DateTime.Now.AddDays(1);
                return("ok");
            }
            else
            {
                return("null");
            }
        }
Пример #11
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;

            int id = ViewState["ID"].ToString().ToInt(0);

            if (id > 0)
            {
                var d = VariableValueController.GetByID(id);
                if (d != null)
                {
                    int    variID   = Convert.ToInt32(d.VariableID);
                    string variName = d.VariableName;
                    VariableValueController.Update(id, variID, variName, txtVariableValue.Text, chkIsHidden.Checked, DateTime.Now, username, txtSKUText.Text);
                    PJUtils.ShowMessageBoxSwAlert("Cập nhật thành công", "s", true, Page);
                }
            }
        }
Пример #12
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string password = PJUtils.Encrypt("scode", txtPassword.Text);

            var p = ConfigController.GetByTop1();

            if (password == p.SecurityCode)
            {
                Response.Cookies["loginHiddenPage"].Value   = p.SecurityCode;
                Response.Cookies["loginHiddenPage"].Expires = DateTime.Now.AddDays(60);
                Response.Redirect("/sp");
            }
            else
            {
                lblError.Text    = "Sai mật khẩu!";
                lblError.Visible = true;
            }
        }
Пример #13
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    a        = AccountController.GetByUsername(username);

            if (a != null)
            {
                var re = RefundGoodController.updatestatus((ViewState["ID"].ToString()).ToInt(), Convert.ToInt32(ddlRefundStatus.SelectedValue), DateTime.Now, a.Username, txtRefundsNote.Text);
                if (re != null)
                {
                    PJUtils.ShowMessageBoxSwAlert("Cập nhật đơn hàng đổi trả thành công", "s", true, Page);
                }
                else
                {
                    PJUtils.ShowMessageBoxSwAlert("Thất bại", "e", false, Page);
                }
            }
        }
Пример #14
0
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            string barcodeValue = "";
            string productPrint = "";
            string barcodeImage = "";

            string[] list = hdfListProduct.Value.Split(';');
            if (list.Count() > 0)
            {
                productPrint += "<div class=\"qcode\">";
                for (int i = 0; i < list.Length - 1; i++)
                {
                    string[] list2    = list[i].Split(',');
                    int      quantity = list2[2].ToInt();
                    for (int j = 0; j < quantity; j++)
                    {
                        barcodeValue = list2[1];

                        barcodeImage = "/uploads/barcodes/" + barcodeValue + ".png";

                        System.Drawing.Image barCode = PJUtils.MakeBarcodeImage(barcodeValue, 2, true);

                        barCode.Save(HttpContext.Current.Server.MapPath("" + barcodeImage + ""), ImageFormat.Png);

                        productPrint += "<div class=\"item\">";
                        productPrint += "<div class=\"img\"><img src=\"data:image/png;base64, " + Convert.ToBase64String(File.ReadAllBytes(Server.MapPath("" + barcodeImage + ""))) + "\"></div>";
                        productPrint += "<div><h1>" + barcodeValue + "</h1></div>";
                        productPrint += "</div>";
                    }
                }
                productPrint += "</div>";
                string html = "";
                html         += productPrint;
                ltrprint.Text = html;

                // Delete barcode image after print
                string[] filePaths = Directory.GetFiles(Server.MapPath("/uploads/barcodes/"));
                foreach (string filePath in filePaths)
                {
                    File.Delete(filePath);
                }
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { printBarcode() });", true);
            }
        }
Пример #15
0
        protected void btnUpdateDiscountGroup_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int id = ViewState["ID"].ToString().ToInt(0);
                    if (id > 0)
                    {
                        var now = DateTime.Now;

                        var data = new tbl_DiscountGroup()
                        {
                            ID                       = id,
                            DiscountName             = txtDiscountName.Text,
                            DiscountAmount           = pDiscountAmount.Value.HasValue ? pDiscountAmount.Value.Value : 0,
                            DiscountAmountPercent    = 0,
                            QuantityProduct          = pQuantityProduct.Value.HasValue ? Convert.ToInt32(pQuantityProduct.Value.Value) : 0,
                            FeeRefund                = rRefundGoods.Value.HasValue ? rRefundGoods.Value.Value : 0,
                            NumOfDateToChangeProduct = pNumOfDateToChangeProduct.Value.HasValue ? pNumOfDateToChangeProduct.Value.Value : 0,
                            NumOfProductCanChange    = pNumOfProductCanChange.Value.HasValue ? pNumOfProductCanChange.Value.Value : 0,
                            RefundQuantityNoFee      = pRefundQuantityNoFee.Value.HasValue ? Convert.ToInt32(pRefundQuantityNoFee.Value.Value) : 0,
                            DiscountNote             = pDiscountNote.Content,
                            IsHidden                 = chkIsHidden.Checked,
                            ModifiedBy               = username,
                            ModifiedDate             = now,
                            PermittedRead            = hdfPermittedRead.Value,
                            QuantityRequired         = pQuantityRequired.Value.HasValue ? Convert.ToInt32(pQuantityRequired.Value.Value) : 0,
                        };


                        var result = DiscountGroupController.Update(data);

                        if (!String.IsNullOrEmpty(result))
                        {
                            PJUtils.ShowMessageBoxSwAlert("Cập nhật nhóm khách hàng thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
Пример #16
0
 public static int Insert(int AgentID, string Username, string Email, string Password, int RoleID, int Status, DateTime CreatedDate, string CreatedBy)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Account a = new tbl_Account();
         a.AgentID     = AgentID;
         a.Username    = Username;
         a.Email       = Email;
         a.Password    = PJUtils.Encrypt("userpass", Password);
         a.RoleID      = RoleID;
         a.Status      = Status;
         a.CreatedDate = CreatedDate;
         a.CreatedBy   = CreatedBy;
         dbe.tbl_Account.Add(a);
         dbe.SaveChanges();
         int kq = a.ID;
         return(kq);
     }
 }
Пример #17
0
        /// <summary>
        /// Setting init when load page
        /// </summary>
        private void LoadData(int ID)
        {
            var company = TransportCompanyController.GetAllTransportCompanyByID(ID);

            if (company == null)
            {
                PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhà xe " + ID, "e", true, "/danh-sach-nha-xe", Page);
            }
            else
            {
                this.hdfID.Value             = ID.ToString();
                this.txtCompanyName.Text     = company.CompanyName;
                this.txtCompanyPhone.Text    = company.CompanyPhone;
                this.txtCompanyAddress.Text  = company.CompanyAddress;
                this.rdbPrepay.SelectedValue = company.Prepay ? "true" : "false";
                this.rdbCOD.SelectedValue    = company.COD ? "true" : "false";
                this.pNote.Text = company.Note;
            }
        }
Пример #18
0
        /// <summary>
        /// Cập nhật số lượng 0 với những sản phẩm chưa được kiểm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdateQuantity_Click(object sender, EventArgs e)
        {
            var now      = DateTime.Now;
            var username = Request.Cookies["usernameLoginSystem"].Value;
            var checkID  = hdfCheckHouseID.Value.ToInt(0);
            var acc      = AccountController.GetByUsername(username);

            if (acc == null || acc.RoleID != 0)
            {
                return;
            }

            var products = CheckWarehouseController.getProductRemainingByCheckID(checkID);

            if (products == null)
            {
                PJUtils.ShowMessageBoxSwAlert("Không có sản phẩm nào chưa kiểm tra!", "i", false, Page);
            }
            else
            {
                var productUpdate = products
                                    .Select(x => new UpdateQuantityModel()
                {
                    checkID    = x.CheckWarehouseID,
                    sku        = x.ProductSKU,
                    quantity   = 0,
                    updateDate = now,
                    staff      = username
                })
                                    .ToList();
                var result = CheckWarehouseController.updateQuantity(productUpdate);

                if (result)
                {
                    PJUtils.ShowMessageBoxSwAlert("Thành cập nhật số lượng các sản phẩm chưa kiểm!", "s", true, Page);
                }
                else
                {
                    PJUtils.ShowMessageBoxSwAlert("Thất bại trong việc cập nhật số lượng các sản phẩm chưa kiểm!", "e", false, Page);
                }
            }
        }
Пример #19
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

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

                    ltrProductName.Text = p.Title;
                    ltrContent.Text     = p.Content;

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

                    var image = PostImageController.GetByPostID(id);

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

                    ltrCopyProductInfoButton.Text      = "<p><a href=\"javascript:;\" class=\"btn primary-btn copy-btn h45-btn\" onclick=\"copyPost(" + p.ID + ")\"><i class=\"fa fa-files-o\" aria-hidden=\"true\"></i> Copy</a></p>";
                    ltrDownloadProductImageButton.Text = "<a href =\"javascript:;\" class=\"btn primary-btn h45-btn\" onclick=\"getAllPostImage(" + p.ID + ");\"><i class=\"fa fa-cloud-download\" aria-hidden=\"true\"></i> Tải hình</a>";
                }
            }
        }
Пример #20
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = PJUtils.Encrypt("scode", txtPassword.Text);

            var p   = ConfigController.GetByTop1();
            var acc = AccountController.GetByUsername(username);

            if (password == p.SecurityCode && acc != null)
            {
                Response.Cookies["loginHiddenPage"].Value   = username;
                Response.Cookies["loginHiddenPage"].Expires = DateTime.Now.AddDays(90);
                Response.Redirect("/sp");
            }
            else
            {
                lblError.Text    = "Sai thông tin đăng nhập!";
                lblError.Visible = true;
            }
        }
Пример #21
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var p = PostController.GetByID(id);
                if (p == null)
                {
                    PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page);
                }
                else
                {
                    ViewState["ID"]           = id;
                    ViewState["cateID"]       = p.CategoryID;
                    hdfParentID.Value         = p.CategoryID.ToString();
                    ltrBack.Text              = "<a href=\"/xem-bai-viet?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>";
                    txtPostTitle.Text         = p.Title;
                    pContent.Content          = p.Content;
                    ddlCategory.SelectedValue = p.CategoryID.ToString();
                    ddlFeatured.SelectedValue = p.Featured.ToString();

                    if (p.Image != null)
                    {
                        ListPostThumbnail.Value = p.Image;
                        PostThumbnail.ImageUrl  = p.Image;
                    }

                    var image = PostImageController.GetByPostID(id);
                    imageGallery.Text = "<ul class=\"image-gallery\">";
                    if (image != null)
                    {
                        foreach (var img in image)
                        {
                            imageGallery.Text += "<li><img src='" + img.Image + "' /><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a></li>";
                        }
                    }
                    imageGallery.Text += "</ul>";
                }
            }
        }
        protected void btnLogin_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)
                {
                    int id = Convert.ToInt32(ViewState["ID"]);
                    var pi = ProductImageController.GetByID(id);
                    if (pi != null)
                    {
                        bool isHidden = chkIsHidden.Checked;
                        ///Lưu ảnh
                        string duongdan = "/uploads/images/";
                        string IMG      = "";
                        if (hinhDaiDien.UploadedFiles.Count > 0)
                        {
                            foreach (UploadedFile f in hinhDaiDien.UploadedFiles)
                            {
                                var o = duongdan + Guid.NewGuid() + f.GetExtension();
                                try
                                {
                                    f.SaveAs(Server.MapPath(o));
                                    IMG = o;
                                }
                                catch { }
                            }
                        }
                        else
                        {
                            IMG = imgDaiDien.ImageUrl;
                        }
                        ProductImageController.Update(id, IMG, isHidden, currentDate, username);
                        PJUtils.ShowMessageBoxSwAlert("Cập nhật hình ảnh thành công", "s", true, Page);
                    }
                }
            }
        }
Пример #23
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["usernameLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc != null)
            {
                int    AgentID = Convert.ToInt32(acc.AgentID);
                string note    = "Nhập kho 2 bằng chức năng nhập kho 2";
                var    data    = String.IsNullOrEmpty(hdfvalue.Value) ?
                                 new List <WarehousePostModel>() :
                                 JsonConvert.DeserializeObject <List <WarehousePostModel> >(hdfvalue.Value);

                foreach (var item in data)
                {
                    var stock2 = StockManagerController.warehousing2(new StockManager2()
                    {
                        AgentID           = AgentID,
                        ProductID         = item.productID,
                        ProductVariableID = item.productVariableID,
                        SKU             = item.sku,
                        ParentSKU       = item.parentSKU,
                        Type            = 1,
                        Quantity        = item.quantity,
                        QuantityCurrent = item.quantityCurrent,
                        Status          = 16,
                        Note            = note,
                        CreatedDate     = currentDate,
                        CreatedBy       = username,
                        ModifiedDate    = currentDate,
                        ModifiedBy      = username,
                    });

                    StockManagerController.warehousing1(stock2);
                }

                PJUtils.ShowMessageBoxSwAlert("Nhập kho 2 thành công!", "s", true, Page);
            }
        }
Пример #24
0
        protected void txtProductSKU_Changed(object sender, EventArgs e)
        {
            var productSKU = txtProductSKU.Text.Trim().ToUpper();

            if (!String.IsNullOrEmpty(productSKU))
            {
                if (productSKU != _productSKU)
                {
                    var product = ProductController.GetBySKU(txtProductSKU.Text.Trim().ToLower());

                    if (product != null)
                    {
                        txtProductSKU.Text = ViewState["SKU"].ToString();
                        PJUtils.ShowMessageBoxSwAlert(String.Format("Mã #SKU - {0} đã tồn tại", productSKU), "e", false, Page);
                        return;
                    }
                }

                var stocks = StockManagerController.warehousing1ByParentSKU(_productSKU);

                if (stocks.Count > 0)
                {
                    txtProductSKU.Text = ViewState["SKU"].ToString();
                    PJUtils.ShowMessageBoxSwAlert(String.Format("Sản phẩm #{0} đã tạo mã vạch nhập kho rồi nên không thể sửa", ViewState["SKU"]), "i", false, Page);
                    return;
                }

                var skuOld = ViewState["SKU"].ToString().Trim().ToUpper();
                var skuNew = productSKU;

                ViewState["SKU"] = productSKU;
                JavaScript.AfterPageLoad(Page).ExecuteCustomScript("updateVariationSKUA('{0}', '{1}');", new object[] { skuOld, skuNew });
            }
            else
            {
                txtProductSKU.Text = ViewState["SKU"].ToString();
                PJUtils.ShowMessageBoxSwAlert("Bạn đã quên nhập mã sản phẩm. Tôi đã lấy mã sản phẩm củ cho bạn", "i", false, Page);
            }
        }
Пример #25
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int id = ViewState["ID"].ToString().ToInt(0);
                    if (id > 0)
                    {
                        var d = DiscountGroupController.GetByID(id);
                        if (d != null)
                        {
                            DiscountGroupController.Update(id, txtDiscountName.Text, Convert.ToDouble(pDiscountAmount.Value), Convert.ToDouble(pDiscountAmountPercent.Value), pDiscountNote.Content, chkIsHidden.Checked, DateTime.Now, username, Convert.ToDouble(rRefundGoods.Value), Convert.ToDouble(pNumOfDateToChangeProduct.Value), Convert.ToDouble(pNumOfProductCanChange.Value));
                            PJUtils.ShowMessageBoxSwAlert("Cập nhật nhóm khách hàng thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
Пример #26
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int ID = hdfCustomerID.Value.ToInt(0);
                    if (ID > 0)
                    {
                        var c = DiscountCustomerController.GetByID(ID);
                        if (c != null)
                        {
                            DiscountCustomerController.Delete(c.ID);
                            PJUtils.ShowMessageBoxSwAlert("Xóa khách hàng thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
Пример #27
0
        protected void btnCloseCheckWareHouse_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["usernameLoginSystem"].Value;
            var      acc         = AccountController.GetByUsername(username);

            if (acc == null || acc.RoleID != 0)
            {
                return;
            }

            var result = CheckWarehouseController.closeCheckHouse(hdfCheckHouseID.Value.ToInt(0), DateTime.Now, acc.Username);

            if (result)
            {
                PJUtils.ShowMessageBoxSwAlert("Thành công trong việc đóng lại hoạt động kiểm tra kho!", "s", true, Page);
            }
            else
            {
                PJUtils.ShowMessageBoxSwAlert("Thất bại trong việc đóng lại hoạt động kiểm tra kho!", "e", true, Page);
            }
        }
Пример #28
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["userLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int id = ViewState["ID"].ToString().ToInt(0);
                    if (id > 0)
                    {
                        var d = VariableController.GetByID(id);
                        if (d != null)
                        {
                            VariableController.Update(id, txtCustomerName.Text, "", chkIsHidden.Checked, DateTime.Now, username);
                            PJUtils.ShowMessageBoxSwAlert("Cập nhật thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
Пример #29
0
        protected void btnLogin_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)
                {
                    int  productID = ViewState["productid"].ToString().ToInt(0);
                    bool isHidden  = chkIsHidden.Checked;
                    ///Lưu ảnh
                    string path = "/uploads/images/";
                    string IMG  = "";
                    if (hinhDaiDien.UploadedFiles.Count > 0)
                    {
                        foreach (UploadedFile f in hinhDaiDien.UploadedFiles)
                        {
                            var o = path + productID.ToString() + '-' + convertToSlug(Path.GetFileName(f.FileName));
                            try
                            {
                                f.SaveAs(Server.MapPath(o));
                                IMG = o;
                                ProductImageController.Insert(productID, IMG, isHidden, currentDate, username);
                            }
                            catch { }
                        }

                        PJUtils.ShowMessageBoxSwAlert("Thêm hình ảnh thành công", "s", true, Page);
                    }
                    else
                    {
                        PJUtils.ShowMessageBoxSwAlert("Vui lòng chọn hình ảnh", "e", true, Page);
                    }
                }
            }
        }
Пример #30
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DateTime currentDate = DateTime.Now;
            string   username    = Request.Cookies["usernameLoginSystem"].Value;
            int      id          = Convert.ToInt32(ViewState["ID"]);

            if (id != 0)
            {
                var variname = VariableController.GetByID(id);
                if (variname != null)
                {
                    var acc = AccountController.GetByUsername(username);
                    if (acc != null)
                    {
                        if (acc.RoleID == 0)
                        {
                            int    ID            = id;
                            string variableName  = variname.VariableName.Trim();
                            string VariableValue = txtVariableValue.Text.Trim();
                            string SKUText       = txtSKUText.Text.Trim();
                            var    check         = VariableValueController.GetByValueAndSKUText(id, VariableValue, SKUText);
                            if (check != null)
                            {
                                lblError.Text    = "Tên thuộc tính hoặc SKUText đã tồn tại vui lòng chọn tên khác.";
                                lblError.Visible = true;
                            }
                            else
                            {
                                lblError.Visible = false;
                                VariableValueController.Insert(ID, variableName, VariableValue, false, currentDate, username, SKUText);
                                PJUtils.ShowMessageBoxSwAlert("Thêm thuộc tính thành công", "s", true, Page);
                                Response.Redirect("quan-ly-thuoc-tinh-san-pham?id=" + id);
                            }
                        }
                    }
                }
            }
        }