示例#1
0
        //get and populate full account and holder details (for edit and view)
        private void GetAndPopulateAccountAndHolderDetails(int accNumber)
        {
            Account        acc;
            BLLAccountMgmt bllAM = new BLLAccountMgmt();

            acc = bllAM.GetAccountDetailsBLL(accNumber);


            //get holder details
            int           holderID = acc.AccountHolderID;
            AccountHolder accHold;

            accHold = bllAM.GetAccHolderDetailsBLL(holderID);

            if (accHold.FirstName != null)
            {
                //display holder details
                txtManAccPFullDetFName.Text          = accHold.FirstName;
                txtManAccPFullDetLName.Text          = accHold.Surname;
                txtManAccPFullDetEmail.Text          = accHold.Email;
                txtManAccPFullDetPho.Text            = accHold.Phone;
                txtManAccPFullDetAddr1.Text          = accHold.Address1;
                txtManAccPFullDetAddr2.Text          = accHold.Address2;
                txtManAccPFullDetCity.Text           = accHold.City;
                cmbManAccPFullDetCounty.SelectedItem = accHold.County;
                txtManAccPFullDetAccHolder.Text      = accHold.ID.ToString();

                //display account details
                txtManAccPFullDetAccNo.Text  = acc.Id.ToString();
                txtManAccPFullDetSortC.Text  = acc.SortCode;
                txtManAccPFullDetIntBal.Text = acc.Balance.ToString();



                if (acc.Type.ToString().ToLower() == "current")
                {
                    rbtManAccPFullDetCurrent.Checked = true;
                    txtManAccPFullDetIntRate.Enabled = false;
                }

                else if (acc.Type.ToString().ToLower() == "savings")
                {
                    rbtManAccPFullDetSavings.Checked = true;
                    txtManAccPFullDetOverdr.Enabled  = false;
                }


                txtManAccPFullDetOverdr.Text  = acc.OverdraftLimit.ToString();
                txtManAccPFullDetIntRate.Text = acc.InterestRate.ToString();
            }

            else
            {
                MessageBox.Show("Entered account does not exist");
                BackToHomeGridView();
            }
        }
示例#2
0
        //populate accounts dgv
        public void PopulateAccountsDGV()
        {
            dgvManAcc.DataSource = null;

            BLLAccountMgmt bllAM = new BLLAccountMgmt();
            DataSet        ds    = bllAM.GetAllAccountsBLL();

            dgvManAcc.DataSource = ds.Tables[0];

            dgvManAcc.Columns[0].HeaderCell.Value = "account holder ID";
            dgvManAcc.Columns[1].HeaderCell.Value = "first name";
            dgvManAcc.Columns[2].HeaderCell.Value = "last name";
            dgvManAcc.Columns[3].HeaderCell.Value = "account number";
            dgvManAcc.Columns[4].HeaderCell.Value = "account type";
            dgvManAcc.Columns[5].HeaderCell.Value = "balance";
            dgvManAcc.Columns[6].HeaderCell.Value = "interest rate";
            dgvManAcc.Columns[7].HeaderCell.Value = "overdraft limit";
        }
示例#3
0
        //CLICK save changes to account or/and account holder
        private void btnManAccPFullDetSaveEdit_Click(object sender, EventArgs e)
        {
            bool successHolder  = false;
            bool successAccount = false;

            //create a holder object
            AccountHolder accHold = CreateNewAccHolderObject();

            //create an account object
            Account account = CreateNewAccountObjectNoHolderID();

            //send both to DB
            if (account != null && accHold != null)
            {
                accHold.ID = int.Parse(txtManAccPFullDetAccHolder.Text);
                account.Id = int.Parse(txtManAccPFullDetAccNo.Text);

                BLLAccountMgmt bllAM = new BLLAccountMgmt();
                successHolder  = bllAM.EditAccHolderBLL(accHold);
                successAccount = bllAM.EditAccountBLL(account);
            }

            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                //edit status messages
                if (successHolder && successAccount)
                {
                    MessageBox.Show("All changes saved");
                    BackToHomeGridView();
                }

                if (successHolder == false)
                {
                    MessageBox.Show("Account holder changes failed to save");
                }

                if (successAccount == false)
                {
                    MessageBox.Show("Account changes failed to save");
                }
            }
        }
示例#4
0
        // Method to load account holder only
        private bool LoadAccountHolder(int holderId, ref AccountHolder holder)
        {
            bool          loaded;
            AccountHolder tempHolder;

            loaded = false;

            BLLAccountMgmt bllAM = new BLLAccountMgmt();

            tempHolder = bllAM.GetAccHolderDetailsBLL(holderId);

            if ((tempHolder != null) && (tempHolder.ID != 0))
            {
                loaded = true;
                // if account holder is not a default empty one, assign reference
                holder = tempHolder;
            }

            return(loaded);
        }
示例#5
0
        // Method to load account only
        private bool LoadAccount(int number, ref Account account)
        {
            bool loaded;

            loaded = false;
            Account tempAccount;

            BLLAccountMgmt bllAM = new BLLAccountMgmt();

            tempAccount = bllAM.GetAccountDetailsBLL(number);

            if ((tempAccount != null) && (tempAccount.Id != 0))
            {
                loaded = true;
                // if account is not a default empty one, assign reference
                account = tempAccount;
            }

            return(loaded);
        }
示例#6
0
        //CLICK user logges in. Show frmManageAaccounts
        private void btnHomePLoginLogin_Click(object sender, EventArgs e)
        {
            bool success = false;

            Staff stf = new Staff();

            stf.Name     = txtHomePLoginUserName.Text;
            stf.Password = txtHomePLoginPassword.Text;

            BLLAccountMgmt bllAM = new BLLAccountMgmt();

            success = bllAM.CheckLoginBLL(stf);

            if (success)
            {
                this.Hide(); //must not close frmHome - Application Run form

                frmManageAccounts ma = new frmManageAccounts();

                ma.PopulateAccountsDGV();

                ma.panelAccManNewAcc.Visible     = false;
                ma.panelManAccEditSearch.Visible = false;
                ma.panelManAccFullDet.Visible    = false;
                ma.ShowDialog();
            }
            else
            {
                MessageBox.Show("Invalid Username or Password");

                panelHomeLogin.Visible     = false;
                btnHomeLogin.Visible       = true;
                txtHomePLoginUserName.Text = "";
                txtHomePLoginPassword.Text = "";
            }
        }
示例#7
0
        //CLICK Next, go to full details page to create account
        private void btnAccManPNewAccNext_Click(object sender, EventArgs e)
        {
            //an option not selected
            if (!rbtnAccManPNewAccNewMem.Checked && !rbtnAccManPNewAccExistingMem.Checked)
            {
                MessageBox.Show("Please select one option");
            }


            //an option is selected
            else
            {
                //****** Existing holder  /   New holder options ********

                string nextHolderID;
                string nextAccNo;
                int    accHolderID = 0;


                //prepare full details panel for adding an account to an EXISTING holder
                if (rbtnAccManPNewAccExistingMem.Checked)
                {
                    //read-only holder fields
                    txtManAccPFullDetFName.ReadOnly = true;
                    txtManAccPFullDetLName.ReadOnly = true;
                    txtManAccPFullDetPho.ReadOnly   = true;
                    txtManAccPFullDetEmail.ReadOnly = true;
                    txtManAccPFullDetAddr1.ReadOnly = true;
                    txtManAccPFullDetAddr2.ReadOnly = true;
                    txtManAccPFullDetCity.ReadOnly  = true;
                    cmbManAccPFullDetCounty.Enabled = false;


                    //validate user input - account holder ID
                    int    outInt;
                    string input = txtManAccPNewAccAccHolder.Text;

                    bool isAnInt = int.TryParse(input, out outInt);

                    if (!isAnInt)
                    {
                        MessageBox.Show("Please enter a  valid account holder ID");
                        txtManAccPNewAccAccHolder.Text = "";
                    }


                    if (isAnInt)
                    {
                        //prepare next panel and display it

                        //read only acc holder details
                        txtManAccPFullDetAccHolder.ReadOnly = true;
                        //read only account details
                        txtManAccPFullDetSortC.ReadOnly = true;
                        txtManAccPFullDetAccNo.ReadOnly = true;



                        //hide/show relevant buttons
                        btnManAccPFullDetSerialize.Visible   = false;
                        btnManAccPFullDetDeserialize.Visible = false;
                        btnManAccPFullDetCancel.Visible      = true;
                        btnManAccPFullDetSaveEdit.Visible    = false;
                        btnManAccPFullDetClose.Visible       = false;
                        btnManAccPFullDetSubmitNew.Visible   = true;

                        //display full details panel
                        panelManAccFullDet.Visible       = true;
                        panelManAccEditSearch.Visible    = true;
                        panelManAccViewAccSearch.Visible = true;


                        //grab holder ID
                        accHolderID = int.Parse(txtManAccPNewAccAccHolder.Text);

                        AccountHolder ah;

                        BLLAccountMgmt bllAM = new BLLAccountMgmt();
                        ah = bllAM.GetAccHolderDetailsBLL(accHolderID); //get holder details

                        nextAccNo = bllAM.GetNextAccNoBLL().ToString(); //get next account number


                        if (ah.FirstName != null) //check if holder details arrived from DB
                        {
                            //holder details
                            txtManAccPFullDetFName.Text          = ah.FirstName;
                            txtManAccPFullDetLName.Text          = ah.Surname;
                            txtManAccPFullDetEmail.Text          = ah.Email;
                            txtManAccPFullDetPho.Text            = ah.Phone;
                            txtManAccPFullDetAddr1.Text          = ah.Address1;
                            txtManAccPFullDetAddr2.Text          = ah.Address2;
                            txtManAccPFullDetCity.Text           = ah.City;
                            cmbManAccPFullDetCounty.SelectedItem = ah.County;
                            txtManAccPFullDetAccHolder.Text      = ah.ID.ToString();
                            //account details
                            txtManAccPFullDetAccNo.Text = nextAccNo;
                            txtManAccPFullDetSortC.Text = sortCode;
                        }


                        else if (ah.FirstName == null)
                        {
                            MessageBox.Show("Account holder not found");

                            BackToHomeGridView();
                        }
                    }
                }



                ////prepare full details panel for adding an account to a NEW holder
                if (rbtnAccManPNewAccNewMem.Checked)
                {
                    //Display next holder id and next account number

                    BLLAccountMgmt bllAM = new BLLAccountMgmt();

                    nextHolderID = bllAM.GetNextHolderIDBLL().ToString();
                    nextAccNo    = bllAM.GetNextAccNoBLL().ToString();


                    txtManAccPFullDetAccHolder.Text = nextHolderID;
                    txtManAccPFullDetAccNo.Text     = nextAccNo;


                    //display sort code from App.config
                    txtManAccPFullDetSortC.Text = sortCode;


                    //prepare next panel and display it

                    //read only acc holder details
                    txtManAccPFullDetAccHolder.ReadOnly = true;
                    //read only account details
                    txtManAccPFullDetSortC.ReadOnly = true;
                    txtManAccPFullDetAccNo.ReadOnly = true;



                    //hide/show relevant buttons
                    btnManAccPFullDetSerialize.Visible   = false;
                    btnManAccPFullDetDeserialize.Visible = false;
                    btnManAccPFullDetCancel.Visible      = true;
                    btnManAccPFullDetSaveEdit.Visible    = false;
                    btnManAccPFullDetClose.Visible       = false;
                    btnManAccPFullDetSubmitNew.Visible   = true;

                    //display full details panel
                    panelManAccFullDet.Visible       = true;
                    panelManAccEditSearch.Visible    = true;
                    panelManAccViewAccSearch.Visible = true;
                }
            }
        } //end of "add new account" event  *********************
示例#8
0
        //CLICK SUBMIT  - create a new holder and / or account
        private void btnManAccPFullDetSubmit_Click(object sender, EventArgs e)
        {
            bool success = false;


            //Create  a NEW holder AND and NEW account

            if (rbtnAccManPNewAccNewMem.Checked)
            {
                //new holder
                AccountHolder ah = CreateNewAccHolderObject();

                //new account
                Account acc = CreateNewAccountObjectNoHolderID();


                //send both objects to  DB
                if (ah != null && acc != null)
                {
                    BLLAccountMgmt bllAM = new BLLAccountMgmt();

                    success = bllAM.AddNewHolderBLL(ah); //holder

                    int accHolderID = int.Parse(txtManAccPFullDetAccHolder.Text);
                    success = bllAM.AddNewAccountBLL(acc, accHolderID); //account
                }
            }



            //Create a new account and add to EXISTING  holder
            if (rbtnAccManPNewAccExistingMem.Checked)
            {
                Account acc = CreateNewAccountObjectNoHolderID();

                if (acc != null)
                {
                    BLLAccountMgmt bllAM = new BLLAccountMgmt();

                    int accHolderID = int.Parse(txtManAccPFullDetAccHolder.Text);
                    success = bllAM.AddNewAccountBLL(acc, accHolderID);
                }
            }



            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                // final result actions
                if (success == true)
                {
                    MessageBox.Show("All details have been saved");
                    //show accounts dgv
                    BackToHomeGridView();
                }

                else if (success == false)

                {
                    MessageBox.Show("Details not saved. Try again.");
                }
            }
        }