示例#1
0
        private void BuyTicketBtn_Click(object sender, EventArgs e)
        {
            var tickets    = Convert.ToInt32(Math.Round(numTickets.Value, 0));
            var concert    = Convert.ToInt32(searchResultView.CurrentRow.Cells[0].Value);
            var useCoupons = useCouponBox.Checked;

            bool success = VendingMachine.BuyTickets(CurrentCustomer, tickets, concert, useCoupons);

            CurrentCustomer = CustomerEngine.SignIn(CurrentCustomer.Name, CurrentCustomer.Password)[0];
            if (success)
            {
                MessageBox.Show("Tickets bought!");
            }
            else
            {
                MessageBox.Show("Oh, something went wrong...");
            }
        }
示例#2
0
        private void Register_Click(object sender, EventArgs e)
        {
            string name     = Nametxt.Text;
            string password = Passwordtxt.Text;

            if (name.Length == 0 || password.Length == 0)
            {
                MessageBox.Show("Please enter name and password");
            }
            else
            {
                bool couldRegisterNewCustomer = CustomerEngine.RegisterNewCustomer(name, password);
                if (couldRegisterNewCustomer)
                {
                    MessageBox.Show("Registration successful");
                }
                else
                {
                    MessageBox.Show($"Oups, something went wrong...");
                }
            }
        }
示例#3
0
        private void buyBtn_Click(object sender, EventArgs e)
        {
            var pesetasAmount = Convert.ToInt32(Math.Round(numOfPesetasUpDown.Value, 0));
            var success       = VendingMachine.BuyPesetas(CurrentCustomer, pesetasAmount);

            if (success)
            {
                MessageBox.Show("Pesetas refilled!");
                //Here i must "sign in" (aka "refresh") the customer again to get the updated information from the Db.
                CurrentCustomer = CustomerEngine.SignIn(CurrentCustomer.Name, CurrentCustomer.Password)[0];
                MyPage myPage = new MyPage(CurrentCustomer);
                myPage.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Hmm, something went wrong...");
                MyPage myPage = new MyPage(CurrentCustomer);
                myPage.Show();
                this.Hide();
            }
        }
示例#4
0
        private void LogIn_Click(object sender, EventArgs e)
        {
            string name     = Nametxt.Text;
            string password = Passwordtxt.Text;

            if (name.Length == 0 || password.Length == 0)
            {
                MessageBox.Show("Please enter name and password");
            }
            else
            {
                List <Customer> customer = CustomerEngine.SignIn(name, password);
                if (customer.Count == 0)
                {
                    MessageBox.Show("Could not find user");
                }
                else
                {
                    this.Hide();
                    MyPage frm2 = new MyPage(customer[0]);
                    frm2.Show();
                }
            }
        }
示例#5
0
 public CustomerEngineTests()
 {
     engine = new CustomerEngine(customerRepository);
 }