Exemple #1
0
        private async void AuthenticateUser()
        {
            string usernameInput = UserNameTextbox.Text;
            string passwordInput = PasswordTextbox.Text;

            try
            {
                LoaderForm loader = new LoaderForm();
                this.Hide();
                loader.Show();
                await Task.Run(() => { employee = new Employee(usernameInput, passwordInput); });

                loader.Close();
                int returnedEmployeeID = employee.GetEmployeeID();
                if (returnedEmployeeID > 0)
                {
                    POSForm posForm = new POSForm(returnedEmployeeID);
                    posForm.Show();
                    this.Close();
                }
            }
            catch (Exception egf)
            {
                this.Show();
                MessageBox.Show("Invalid username and password. Try again...");
                UserNameTextbox.Text = "";
                PasswordTextbox.Text = "";
            }
        }
Exemple #2
0
        //get input of payments and finishing order payment
        private async void CompleteOrderTransaction()
        {
            decimal employeeDiscount = 0;

            decimal.TryParse(OrderDiscountControl.UserInput, out employeeDiscount);
            decimal TotalMoneyPaidByCash = 0;

            decimal.TryParse(CashPaymentControl.UserInput, out TotalMoneyPaidByCash);
            decimal TotalMoneyPaidByCard = 0;

            decimal.TryParse(CardPaymentControl.UserInput, out TotalMoneyPaidByCard);
            int TotalRedeemPoints = 0;

            int.TryParse(RedeemPointControl.UserInput, out TotalRedeemPoints);
            try
            {
                CurrentOrder.AddEmployeeDiscount(employeeDiscount);
                CurrentOrder.PayByCard(TotalMoneyPaidByCard);
                CurrentOrder.PayByCash(TotalMoneyPaidByCash);
                CurrentOrder.RedeemCustomerPoints(TotalRedeemPoints);
                var change = CurrentOrder.GetBalanceDue();
                MessageBox.Show("Change Due: " + change.ToString());
                if (change >= 0)
                {
                    LoaderForm loader = new LoaderForm();
                    loader.Show();
                    await Task.Run(() =>
                    {
                        try
                        {
                            CurrentOrder.SaveOrderToDatabase();
                        }
                        catch { }
                    });

                    loader.Close();
                    this.CloseCurrentOrder(this);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }