// Method for populating and refreshing the Data Grid public void PrimeMainGrid() { BLLMngr bllManager = new BLLMngr(); // Getting Customer Accounts dataset from Database DataSet ds = bllManager.GetCustomerAccounts(); dgvMain.DataSource = null; dgvMain.DataSource = ds.Tables[0]; // Dataset assigned to Datagrid }
private void Transactions_Load(object sender, EventArgs e) { BLLMngr bllManager = new BLLMngr(); //Taking ID from global variables (populated by GetAccountID()) //Which gets the account ID from dgvMain DataSet ds = bllManager.AuditAccount(ID); //clearing then populating data source// dgvTransactions.DataSource = null; dgvTransactions.DataSource = ds.Tables[0]; }
private void LoginValidate() { // Local Variables // string pass; string user; string passHash; bool isValid; pass = txtPassword.Text; user = txtUser.Text; // Calling Encryption method from the BLL, this takes a password and returns the encrypted string BLLMngr bllMngr = new BLLMngr(); passHash = bllMngr.PassEncrypt(pass); //Instanciating a user UserModel userDetails = new UserModel(user, passHash); //Sending details (UserName and password) through BLL and DAL for validation at the database isValid = bllMngr.IsValidLogin(userDetails); //If it comes back as a valid user allow access and go to main DataGrid if (isValid) { MessageBox.Show("Welcome To DBS Credit Union"); using (DGMain dgm = new DGMain()) { this.Hide(); dgm.ShowDialog(); } this.Show(); txtPassword.Clear(); txtUser.Clear(); } else { MessageBox.Show("Invalid Login"); } }
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(); }
private void btnProcessTransaction_Click(object sender, EventArgs e) { // TRANSACTION DETAILS // string type = cboType.Text; string description = txtDescription.Text; string amountEuro = txtAmountEuro.Text.Trim(); // Takes Euro and Cent values, Adds them and stores cent value as int in Database string amountString = amountEuro + amountCent; int amount; int.TryParse(amountString, out amount); //method used to update the balance in users account int currentBalance = CurrentBalance(balance, amount); AccountModel account = new AccountModel(accountID, currentBalance); TransactionModel transaction = new TransactionModel(accountID, amount, type, description); BLLMngr bllMngr = new BLLMngr(); if(cboType.SelectedIndex == 2) { // Making a record of transaction and Updating Balance bllMngr.CreateTransaction(transaction); bllMngr.UpdateAccountBalance(account); MessageBox.Show("Deposit Complete"); } else if(cboType.SelectedIndex == 1) { if (bllMngr.ValidateWithdrawal(balance, overdraftLimit, amount)) { bllMngr.CreateTransaction(transaction); bllMngr.UpdateAccountBalance(account); MessageBox.Show("Withdrawal Complete"); } else { MessageBox.Show("Insufficient Funds"); } } else if(cboType.SelectedIndex == 0) { using(ProcessTransfer procTransfer = new ProcessTransfer()) { this.Hide(); // common variables procTransfer.Amount = amount; procTransfer.Description = txtDescription.Text; // debtor (cutomer who will send the money) procTransfer.DebtorAccountNumber = int.Parse(txtAccountNumber.Text); procTransfer.DebtorName = txtName.Text; procTransfer.DebtorID = accountID; procTransfer.DebtorSortCode = 101010; procTransfer.DebtorBalance = balance; //creditor (account to which money will be sent) procTransfer.CreditorAccountNumber = int.Parse(txtRecipientAccNo.Text); procTransfer.CreditorSortCode = int.Parse(txtRecipientSortCode.Text); procTransfer.CreditorID = bllMngr.GetAccountID(int.Parse(txtRecipientAccNo.Text)); procTransfer.CreditorBalance = bllMngr.GetAccountBalance(int.Parse(txtRecipientAccNo.Text)); //put values from previous form in here// procTransfer.ShowDialog(); } this.Close(); } this.Close(); }
private void btnAdd_Click(object sender, EventArgs e) { // CUSTOMER INFO // string firstName = txtFirstName.Text; string surname = txtSurname.Text; string address1 = txtAddress1.Text; string address2 = txtAddress2.Text; string city = txtCity.Text; string county = cboCounty.SelectedItem.ToString(); // ACCOUNT INFO // accountNo = 0; int.TryParse(txtAccountNo.Text, out accountNo); int sortCode = 0; int.TryParse(txtSortCode.Text, out sortCode); string amountEuro = txtAmountEuro.Text.Trim(); string amountCent = txtAmountCent.Text.Trim(); string amountString = amountEuro + amountCent; int amount; int.TryParse(amountString, out amount); string accountType = ""; if (rdoCurrent.Checked) { accountType = "Current"; } else if (rdoSavings.Checked) { accountType = "Savings"; } // TRANSACTION INFO // string description = "Initial Transaction"; string type = "Deposit"; // Creating three Objects // CustomerModel customer = new CustomerModel(firstName, surname, email, phone, address1, address2, city, county); AccountModel account = new AccountModel(accountType, accountNo, sortCode, amount, overDraftLimit); TransactionModel transaction = new TransactionModel(amount, type, description); // Sending to BLL // BLLMngr bllMngr = new BLLMngr(); bllMngr.CreateCustomerAccount(customer, account, transaction); MessageBox.Show("Customer Account Added"); this.Close(); }
private void editAccountToolStripMenuItem_Click(object sender, EventArgs e) { using (EditCustomer EditCust = new EditCustomer()) { if (dgvMain.SelectedRows.Count == 1) { BLLMngr bll = new BLLMngr(); // Method to pull full customer details of one customer from database and return a DataTable DataTable CustomerDetails = bll.GetFullAccountDetails((int)dgvMain.SelectedRows[selectedRow].Cells[0].Value); // Assigning fields from the table to variables inside EditCustomer form // These variables are then used to pre-populate the form foreach (DataRow row in CustomerDetails.Rows) { EditCust.FirstName = row["FirstName"].ToString(); EditCust.Surname = row["Surname"].ToString(); EditCust.Email = row["Email"].ToString(); EditCust.Phone = row["Phone"].ToString(); EditCust.Address1 = row["Address1"].ToString(); EditCust.Address2 = row["Address2"].ToString(); EditCust.City = row["City"].ToString(); EditCust.County = row["County"].ToString(); EditCust.AccountType = row["AccountType"].ToString(); EditCust.AccountNo = row["AccountNumber"].ToString(); EditCust.SortCode = row["SortCode"].ToString(); EditCust.InitialBalance = row["Balance"].ToString(); EditCust.OverdraftLimit = row["OverdraftLimit"].ToString(); EditCust.AccountID = row["AccountID"].ToString(); EditCust.CustomerID = row["CustomerID"].ToString(); } this.Hide(); EditCust.ShowDialog(); } } this.Show(); PrimeMainGrid(); }
private void exportToXMLToolStripMenuItem_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows.Count > 0) { // Setting relative location for XML file to be saved to string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/CustomerXML.xml"; int id = Convert.ToInt32(dgvMain.Rows[dgvMain.SelectedRows[0].Index].Cells["AccountID"].Value); BLLMngr bllMngr = new BLLMngr(); DataTable dt = bllMngr.GetFullAccountDetails(id); dt.TableName = "CustomerXML"; StreamWriter sW = new StreamWriter(path); dt.WriteXml(sW); MessageBox.Show("Customer Serialized"); } else { MessageBox.Show("Please Select An Account"); } }