private void FrmTransactionChart_Load(object sender, EventArgs e) { //string[] MinDateSQL = { "Min(to_Char(DATE_Created, 'YYYY'))", "account WHERE status = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID" }; string[] AccountSQL = { "accountid", "CONCAT(Name,CONCAT(' - ',accountid)) AS display_name", "account WHERE status = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID" }; //nudYear.Maximum = Convert.ToDecimal(DateTime.Now.ToString("yyyy")); //nudYear.Minimum = Convert.ToDecimal(Reusable.stringfromDB(MinDateSQL)); DataSet Accountds = new DataSet(); chtTransactions.Titles.Add("Monthly Balance"); try { Accountds = Reusable.dsfromDB(AccountSQL); cboAccount.ValueMember = "accountid"; cboAccount.DisplayMember = "display_name"; cboAccount.DataSource = Accountds.Tables[0]; nudYear.Value = Convert.ToDecimal(DateTime.Now.ToString("yyyy")); PopulateChart(cboAccount.SelectedValue.ToString()); } catch { cboAccount.Text = "Error!"; MessageBox.Show("Error 010: Could not connect to database. Please contact an administratior"); } }
public static void Deposit(ref Transaction T) { string[] Transaction = { "transactionid ", "Transaction" }; OracleConnection conn = new OracleConnection(DBConnect.oradb); conn.Open(); T.TransactionID = Reusable.GetNextId(Transaction).ToString("D14"); T.timestamp = DateTime.Now.ToString("dd/MM/yyyy/HH:mm:ss"); String CustSQL = "INSERT INTO Transaction(transactionid,accountid,Type,amount,note,timestamp) " + "VALUES('" + T.TransactionID + "', '" + T.account + "', '" + T.type + "', '" + T.amount + "', '" + T.note + "', TO_DATE('" + T.timestamp + "', 'DD/MM/YYYY HH24:MI:SS'))"; OracleCommand Custcmd = new OracleCommand(CustSQL, conn); Custcmd.ExecuteNonQuery(); string[] findbalance = { "balance", "account where accountid = " + T.account }; string balance = Reusable.stringfromDB(findbalance); decimal d1 = decimal.Parse(balance); decimal d2 = decimal.Parse(T.amount); string newbalance = (d1 + d2).ToString("F2"); String LogSQL = "UPDATE Account SET BALANCE = '" + newbalance + "' where accountid = " + T.account; OracleCommand Logcmd = new OracleCommand(LogSQL, conn); Logcmd.ExecuteNonQuery(); conn.Close(); }
public static void AddUser() { string[] Cust = { "Customerid", "Customer" }; string[] Log = { "Loginid", "Login" }; OracleConnection conn = new OracleConnection(DBConnect.oradb); conn.Open(); Customer.CustomerId = Reusable.GetNextId(Cust).ToString("D8"); String CustSQL = "INSERT INTO Customer(Customerid,first_name,last_name,pps_number,country_code,phone_number,date_of_birth,address_line_1,address_line_2,address_line_3,town,county,eircode,date_created) " + "VALUES('" + Customer.CustomerId + "', '" + Customer.Fname + "', '" + Customer.Lname + "', '" + Customer.PPSNo + "', '" + Customer.CountryCode + "', '" + Customer.PhoneNo + "', TO_DATE('" + Customer.DOB + "', 'DD/MM/YYYY'), '" + Customer.AddressL1 + "', '" + Customer.AddressL2 + "', '" + Customer.AddressL3 + "', '" + Customer.Town + "', '" + Customer.County + "', '" + Customer.Eir + "', TO_DATE('" + Customer.DateCreated + "', 'DD/MM/YYYY'))"; OracleCommand Custcmd = new OracleCommand(CustSQL, conn); Custcmd.ExecuteNonQuery(); string LogId = Reusable.GetNextId(Log).ToString("D8"); String LogSQL = "INSERT INTO Login(Loginid,Customerid,pac) " + "VALUES('" + LogId + "', '" + Customer.CustomerId + "', '" + Customer.PAC + "')"; OracleCommand Logcmd = new OracleCommand(LogSQL, conn); Logcmd.ExecuteNonQuery(); conn.Close(); }
private void FrmUpdateAccount_Load(object sender, EventArgs e) { string[] Accountarr = { "accountid", "CONCAT(Name,CONCAT(' - ',accountid)) AS display_name", "account WHERE Status = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID" }; string[] Accounttypearr = { "id", "Name", "account_type" }; DataSet Accountds = new DataSet(); DataSet Accounttypeds = new DataSet(); try { Accountds = Reusable.dsfromDB(Accountarr); cboAccount.ValueMember = "accountid"; cboAccount.DisplayMember = "display_name"; cboAccount.DataSource = Accountds.Tables[0]; } catch { MessageBox.Show("Error 006: Could not connect to database. Please contact an administratior"); } try { Accounttypeds = Reusable.dsfromDB(Accounttypearr); cboType.ValueMember = "id"; cboType.DisplayMember = "NAME"; cboType.DataSource = Accounttypeds.Tables[0]; } catch { MessageBox.Show("Error 006: Could not connect to database. Please contact an administratior"); } }
private void FrmCreateAccount_Load(object sender, EventArgs e) { dtpdob.MaxDate = DateTime.Today; string[] countryarr = { "countryid", "CONCAT(country,CONCAT(' ',CONCAT('(',CONCAT(code,')')))) AS country", "country_code" }; string[] countyarr = { "countyid", "county", "county" }; DataSet countryds = new DataSet(); DataSet countyds = new DataSet(); try { countryds = Reusable.dsfromDB(countryarr); cboCountryCode.ValueMember = "countryid"; cboCountryCode.DisplayMember = "country"; cboCountryCode.DataSource = countryds.Tables[0]; } catch { MessageBox.Show("Error 003: Could not connect to database. Please contact an administratior"); } try { countyds = Reusable.dsfromDB(countyarr); cboCounty.ValueMember = "countyid"; cboCounty.DisplayMember = "county"; cboCounty.DataSource = countyds.Tables[0]; } catch { MessageBox.Show("Error 004: Could not connect to database. Please contact an administratior"); } }
private void mnuCreateAccount_Click(object sender, EventArgs e) { Reusable.resetupdate(); FrmCreateAccount create = new FrmCreateAccount(); create.Show(); this.Hide(); }
private void llbCreateAccount_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Reusable.resetupdate(); FrmCreateAccount create = new FrmCreateAccount(); create.Show(); this.Hide(); }
private void mnuUpdateCustomer_Click(object sender, EventArgs e) { Reusable.resetupdate(); FrmUpdateCustomer updatecust = new FrmUpdateCustomer(); updatecust.Show(); this.Hide(); }
private void mnuTerminateCustomer_Click(object sender, EventArgs e) { Reusable.resetupdate(); FrmTerminateCustomer Terminate = new FrmTerminateCustomer(); Terminate.Show(); this.Hide(); }
private void createAccountToolStripMenuItem_Click(object sender, EventArgs e) { Reusable.resetupdate(); FrmCreateAccount create = new FrmCreateAccount(); create.Show(); this.Hide(); }
private void transferToolStripMenuItem_Click(object sender, EventArgs e) { if (!tableLayoutPanel1.Visible) { Reusable.resetupdate(); FrmTransfer transfer = new FrmTransfer(); transfer.Show(); this.Hide(); } else { MessageBox.Show("You do not curently have an Active account.\nPlease Create one before continuing"); } }
private void cboCreditorAccount_SelectedIndexChanged(object sender, EventArgs e) { string[] Accountinfo = { "Balance", "ACCOUNT WHERE AccountID = " + cboCreditorAccount.SelectedValue }; DataSet Accounts = new DataSet(); try { Accounts = Reusable.dsfromDB(Accountinfo); lblBalanceAmount.Text = "€" + Accounts.Tables[0].Rows[0][0].ToString(); } catch { } }
private void mnuTransfer_Click(object sender, EventArgs e) { if (!tlpNoAccount.Visible) { Reusable.resetupdate(); FrmTransfer transfer = new FrmTransfer(); transfer.Show(); this.Hide(); } else { MessageBox.Show("You do not curently have an Active account.\nPlease Create one before continuing"); } }
public void FillGroupBox() { string[] Transactionsarr = { "T.TransactionID", "Y.NAME", "T.note", "T.Amount", "T.Timestamp", "Transaction T INNER JOIN Transaction_Type Y ON T.TYPE = Y.Type_Code WHERE AccountID = " + cboAccount.SelectedValue + " ORDER BY TransactionID DESC" }; DataSet accounts = new DataSet(); try { accounts = Reusable.dsfromDB(Transactionsarr); dataGridView1.DataSource = accounts.Tables[0]; } catch { MessageBox.Show("Error 002: Could not connect to database. Please contact an administratior"); } }
private void cboAccount_SelectedIndexChanged(object sender, EventArgs e) { string[] Accountinfo = { "Balance", "ACCOUNT WHERE AccountID = " + cboAccount.SelectedValue }; DataSet Accounts = new DataSet(); try { Accounts = Reusable.dsfromDB(Accountinfo); lblBalanceAmount.Text = "€" + Accounts.Tables[0].Rows[0][0].ToString(); } catch { lblBalanceAmount.Text = "Error!"; MessageBox.Show("Error 015: Could not connect to database. Please contact an administratior"); } }
public void DisplayTransactionhistory() { string[] Transactioninfo = new string[5]; Transactioninfo[0] = "T.TransactionID"; Transactioninfo[1] = "Y.name"; Transactioninfo[2] = "T.Amount"; Transactioninfo[3] = "T.Note"; Transactioninfo[4] = "Transaction T INNER JOIN Transaction_TYPE Y ON T.TYPE = Y.Type_code WHERE AccountID = " + cboAccount.SelectedValue + " ORDER BY TransactionID DESC"; DataSet Transactions = new DataSet(); Transactions = Reusable.dsfromDB(Transactioninfo); for (int i = 0; i < Transactions.Tables[0].Rows.Count && i < 10; i++) { //Create label Label TransactionID = new Label(); Label Transaction_Type = new Label(); Label Transaction_Amount = new Label(); Label Transaction_Note = new Label(); //Add Text TransactionID.Text = Transactions.Tables[0].Rows[i]["TransactionID"].ToString(); Transaction_Type.Text = Transactions.Tables[0].Rows[i]["name"].ToString(); Transaction_Amount.Text = "€" + Transactions.Tables[0].Rows[i]["Amount"].ToString(); Transaction_Note.Text = Transactions.Tables[0].Rows[i]["Note"].ToString(); //properties TransactionID.Left = 0; TransactionID.Top = ((i + 1) * 25) + 75; Transaction_Type.Left = 100; Transaction_Type.Top = ((i + 1) * 25) + 75; Transaction_Amount.Left = 500; Transaction_Amount.Top = ((i + 1) * 25) + 75; Transaction_Amount.Width = 75; Transaction_Amount.AutoSize = false; Transaction_Amount.TextAlign = System.Drawing.ContentAlignment.MiddleRight; Transaction_Note.Top = ((i + 1) * 25) + 75; Transaction_Note.Left = 200; Transaction_Note.Width = 350; //Add form this.Controls.Add(TransactionID); this.Controls.Add(Transaction_Type); this.Controls.Add(Transaction_Amount); this.Controls.Add(Transaction_Note); } }
public void FillcboBox() { string[] Account = { "accountid", "CONCAT(Name,CONCAT(' - ',accountid)) AS display_name", "account WHERE Status = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID" }; DataSet Accountds = new DataSet(); try { Accountds = Reusable.dsfromDB(Account); cboAccount.ValueMember = "accountid"; cboAccount.DisplayMember = "display_name"; cboAccount.DataSource = Accountds.Tables[0]; } catch { MessageBox.Show("Error 006: Could not connect to database. Please contact an administratior"); } }
private void FrmWithdraw_Load(object sender, EventArgs e) { string[] Account = { "accountid", "CONCAT(Name,CONCAT(' - ',accountid)) AS display_name", "account WHERE status = 'A' AND CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID" }; DataSet Accountds = new DataSet(); try { Accountds = Reusable.dsfromDB(Account); cboAccount.ValueMember = "accountid"; cboAccount.DisplayMember = "display_name"; cboAccount.DataSource = Accountds.Tables[0]; } catch { cboAccount.Text = "Error!"; MessageBox.Show("Error 014: Could not connect to database. Please contact an administratior"); } }
private void cboAccount_SelectedIndexChanged(object sender, EventArgs e) { string[] Accountinfoarr = { "accountid", "Name", "Type", "account WHERE AccountID = " + cboAccount.SelectedValue }; DataSet Accountinfo = new DataSet(); try { FillGroupBox(); Accountinfo = Reusable.dsfromDB(Accountinfoarr); txtAccountNumber.Text = Accountinfo.Tables[0].Rows[0][0].ToString(); txtName.Text = Accountinfo.Tables[0].Rows[0][1].ToString(); cboType.SelectedValue = Convert.ToInt32(Accountinfo.Tables[0].Rows[0][2].ToString()); } catch { MessageBox.Show("Error 006: Could not connect to database. Please contact an administratior"); } }
public static bool CheckBalance(ref Transaction T) { string[] Checkbalance = { "balance", "account where accountid = " + T.account }; string balance = Reusable.stringfromDB(Checkbalance); decimal d1 = decimal.Parse(balance); decimal d2 = decimal.Parse(T.amount); if (d1 >= d2) { return(true); } else { return(false); } }
public static void AddAccount(ref Account A) { string[] Acc = { "Accountid", "Account" }; OracleConnection conn = new OracleConnection(DBConnect.oradb); conn.Open(); A.AccountId = Reusable.GetNextId(Acc).ToString("D9"); String CustSQL = "INSERT INTO Account(AccountID,Customerid,name,type,Date_created) " + "VALUES('" + A.AccountId + "', '" + Customer.CustomerId + "', '" + A.Name + "', '" + A.Type + "', TO_DATE('" + A.Creation + "', 'DD/MM/YYYY'))"; OracleCommand Custcmd = new OracleCommand(CustSQL, conn); Custcmd.ExecuteNonQuery(); conn.Close(); }
private void FrmCreatAccount_Load(object sender, EventArgs e) { string[] AccountTypes = { "id", "name", "Account_type" }; DataSet AccountTypesds = new DataSet(); try { AccountTypesds = Reusable.dsfromDB(AccountTypes); cboAccountType.ValueMember = "id"; cboAccountType.DisplayMember = "name"; cboAccountType.DataSource = AccountTypesds.Tables[0]; lblDisplayName.Text = cboAccountType.Text; } catch { cboAccountType.Text = "Error!"; MessageBox.Show("Error 008: Could not connect to database. Please contact an administratior"); } }
public static void Transfer(ref Transaction T) { string[] Transaction = { "transactionid ", "Transaction" }; OracleConnection conn = new OracleConnection(DBConnect.oradb); conn.Open(); T.TransactionID = Reusable.GetNextId(Transaction).ToString("D14"); T.timestamp = DateTime.Now.ToString("dd/MM/yyyy/HH:mm:ss"); String transferSQL = "INSERT INTO Transaction(transactionid,accountid,Type,amount,note,timestamp) " + "VALUES('" + T.TransactionID + "', '" + T.account + "', '" + T.type + "', '" + T.amount + "', '" + T.note + "', TO_DATE('" + T.timestamp + "', 'DD/MM/YYYY HH24:MI:SS'))"; OracleCommand Transfercmd = new OracleCommand(transferSQL, conn); Transfercmd.ExecuteNonQuery(); string[] creditorarr = { "balance", "account where accountid = " + T.account }; string[] debtorarr = { "balance", "account where accountid = " + T.debtor }; string creditorbal = Reusable.stringfromDB(creditorarr); string debtorbal = Reusable.stringfromDB(debtorarr); decimal Cbal = decimal.Parse(creditorbal); decimal amount = decimal.Parse(T.amount); decimal Dbal = decimal.Parse(debtorbal); string newCreditorbal = (Cbal - amount).ToString("F2"); string newDebtorbal = (Dbal + amount).ToString("F2"); String removebal = "UPDATE Account SET BALANCE = '" + newCreditorbal + "' where accountid = " + T.account; String addbal = "UPDATE Account SET BALANCE = '" + newDebtorbal + "' where accountid = " + T.debtor; OracleCommand removebalance = new OracleCommand(removebal, conn); removebalance.ExecuteNonQuery(); OracleCommand addbalance = new OracleCommand(addbal, conn); addbalance.ExecuteNonQuery(); conn.Close(); }
private void FrmTerminateCustomer_Load(object sender, EventArgs e) { txtFName.Text = Customer.Fname; txtLName.Text = Customer.Lname; txtPhoneNo.Text = Customer.CountryCode + Customer.PhoneNo; txtDOB.Text = Customer.DOB; txtAddressL1.Text = Customer.AddressL1; txtAddressL2.Text = Customer.AddressL2; txtAddressL3.Text = Customer.AddressL3; txtTown.Text = Customer.Town; txtCounty.Text = Customer.County; txtEircode.Text = Customer.Eir; txtPhoneNo.Text = Customer.CountryCode + Customer.PhoneNo; txtDOB.Text = Customer.DOB; string[] accountsarr = { "A.ACCOUNTID", "A.Name", "A.STATUS", "T.NAME Type", "A.BALANCE", "A.DATE_created \"Date Created\"", "ACCOUNT A INNER JOIN ACCOUNT_TYPE T ON A.TYPE = T.ID WHERE CUSTOMERID = " + Customer.CustomerId + " ORDER BY ACCOUNTID ASC" }; DataSet accounts = new DataSet(); try { accounts = Reusable.dsfromDB(accountsarr); dataGridView1.DataSource = accounts.Tables[0]; dataGridView1.Columns[0].Width = 75; dataGridView1.Columns[1].Width = 175; dataGridView1.Columns[2].Width = 75; dataGridView1.Columns[3].Width = 50; dataGridView1.Columns[4].Width = 75; dataGridView1.Columns[5].Width = 100; } catch { MessageBox.Show("Error 002: Could not connect to database. Please contact an administratior"); } }
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 FrmUpdateCustomer_Load(object sender, EventArgs e) { string[] infoarr = { "Status", "Country_Code", "county", "Customer Where Customerid = " + Customer.CustomerId }; string[] countryarr = { "countryid", "CONCAT(country,CONCAT(' ',CONCAT('(',CONCAT(code,')')))) AS country", "country_code" }; string[] countyarr = { "countyid", "county", "county" }; DataSet info = new DataSet(); DataSet countryds = new DataSet(); DataSet countyds = new DataSet(); try { countryds = Reusable.dsfromDB(countryarr); cboCountryCode.ValueMember = "countryid"; cboCountryCode.DisplayMember = "country"; cboCountryCode.DataSource = countryds.Tables[0]; } catch { MessageBox.Show("Error 002: Could not connect to database. Please contact an administratior"); } try { countyds = Reusable.dsfromDB(countyarr); cboCounty.ValueMember = "countyid"; cboCounty.DisplayMember = "county"; cboCounty.DataSource = countyds.Tables[0]; } catch { MessageBox.Show("Error 003: Could not connect to database. Please contact an administratior"); } try { info = Reusable.dsfromDB(infoarr); } catch { MessageBox.Show("Error 003: Could not connect to database. Please contact an administratior"); } txtCustomerID.Text = Customer.CustomerId; if (info.Tables[0].Rows[0][0].ToString().Equals("A")) { txtStatus.Text = "Active"; } else { txtStatus.Text = "Terminated"; } txtCreationDate.Text = Customer.DateCreated; txtFName.Text = Customer.Fname; txtLName.Text = Customer.Lname; txtDOB.Text = Customer.DOB; txtPPSNo.Text = Customer.PPSNo; cboCountryCode.SelectedValue = info.Tables[0].Rows[0][1].ToString(); txtPhoneNo.Text = Customer.PhoneNo; txtAddressL1.Text = Customer.AddressL1; txtAddressL2.Text = Customer.AddressL2; txtAddressL3.Text = Customer.AddressL3; txtTown.Text = Customer.Town; cboCounty.SelectedValue = info.Tables[0].Rows[0][2].ToString(); txtEircode.Text = Customer.Eir; }
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"); } } }
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"); } } }