private void btnWithdrawConfirm_Click(object sender, EventArgs e) { decimal wa; if (!decimal.TryParse(txtWithdrawAmount.Text, out wa)) { lblWithdrawAmount.Text = "Please enter a number!"; } else { var be = new Banking(); var data = (from account in be.Accounts where account.AccountNo == Account_No select account).Single(); decimal new_bal = data.Balance - wa; if (new_bal < 0) { lblWithdrawAmount.Text = "Not enough Funds!"; } else { data.Balance = new_bal; var withdrawal = new Transactions("w", data.AccountNo, wa, DateTime.Now); be.Transactions.InsertOnSubmit(withdrawal); be.SubmitChanges(); Close(); } } }
private void btnConfirmDeposit_Click(object sender, EventArgs e) { decimal da; if (!decimal.TryParse(txtDepositAmount.Text, out da)) { lblDepositAmount.Text = "Please enter a number!"; } else { var be = new Banking(); var data = (from account in be.Accounts where account.AccountNo == Account_No select account).Single(); data.Balance += da; var deposit = new Transactions("d", data.AccountNo, da, DateTime.Now); be.Transactions.InsertOnSubmit(deposit); be.SubmitChanges(); Close(); } }