private void mnuBack_Click(object sender, EventArgs e)
        {
            FrmDisplayAccounts Display = new FrmDisplayAccounts();

            Display.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void backToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmDisplayAccounts Display = new FrmDisplayAccounts();

            Display.Show();
            this.Hide();
        }
Exemplo n.º 3
0
        private void btnWithdraw_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            Transaction T = new Transaction();

            T.amount  = txtWithdrawAmount.Text;
            T.note    = txtWithdrawNote.Text;
            T.account = cboAccount.SelectedValue.ToString();
            T.type    = "W";
            Validation v     = new Validation();
            bool       valid = true;

            if (!v.IsAmount(T.amount) || decimal.Parse(T.amount).Equals(0))
            {
                errorProvider1.SetError(txtWithdrawAmount, "Amount must only be numbers and in the format 0.00 and greater then 0.01");
                valid = false;
            }
            if ((!v.IsAccount(T.note)) && (!T.note.Equals("")))
            {
                errorProvider1.SetError(txtWithdrawNote, "Note must not contain any special characters");
                valid = false;
            }

            if (valid)
            {
                try
                {
                    if (TransactionSQL.CheckBalance(ref T))
                    {
                        try
                        {
                            TransactionSQL.Withdraw(ref T);
                            MessageBox.Show("You just withdrew €" + T.amount);

                            FrmDisplayAccounts Display = new FrmDisplayAccounts();
                            Display.Show();
                            this.Hide();
                        }
                        catch
                        {
                            MessageBox.Show("Error 017: Could not connect to database. Your Withdrawal Has not been processed \nPlease contact an administratior");
                        }
                    }
                    else
                    {
                        MessageBox.Show("You do not have enough money in your account to process this Withdrawal");
                    }
                }
                catch
                {
                    MessageBox.Show("Error 016: Could not connect to database. Please contact an administratior");
                }
            }
        }
        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");
            }
        }
Exemplo n.º 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            bool valid = true;

            Customer.PPSNo      = null;
            Customer.CustomerId = txtCustomerid.Text;
            Customer.PAC        = txtPUC.Text;
            Validation v = new Validation();

            errorProvider.Clear();

            if (Customer.CustomerId.Length != 8 || !v.IsNumeric(Customer.CustomerId))
            {
                valid = false;
                errorProvider.SetError(txtCustomerid, "Please enter a valid customerID");
            }
            if (Customer.PAC.Length != 5 || !v.IsNumeric(Customer.PAC))
            {
                valid = false;
                errorProvider.SetError(txtPUC, "Please enter a valid PAC");
            }
            if (valid)
            {
                try
                {
                    if (CustomerSQL.Login(Customer.CustomerId, Customer.PAC))
                    {
                        FrmDisplayAccounts Display = new FrmDisplayAccounts();
                        Display.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Login failed: Please try again");
                    }
                }
                catch
                {
                    MessageBox.Show("Error 001: Could not connect to database. Please contact an administratior");
                }
            }
        }
Exemplo n.º 6
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");
                }
            }
        }
Exemplo n.º 7
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");
            }
        }
Exemplo n.º 8
0
        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");
                }
            }
        }
Exemplo n.º 9
0
        private void btnDeposit_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            Transaction T = new Transaction();

            T.amount  = txtDepositAmount.Text;
            T.note    = txtDepositNote.Text;
            T.account = cboAccount.SelectedValue.ToString();
            T.type    = "D";
            Validation v     = new Validation();
            bool       valid = true;

            if (!v.IsAmount(T.amount) || decimal.Parse(T.amount).Equals(0))
            {
                errorProvider1.SetError(txtDepositAmount, "Amount must only be numbers and in the format 0.00 and greater then 0.01");
                valid = false;
            }
            if ((!v.IsAccount(T.note)) && (!T.note.Equals("")))
            {
                errorProvider1.SetError(txtDepositNote, "Note must not contain any special characters");
                valid = false;
            }

            if (valid)
            {
                string[] findbalance = { "balance", "account where accountid = " + cboAccount.SelectedValue.ToString() };
                try
                {
                    string  balance = Reusable.stringfromDB(findbalance);
                    decimal d1      = decimal.Parse(balance);
                    decimal d2      = decimal.Parse(txtDepositAmount.Text);
                    decimal d4      = decimal.Parse("9999999.99");
                    decimal d3      = d1 + d2;
                    if (d3 <= d4)
                    {
                        if (MessageBox.Show("Are you sure you want to Deposit €" + T.amount, "Confirm Deposit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            try
                            {
                                TransactionSQL.Deposit(ref T);
                                MessageBox.Show("You deposited €" + T.amount);
                                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                                Display.Show();
                                this.Hide();
                            }
                            catch
                            {
                                MessageBox.Show("Error 013: Could not connect to database. Please contact an administratior");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Woah there! with this deposit you'll have too much money in your account.\nPlease deposit that into another Account");
                    }
                }
                catch
                {
                    MessageBox.Show("Error 012: Could not connect to database. Please contact an administratior");
                }
            }
        }
        private void btnUpdateCustomer_Click(object sender, EventArgs e)
        {
            Validation v     = new Validation();
            bool       valid = true;

            //making things uppercase
            Customer.Eir = Customer.Eir.ToUpper();

            errorProvider1.Clear();

            if (!v.IsAlphabeticNoSpace(txtFName.Text))
            {
                errorProvider1.SetError(txtFName, "First name must only contain letters");
                valid = false;
            }
            if (!v.IsAlphabeticNoSpace(txtLName.Text))
            {
                errorProvider1.SetError(txtLName, "Last name must only contain letters");
                valid = false;
            }
            if (!v.IsNumeric(txtPhoneNo.Text))
            {
                errorProvider1.SetError(txtPhoneNo, "phone number must only contain numbers");
                valid = false;
            }
            if (v.IsEmpty(txtAddressL1.Text))
            {
                errorProvider1.SetError(txtAddressL1, "Please enter an address");
                valid = false;
            }
            if (!v.IsAlphabetic(txtTown.Text))
            {
                errorProvider1.SetError(txtTown, "Town must only be alphabetic");
                valid = false;
            }
            if (!v.IsEir(txtEircode.Text))
            {
                errorProvider1.SetError(txtEircode, "Please enter a valid eircode");
                valid = false;
            }

            if (valid.Equals(true))
            {
                Customer.Fname       = txtFName.Text;
                Customer.Lname       = txtLName.Text;
                Customer.CountryCode = cboCountryCode.SelectedValue.ToString();
                Customer.PhoneNo     = txtPhoneNo.Text;
                Customer.AddressL1   = txtAddressL1.Text;
                Customer.AddressL2   = txtAddressL2.Text;
                Customer.AddressL3   = txtAddressL3.Text;
                Customer.County      = cboCounty.SelectedValue.ToString();
                Customer.Town        = txtTown.Text;
                Customer.Eir         = txtEircode.Text;

                Customer.Fname = char.ToUpper(Customer.Fname[0]) + Customer.Fname.Substring(1);
                Customer.Lname = char.ToUpper(Customer.Lname[0]) + Customer.Lname.Substring(1);
                Customer.Lname = Customer.Lname.Replace("'", "''");
                if (!Customer.Eir.Contains(" "))
                {
                    Customer.Eir = Customer.Eir.Substring(0, 3) + " " + Customer.Eir.Substring(3, 4);
                }
                CustomerSQL.UpdateInfo();

                MessageBox.Show("Your Information has been updated");

                CustomerSQL.GetCustInfo();

                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                Display.Show();
                this.Hide();
                MessageBox.Show("Error 004: Could not connect to database. Please contact an administratior");
            }
        }