Beispiel #1
0
        public void CartProductBox_ChangeProductQuantity(object sender, EventArgs e)
        {
            NumericUpDown    NumericCartProductQuantity = (sender as NumericUpDown);
            CartProductPanel CartProductPanel           = (NumericCartProductQuantity.Parent as CartProductPanel);

            OrderProduct CartProduct = CartProductPanel.CartProduct;

            if (CartProduct.Quantity < Convert.ToInt16(NumericCartProductQuantity.Value))
            {
                CartProduct.Quantity++;
                CartProduct.Product.Quantity--;
            }
            else
            {
                CartProduct.Quantity--;
                CartProduct.Product.Quantity++;
            }

            if (CartProduct.Product.Promotion)
            {
                CartProductPanel.LabelCartProductValue.Text = "$" + (CartProduct.Quantity * CartProduct.Product.PromotionValue).ToString("0.00");
            }
            else
            {
                CartProductPanel.LabelCartProductValue.Text = "$" + (CartProduct.Quantity * CartProduct.Product.Value).ToString("0.00");
            }

            CartPanel.UpdateView();
        }
Beispiel #2
0
        public void Reset()
        {
            ProductBox.Products = DAO.Products.ListEnableds();
            ProductBox.Products = ProductBox.Products.OrderBy(Product => !Product.Promotion).ThenByDescending(Product => Product.PromotionPercentage).ToList();
            ProductBox.UpdateView();

            CartPanel.Order.Products.Clear();
            CartPanel.CartProductBox.UpdateView();
            CartPanel.UpdateView();
        }
Beispiel #3
0
 private void btnCartInfo_Click(object sender, EventArgs e)
 {
     if (ActiveCustomer.Cart.Count != 0)
     {
         CartPanel cart = new CartPanel();
         cart.ShowDialog();
     }
     else
     {
         MessageBox.Show("Sepette Ürün Yok");
     }
 }
Beispiel #4
0
        public void CartProductBox_ClickProductRemove(object sender, EventArgs e)
        {
            Button       ButtonCartProductRemove = (Button)sender;
            OrderProduct CartProduct             = (ButtonCartProductRemove.Parent as CartProductPanel).CartProduct;

            if (MessageBox.Show("Deseja excluir o produto (" + CartProduct.Product.Name + ") do seu carrinho?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes))
            {
                CartPanel.CartProductBox.CartProducts.Remove(CartProduct);
                CartPanel.CartProductBox.UpdateView();
            }

            CartPanel.UpdateView();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session[fromPageSession] != null)
                {
                    Session[fromPageSession] = pageName;
                }

                DatabaseConnection connection = new DatabaseConnection();
                MySqlConnection    conn       = connection.getConnection();

                if (Session[tableIDSession] != null && Session[userNameSession] != null)
                {     //if user is signed in with their table
                    if (Session[orderIDSession] != null)
                    { //user has their order placed
                        if (Session[cartSession] != null)
                        {
                            cart = (CartPanel)Session[cartSession];
                            if (cart.getTotalPrice() == 0)
                            {
                                cart.order.getOrderItemsObject().close();
                                Response.Redirect(Session[fromPageSession].ToString(), false);
                            }
                            pnlCheckout.Controls.Add(cart.getHeadPanel());

                            Button checkOut = new Button();
                            checkOut.Text     = "Confirm Order";
                            checkOut.CssClass = "btn btn-dark";
                            checkOut.Click   += new EventHandler(checkoutBtnClicked);
                            pnlCheckout.Controls.Add(checkOut);
                        }
                    }
                    else
                    {
                        Response.Redirect("CustomerOrder.aspx", false);
                    }
                }
                else
                {//send them to login/signup page
                    Response.Redirect("CustomerLogin.aspx", false);
                }
            }
            catch (Exception x)
            {
                Session[errorSession] = x.Message.ToString();
                Response.Redirect("Error.aspx");
            }
        }
Beispiel #6
0
        public void CartPanel_ClickFinishOrder(object sender, EventArgs e)
        {
            if (!CartPanel.ValidateProducts())
            {
                MessageBox.Show("O carrinho está vazio.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!CartPanel.ValidatePayment())
            {
                MessageBox.Show("Selecione um método de pagamento.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (Session.User == null)
            {
                FormLogin login = new FormLogin(this);
                login.Login += Login_OnLogin;
                login.ShowDialog();

                return;
            }

            if (MessageBox.Show("Tem certeza que deseja confirmar seu pedido?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes))
            {
                CartPanel.Order.Customer  = (Customer)Session.User;
                CartPanel.Order.Status    = OrderStatus.Pending;
                CartPanel.Order.CreatedAt = DateTime.Now;
                CartPanel.Order.UpdatedAt = DateTime.Now;

                try {
                    DAO.Orders.Add(CartPanel.Order);
                    MessageBox.Show("Pedido inserido com sucesso.");

                    Session.User = DAO.Customers.FindOneByUsername(Session.User.Username);

                    Reset();
                } catch {
                    MessageBox.Show("Ocorreu um erro interno, tente novamente mais tarde.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session[errorSession]    = null;
            Session[fromPageSession] = pageName;

            try
            {
                btnSearch_Click(new object(), new EventArgs());
                if (Session[userNameSession] != null)
                {//if the user has logged in, display their name instead of the log in label on the navbar
                    lblLogin.Text = Session[userNameSession].ToString();

                    if (Session[tableIDSession] != null)
                    {     //if logged in user has tableid (should be if they logged in)
                        if (Session[orderIDSession] != null)
                        { //if the user had an order pending but closed the thing
                            if (order == null)
                            {
                                order = new Order(int.Parse(Session[orderIDSession].ToString())); //at this point we need a customer ID to make a new order, have to fix
                                order.updateOrderNameAndTable(Session[userNameSession].ToString(), int.Parse(Session[tableIDSession].ToString()));
                                if (Session[selectedWaiterIDSession] != null)
                                {
                                    if (order.updateOrderWaiter(int.Parse(Session[selectedWaiterIDSession].ToString())) != true)
                                    {
                                        throwEx(new Exception("Could not set your waiter, please contact a staff member"));
                                    }
                                }
                                else
                                {
                                    throwEx(new Exception("Could not find selected waiter, please log in again"));
                                }
                            }
                        }
                        else
                        {
                            if (order == null)
                            {
                                if (Session[selectedWaiterIDSession] != null)
                                {
                                    order = new Order(Session[userNameSession].ToString(), int.Parse(Session[tableIDSession].ToString()), 0, 0, int.Parse(Session[selectedWaiterIDSession].ToString()), 0);
                                    Session[orderIDSession] = order.getOrderID();
                                }
                                else
                                {
                                    throwEx(new Exception("Could not find selected waiter, please log in again"));
                                }
                            }
                        }
                    }
                    else
                    {
                        Page_Init(new object(), new EventArgs());
                    }
                }
                else
                {
                    Response.Redirect("CustomerLogin.aspx", false);
                    Context.ApplicationInstance.CompleteRequest();
                }
                if (cartPanel == null)
                {
                    cartPanel = new CartPanel(order.getConnection(), order.getOrderID());
                }


                if (!IsPostBack || !isSearched)
                {//if the user hasn't searched anything or 1st time page loaded
                    showProducts(conn, "SELECT * FROM `MENU-ITEM`");
                }

                if (isSearched)
                {
                    //if the user did search in the products for what the user wants
                    isSearched = false;
                }

                pnlOrder.Controls.Clear();
                pnlOrder.Controls.Add(cartPanel.getHeadPanel());
            }
            catch (Exception ee)
            {
                throwEx(ee);
            }
        }