Esempio n. 1
0
        private void ConfirmOrderButton_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (MethodOfPaymentComboBox.Text == "")//validation part
            {
                MessageBox.Show("Please, insert Method of Payment");
            }

            else
            {
                if (MethodOfPaymentComboBox.Text == "Points")
                {
                    int yourpoints = controllerObj.GetCuPoints(username);
                    if (yourpoints >= points)
                    {
                        controllerObj.DecCuPoints(username, points);
                    }
                    else
                    {
                        MessageBox.Show("Im Sorry,You Dont Have Enough Points");
                        flag = false;
                    }
                }
                else
                {
                    controllerObj.IncCuPoints(username, points);
                }


                if (flag == true)
                {
                    int r1 = controllerObj.AddOrder(CID);
                    if (r1 > 0)
                    {
                        MessageBox.Show("Thank You For Using Our Application,The Item(s) Has Moved To Your Orders Section, They Will reach you as soon as possible");

                        int       r2  = controllerObj.DeleteSC(CID);
                        DataTable dt2 = controllerObj.GetSC(CID);
                        dataGridView1.DataSource = dt2;
                        dataGridView1.Refresh();
                    }
                    else
                    {
                        MessageBox.Show("Order Failed");
                    }
                    int r = controllerObj.UpdateMethod(CID, MethodOfPaymentComboBox.Text.ToString());

                    CustomerOrders x = new CustomerOrders(username);
                    x.Show();
                    this.Hide();
                }
            }
        }