Advertisement
Tec4Gen

Untitled

Dec 5th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using Warehouse;
  6. using Warehouse.Item;
  7. using Kits;
  8. namespace StartPoint
  9. {
  10.  
  11. class Program
  12. {
  13. static void Main()
  14. {
  15. string selection,TitleKit, TitleItem, ProdData;
  16. string[] ArrTitleItem;
  17.  
  18. List<Item> ArrItem = new List<Item>();
  19. //Комплекты
  20. List<Item> KitList = new List<Item>();
  21.  
  22. List<Kit> KitListAll = new List<Kit>();
  23. //Партии
  24. List<Item> PartyList = new List<Item>();
  25.  
  26. List<Party> PartyListAll = new List<Party>();
  27. //общий список
  28. List<Product> ProductsAll = new List<Product>();
  29.  
  30. using (StreamReader fileIn = new StreamReader(@"../../DataItem.txt"))
  31. {
  32. while (!fileIn.EndOfStream)
  33. {
  34. string[] Line;
  35. Line = fileIn.ReadLine().Split(' ');
  36.  
  37. Item obj = new Item(Line[0], Convert.ToInt32(Line[1]), Line[2], Line[3]);
  38. ArrItem.Add(obj);
  39.  
  40. ProductsAll.Add(obj);
  41. }
  42. }
  43.  
  44. switchMenu:
  45. Console.WriteLine("Выбирите действие");
  46. Console.WriteLine("1) Найти информацию об 1 товаре");
  47. Console.WriteLine("2) Собрать комплект из нескольки товаров");
  48. Console.WriteLine("3) Собрать партию");
  49. Console.WriteLine("4) Отсортировать партию");
  50. Console.WriteLine("5) Отсортировать Комплект");
  51. Console.WriteLine();
  52. selection = Console.ReadLine();
  53. switch (selection)
  54. {
  55. case "1":
  56. Console.WriteLine("Введите название товара");
  57. selection = Console.ReadLine();
  58.  
  59. foreach (var item in ArrItem)
  60. {
  61. if(selection == item.Title)
  62. {
  63. item.ItemInfo();
  64. }
  65. else
  66. {
  67. Console.WriteLine("Такого товара нет");
  68. }
  69. }
  70. goto switchMenu;
  71.  
  72. case "2":
  73. Console.WriteLine("Введите навание комплекта");
  74. TitleKit = Console.ReadLine();
  75. Console.Write("Введите названия товаров: ");
  76. TitleItem = Console.ReadLine();
  77.  
  78. ArrTitleItem = TitleItem.Split(' ');
  79.  
  80. for (int i = 0; i < ArrTitleItem.Length; i++)
  81. {
  82. var temp = ArrItem.Where(item => item.Title == ArrTitleItem[i]).ToList();
  83.  
  84. foreach (Item item in temp)
  85. {
  86. KitList.Add(item);
  87. }
  88. }
  89. Kit Kits = new Kit(TitleKit, KitList);
  90.  
  91. Console.Write("Комплект {0} собран", TitleKit);
  92. Kits.ItemInfo();
  93.  
  94. KitListAll.Add(Kits);
  95. ProductsAll.Add(Kits);
  96.  
  97. goto switchMenu;
  98. case "3":
  99. Console.WriteLine("Введите навание партии");
  100. TitleKit = Console.ReadLine();
  101. Console.WriteLine("Введите цену партии");
  102. int.TryParse(Console.ReadLine(),out int PriceParty);
  103. Console.WriteLine("Введите Срок годности партии");
  104. ProdData = Console.ReadLine();
  105. Console.WriteLine("Введите количество");
  106. int.TryParse(Console.ReadLine(),out int CountPartyItem);
  107.  
  108. Console.Write("Введите названия товаров: ");
  109. TitleItem = Console.ReadLine();
  110.  
  111. ArrTitleItem = TitleItem.Split(' ');
  112.  
  113. for (int i = 0; i < ArrTitleItem.Length; i++)
  114. {
  115. var temp = ArrItem.Where(item => item.Title == ArrTitleItem[i]).ToList();
  116.  
  117. foreach (Item item in temp)
  118. {
  119. PartyList.Add(item);
  120. }
  121. }
  122.  
  123. Party Party = new Party(TitleKit,PriceParty,ProdData,CountPartyItem, PartyList);
  124.  
  125. Console.Write("Партия {0} собрана", TitleKit);
  126. Party.ItemInfo();
  127.  
  128. PartyListAll.Add(Party);
  129. ProductsAll.Add(Party);
  130.  
  131. goto switchMenu;
  132. case "4":
  133.  
  134. Console.WriteLine("Выберите комплект для сортировки");
  135. selection = Console.ReadLine();
  136. if (PartyListAll!=null)
  137. {
  138. int i = 0;
  139. foreach (var item in PartyListAll)
  140. {
  141. Console.WriteLine("{0}) {1} ",i,item.Title);
  142. }
  143. int.TryParse(Console.ReadLine(),out int kek);
  144. //тут я уже очень устал
  145. PartyListAll[i].ListProducts.Sort();
  146.  
  147. Console.WriteLine("Отсортирован*");
  148. PartyListAll[i].ItemInfo();
  149.  
  150. }
  151.  
  152. goto switchMenu;
  153. default:
  154. Console.WriteLine("Вы нажали неизвестную букву");
  155. break;
  156. }
  157.  
  158. }
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement