public void CreateTransfer(int credID, int debID, TransferModel transfer) { DALMngr dalMngr = new DALMngr(); dalMngr.CreateTransfer(credID, debID, transfer); }
private void btnProcessTransfer_Click(object sender, EventArgs e) { BLLMngr bllMngr = new BLLMngr(); string type = "Transfer"; // Creating debtor and creditor models and adding two transactions to DB TransactionModel debtor = new TransactionModel(DebtorID, Amount, type, Description); bllMngr.CreateTransaction(debtor); int debID = bllMngr.TransactionID; // Taking Id from debtor transaction TransactionModel creditor = new TransactionModel(CreditorID, Amount, type, Description); bllMngr.CreateTransaction(creditor); int credID = bllMngr.TransactionID; // Taking ID from creditor transaction TransferModel transfer = new TransferModel(debID, credID, CreditorSortCode, CreditorAccountNumber); CreditorBalance += Amount; DebtorBalance -= Amount; // Creating models so that balance may be updated in UpdateAccountBalance() below AccountModel credAcc = new AccountModel(CreditorID, CreditorBalance); AccountModel debAcc = new AccountModel(DebtorID, DebtorBalance); bllMngr.CreateTransfer(credID, debID, transfer); bllMngr.UpdateAccountBalance(debAcc); bllMngr.UpdateAccountBalance(credAcc); MessageBox.Show("Transfer Complete"); this.Close(); }
public void CreateTransfer(int credID, int debID, TransferModel transfer) { // trying to get the account details to get customer details // AccountModel creditorsAccount = new AccountModel(credit.AccountID); // How to get the name based on account // using (SqlConnection cxn = new SqlConnection(cxnString)) { SqlCommand cmdTransfer = new SqlCommand("spAddTransfer", cxn); cmdTransfer.CommandType = CommandType.StoredProcedure; SqlParameter transactionCreditIDParam = new SqlParameter("@TransactionCreditID", SqlDbType.Int); transactionCreditIDParam.Value = credID; SqlParameter transactionDebitIDParam = new SqlParameter("@TransactionDebitID", SqlDbType.Int); transactionDebitIDParam.Value = debID; SqlParameter DestinationSortCodeParam = new SqlParameter("@DestinationSortCode", SqlDbType.NVarChar, 50); DestinationSortCodeParam.Value = transfer.DestinationSortCode; SqlParameter DestinationAccountNumberParam = new SqlParameter("@DestinationAccountNumber", SqlDbType.Int); DestinationAccountNumberParam.Value = transfer.DestinationAccountNumber; SqlParameter TransferIDParam = new SqlParameter("@TransferID", SqlDbType.Int); TransferIDParam.Direction = ParameterDirection.Output; //ADD PARAMETERS// cmdTransfer.Parameters.Add(transactionCreditIDParam); cmdTransfer.Parameters.Add(transactionDebitIDParam); cmdTransfer.Parameters.Add(DestinationSortCodeParam); cmdTransfer.Parameters.Add(DestinationAccountNumberParam); cmdTransfer.Parameters.Add(TransferIDParam); cxn.Open(); cmdTransfer.ExecuteNonQuery(); cxn.Close(); } }