/// <summary> /// This is the sign up form. /// </summary> public void NewCustomerForm() { Console.Clear(); Customer customer = new Customer(); Console.WriteLine("\n Please insert the following details: \n"); #region FillForm: Console.Write(" 1. User Name: "); customer.UserName = input.GetUserInput <string>(); Console.Write(" 2. Password: "******" 3. First Name: "); customer.FirstName = input.GetUserInput <string>(); Console.Write(" 4. Last Name: "); customer.LastName = input.GetUserInput <string>(); Console.Write(" 5. Credit Card Number: "); customer.CreditNumber = input.GetUserInput <string>(); #endregion // The program will check if the selected username is taken or not. if (storeDAO.GetCustomerByUsername(customer.UserName).ID != 0) { storeDAO.AddLogRecord( new LogRecord(DateTime.Now, $"A user attempted to create new customer account", "No", $"The username: {customer.UserName} Already exists")); HandleError(new UserNameAlreadyExistException("User name already exist")); return; } if (mode == TestMode.On) { return; } storeDAO.CreateCustomer(customer); Console.WriteLine("\n Your account created successfully! Press Enter to procced."); Console.ReadKey(); storeDAO.AddLogRecord( new LogRecord(DateTime.Now, $"A new customer account has been created by user: {customer.UserName}", "Yes", "")); MainForm mainForm = new MainForm(mode); mainForm.StartScreen(); }
/// <summary> /// This is the sign up form. /// </summary> public void NewSupplierForm() { Console.Clear(); Supplier supplier = new Supplier(); Console.WriteLine("\n Please insert the following details: \n"); Console.Write(" 1. User Name: "); supplier.UserName = input.GetUserInput <string>(); Console.Write(" 2. Password: "******" 3. Company Name: "); supplier.Company = input.GetUserInput <string>(); // The program will check if the selected username is taken or not. if (storeDAO.GetSupplierByUsername(supplier.UserName).ID != 0) { storeDAO.AddLogRecord( new LogRecord(DateTime.Now, $"A user attempted to create new supplier account", "No", $"The username: {supplier.UserName} Already exists")); HandleError(new UserNameAlreadyExistException("User name already exist")); SignInScreen(); return; } if (mode == TestMode.On) { return; } storeDAO.CreateNewSupplier(supplier); Console.WriteLine("\n Your account created successfully! Press Enter to procced."); Console.ReadKey(); storeDAO.AddLogRecord( new LogRecord(DateTime.Now, $"A new supplier account was created by the user: {supplier.UserName}", "Yes", "")); MainForm mainForm = new MainForm(mode); mainForm.StartScreen(); }