Ejemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    int id = ViewState["ID"].ToString().ToInt(0);
                    if (id > 0)
                    {
                        var d = DiscountGroupController.GetByID(id);
                        if (d != null)
                        {
                            var dc = DiscountController.update(id, txtQuantity.Text.ToInt(), txtDiscountPerProduct.Text.ToInt(), username);
                            if (dc > 0)
                            {
                                PJUtils.ShowMessageBoxSwAlert("Cập nhật thành công", "s", true, Page);
                            }
                            else
                            {
                                PJUtils.ShowMessageBoxSwAlert("Thất bại", "e", false, Page);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var d = DiscountGroupController.GetByID(id);
                if (d != null)
                {
                    ViewState["ID"] = id;
                    LoadCustomerIn(id);
                    LoadCustomerNotIn(id);
                }
            }
        }
Ejemplo n.º 3
0
        public void LoadData()
        {
            LoadAccount();

            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var discountGroup = DiscountGroupController.GetByID(id);
                if (discountGroup != null)
                {
                    ViewState["ID"]                 = id;
                    txtDiscountName.Text            = discountGroup.DiscountName;
                    pQuantityRequired.Value         = discountGroup.QuantityRequired;
                    pDiscountAmount.Value           = discountGroup.DiscountAmount;
                    pQuantityProduct.Value          = discountGroup.QuantityProduct;
                    rRefundGoods.Value              = discountGroup.FeeRefund;
                    pNumOfDateToChangeProduct.Value = discountGroup.NumOfDateToChangeProduct;
                    pNumOfProductCanChange.Value    = discountGroup.NumOfProductCanChange;
                    pRefundQuantityNoFee.Value      = discountGroup.RefundQuantityNoFee;
                    pDiscountNote.Content           = discountGroup.DiscountNote;
                    chkIsHidden.Checked             = discountGroup.IsHidden.HasValue ? discountGroup.IsHidden.Value : false;
                    hdfPermittedRead.Value          = discountGroup.PermittedRead;

                    // Create tag Owner
                    var owner = new { value = acc.ID, text = acc.Username };

                    // Create tag orther
                    var accountOther = AccountController.GetAllUser()
                                       .Where(x =>
                                              x.ID.ToString() == hdfPermittedRead.Value ||
                                              hdfPermittedRead.Value.StartsWith(x.ID.ToString() + ",") ||
                                              hdfPermittedRead.Value.Contains("," + x.ID.ToString() + ",") ||
                                              hdfPermittedRead.Value.EndsWith("," + x.ID.ToString())
                                              )
                                       .Where(x => x.ID != owner.value)
                                       .Select(x => new
                    {
                        value = x.ID,
                        text  = x.Username
                    })
                                       .ToList();

                    var script = "$(function () { showOwner(" + JsonConvert.SerializeObject(owner) + "); showAccoutPermittedAccess(" + JsonConvert.SerializeObject(accountOther) + "); });";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", script, true);
                }
            }
        }
Ejemplo n.º 4
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)
                {
                    DiscountGroupController.Insert(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));
                    Response.Redirect("/danh-sach-nhom-khach-hang.aspx");
                    //PJUtils.ShowMessageBoxSwAlert("Tạo mới thành công", "s", true, Page);
                }
            }
        }
Ejemplo n.º 5
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void LoadData()
        {
            int id = Request.QueryString["id"].ToInt(0);

            if (id > 0)
            {
                var d = DiscountGroupController.GetByID(id);
                if (d != null)
                {
                    ViewState["ID"]                 = id;
                    txtDiscountName.Text            = d.DiscountName;
                    pDiscountAmount.Value           = d.DiscountAmount;
                    pDiscountAmountPercent.Value    = d.DiscountAmountPercent;
                    pDiscountNote.Content           = d.DiscountNote;
                    chkIsHidden.Checked             = Convert.ToBoolean(d.IsHidden);
                    rRefundGoods.Value              = Convert.ToDouble(d.FeeRefund);
                    pNumOfDateToChangeProduct.Value = Convert.ToDouble(d.NumOfDateToChangeProduct);
                    pNumOfProductCanChange.Value    = Convert.ToDouble(d.NumOfProductCanChange);
                }
            }
        }
Ejemplo n.º 7
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
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)
                        {
                            SupplierController.Update(id, txtSupplierName.Text, pDiscountNote.Content, txtSupplierPhone.Text, txtSupplierAddress.Text,
                                                      txtSupplierEmail.Text, chkIsHidden.Checked, DateTime.Now, username);
                            PJUtils.ShowMessageBoxSwAlert("Cập nhật thành công", "s", true, Page);
                        }
                    }
                }
            }
        }
        public void LoadData()
        {
            string s = "";

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

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

            if (acc != null)
            {
                int agentID = Convert.ToInt32(acc.AgentID);
                var orders  = DiscountGroupController.GetAll(s);
                if (orders.Count > 0)
                {
                    pagingall(orders);
                }
            }
        }
Ejemplo n.º 10
0
        protected void btnCreateDiscountGroup_Click(object sender, EventArgs e)
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.RoleID == 0)
                {
                    var now  = DateTime.Now;
                    var data = new tbl_DiscountGroup()
                    {
                        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,
                        CreatedBy        = username,
                        CreatedDate      = now,
                        ModifiedBy       = username,
                        ModifiedDate     = now,
                        PermittedRead    = hdfPermittedRead.Value,
                        QuantityRequired = pQuantityRequired.Value.HasValue ? Convert.ToInt32(pQuantityRequired.Value.Value) : 0
                    };

                    DiscountGroupController.Insert(data);

                    Response.Redirect("/danh-sach-nhom-khach-hang.aspx");
                    PJUtils.ShowMessageBoxSwAlert("Tạo mới thành công", "s", true, Page);
                }
            }
        }
Ejemplo n.º 11
0
        public void LoadData()
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);

            if (acc != null)
            {
                if (acc.ID == 1)
                {
                    hdfPermittedEdit.Value = "1";
                }
                else
                {
                    hdfPermittedEdit.Value = "0";
                }

                var groups         = DiscountGroupController.getByAccount(acc);
                var customerGroups = DiscountCustomerController.getByDiscountGroup(groups)
                                     .Where(x => x.DiscountGroupID.HasValue)
                                     .GroupBy(g => g.DiscountGroupID.Value)
                                     .Select(x => new
                {
                    DiscountGroupID = x.Key,
                    NumberCustomer  = x.Count()
                })
                                     .ToList();

                var discounts = groups
                                .GroupJoin(
                    customerGroups,
                    g => g.ID,
                    c => c.DiscountGroupID,
                    (g, c) => new { group = g, customer = c }
                    )
                                .SelectMany(
                    x => x.customer.DefaultIfEmpty(),
                    (parent, child) => new DiscountGroupModel()
                {
                    ID                       = parent.group.ID,
                    DiscountName             = parent.group.DiscountName,
                    NumberCustomer           = child != null ? child.NumberCustomer : 0,
                    DiscountAmount           = parent.group.DiscountAmount,
                    DiscountAmountPercent    = parent.group.DiscountAmountPercent,
                    DiscountNote             = parent.group.DiscountNote,
                    IsHidden                 = parent.group.IsHidden,
                    CreatedDate              = parent.group.CreatedDate,
                    CreatedBy                = parent.group.CreatedBy,
                    ModifiedDate             = parent.group.ModifiedDate,
                    ModifiedBy               = parent.group.ModifiedBy,
                    FeeRefund                = parent.group.FeeRefund,
                    NumOfDateToChangeProduct = parent.group.NumOfDateToChangeProduct,
                    NumOfProductCanChange    = parent.group.NumOfProductCanChange,
                    QuantityProduct          = parent.group.QuantityProduct,
                    RefundQuantityNoFee      = parent.group.RefundQuantityNoFee,
                    PermittedRead            = parent.group.PermittedRead
                }
                    )
                                .ToList();

                if (discounts.Count > 0)
                {
                    pagingall(discounts);
                }
            }
        }
Ejemplo n.º 12
0
        public void LoadData()
        {
            if (discountGroupID > 0)
            {
                string username = Request.Cookies["usernameLoginSystem"].Value;
                acc = AccountController.GetByUsername(username);

                var discount = DiscountGroupController.GetByID(discountGroupID);
                if (discount != null)
                {
                    hdfDiscountGroupID.Value = discountGroupID.ToString();


                    // Hiển thị thông tin của discount group
                    ltrGroupName.Text = discount.DiscountName;
                    var numberCustomer = DiscountCustomerController.GetByGroupID(discount.ID).Count;
                    if (numberCustomer > 0)
                    {
                        ltrNumberCustomer.Text = String.Format("{0:N0} khách", numberCustomer);
                    }
                    if (discount.DiscountAmount.HasValue && discount.DiscountAmount.Value > 0)
                    {
                        ltrDiscount.Text = String.Format("{0:N0}đ/cái", discount.DiscountAmount);
                    }
                    if (discount.QuantityRequired.HasValue && discount.QuantityRequired.Value > 0)
                    {
                        ltrQuantityRequired.Text = String.Format("{0:N0} cái", discount.QuantityRequired);
                    }
                    if (discount.QuantityProduct.HasValue && discount.QuantityProduct.Value > 0)
                    {
                        ltrQuantityProduct.Text = String.Format("{0:N0} cái", discount.QuantityProduct);
                    }
                    if (discount.FeeRefund.HasValue && discount.FeeRefund.Value > 0)
                    {
                        ltrFeeRefund.Text = String.Format("{0:N0}đ/cái", discount.FeeRefund);
                    }
                    else
                    {
                        ltrFeeRefund.Text = "miễn phí";
                    }
                    if (discount.NumOfDateToChangeProduct.HasValue && discount.NumOfDateToChangeProduct.Value > 0)
                    {
                        ltrNumberOfDateToChnageProduct.Text = String.Format("{0:N0} ngày", discount.NumOfDateToChangeProduct);
                    }
                    if (discount.NumOfProductCanChange.HasValue && discount.NumOfProductCanChange.Value > 0)
                    {
                        ltrNumberOfProductCanChange.Text = String.Format("{0:N0} cái/{1} ngày", discount.NumOfProductCanChange, discount.NumOfDateToChangeProduct);
                    }
                    if (discount.RefundQuantityNoFee.HasValue && discount.RefundQuantityNoFee.Value > 0)
                    {
                        ltrRefundQuantityNoFee.Text = String.Format("{0:N0} cái", discount.RefundQuantityNoFee);
                    }

                    string createdBy = "";
                    if (acc.RoleID == 2)
                    {
                        createdBy = acc.Username;
                    }
                    // Hiển thị thông tin khách hàng được hưởng chiết khấu
                    var customer = CustomerController.getByDiscountGroupID(discountGroupID, createdBy)
                                   .OrderBy(o => o.FullName)
                                   .ToList();

                    if (customer.Count > 0)
                    {
                        pagingall(customer);
                    }
                }
            }
        }