Esempio n. 1
0
        // loads all active users in DB
        public void Load_ActiveUsers()
        {
            string querySelectAllActiveUsers = string.Format("SELECT " +
                                                             "users_information.emp_id AS Emp_ID," +
                                                             "users_information.fname AS FName," +
                                                             "users_information.lname AS LName," +
                                                             "roles.description AS Role " +
                                                             "FROM users_information LEFT JOIN users " +
                                                             "ON users_information.emp_id = users.emp_id " +
                                                             "LEFT JOIN roles " +
                                                             "ON users.role_id = roles.role_id " +
                                                             "WHERE users_information.status = 'Active'");

            try
            {
                this.dgUserList.ItemsSource = SqlQueries.Load_DataGridItems(querySelectAllActiveUsers).DefaultView;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Esempio n. 2
0
        // sets constraints for start date and end date
        private void SetCalendarConstraints()
        {
            string queryFirstIncomeDate = string.Format("SELECT TOP 1 date " +
                                                        "FROM daily_IncomeRecord " +
                                                        "ORDER BY date ASC");

            string resultDate = SqlQueries.GetFirstIncomeDate(queryFirstIncomeDate);

            if (resultDate != null)
            {
                DateTime startingDate = Convert.ToDateTime(resultDate);

                dateStart.DisplayDateStart = startingDate;
                dateStart.DisplayDateEnd   = DateTime.Now;

                dateEnd.DisplayDateEnd   = DateTime.Now;
                dateEnd.DisplayDateStart = startingDate;
            }
            else
            {
                MessageBox.Show("No starting date detected");
            }
        }
Esempio n. 3
0
        // button to logout
        // sets logout data to true to close application
        private void BtnLogout_Click(object sender, RoutedEventArgs e)
        {
            string queryLoggerOut = string.Format("INSERT INTO timelog" +
                                                  "(emp_id, log_time, log_status) " +
                                                  "VALUES(@emp_id, @log_time, @log_status)");

            if (cartTotal == 0)
            {
                if (SqlQueries.Logger(queryLoggerOut, Globals.Emp_ID, btnLogout.Content.ToString()) == true)
                {
                    MessageBox.Show("Logging Out");

                    lblEmpID.Content    = " ";
                    lblEmployee.Content = " ";

                    Login login = new Login();

                    logout = true;

                    if (logout == true)
                    {
                        this.Close();
                    }


                    login.Show();
                }
                else
                {
                    MessageBox.Show("Something went wrong logging out");
                }
            }
            else
            {
                MessageBox.Show("Transaction Ongoing");
            }
        }
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                string queryDeactivateUser = string.Format("UPDATE users_information " +
                                                           "SET status = 'Inactive' " +
                                                           "WHERE emp_id = @emp_id");

                if (SqlQueries.DeactivateUser(queryDeactivateUser, Convert.ToInt32(row["Emp_ID"])) == true)
                {
                    MessageBox.Show("User Deactivated");

                    main.Load_ActiveUsers();

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Something went wrong");
                }
            }
        }
Esempio n. 5
0
        // records transaction into Transactions table and Transaction Details table
        private void BtnDone_Click(object sender, RoutedEventArgs e)
        {
            if (cbDineIn.IsSelected = false && cbTakeOut.IsSelected == false && cbDriveThru.IsSelected == false)
            {
                MessageBox.Show("Select Order Type!");
            }
            else if (hasPaid == false)
            {
                MessageBox.Show("Enter amount paid!");
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Finish transaction?", "Confrim", MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    string queryInsertIntoTransactionsTable = string.Format(
                        "INSERT INTO transactions" +
                        "(transaction_date, total_price, emp_id, order_type, amount_paid, change) " +
                        "VALUES(" +
                        "@transaction_date, @total_price, @emp_id, " +
                        "(SELECT orderType_id " +
                        "FROM order_type " +
                        "WHERE orderType_description = @order_type), " +
                        "@amount_paid, @change" +
                        ")"
                        );

                    string queryInsertIntoTransactionDetails = string.Format("INSERT INTO transaction_details" +
                                                                             "(transaction_id, item_code, total_item_price, quantity) " +
                                                                             "VALUES(" +
                                                                             "(SELECT TOP 1 transaction_id " +
                                                                             "FROM transactions " +
                                                                             "ORDER BY transaction_id DESC), " +
                                                                             "@item_code, @total_item_price, @quantity" +
                                                                             ")"
                                                                             );

                    cbResult = cborderType.SelectionBoxItem.ToString();

                    if (SqlQueries.SqlExecNQInsertTransactionsTable(queryInsertIntoTransactionsTable, cartTotal, Globals.Emp_ID, cbResult, amountPaid, change) == true)
                    {
                        if (SqlQueries.SqlExecNQInsertTransactionDetails(queryInsertIntoTransactionDetails, items) == true)
                        {
                            MessageBox.Show("Transaction Complete!");
                            MessageBox.Show(cbResult.ToString());
                            Receipt receipt = new Receipt(items, cartTotal, amountPaid, change, cbResult, main);
                            receipt.ShowDialog();

                            //main.ClearOrderList();
                            //main.ClearOrder();
                            //main.GetCurrentDailyIncome();
                            //main.Load_DailyTransactions();

                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Something went wrongggg");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Something went wrong asadsad");
                    }
                }
            }
        }