public static void PrintMainMenuCMS(Menu menuCMSInstance) { Console.Clear(); Console.ResetColor(); CMSmenuView.LogoScreen(); menuCMSInstance.PrintMenuList(); }
public static void MainAddNewProduct() { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Please follow the next instructions to add a new record to Shop's Database.\n"); ConnectDB conection_DB = new ConnectDB(); PrintAvailableTables(conection_DB.GetTableNamesFromDb()); string table_name1 = CMSmenuView.GetTableName(); List <string> newEntryData = CMSmenuView.GetEntryToDbInput(table_name1, new List <string>() { "name", "division", "brigade", "battalion", "quantity", "unit", "status", "price" }); Product productToBeAdded = new Product(newEntryData[0], newEntryData[1], newEntryData[2], newEntryData[3], Int16.Parse(newEntryData[4]), newEntryData[5], newEntryData[6].ToUpper(), float.Parse(newEntryData[7])); conection_DB.AddProduct(table_name1, productToBeAdded); Console.ReadKey(); }
public static void PreviewAllItemsInStock() { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Please follow the next instructions to add a new record to Shop's Database.\n"); ConnectDB conection_DB_100 = new ConnectDB(); PrintAvailableTables(conection_DB_100.GetTableNamesFromDb()); string tableName = CMSmenuView.GetTableName(); List <string> columnsToQuery = conection_DB_100.GetColumnNamesFromTable(tableName); conection_DB_100.ReadTable(tableName, new List <string>() { "name", "division", "status" }); Console.ReadKey(); }
public void PrintmainMenu() { while (this.mainMenu.menuDisplayed) { mainMenu.current = mainMenu.menuItems[mainMenu.currentItemIndex]; // TODO: think about List<Menu> change to HashMap<Menu><bool> // to store info about current menu item mainMenu.current.isChecked = true; CMSmenuView.PrintMainMenuCMS(mainMenu); mainMenu.current.isChecked = false; var pressedKey = Console.ReadKey().Key; if (pressedKey == ConsoleKey.Enter) { // Parse current menu item content (string) to defined enum Enum.TryParse(mainMenu.current.Content, out CMSmenuOptions temp); switch ((int)temp) { case 0: // CREATE_NEW_RECORD CMSmenuView.MainAddNewProduct(); break; case 1: // READ_RECORDS CMSmenuView.SearchInStock(); break; case 2: // UPDATE_OR_DELETE_RECORD CMSmenuView.UpdateOrDelete(); break; case 3: // PREVIEW_ALL_ITEMS_IN_STOCK CMSmenuView.PreviewAllItemsInStock(); break; case 4: // EXIT_CMS mainMenu.menuDisplayed = false; break; } } mainMenu.NavigateMenu(pressedKey); } }
public static void SearchInStock() { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Display specific tables, columns or products\n"); ConnectDB conection_DB5 = new ConnectDB(); PrintAvailableTables(conection_DB5.GetTableNamesFromDb()); string table_name5 = CMSmenuView.GetTableName(); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("\nEnter a letter or word: "); Console.ResetColor(); string frag_cond = Console.ReadLine(); conection_DB5.SearchInTable(table_name5, frag_cond); Console.ReadKey(); }
public static List <string> GetEntryToDbInput(string dbTableName, List <string> requiredColumns) { List <string> dataRowInput = new List <string>(); Console.ForegroundColor = ConsoleColor.DarkGray; System.Console.WriteLine($"\nEnter the following information about new product which you want to add."); Console.ResetColor(); foreach (string column in requiredColumns) { string userInput; do { Console.Write($"{column.ToUpper()}: "); Console.ForegroundColor = ConsoleColor.DarkYellow; userInput = Console.ReadLine(); Console.ResetColor(); } while (!CMSmenuView.ValidateInputData(userInput, dbTableName, column)); dataRowInput.Add(userInput); } return(dataRowInput); }