/*Search method show search menu and show input matching account*/ public void search() { Console.Clear(); WriteLine("Search Menu:\n"); Customer_BO customer = getInput(); Write("Account Number: "); string input = ReadLine(); if (input == "") { customer.Account_No = -100;/*since acoountNO is not -ve we store -ve value to show administrator does not update accountNO*/ } else { customer.Account_No = System.Convert.ToInt32(input); } Administrator_BLL administrator_BLL = new Administrator_BLL(); List <Customer_BO> list = administrator_BLL.search_BLL(customer); if (list != null) { WriteLine("==== SEARCH RESULTS ======"); Write( format: "{0,-13} {1,-13} {2,-13}", arg0: "Account ID", arg1: "User ID", arg2: "Holder Name"); WriteLine( format: "{0,-13} {1,-13} {2,-13}", arg0: "Type", arg1: "Balance", arg2: "Status" ); foreach (Customer_BO cus in list) { Write( format: "{0,-13} {1,-13} {2,-13}", arg0: cus.Account_No, arg1: cus.userName, arg2: cus.holderName); WriteLine("{0,-13} {1,-13} {2,-13}", arg0: cus.Type, arg1: cus.Balance, arg2: cus.Status); } WriteLine("Press any key to continue"); } else { WriteLine("Not a single Account exists with these attributes."); } }
/* * USER NAME and Passwrod of both customer and administrator are saved after encryption. * One customer from file user name and password are * User name = ariz123 * Password = 12345 * * Administrator user name and password are * User name = Gull * Password = 12345 */ public void homeScreen() { int choice = 0; bool l_break = false; while (true) { Console.Clear(); WriteLine("\n\n\t\t\t\t ATM SOFTWARE\n\n"); WriteLine("\t\t\t Please Select the LogIn Type.\n\n\t\t\t Enter 1. For Administrator,\n\t\t\t 2. For Customer" + "\n\t\t\t 3. For exit."); try { Write("\t\t\t "); choice = System.Convert.ToInt32(ReadLine()); switch (choice) { case 1: string pre_login = ""; int login_count = 1; bool loop_break = false; while (true) { Console.Clear(); Write("\n\n\t\t\tEnter login: "******"\t\t\tEnter Pin code: "); Console.ForegroundColor = ConsoleColor.Green; string pin = pinInput(); Console.ForegroundColor = ConsoleColor.White; Administrator_BLL administrator_BLL = new Administrator_BLL(); if (administrator_BLL.loginAccessAdmin(u_id, pin) == true) { Administrator_View administrator_View1 = new Administrator_View(); administrator_View1.administratorMenu(); loop_break = true; } if (administrator_BLL.loginAccessAdmin(u_id, pin) == false) { WriteLine("\n\n\t\tWrong Credientials Press any Key to continue\t\t"); ReadKey(); Console.Clear(); } if (pre_login == u_id) { login_count++; } pre_login = u_id; if (loop_break == true) { break; } if (login_count == 3) { administrator_BLL.disableAccount(u_id); WriteLine("\n\nYou enter 3 time wrong password your account is disable Please contact to administrator. Press any key to continue"); ReadKey(); Console.Clear(); break; } } break; case 2: bool loop_b = false; int count = 1; string previousLogin = ""; while (true) { /*For disable account we suspose that customer always enter correct user name; * password is incorrect * Hence, we disable the account for this user name customer*/ Console.Clear(); WriteLine("\n\n\t\t\tCustomer Service.\n\n"); Write("\t\t\tEnter login: "******"\t\t\tEnter Pin code: "); Console.ForegroundColor = ConsoleColor.Green; string pin_code = pinInput(); Console.ForegroundColor = ConsoleColor.White; Customer_BLL customer_BLL = new Customer_BLL(); if (customer_BLL.loginAccess(login, pin_code) == true) { Customer_BO customer = customer_BLL.createCustomer(login, pin_code); Customer_View customer_View = new Customer_View(); customer_View.customerMenu(customer); loop_b = true; } else { WriteLine("\n\n\tWrong Credientials or account is disable Press any Key to continue\t\t\t"); ReadKey(); } if (previousLogin == login) { count++; } previousLogin = login; if (loop_b == true) { break; } if (count == 3) { customer_BLL.disableAccount(login); WriteLine("\n\nYou enter 3 time wrong password your account is disable Please contact to administrator. Press any key to continue"); ReadKey(); Console.Clear(); break; } } break; case 3: l_break = true; break; default: WriteLine("\n\tinvalid input Press any key to continue.\t"); ReadKey(); Console.Clear(); break; } } catch (System.FormatException) { WriteLine("Invalid input please enter integer value Press any key to continue"); ReadKey(); Console.Clear(); } catch (OverflowException) { WriteLine("\n\n\tPlease enter 1 or 2 or 3 Press any key to Continue"); ReadKey(); Console.Clear(); } catch (Exception e) { WriteLine(e.Message + " Invalid Input."); } if (l_break == true) { break; } } }
/*method get input from administrator and create account*/ public void createAccount() { Administrator_BLL administrator_BLL = new Administrator_BLL(); int balance = 0; string type = ""; string status = ""; string login = inputString("Login"); string password = ""; while (true) { password = inputString("5 Digit Pin Code"); if (password.Length == 5) { break; } WriteLine("Pin code should be 5 digit"); } string name = inputString("Holder Name"); while (true) { bool l_b = false; try { Write("Type (Saving, Current): "); type = ReadLine(); if (type.ToLower() != "saving" && type.ToLower() != "savings" && type.ToLower() != "current") { throw new Exception(); } else { l_b = true; } } catch (Exception) { WriteLine("Please enter correct type saving or current. Press any key to continue"); ReadKey(); WriteLine(""); } if (l_b == true) { break; } } while (true) { balance = inputInt("Enter Starting Balance > 100: "); if (balance < 100) { WriteLine("Balance should b greater than 1000. Enter Again press any key to continue."); ReadKey(); WriteLine(""); } if (balance >= 100) { break; } } while (true) { bool l_break = false; try { Write("Status(active or disable): "); status = ReadLine(); if (status.ToLower() != "active" && status.ToLower() != "disable") { throw new Exception(); } else { l_break = true; } } catch (Exception) { WriteLine("Please enter valid status e.g(active,disable). press any key to continue."); ReadKey(); WriteLine(""); } if (l_break == true) { break; } } Customer_BO customer = new Customer_BO { userName = login, Password = password, holderName = name, Balance = balance, Status = status, Type = type }; int accountNumber = administrator_BLL.createAccount(customer); if (accountNumber > 0) { WriteLine("\nAccount Successfully created account number assigned is: " + accountNumber); WriteLine("Press any key to continue"); } else { WriteLine("\nProblem in File Account is not created"); WriteLine("Press any key to continue"); } }
/*method take starting date and ending date and show reports according to these dates*/ private void showByDate() { bool l_break = false; while (true) { Console.Clear(); try { Console.Clear(); DateTime s_date, e_date; Administrator_BLL administrator_BLL = new Administrator_BLL(); WriteLine("Date Formate dd/MM/yyyy\n"); WriteLine("Enter the starting date: "); s_date = DateTime.ParseExact(ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture); WriteLine("Enter the ending date: "); e_date = DateTime.ParseExact(ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture); List <Transaction_BO> list = administrator_BLL.byDate(s_date, e_date); if (list != null) { WriteLine("==== SEARCH RESULTS ======"); Write( format: "{0,-16} {1,-16} {2,-16}", arg0: "Transaction Type", arg1: "User ID", arg2: "Holder Name"); WriteLine( format: "{0,-16} {1,-16}", arg0: "Amount", arg1: "Date" ); foreach (Transaction_BO tr in list) { Write( format: "{0,-16} {1,-16} {2,-16}", arg0: tr.type, arg1: tr.user_id, arg2: tr.holderName); WriteLine("{0,-13} {1,-13}", arg0: tr.amount, arg1: tr.date.ToString("dd/MM/yyyy")); } l_break = true; } else { WriteLine("Record is not found for this Search Attributes"); l_break = true; } } catch (Exception) { WriteLine("Invalid input. Press any key to continue"); ReadKey(); } if (l_break == true) { break; } } }
/*method take mini. and max. amounts and show reports by this amount*/ private void showByAmount() { bool l_break = false; while (true) { Console.Clear(); try { int mini, max; Write("Enter the minimum amount: "); mini = System.Convert.ToInt32(ReadLine()); Write("Enter the maximum amount: "); max = System.Convert.ToInt32(ReadLine()); Administrator_BLL administrator_BLL = new Administrator_BLL(); List <Customer_BO> list = administrator_BLL.byAmounts(mini, max); if (list != null) { WriteLine("==== SEARCH RESULTS ======"); Write( format: "{0,-13} {1,-13} {2,-13}", arg0: "Account ID", arg1: "User ID", arg2: "Holder Name"); WriteLine( format: "{0,-13} {1,-13} {2,-13}", arg0: "Type", arg1: "Balance", arg2: "Status" ); foreach (Customer_BO cus in list) { Write( format: "{0,-13} {1,-13} {2,-13}", arg0: cus.Account_No, arg1: cus.userName, arg2: cus.holderName); WriteLine("{0,-13} {1,-13} {2,-13}", arg0: cus.Type, arg1: cus.Balance, arg2: cus.Status); } l_break = true; } else { WriteLine("Record is not found for this Search Attributes"); l_break = true; } } catch (Exception) { WriteLine("Input is not correct. Press any key to continue"); ReadKey(); } if (l_break == true) { break; } } }
/*method get account no from administrator and then take input to update account info*/ public void update() { bool l_break = false; while (true) { Console.Clear(); try { int accountNO; accountNO = inputInt("Enter the Account Number: "); Administrator_BLL administrator = new Administrator_BLL(); Customer_BO customerPrevious = administrator.giveAccount(accountNO); if (customerPrevious != null) { Console.Clear(); WriteLine("\n\nPrevious Details of Account."); showAccount(customerPrevious);// method display info of account WriteLine("\nPlease enter in the fields you wish to update (leave blank otherwise):\n"); Customer_BO customerNew = new Customer_BO(); customerNew = getInput(); while (true) { bool l_b = false; try { Write("Account Number: "); string input = ReadLine(); if (input == "") { customerNew.Account_No = -100;/*since acoountNO is not -ve we store -ve value to show administrator does not update accountNO*/ l_b = true; } else { customerNew.Account_No = System.Convert.ToInt32(input); l_b = true; } } catch (Exception) { WriteLine("please enter valid account number. Press any key to continue"); ReadKey(); } if (l_b == true) { break; } } bool result = administrator.update_BLL(customerPrevious, customerNew); if (result == true) { WriteLine("Your account has been successfully been updated."); l_break = true; } else { WriteLine("Your account is not updated."); l_break = true; } } else { WriteLine("Account is not Eixsts."); l_break = true; } } catch (Exception) { WriteLine("Input is not correct. Press any key to continue."); } if (l_break == true) { break; } } }
/*method get account number from adminstrator and delete this specific account*/ public void deleteAccount() { Administrator_BLL administrator = new Administrator_BLL(); bool l_break = false; while (true) { try { Console.Clear(); int accountNo; accountNo = inputInt("Enter the account number to which you want to delete: "); Customer_BO customer = administrator.giveAccount(accountNo); if (customer != null) { WriteLine("\n\nYou wish to delete the account held by Mr " + customer.holderName + " If this information is correct please re - enter the account number: "); int input_2nd = 0; try { input_2nd = System.Convert.ToInt32(ReadLine()); } catch (Exception) { } if (input_2nd == accountNo) { bool result = administrator.deleteAccount(accountNo); if (result == true) { WriteLine("\n\nAccount Deleted Successfully"); l_break = true; } else { WriteLine("Error in deleting account."); l_break = true; } } else { WriteLine("You enter wrong account number."); l_break = true; } } else { WriteLine("Account is not Exist."); l_break = true; } if (l_break == true) { break; } } catch (Exception) { WriteLine("Input is not correct"); } } }