예제 #1
0
        /*
         *  Function    : OrderBtn_Click
         *  Description : Display the Cart Data Grid
         *
         *
         *  Parameters  : object sender, RoutedEventArgs e
         *
         *  Returns     : void
         *
         */
        private void OrderBtn_Click(object sender, RoutedEventArgs e)
        {
            DBMS   dbms    = new DBMS();
            string orderID = "";
            int    status  = 0;
            int    retCode;

            if (sessionID.Count != 0)
            {
                string custID   = dbms.GetCustomerID(customerName);
                string bID      = dbms.GetBranchID(branchName);
                int    retCode1 = dbms.AddOrder(custID, bID);
                if (retCode1 == 1)
                {
                    foreach (var key in ProNameQuant.Keys)
                    {
                        string proID = dbms.GetProductID(key.ToString());

                        orderID = dbms.GetOrderID();
                        retCode = dbms.AddOrderLine(orderID, proID, quantity.ToString());
                        if (retCode != 1)
                        {
                            status = 1;
                            break;
                        }
                    }
                }
                else
                {
                    status = 1;
                }

                if (status == 0)
                {
                    foreach (var i in sessionID)
                    {
                        dbms.RemoveFromCart(i);
                    }
                    Show_Cart_Click(sender, e);
                    MessageBox.Show("Order Created Successfully");
                    Window addCust = new Sales_Record(orderID, customerName, branchName, ProNameQuant);
                    addCust.Show();
                    totalP.Text = "";
                }
                else
                {
                    MessageBox.Show("Error Occured, Please try again");
                }
                customerName = "";
                ProNameQuant.Clear();
                quantity   = 0;
                branchName = "";
                cost       = 0;;
                sessionID.Clear();
            }
            else
            {
                MessageBox.Show("No product is selected");
            }
        }
예제 #2
0
        /*
         *  Function    : RemoveBtn_Click
         *  Description : Removes the Order from the cart
         *
         *
         *  Parameters  : object sender, RoutedEventArgs e
         *
         *  Returns     : void
         *
         */
        private void RemoveBtn_Click(object sender, RoutedEventArgs e)
        {
            DBMS dbms = new DBMS();

            if (sessionID.Count != 0)
            {
                foreach (var key in ProNameQuant.Keys)
                {
                    string proID = dbms.GetProductID(key.ToString());
                    dbms.UpdateDatabaseQuantity(proID, ProNameQuant[key], 1);
                }
                foreach (var i in sessionID)
                {
                    dbms.RemoveFromCart(i);
                }
                this.NavigationService.Navigate(new Cart_Page());
                Show_Cart_Click(sender, e);
                MessageBox.Show("Product removed from the Cart");
            }
            else
            {
                MessageBox.Show("No Product is selected");
            }
        }