示例#1
0
        protected void ClearButton1_Click(object sender, EventArgs e)
        {
            var username = User.Identity.Name;
            SecurityController securitymgr = new SecurityController();
            int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
            EmployeeController sysmgrs = new EmployeeController();
            Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

            int employeeID = info.EmployeeID;



            MessageUserControl.TryRun(() =>
            {
                ShoppingCartController sysmgr = new ShoppingCartController();

                sysmgr.ClearButton_Shopping(employeeID);

                List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                CartSalesGridView.DataSource = datainfo;

                AddButtonn.Enabled = true;
                //InvoiceIDText.Text = null;
                //InvoiceIDText.Visible = false;
                CartSalesGridView.Enabled = true;
                CartSalesGridView.DataBind();
                QuantityTextBox.Text = "1";
                PanelInvoice.Visible = false;
                CategoryDDL.Enabled  = true;
                ProductDDL.Enabled   = true;
            }, "Empty", "Shopping Cart is Empty Now");
        }
示例#2
0
        protected void AddButtonn_Click(object sender, EventArgs e)
        {
            CartSalesGridView.Enabled   = true;
            PanelPaymentButtons.Visible = true;
            Product products = new Product();

            products.QuantityOnOrder = int.Parse(QuantityTextBox.Text);

            if (string.IsNullOrEmpty(CategoryDDL.SelectedValue) || string.IsNullOrEmpty(ProductDDL.SelectedValue))
            {
                MessageUserControl.ShowInfo("Required Data", "Please Select Category and Product");
            }
            else if (CategoryDDL.SelectedIndex == 0)
            {
                MessageUserControl.ShowInfo("Please Select a Category");
            }
            //else if(ProductDDL.SelectedIndex == 0)
            //{
            //    MessageUserControl.ShowInfo("Please Select a Product");
            //}
            else if (products.QuantityOnOrder <= 0)
            {
                MessageUserControl.ShowInfo("Required Data", "Please Enter Quantity, Should be greater or equal 1");
                PanelPaymentButtons.Visible = false;
            }
            else
            {
                string category = CategoryDDL.SelectedValue;

                int qty       = int.Parse(QuantityTextBox.Text);
                int productid = int.Parse(ProductDDL.SelectedValue);

                var username = User.Identity.Name;
                SecurityController securitymgr = new SecurityController();
                int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
                EmployeeController sysmgrs = new EmployeeController();
                Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

                int employeeID = info.EmployeeID;



                MessageUserControl.TryRun(() =>
                {
                    ShoppingCartController sysmgr = new ShoppingCartController();
                    sysmgr.Add_ItemToCart(employeeID, productid, qty);

                    List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                    CartSalesGridView.DataSource = datainfo;
                    CartSalesGridView.DataBind();
                }, "Adding Item", "Item has been added to the cart");

                var controller = new ShoppingCartController();
                var countTotal = controller.ShoppingCart_OrderList();
                SubtotalText.Text = countTotal.Sum(x => x.Quantity * x.Price).ToString("C");
                TaxText.Text      = countTotal.Sum(t => t.Quantity * t.Price * decimal.Parse(0.05.ToString())).ToString("C");
                TotalText.Text    = countTotal.Sum(tos => tos.Quantity * tos.Price * decimal.Parse(0.05.ToString()) + (tos.Quantity * tos.Price)).ToString("C");
            }
        }
示例#3
0
        protected void CartSalesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Refresh"))
            {
                PanelPaymentButtons.Visible = true;
                int productid = int.Parse(e.CommandArgument.ToString());
                int qty       = 0;
                for (int rowindex = 0; rowindex < CartSalesGridView.Rows.Count; rowindex++)
                {
                    if ((CartSalesGridView.Rows[rowindex].FindControl("ProductID") as Label).Text == e.CommandArgument.ToString())
                    {
                        qty = int.Parse((CartSalesGridView.Rows[rowindex].FindControl("Quantity") as TextBox).Text);
                    }
                }
                if (qty <= 0)
                {
                    MessageUserControl.ShowInfo("Quantity Cannot be negative number or zero, Please add quantity or remove the item from your Cart.");
                }
                else
                {
                    var username = User.Identity.Name;
                    SecurityController securitymgr = new SecurityController();
                    int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
                    EmployeeController sysmgrs = new EmployeeController();
                    Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

                    int employeeID = info.EmployeeID;

                    MessageUserControl.TryRun(() =>
                    {
                        ShoppingCartController sysmgr = new ShoppingCartController();

                        //Call for adjusting quantity
                        sysmgr.Quantity_Refresh(employeeID, productid, qty);

                        List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                        CartSalesGridView.DataSource = datainfo;
                        CartSalesGridView.DataBind();
                    }, "Refreshing", "Item Quantity Updated");
                    var controller = new ShoppingCartController();
                    var countTotal = controller.ShoppingCart_OrderList();
                    SubtotalText.Text = countTotal.Sum(x => x.Quantity * x.Price).ToString();
                    TaxText.Text      = countTotal.Sum(t => t.Quantity * t.Price * decimal.Parse(0.05.ToString())).ToString();
                    TotalText.Text    = countTotal.Sum(tos => tos.Quantity * tos.Price * decimal.Parse(0.05.ToString()) + (tos.Quantity * tos.Price)).ToString();
                }
            }
            else
            {
                PanelPaymentButtons.Visible = true;
                int productid = int.Parse(e.CommandArgument.ToString());


                var username = User.Identity.Name;
                SecurityController securitymgr = new SecurityController();
                int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
                EmployeeController sysmgrs = new EmployeeController();
                Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

                int employeeID = info.EmployeeID;

                MessageUserControl.TryRun(() =>
                {
                    ShoppingCartController sysmgr = new ShoppingCartController();

                    sysmgr.Delete_ProductItem(employeeID, productid);

                    List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                    CartSalesGridView.DataSource = datainfo;
                    CartSalesGridView.DataBind();
                }, "Deleting Product", "Item Has been Removed from the Cart");
                var controller = new ShoppingCartController();
                var countTotal = controller.ShoppingCart_OrderList();
                SubtotalText.Text = countTotal.Sum(x => x.Quantity * x.Price).ToString("C");
                TaxText.Text      = countTotal.Sum(t => t.Quantity * t.Price * decimal.Parse(0.05.ToString())).ToString("C");
                TotalText.Text    = countTotal.Sum(tos => tos.Quantity * tos.Price * decimal.Parse(0.05.ToString()) + (tos.Quantity * tos.Price)).ToString("C");
            }
        }