Пример #1
0
        protected void CheckCouponButton_Click(object sender, EventArgs e)
        {
            double           totalprice = double.Parse(subtotalLabel.Text.Replace(@"$", string.Empty));
            double           taxprice   = double.Parse(TaxLabel.Text.Replace(@"$", string.Empty));
            CouponController sysmgr     = new CouponController();
            Coupon           info       = sysmgr.Coupons_Get(CouponTextBox.Text);

            if (info == null)
            {
                PercentageLabel.Text = "";
                DiscountLabel.Text   = "0";
                MessageUserControl.ShowInfo("Warning", "Your coupon does not exist");
            }
            else
            {
                if (DateTime.Now > info.EndDate)
                {
                    PercentageLabel.Text = "";
                    DiscountLabel.Text   = "0";
                    MessageUserControl.ShowInfo("Warning", "Your coupon seems already expired");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        PercentageLabel.Text = info.CouponDiscount.ToString();
                        int discountTemp     = info.CouponDiscount;
                        DiscountLabel.Text   = "$" + (totalprice * (double)discountTemp * 0.01).ToString();
                        totalLabel2.Text     = "$" + ((totalprice + taxprice - (totalprice * (double)discountTemp * 0.01))).ToString();
                    }, "Success", "Your coupon is valid!");
                }
            }
        }
Пример #2
0
 protected void CouponUseButton_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         CouponController csysmgr = new CouponController();
         Coupon cinfo             = csysmgr.Coupons_Get(CouponInput.Text);
         if (cinfo == null)
         {
             MessageUserControl.ShowInfo("Warning", "Please enter valid coupon value!");
         }
         else
         {
             if (cinfo.StartDate > DateTime.Now || cinfo.EndDate < DateTime.Now)
             {
                 MessageUserControl.ShowInfo("Warning", "This coupon cannot be used for now! Please check the valid date!");
             }
             else
             {
             }
         }
     }, "Success", "Coupom has been used");
 }
Пример #3
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");
                }
            }
        }