Exemplo n.º 1
0
        public void OrderItem()
        {
            string productName;
            int    amount;

            Console.WriteLine("Enter product name:");
            productName = Console.ReadLine();
            Console.WriteLine("Enter amount:");
            amount = int.Parse(Console.ReadLine());
            string result = manageInventoryDAO.OrderItem(productName, amount, client);

            if (result == "Order created successfully")
            {
                Console.WriteLine(result);
                HistoryDAO.Create("Order Item", result);
            }
            else if (result == "Not enough in stock")
            {
                Console.WriteLine(result);
                HistoryDAO.Create("Order Item", "Failed " + result);
            }
            else if (result == "Item does not exist in stock")
            {
                Console.WriteLine(result);
                HistoryDAO.Create("Order Item", "Failed " + result);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            bool check = true;

            while (check)
            {
                Console.WriteLine("Welcome to SmartCo Database Managing App (SDMA) ");
                Console.WriteLine("Choose a Function: \n" +
                                  "1. Login Client \n" +
                                  "2. Create New Client \n" +
                                  "3. Login Supplier \n" +
                                  "4. Create New Supplier \n" +
                                  "5. Actions History");
                int choice;
                try
                {
                    choice = int.Parse(Console.ReadLine());
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter a valid choice (1-5) ");
                    continue;
                }

                switch (choice)
                {
                case 1:
                    clientLogic.loginPrompt();
                    break;

                case 2:
                    clientLogic.CreateUser();
                    break;

                case 3:
                    supplierLogic.loginPrompt();
                    break;

                case 4:
                    supplierLogic.CreateSupplier();
                    break;

                case 5:
                    HistoryDAO.ViewAll();
                    break;

                default:
                    Console.WriteLine("Please enter a valid choice (1-5) ");
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public void clientMenu()
        {
            bool check = true;

            while (check)
            {
                Console.WriteLine($"Hello {client.Name} what would you like to do?");
                Console.WriteLine("Choose a Function: \n" +
                                  "1. View all of my orders \n" +
                                  "2. View all Products \n" +
                                  "3. Order a product \n" +
                                  "4. Logout");
                int choice;
                try
                {
                    choice = int.Parse(Console.ReadLine());
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter a valid choice (1-4) \n");
                    continue;
                }

                switch (choice)
                {
                case 1:
                    manageInventoryDAO.ShoppingHistory(client);
                    HistoryDAO.Create("Client requested order history", "");
                    break;

                case 2:
                    manageInventoryDAO.ShoppingCatalog();
                    HistoryDAO.Create("Client requested Shopping Catalog", "");
                    break;

                case 3:
                    OrderItem();
                    break;

                case 4:
                    check = false;
                    HistoryDAO.Create("Client logged out", "");
                    client = null;
                    break;

                default:
                    Console.WriteLine("Please enter a valid choice (1-4) ");
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public void CreateUser()
        {
            bool retry = true;

            while (retry)
            {
                string username;
                string password;
                string firstName;
                string lastName;
                string cardNumber;
                Console.WriteLine("Enter username:"******"Enter password:"******"Enter first name:");
                firstName = Console.ReadLine();
                Console.WriteLine("Enter last name:");
                lastName = Console.ReadLine();
                Console.WriteLine("Enter card number:");
                cardNumber = Console.ReadLine();

                string result = clientDAO.Create(username, password, firstName, lastName, cardNumber);
                if (result == "Username already exists")
                {
                    HistoryDAO.Create("Create Client", "Failed " + result);
                    Console.WriteLine(result);
                    Console.WriteLine("Try again? (y/n)");
                    string tmp = Console.ReadLine();
                    if (tmp != "y")
                    {
                        retry = false;
                    }
                }
                else if (result == "Client created successfully")
                {
                    HistoryDAO.Create("Create Client", result);
                    Console.WriteLine(result);
                    retry = false;
                }
            }
        }
Exemplo n.º 5
0
        public void supplierMenu()
        {
            bool check = true;

            while (check)
            {
                Console.WriteLine($"Hello {supplier.CompanyName} what would you like to do?");
                Console.WriteLine("Choose a Function: \n" +
                                  "1. Manage my products\n" +
                                  "2. View all of my Products in the store \n" +
                                  "3. Logout");
                int choice;
                try
                {
                    choice = int.Parse(Console.ReadLine());
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter a valid choice (1-2) ");
                    break;
                }

                switch (choice)
                {
                case 1:
                    AddItemToShop();
                    break;

                case 2:
                    manageInventoryDAO.SuppliersProducts(supplier);
                    HistoryDAO.Create("Supplier requested to view his products", "");
                    break;

                case 3:
                    supplier = null;
                    check    = false;
                    HistoryDAO.Create("Supplier logged out", "");
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public void loginPrompt()
        {
            bool retry = true;

            while (retry)
            {
                string username;
                string password;
                Console.WriteLine("Enter username:"******"Enter password:"******"Login Client", "Failed " + "Wrong username or password");
                    Console.WriteLine("Wrong username or password");
                    Console.WriteLine("Try again? (y/n)");
                    string tmp = Console.ReadLine();
                    if (tmp != "y")
                    {
                        retry = false;
                    }
                }
                else
                {
                    HistoryDAO.Create("Login Client", "login successful");
                    Console.WriteLine("login successful");
                    client = c;
                    clientMenu();
                    retry = false;
                }
            }
        }
Exemplo n.º 7
0
        public void CreateSupplier()
        {
            bool retry = true;

            while (retry)
            {
                string username;
                string password;
                string companyName;
                Console.WriteLine("Enter username:"******"Enter password:"******"Enter company name:");
                companyName = Console.ReadLine();

                string result = supplierDAO.Create(username, password, companyName);
                if (result == "Username already exists")
                {
                    HistoryDAO.Create("Create Supplier", "Failed " + result);
                    Console.WriteLine(result);
                    Console.WriteLine("Try again? (y/n)");
                    string tmp = Console.ReadLine();
                    if (tmp != "y")
                    {
                        retry = false;
                    }
                }
                else if (result == "Supplier created successfully")
                {
                    HistoryDAO.Create("Create Supplier", result);
                    Console.WriteLine(result);
                    retry = false;
                }
            }
        }
Exemplo n.º 8
0
        public void AddItemToShop()
        {
            bool check = true;

            while (check)
            {
                Console.WriteLine("Choose an option (1-2):\n" +
                                  "1. Add a product to store inventory\n" +
                                  "2. Add amount to an existing product");
                int choice;
                try
                {
                    choice = int.Parse(Console.ReadLine());
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter a valid choice (1-2) ");
                    continue;
                }
                if (choice > 2)
                {
                    Console.WriteLine("Please enter a valid choice (1-2) ");
                }
                string productName;
                Console.WriteLine("Enter Product Name:");
                productName = Console.ReadLine();
                Product p = manageInventoryDAO.FindProduct(productName);

                if (choice == 1)
                {
                    if (p == null)
                    {
                        float price;
                        int   amount;
                        Console.WriteLine("Enter Price:");
                        price = float.Parse(Console.ReadLine());
                        Console.WriteLine("Enter Amount:");
                        amount = int.Parse(Console.ReadLine());
                        manageInventoryDAO.CreateNewProduct(productName, supplier.Id, amount, price);
                        string result = "Product added to the shop";
                        Console.WriteLine(result);
                        HistoryDAO.Create("Add new item to the shop", result);
                        check = false;
                    }
                    else
                    {
                        string result = "Item already exists";
                        HistoryDAO.Create("Add new item to the shop", "Failed, " + result);
                        Console.WriteLine(result + "\n Returning back to menu...");
                    }
                }
                else if (choice == 2)
                {
                    if (p.SupplierId == supplier.Id)
                    {
                        int amount;
                        Console.WriteLine("Enter Amount:");
                        amount = int.Parse(Console.ReadLine());
                        manageInventoryDAO.AddAmountToStock(productName, amount);
                        string result = "Product amount increased";
                        HistoryDAO.Create("Add amount to product", result);
                        check = false;
                    }
                    else
                    {
                        string result = "Item already exists from another supplier";
                        HistoryDAO.Create("Add amount to product", "Failed, " + result);
                        Console.WriteLine(result + "\n Returning back to menu...");
                    }
                }
            }
        }