public bool Transfer(int account1, int account2, double transferAmount) { double balance = 0; double balance2 = 0; DataAccessTier.Account da = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = da.SelectRecordswithsmallID(account1); balance = Convert.ToDouble(dt.Rows[0][4]); DataTable dt2 = new DataTable(); dt2 = da.SelectRecordswithsmallID(account2); balance2 = Convert.ToDouble(dt2.Rows[0][4]); if (transferAmount >= balance) { throw new ApplicationException("transfer amount must be greater than balance"); } else if (transferAmount <= 0) { throw new ApplicationException("invalid transfer amount"); } balance = balance - transferAmount; balance2 += transferAmount; da.UpdateAccount(dt.Rows[0][2].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), balance, dt.Rows[0][5].ToString()); da.UpdateAccount(dt2.Rows[0][2].ToString(), dt2.Rows[0][2].ToString(), dt2.Rows[0][3].ToString(), balance2, dt2.Rows[0][5].ToString()); return(true); }
private void btnAdd_Click(object sender, EventArgs e) { DataAccessTier.Account dp = new DataAccessTier.Account(); string title = txtAccTitle.Text; double balance = Convert.ToDouble(txtCurrBal.Text); string date = dateOpened.Text; dp.UpdateAccount(cmdLoad.Text, TxtAccount.Text, title, balance, date); MessageBox.Show("Update Sucessful"); }
private void cmdLoad_SelectedIndexChanged(object sender, EventArgs e) { DataAccessTier.Account dp = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = dp.SelectRecordswithID(cmdLoad.Text); TxtAccount.Text = cmdLoad.Text; txtAccTitle.Text = dt.Rows[0][3].ToString(); txtCurrBal.Text = dt.Rows[0][4].ToString(); dateOpened.Text = dt.Rows[0][5].ToString(); }
private void EditAccount_Load(object sender, EventArgs e) { DataAccessTier.Account dp = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = dp.SelectRecords(); for (int i = 0; i < dt.Rows.Count; i++) { cmdLoad.Items.Add(dt.Rows[i][2]); } }
private void AddTransaction_Load(object sender, EventArgs e) { DataAccessTier.Account dp = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = dp.SelectRecords(); for (int i = 0; i < dt.Rows.Count; i++) { cmdLoad.Items.Add(dt.Rows[i][0]); metroComboBox1.Items.Add(dt.Rows[i][0]); } }
private void btnAdd_Click(object sender, EventArgs e) { string num = txtAccNum.Text; string title = txtAccTitle.Text; double balance = Convert.ToDouble(txtCurrBal.Text); string date = dateOpened.Text; int id = Convert.ToInt32(cmdLoad.Text); DataAccessTier.Account ac = new DataAccessTier.Account(); ac.InsertAccount(id, num, title, balance, date); MessageBox.Show("Success"); }
private void btnDelte_Click(object sender, EventArgs e) { int id = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value); DataAccessTier.Account dp = new DataAccessTier.Account(); dp.DeleteAccount(id); MessageBox.Show("Delete Sucessful"); DataTable dt = new DataTable(); dt = dp.SelectRecords(); dataGridView1.DataSource = dt; }
public bool Deposit(int accountnumber, double amount) { double balance = 0; DataAccessTier.Account da = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = da.SelectRecordswithsmallID(accountnumber); balance = Convert.ToDouble(dt.Rows[0][4]); if (amount == 0) { MessageBox.Show("invalid Deposit amount"); } else { balance = amount + balance; da.UpdateAccount(dt.Rows[0][2].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), balance, dt.Rows[0][5].ToString()); } return(true); }
private void DeleteAccount_Load(object sender, EventArgs e) { dataGridView1.BorderStyle = BorderStyle.None; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Green; dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; dataGridView1.BackgroundColor = Color.White; dataGridView1.EnableHeadersVisualStyles = false; dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(50, 205, 50); dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; DataAccessTier.Account dp = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = dp.SelectRecords(); dataGridView1.DataSource = dt; }
public bool Withdraw(double amount, int accountnumber) { double balance = 0; DataAccessTier.Account da = new DataAccessTier.Account(); DataTable dt = new DataTable(); dt = da.SelectRecordswithsmallID(accountnumber); balance = Convert.ToDouble(dt.Rows[0][4]); if (amount < balance) { balance = balance - amount; da.UpdateAccount(dt.Rows[0][2].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), balance, dt.Rows[0][5].ToString()); } else { MessageBox.Show("invalid withdrawal amount"); } return(true); }