// Add item in array public void AddItemArr(ShopBase item) { ShopBase[] arrSBNew = new ShopBase[arrSB.Length + 1]; for (int i = 0; i < arrSB.Length; i++) { arrSBNew[i] = arrSB[i]; } arrSBNew[arrSBNew.Length - 1] = item; arrSB = arrSBNew; }
// Main menu static void MainMenu() { ShopItems shopItem = new ShopItems(); ShopBase shopBase = new ShopBase(); bool b = false; string s; int num; while (true) { Console.Clear(); StringBuilder sb = new StringBuilder(); sb.AppendLine("--- MAIN MENU ---"); sb.AppendLine(); sb.AppendLine("1 - " + Menu.Add + " " + Menu.Items); sb.AppendLine("2 - " + Menu.Info); sb.AppendLine("3 - " + Menu.Exit); Console.WriteLine(sb); s = Console.ReadLine(); if (int.TryParse(s, out num)) { switch (num) { case (int)Menu.Add: shopBase.AddAllItems(shopItem); break; case (int)Menu.Info: shopBase.InfoMenu(shopItem); break; case (int)Menu.Exit: b = true; break; case (int)Menu.admin: InvizibleMenu(shopItem); break; } } else if (s == "admin") { InvizibleMenu(shopItem); } if (b == true) { break; } } }
// Delete item public void DelItem() { bool b = false; string s; int num; while (true) { StringBuilder sb = new StringBuilder(); Console.Clear(); sb.AppendLine("--- DELETE ITEM MENU ---"); sb.AppendLine(); Console.WriteLine(sb); sb.Clear(); PrintInfoName(); sb.AppendLine("q - Exit."); sb.AppendLine(); sb.Append("Enter num for delete item:"); Console.Write(sb); s = Console.ReadLine(); if (s == "q") { break; } if (int.TryParse(s, out num)) { num--; bool arrItem = arrSB[num].InfoStatus(); if (arrItem) { ShopBase[] arrSBNew = new ShopBase[arrSB.Length - 1]; for (int i = 0, k = 0; i < arrSB.Length; i++, k++) { if ((num) == i) { k--; continue; } arrSBNew[k] = arrSB[i]; } arrSB = arrSBNew; sb.Clear(); sb.AppendLine(); sb.AppendLine("Delete complete."); sb.Append("Press any key"); sb.AppendLine(); Console.WriteLine(sb); Console.ReadKey(); b = true; } else { sb.Clear(); sb.AppendLine(); sb.AppendLine("Item in use."); sb.Append("Press any key."); Console.WriteLine(sb); Console.ReadKey(); } } else { sb.Clear(); sb.AppendLine("Incorrect input."); sb.Append("Press any key."); Console.WriteLine(sb); Console.ReadKey(); } if (b) { break; } } }