Пример #1
0
        protected void stockList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            ShoppingCartList.Visible = true;
            totalLabel.Visible       = true;
            TotalbuttonLabel.Visible = true;

            string username = User.Identity.Name;
            int    itemid   = int.Parse(e.CommandArgument.ToString());
            int    employeeid;

            MessageUserControl.TryRun(() =>
            {
                //connect to your BLL
                ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                EmployeeInfo info             = secmgr.User_GetEmployee(username);
                employeeid   = info.EmployeeID;
                int quantity = int.Parse((e.Item.FindControl("QuantityLabel") as TextBox).Text);
                ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                sysmgr.Add_AddToCart(employeeid, itemid, quantity);//Need to put the quantity in the list!!!!!

                List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                notificationIcon.Style.Remove("visibility");
                //TotalButton.InnerText = (e.Item.FindControl("Total") as Label).ToString();
                ShoppingCartList.DataSource = infos;
                notificationIcon.Value      = infos.Count.ToString();
                ShoppingCartList.DataBind();

                refresh_totallabel();
            }, "Shopping Items Added", $"The item has been addded, you have currently {notificationIcon.Value} items in the shopping cart");
        }
Пример #2
0
        public void refresh_shoppingcart()
        {
            string username = User.Identity.Name;
            int    employeeid;
            ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
            EmployeeInfo           info   = secmgr.User_GetEmployee(username);

            employeeid = info.EmployeeID;

            ShoppingCartItemController  systemmgr = new ShoppingCartItemController();
            List <UserShoppingCartItem> infos     = systemmgr.List_ItemsForShoppingCart(employeeid);

            ShoppingCartList.DataSource = infos;
            ShoppingCartList.DataBind();
            totalLabel.DataBind();
        }
Пример #3
0
        protected void Checkout_Click(object sender, EventArgs e)
        {
            SaleList.Visible          = true;
            totalLabel2.Visible       = true;
            TaxLabel.Visible          = true;
            subtotalLabel.Visible     = true;
            CouponTextBox.Visible     = true;
            DiscountLabel.Visible     = true;
            CheckCouponButton.Visible = true;
            Label2.Visible            = true;
            Label3.Visible            = true;
            Label6.Visible            = true;
            Label4.Visible            = true;
            Label8.Visible            = true;
            PaymentTypeDDL.Visible    = true;

            string username = User.Identity.Name;
            int    employeeid;

            if (ShoppingCartList.Items.Count == 0)
            {
                MessageUserControl.ShowInfo("Warning", "No items in current shopping cart");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                    EmployeeInfo info             = secmgr.User_GetEmployee(username);
                    employeeid = info.EmployeeID;
                    ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                    List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                    if (infos.Count == 0)
                    {
                        MessageUserControl.ShowInfo("Warning", "No items in current shopping cart");
                    }
                    SaleList.DataSource = infos;
                    SaleList.DataBind();
                }, "Great", "Here is your chekout info");
                checkout_details();
            }
        }
Пример #4
0
        protected void PlaceOrder_Click(object sender, EventArgs e)
        {
            List <SaleDetailsList> listsaledetails = new List <SaleDetailsList>();
            List <ListSale>        listsales       = new List <ListSale>();
            string username = User.Identity.Name;
            int    employeeid;

            if (SaleList.Items.Count == 0)
            {
                MessageUserControl.ShowInfo("Warning", "Please add at least one product in order to place order.");
            }
            else
            {
                if (PaymentTypeDDL.SelectedIndex == 0)
                {
                    MessageUserControl.ShowInfo("Warning", "Please select a payment method to place order.");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                        EmployeeInfo info             = secmgr.User_GetEmployee(username);
                        employeeid = info.EmployeeID;

                        foreach (ListViewItem item in SaleList.Items)
                        {
                            Label quantityLabel     = item.FindControl("QuantityLabel") as Label;
                            Label priceLabel        = item.FindControl("PriceLabel") as Label;
                            HiddenField itemIDLabel = item.FindControl("StockItemIDLabel") as HiddenField;
                            Label descriptionLabel  = item.FindControl("DescriptionLabel") as Label;

                            SaleDetailsList newSaleDetailsList = new SaleDetailsList();
                            newSaleDetailsList.Description     = descriptionLabel.Text;
                            newSaleDetailsList.Price           = decimal.Parse(priceLabel.Text.Replace(@"$", string.Empty));
                            newSaleDetailsList.Quantity        = int.Parse(quantityLabel.Text);
                            newSaleDetailsList.StockItemID     = int.Parse(itemIDLabel.Value);
                            listsaledetails.Add(newSaleDetailsList);
                        }

                        Label SubtotalLabel    = (Label)UpdatePanel3.FindControl("totalLabel2") as Label;
                        Label taxLabel         = (Label)UpdatePanel3.FindControl("TaxLabel") as Label;
                        CouponController cpmgr = new CouponController();
                        Coupon coupon          = cpmgr.Coupons_Get(CouponTextBox.Text);

                        ListSale newSaleList    = new ListSale();
                        newSaleList.PaymentType = PaymentTypeDDL.SelectedItem.ToString();
                        newSaleList.CouponID    = coupon == null ? null : coupon.CouponID;
                        newSaleList.SubTotal    = decimal.Parse(SubtotalLabel.Text.Replace(@"$", string.Empty));
                        newSaleList.TaxAmount   = decimal.Parse(taxLabel.Text.Replace(@"$", string.Empty));
                        listsales.Add(newSaleList);

                        SaleDetailController sysmgr = new SaleDetailController();
                        sysmgr.Add_AddToSale(employeeid, listsales, listsaledetails);

                        foreach (ListViewItem item in SaleList.Items)
                        {
                            HiddenField itemidLabel = item.FindControl("ItemIDLabel") as HiddenField;
                            int itemid = int.Parse(itemidLabel.Value);
                            ShoppingCartItemController spcitemmgr = new ShoppingCartItemController();
                            spcitemmgr.DeleteShoppingItems(employeeid, itemid);
                        }

                        ShoppingCartController spcmgr = new ShoppingCartController();
                        spcmgr.DeleteShoppingCart(employeeid);

                        //refresh the table
                        ShoppingCartItemController systemmgr = new ShoppingCartItemController();
                        List <UserShoppingCartItem> infos    = systemmgr.List_ItemsForShoppingCart(employeeid);
                        ShoppingCartList.DataSource          = infos;
                        ShoppingCartList.DataBind();

                        subtotalLabel.Text           = "$" + "0";
                        TaxLabel.Text                = "$" + "0";
                        CouponTextBox.Text           = "";
                        DiscountLabel.Text           = "$" + "0";
                        totalLabel2.Text             = "$" + "0";
                        PaymentTypeDDL.SelectedIndex = 0;
                    }, "Success", "Order has been placed");
                }
            }
        }
Пример #5
0
        protected void ShoppingCartList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "remove")
            {
                string username = User.Identity.Name;
                int    itemid   = int.Parse(e.CommandArgument.ToString());
                int    employeeid;

                if (ShoppingCartList.Items.Count == 0)
                {
                    MessageUserControl.ShowInfo("Warning", "You have clear the shopping cart.");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                        EmployeeInfo info             = secmgr.User_GetEmployee(username);
                        employeeid = info.EmployeeID;
                        ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                        sysmgr.DeleteShoppingItems(employeeid, itemid);

                        List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                        ShoppingCartList.DataSource       = infos;
                        notificationIcon.Value            = infos.Count.ToString();
                        ShoppingCartList.DataBind();
                        totalLabel.DataBind();

                        refresh_totallabel();
                    }, "Removed", $"Item(s) {itemid} have been removed");
                }
            }
            else if (e.CommandName == "refresh")
            {
                string username = User.Identity.Name;
                int    itemid   = int.Parse(e.CommandArgument.ToString());
                int    employeeid;
                int    quantity = int.Parse((e.Item.FindControl("QuantityLabel") as TextBox).Text);

                MessageUserControl.TryRun(() =>
                {
                    ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                    EmployeeInfo info             = secmgr.User_GetEmployee(username);
                    employeeid = info.EmployeeID;
                    ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                    sysmgr.Update_RefreshCart(employeeid, itemid, quantity);

                    List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                    ShoppingCartList.DataSource       = infos;
                    notificationIcon.Value            = infos.Count.ToString();
                    ShoppingCartList.DataBind();
                    totalLabel.DataBind();

                    refresh_totallabel();
                }, "Updated", $"Item(s) {itemid} have been updated");
            }
            else
            {
                MessageUserControl.ShowInfo("Glad you found this error, cauz I don't even know what should I call this error.");
            }
        }