public void CreateNewAccount() //to create user account with all validations and takes input in a customer object { //and then send that object to bll to create account. MainBLL bllTemp = new MainBLL(); WriteLine("CREATE NEW ACCOUNT\n\n"); bool checkValidity; d1: Write("Login: "******"\n=> Login ID only contains numbers or characters\n"); goto d1; } if (isAlreadyExist) { WriteLine("\n=> Login ID already Exists\n"); goto d1; } d3: Write("User ID: "); cbo.UserID = ReadLine(); checkValidity = bllTemp.DigitValidation(cbo.UserID); //userid validation isAlreadyExist = bllTemp.isLoginUseridExist(null, cbo.UserID); //check account exist or not based on user id if (cbo.UserID == "" || !checkValidity || cbo.UserID.Length != 5) { WriteLine("\n=> User ID only contains numbers - User ID must be 5 characters long\n"); goto d3; } if (isAlreadyExist) { WriteLine("\n=> User ID already Exists\n"); goto d3; } d4: Write("Pin Code: "); cbo.Pin = ReadLine(); checkValidity = bllTemp.DigitValidation(cbo.Pin); //pin validation if (cbo.Pin == "" || !checkValidity || cbo.Pin.Length != 5) { WriteLine("\n=> Pin only contains numbers - Pin must be of 5 digit long\n"); goto d4; } i1: Write("Holder's Name: "); cbo.Name = ReadLine(); if (cbo.Name == "") { WriteLine("\n=> Name must not be empty\n"); goto i1; } d5: Write("Type(Savings, Current): "); cbo.Type = ReadLine().ToLower(); checkValidity = bllTemp.TypeValidation(cbo.Type); //type validation if (cbo.Type == "" || !checkValidity) { WriteLine("\n=> There are only two types(Savings, Current)\n"); goto d5; } d7: Write("Starting Balance: "); string tmp = ReadLine(); bool isValid = bllTemp.AmountValidation(tmp); //amount validation if (!isValid) { WriteLine("\n=> Invalid Input\n"); goto d7; } cbo.Balance = decimal.Parse(tmp); d6: Write("Status: "); cbo.Status = ReadLine().ToLower(); checkValidity = bllTemp.StatusValidation(cbo.Status); //status validation if (cbo.Status == "" || !checkValidity) { WriteLine("\n=> There can be only two statuses of account(Active, Disable)\n"); goto d6; } cbo.AccountNo = bllTemp.LastAccountNumber() + 1; WriteLine($"\n=> Account Sucessfully Created - the account number assigned is: {cbo.AccountNo}"); MainBLL bll = new MainBLL(); bll.CreateCustomerAccount(cbo); }
public void MainScreen() //main screen with which the user interact very firstly. It also validate login credentials { //in case of wrong login id just displays error message and ask for input again, but in case of int wrongs = 0; //wrong pin code it displays counter for 3 wrong pins validation. in case of admins after 3 wrong Clear(); //pins it will say admin to try again later but in case of customer it will send request too bll WriteLine("\t\t*** Welcome To ATM Management System ***\n\n"); //to disable that customer account. d2: Write("Enter Login: "******"\n=> Login ID only contain numbers or characters\n"); goto d2; } l1: Write("\nEnter Pin: "); string code = ReadLine(); bool isPinValid = bll.DigitValidation(code); if (code == "" || code.Length != 5 || !isPinValid) { WriteLine("\n=> Pin code only contains numbers - Pin must have 5 digits"); } AdminBO bo = new AdminBO { Login = login, pin = code }; int who = -1; //for differetiation between customer and admin; 0 for customer and 1 for admin bool isUserFileExist = true; bool isCorrect = bll.IsLoginMatched(login, code, ref wrongs, ref who, ref isUserFileExist); bool isUserExist = bll.isLoginUseridExist(login, null); bool isAdminExist = bll.isAdminIDExist(login); if (isCorrect && who == -1) //success scenerio of admin { int AdminChoice = 0; AdminChoice = DisplayAdminMenu(); CheckAdminChoice(AdminChoice); } else if (!isCorrect && !isAdminExist && who == -1) //failure scenerio of admin { WriteLine($"\n=> No Account exist with the Login ID: {login}\n"); wrongs--; goto d2; } else if (!isCorrect && who == -1 && wrongs == 3) //failure scenerio as wrong inputs are now 3. so admin { //now should try next time or after a while. Console.WriteLine("\n=> Invalid Username or Password - Try Again Later\n"); System.Environment.Exit(1); } else if (isCorrect && who == 0) //success scenerio of customer { bool isDisable = bll.IsAccountDisable(login); //check whether account is disables or not if (isDisable) { WriteLine($"\n=> Account is against Login ID: {login} is unfortunately Disabled\n"); goto d2; } int choice = 0; cbo = bll.GetCurrentUser(login, null, 0); choice = DisplayUserMenu(); CheckUserChoice(choice); } else if (!isUserFileExist) { WriteLine("\n=> We Have No Records !\n"); wrongs--; goto d2; } else if (!isCorrect && who == 0 && wrongs == 3) //if wrong entries of pin are 3 now so make account disable { Console.WriteLine($"\n=> Multiple Wrong Pins - Account against Login ID: {login} is Disabled Now\n"); bll.MakeAccountDisable(login); System.Environment.Exit(1); } else if (!isCorrect && !isUserExist && who == 0) { WriteLine($"\n=> No Account exist with the Login ID: {login}\n"); wrongs--; goto d2; } else { WriteLine($"\n=> Wrong Pin - Try Again - {3 - wrongs} tries left"); goto l1; } }