private void btnUpdateAccount_Click(object sender, EventArgs e)
        {
            try
            {
                AccountSQL.UpdateAccount(txtName.Text, cboAccount.SelectedValue.ToString(), cboType.SelectedValue.ToString());
                MessageBox.Show("Account Updated");

                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                Display.Show();
                this.Hide();
            }
            catch
            {
                MessageBox.Show("Error 000: Could not connect to database. Please contact an administratior");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (AccountSQL.AllBalanceEmpty())
            {
                if (MessageBox.Show("Are you sure you want to terminate your account?\n\nYou will not be able to login again and all open accounts will be closed!", "Terminate Account", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    AccountSQL.CloseCustAccounts();
                    CustomerSQL.TerminateAccount(Customer.CustomerId);

                    Customer.Clear();
                    FrmStartScreen start = new FrmStartScreen();
                    start.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Please Empty all open accounts of funds");
            }
        }
示例#3
0
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            errorProvider.Clear();
            Validation v = new Validation();

            Acc.Name     = txtAccountName.Text;
            Acc.Type     = cboAccountType.SelectedValue.ToString();
            Acc.Creation = DateTime.Today.ToString("dd/MM/yyyy");
            if (v.IsEmpty(Acc.Name))
            {
                errorProvider.SetError(txtAccountName, "Please enter an account name");
            }
            else if (!v.IsAccount(Acc.Name))
            {
                errorProvider.SetError(txtAccountName, "Account name cannot contain special characters");
            }
            else if (AccountSQL.AccountNameExists(Acc.Name))
            {
                errorProvider.SetError(txtAccountName, "Account with this name already exists");
            }
            else
            {
                try
                {
                    AccountSQL.AddAccount(ref Acc);
                    MessageBox.Show("You Created a " + cboAccountType.Text + " Account\nwith the name " + Acc.Name);

                    FrmDisplayAccounts start = new FrmDisplayAccounts();
                    start.Show();
                    this.Hide();
                }
                catch
                {
                    MessageBox.Show("Error 009: Could not connect to database. Please contact an administratior\n\nAccount Not Created");
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[] findbalance = { "balance", "account where accountid = " + cboAccount.SelectedValue.ToString() };
            string   balance     = Reusable.stringfromDB(findbalance);

            if (balance.Equals("0.00"))
            {
                if (MessageBox.Show("Are you sure you want to close this account?", "Close Account", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    AccountSQL.CloseAccount(cboAccount.SelectedValue.ToString());
                    MessageBox.Show("You Closed " + cboAccount.SelectedText.ToString() + " has been closed");
                    FrmDisplayAccounts back = new FrmDisplayAccounts();
                    back.Show();
                    this.Hide();
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("Please empty your account of money before closing your account");
            }
        }
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            Validation  v     = new Validation();
            Transaction T     = new Transaction();
            bool        valid = true;

            T.account = cboCreditorAccount.SelectedValue.ToString();
            T.amount  = txtCreditorAmount.Text;
            T.note    = txtCreditorNote.Text;
            T.debtor  = txtDebtorAccount.Text;

            if (!v.IsAmount(T.amount))
            {
                valid = false;
                errorProvider1.SetError(txtCreditorAmount, "Amount must only be numbers and in the format 0.00 and greater then 0.01");
            }

            if (!v.IsEmpty(T.note) && !v.IsAccount(T.note))
            {
                valid = false;
                errorProvider1.SetError(txtCreditorNote, "Note must not contain special characters");
            }
            if (!v.isAccountNumber(T.debtor) && !v.isIBAN(T.debtor))
            {
                valid = false;
                errorProvider1.SetError(txtDebtorAccount, "Please enter a valid account number or IBAN");
            }
            else if (T.debtor == T.account)
            {
                valid = false;
                errorProvider1.SetError(txtDebtorAccount, "Please select a different account");
            }
            if (valid)
            {
                if (TransactionSQL.CheckBalance(ref T))
                {
                    if (v.isIBAN(T.debtor))
                    {
                        try
                        {
                            if (MessageBox.Show("Are you sure?", "Pay", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                T.type = "P";
                                TransactionSQL.Pay(ref T);
                                MessageBox.Show("You just made a payment too " + T.debtor);

                                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                                Display.Show();
                                this.Hide();
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Error 007: Could not connect to database. Please contact an administratior");
                        }
                    }
                    else if (v.isAccountNumber(T.debtor) && AccountSQL.AccountExists(T.debtor))
                    {
                        if (MessageBox.Show("Are you sure?", "Transfer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            try
                            {
                                T.type = "T";
                                TransactionSQL.Transfer(ref T);
                                MessageBox.Show("You transfered money too " + T.debtor);

                                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                                Display.Show();
                                this.Hide();
                            }
                            catch
                            {
                                MessageBox.Show("Error 007: Could not connect to database. Please contact an administratior");
                            }
                        }
                    }
                    else
                    {
                        errorProvider1.SetError(txtDebtorAccount, "That Account doesn't exist or has been closed");
                    }
                }
                else
                {
                    errorProvider1.SetError(txtCreditorAmount, "You do not currently have enough money in your account to make that transaction");
                }
            }
        }
        public void CheckAndDisplayAccounts(bool b)
        {
            int count = 0;

            try
            {
                count = AccountSQL.FindActiveAccounts();
            }
            catch
            {
                MessageBox.Show("Error 006: Could not connect to database. Please contact an administratior");
            }

            if (count >= 1)
            {
                string[] Accountinfo = new string[7];
                tlpNoAccount.Visible = false;
                if (b)
                {
                    Accountinfo[0] = "A.ACCOUNTID";
                    Accountinfo[1] = "A.STATUS";
                    Accountinfo[2] = "A.NAME";
                    Accountinfo[3] = "T.NAME Type";
                    Accountinfo[4] = "A.BALANCE";
                    Accountinfo[5] = "A.DATE_created";
                    Accountinfo[6] = "ACCOUNT A INNER JOIN ACCOUNT_TYPE T ON A.TYPE = T.ID WHERE CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID ASC";
                }
                else if (!b)
                {
                    Accountinfo[0] = "A.ACCOUNTID";
                    Accountinfo[1] = "A.STATUS";
                    Accountinfo[2] = "A.NAME";
                    Accountinfo[3] = "T.NAME Type";
                    Accountinfo[4] = "A.BALANCE";
                    Accountinfo[5] = "A.DATE_created";
                    Accountinfo[6] = "ACCOUNT A INNER JOIN ACCOUNT_TYPE T ON A.TYPE = T.ID WHERE STATUS = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID ASC";
                }

                DataSet Accounts = new DataSet();
                try
                {
                    Accounts = Reusable.dsfromDB(Accountinfo);
                    for (int i = 0; i < Accounts.Tables[0].Rows.Count; i++)
                    {
                        //Create label
                        Label Account_Name_ID = new Label();
                        Label Account_Status  = new Label();
                        Label Account_Type    = new Label();
                        Label Account_Balance = new Label();

                        //Add Text
                        Account_Name_ID.Text = Accounts.Tables[0].Rows[i]["Name"].ToString() + " - " + Accounts.Tables[0].Rows[i]["ACCOUNTID"].ToString();

                        if (Accounts.Tables[0].Rows[i]["STATUS"].ToString() == "A")
                        {
                            Account_Status.Text = "Active";
                        }
                        else if (Accounts.Tables[0].Rows[i]["STATUS"].ToString() == "C")
                        {
                            Account_Status.Text = "Closed";
                        }
                        else
                        {
                            Account_Status.Text = "Unknown";
                        }

                        Account_Type.Text    = Accounts.Tables[0].Rows[i]["Type"].ToString();
                        Account_Balance.Text = "€" + Accounts.Tables[0].Rows[i]["BALANCE"].ToString();

                        //Properties
                        Account_Name_ID.Left      = 250;
                        Account_Name_ID.Top       = ((i + 1) * 50) + 125;
                        Account_Name_ID.Width     = 300;
                        Account_Name_ID.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                        Account_Name_ID.Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                        Account_Status.Left = 50;
                        Account_Status.Top  = ((i + 1) * 50) + 145;

                        Account_Type.Left      = 350;
                        Account_Type.Top       = ((i + 1) * 50) + 145;
                        Account_Type.AutoSize  = false;
                        Account_Type.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                        Account_Type.Width     = 100;


                        Account_Balance.AutoSize  = false;
                        Account_Balance.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
                        Account_Balance.Top       = ((i + 1) * 50) + 145;
                        Account_Balance.Width     = 100;
                        Account_Balance.Left      = 650;
                        Account_Balance.Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                        //Add to form
                        this.Controls.Add(Account_Name_ID);
                        this.Controls.Add(Account_Status);
                        this.Controls.Add(Account_Type);
                        this.Controls.Add(Account_Balance);
                    }
                }
                catch
                {
                    MessageBox.Show("Error 007: Could not connect to database. Please contact an administratior");
                }
            }
        }