Esempio n. 1
0
        private void CreateNewTransaction()
        {
            int empID = 0;

            for (int i = 0; i < Database.EmployeeInfo.Count; i++)
            {
                if (cmbEmployee.Text == (Database.EmployeeInfo[i].FirstName + " " + Database.EmployeeInfo[i].LastName))
                {
                    empID = Database.EmployeeInfo[i].ID;
                }
            }

            string reason;

            if (txtReason.Text == "")
            {
                reason = " ";
            }
            else
            {
                reason = txtReason.Text;
            }
            // Creates a new transaction object then sends it to the database
            // class to be added to the list and the database
            Transaction newTransaction = new Transaction("Adjusted", int.Parse(txtNumRounds.Value.ToString()), currentRounds, newRounds, email, empID, ID, reason);

            // Refreshes to the new values on the details window and the main screen
            editAccount.EditWindowRefresh(ID);
            if (noEmail)
            {
                Email.SendEmail(newTransaction, Database.ResidentTransactions(ID));
                // Email.RoundsAdjustedEmail(int.Parse(txtNumRounds.Value.ToString()), newRounds, email, txtReason.Text);
            }
            Database.SubmitTransaction(newTransaction);
        }
        private void dgvAddRounds_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                if (e.RowIndex >= 0)
                {
                    // If the button is clicked it creates a new transaction object
                    // and adds it to the transaction table
                    newRounds      = currentRounds + Database.GolfRounds[e.RowIndex].TotalRounds;
                    newTransaction = new Transaction("Purchased", Database.GolfRounds[e.RowIndex].TotalRounds, currentRounds, newRounds, email, Database.LoggedInEmployee.ID, ID, " ");

                    if (noEmail)
                    {
                        Email.SendEmail(newTransaction, Database.ResidentTransactions(ID));
                    }

                    Database.SubmitTransaction(newTransaction);
                    editAccount.EditWindowRefresh(ID);
                    this.Close();
                    // MessageBox.Show("Rounds Added");
                }
            }
        }