Exemplo n.º 1
0
        }//End of TransferClick

        //this is just get money from an external account
        private void btnExternalSource_Click(object sender, EventArgs e)
        {
            BLLAccountManager manager = new BLLAccountManager();

            txtAccountNumber.Text = esternalTransferAcc;
            SourceAccount         = manager.GetAccountRecord(int.Parse(esternalTransferAcc));
        }//end of external
Exemplo n.º 2
0
        }//end of edit account

        //method returns selected student object from data grid
        private Student GetSelectedStudent()
        {
            BLLAccountManager bllAccMngr = new BLLAccountManager();

            Student selStudent = null;

            int studentID = 0;
            // the StudentID is the last column in Main Display dgv - using enum instead of majic numbers
            int columnIndex = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_StudentID));
            int rowIndex    = 0;

            if (dgvDisplay.SelectedRows.Count > 0)
            {
                // this ensures you select only 1 row, not multi-select
                rowIndex = dgvDisplay.SelectedRows[0].Index;

                //getting the studentID
                studentID = (int)dgvDisplay.Rows[rowIndex].Cells[columnIndex].Value;

                // inputting a list of Students into stuList
                stuList = bllAccMngr.getStudents();

                // circulating through the list to find the matching student number
                for (int i = 0; i < stuList.Count; i++)
                {
                    if (stuList[i].StudentID == studentID)
                    {
                        selStudent = stuList[i];
                        break;
                    }
                }
            }
            return(selStudent);
        }//end of GetSelectedStudent
Exemplo n.º 3
0
        }//end of primeGrid()

        //method to filter account using name and surname
        private void btnSearch_Click(object sender, EventArgs e)
        {
            BLLAccountManager manager = new BLLAccountManager();

            string         firstName   = txtFirstName.Text;
            string         lastName    = txtLastName.Text;
            List <Account> accsFromBll = new List <Account>(2);

            // testing to see what search option to use
            if (firstName == string.Empty && lastName == String.Empty)
            {
                MessageBox.Show("Please enter student first name or last name or both");
            }
            else if ((firstName != String.Empty) && (lastName != String.Empty))
            {
                accsFromBll = manager.GetAcountsByStudentName(firstName, lastName);
            }
            else if (firstName != String.Empty)
            {
                accsFromBll = manager.GetAcountsByStudentFirsName(firstName);
            }
            else if (lastName != String.Empty)
            {
                accsFromBll = manager.GetAcountsByStudentLastName(lastName);
            }

            dgvDisplay.DataSource = accsFromBll;

            if (!accsFromBll.Any())
            {
                MessageBox.Show("No account or student found");
            }
        }//End of search button click
Exemplo n.º 4
0
        //method to populate datagrid
        private void PrimeListGrid()
        {
            BLLAccountManager bllAccMgnr     = new BLLAccountManager();
            List <Account>    AccDetailsList = bllAccMgnr.GetAccountDetailsAsList();

            //// set auto generate columns to false
            dgvAccounts.AutoGenerateColumns = false;
            dgvAccounts.ColumnCount         = 7;
            // fit everything to the size of the windows form
            dgvAccounts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            //setting the headers
            dgvAccounts.Columns[0].HeaderText       = "Account Number"; // what will be displayed in dgv
            dgvAccounts.Columns[0].DataPropertyName = "AccountNo";      // from column names in SQL Server

            dgvAccounts.Columns[1].HeaderText       = "Account Type";
            dgvAccounts.Columns[1].DataPropertyName = "AccountType";

            dgvAccounts.Columns[2].HeaderText       = "Sort Code";
            dgvAccounts.Columns[2].DataPropertyName = "SortCode";

            dgvAccounts.Columns[3].HeaderText       = "Initial Balance";
            dgvAccounts.Columns[3].DataPropertyName = "InitBal";

            dgvAccounts.Columns[4].HeaderText       = "Current Balance";
            dgvAccounts.Columns[4].DataPropertyName = "CurtBal";

            dgvAccounts.Columns[5].HeaderText       = "Over Draft Limit";
            dgvAccounts.Columns[5].DataPropertyName = "OverDraft";

            dgvAccounts.Columns[6].HeaderText       = "Student ID";
            dgvAccounts.Columns[6].DataPropertyName = "StudentID";

            dgvAccounts.DataSource = AccDetailsList;
        }//end of primeGrid()
Exemplo n.º 5
0
        }//End of search button click

        //method to repopulate datagrid with all accounts
        private void btnDisplayAll_Click(object sender, EventArgs e)
        {
            BLLAccountManager manager = new BLLAccountManager();

            List <Account> accs = manager.GetAccountDetailsAsList();

            dgvDisplay.DataSource = accs;
        }//end of display all accs btn
Exemplo n.º 6
0
        }//end of back button

        //this will set account details that are needed to create an external transfer
        private void btnExternal_Click(object sender, EventArgs e)
        {
            BLLAccountManager manager = new BLLAccountManager();

            DestinationAccount          = manager.GetAccountRecord(int.Parse(esternalTransferAcc));
            txtAccOutNumber.Text        = esternalTransferAcc;
            txtDestinationSortCode.Text = outSortCode;
            txtRecepientName.Text       = externalName;
            ExternalTransfer            = true;
        }//end of external
Exemplo n.º 7
0
        }//end of go back

        //event will sent new student object in order to change the details in database
        private void btnEdit_Click(object sender, EventArgs e)
        {
            Student stu = new Student();

            BLLAccountManager bllAccMngr = new BLLAccountManager();

            bool retVal = false;

            // fill up stu with details on edit form
            stu = CaptureStudentFields();

            // pass info to DB
            retVal = bllAccMngr.EditStudentDetails(stu);
            if (retVal)
            {
                MessageBox.Show("Details saved");
            }
        }//end of edit button click
Exemplo n.º 8
0
        }//end of GetSelectedStudent

        //method returns selected account from datagrid
        private Account GetSelectedAccount()
        {
            BLLAccountManager bllAccMngr = new BLLAccountManager();

            // inputting a list of Accounts into accList
            accList = bllAccMngr.GetAccountDetailsAsList();

            Account selAccount = null;

            int    studentID = 0;
            string accType   = "";
            // using enum instead of majic numbers
            int studentIDIndex = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_StudentID));
            int accTypeIndex   = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_AccountType));
            int rowIndex       = 0;

            if (dgvDisplay.SelectedRows.Count > 0)
            {
                // this ensures you select only 1 row, not multi-select
                rowIndex = dgvDisplay.SelectedRows[0].Index;

                // getting the studentID
                studentID = (int)dgvDisplay.Rows[rowIndex].Cells[studentIDIndex].Value;
                // getting the account type
                accType = dgvDisplay.Rows[rowIndex].Cells[accTypeIndex].Value.ToString();

                // circulating through the list to find the matching student number and account type
                for (int i = 0; i < accList.Count; i++)
                {
                    // checking student id
                    if (accList[i].StudentID == studentID)
                    {
                        // checking matching account type
                        if (accList[i].AccountType == accType)
                        {
                            selAccount = accList[i];
                            break;
                        }
                    }
                }
            }
            return(selAccount);
        }//end of GetSelectedAccount
Exemplo n.º 9
0
        }//end of primeGrid()

        //Method eill get details of selected account in the datagrid and will return an object
        private Account GetSelectedAccount()
        {
            BLLAccountManager bllAccMngr = new BLLAccountManager();

            // inputting a list of Accounts into accList
            accList = bllAccMngr.GetAccountDetailsAsList();

            Account selAccount = null;

            int    studentID = 0;
            string accType   = "";
            // as the StudentID is the last column in Main Display dgv - using enum
            int studentIDIndex = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_StudentID));
            int accTypeIndex   = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_AccountType));
            int rowIndex       = 0;

            if (dgvAccounts.SelectedRows.Count > 0)
            {
                // this ensures you select only 1 row, not multi-select
                rowIndex = dgvAccounts.SelectedRows[0].Index;

                // getting the studentID
                studentID = (int)dgvAccounts.Rows[rowIndex].Cells[studentIDIndex].Value;
                // getting the account type
                accType = dgvAccounts.Rows[rowIndex].Cells[accTypeIndex].Value.ToString();

                for (int i = 0; i < accList.Count; i++)
                {
                    if (accList[i].StudentID == studentID)
                    {
                        if (accList[i].AccountType == accType)
                        {
                            selAccount = accList[i];
                            break;
                        }
                    }
                }
            }
            return(selAccount);
        }//End of GetSelectedAccount
Exemplo n.º 10
0
        }//end of prime

        //method that populates the datagrid and configures the way data is displayd in it
        private void PrimeListGrid(bool clearDataSource)
        {
            if (clearDataSource)
            {
                dgvDisplay.DataSource = null;
            }

            BLLAccountManager bllAccMgnr     = new BLLAccountManager();
            List <Account>    AccDetailsList = bllAccMgnr.GetAccountDetailsAsList();

            dgvDisplay.AutoGenerateColumns = false;
            dgvDisplay.ColumnCount         = 7;
            dgvDisplay.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            //setting the headers
            dgvDisplay.Columns[0].HeaderText       = "Account Number"; // what will be displayed in dgv
            dgvDisplay.Columns[0].DataPropertyName = "AccountNo";

            dgvDisplay.Columns[1].HeaderText       = "Account Type";
            dgvDisplay.Columns[1].DataPropertyName = "AccountType";

            dgvDisplay.Columns[2].HeaderText       = "Sort Code";
            dgvDisplay.Columns[2].DataPropertyName = "SortCode";

            dgvDisplay.Columns[3].HeaderText       = "Initial Balance";
            dgvDisplay.Columns[3].DataPropertyName = "InitBal";

            dgvDisplay.Columns[4].HeaderText       = "Current Balance";
            dgvDisplay.Columns[4].DataPropertyName = "CurtBal";

            dgvDisplay.Columns[5].HeaderText       = "Over Draft Limit";
            dgvDisplay.Columns[5].DataPropertyName = "OverDraft";

            dgvDisplay.Columns[6].HeaderText       = "Student ID";
            dgvDisplay.Columns[6].DataPropertyName = "StudentID";

            dgvDisplay.DataSource = AccDetailsList;
        }//end of primeGrid()
Exemplo n.º 11
0
        }//end of back

        // Method to to create new account
        // If a student exists it will create a new acount that will be linked to existing student
        // If there is no student it will create a student and a new account
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //variable to control display of succesfull record insetion
            bool success = false;

            BLLAccountManager manager = new BLLAccountManager();

            List <Account> accList = new List <Account>();

            //following two lines are here to chech if we have account type allready created
            List <Account> currentExist = new List <Account>(1);
            List <Account> savingtExist = new List <Account>(1);

            accList = manager.GetAccountDetailsAsList();

            //Creating empty account
            Account acc = new Account();

            int accNo;
            int studIdFromDb = 0;

            if (!ExistingStud)
            {
                if (ValidateChildren(ValidationConstraints.Enabled))
                {
                    PopulateStudent();
                    manager.AddStudent(Student, out studIdFromDb);
                    success = true;
                }
                else
                {
                    success = false;
                }
                //PopulateStudent();
                //manager.AddStudent(Student, out studIdFromDb);

                //manager.AddStudent(Student, out studIdFromDb);
                acc.StudentID = studIdFromDb;
            }
            else if (ExistingStud)
            {
                acc.StudentID = int.Parse(txtStudentId.Text);
            }

            string accType = "";

            //getting all accs for a given student that are current or saving
            currentExist = accList.Where(Account => Account.AccountType == "current" && Account.StudentID == acc.StudentID).ToList();
            savingtExist = accList.Where(Account => Account.AccountType == "saving" && Account.StudentID == acc.StudentID).ToList();

            acc.SortCode = int.Parse(txtSortCode.Text);

            string initBal  = txtInitialBalance.Text;
            int    initBal2 = MoneyTransformer.TransformMoney(initBal);

            acc.InitialBalance = initBal2;
            // setting the current Balance to the same value as the inital balance
            acc.CurrentBalance = initBal2;
            string ovaDraft  = txtOverdraft.Text;
            int    ovaDraft2 = MoneyTransformer.TransformMoney(ovaDraft);

            acc.OverDraftLimit = ovaDraft2;

            if (rdoCurrentAcc.Checked)
            {
                //checking if student has a current account allready
                if (currentExist.Any())
                {
                    MessageBox.Show("Student allready has a current account");
                }
                else
                {
                    accType         = "current";
                    acc.AccountType = accType;

                    if (ValidateChildren(ValidationConstraints.Enabled))
                    {
                        manager.AddAccount(acc, out accNo);
                        success = true;
                    }
                    else
                    {
                        success = false;
                    }
                }
            }
            else if (rdoSavingsAcc.Checked)
            {
                //checking if student has saving account allready.
                if (savingtExist.Any())
                {
                    MessageBox.Show("Student allready has saving account");
                }
                else
                {
                    accType         = "saving";
                    acc.AccountType = accType;
                    if (ValidateChildren(ValidationConstraints.Enabled))
                    {
                        manager.AddAccount(acc, out accNo);
                        success = true;
                    }
                    else
                    {
                        success = false;
                    }
                }
            }

            if (success)
            {
                MessageBox.Show("New Account Created");
            }
            else
            {
                MessageBox.Show("No account created try again with correct details");
            }
        }//end of add acc button click