public SearchEmployee(IBL BL) { this.itsBL = BL; minInt = Convert.ToString(Int32.MinValue); maxInt = Convert.ToString(Int32.MaxValue); minDateTime = Convert.ToString(DateTime.MinValue); maxDateTIme = Convert.ToString(DateTime.MaxValue); string cmd; while (true) { Console.Clear(); Console.WriteLine("search employee by :"); Console.WriteLine("\t1. his teudat Zehute "); Console.WriteLine("\t2. his first name "); Console.WriteLine("\t3. his last name "); Console.WriteLine("\t4. department ID "); Console.WriteLine("\t5. salary "); Console.WriteLine("\t6. gender "); Console.WriteLine("\t7. supervisor ID"); Console.WriteLine("\t8. gat all employees "); Console.WriteLine("\t9. back "); Console.WriteLine("\t10. back to main menu "); cmd = Console.ReadLine(); switch (cmd) { case "1": Console.WriteLine("Enter the teudat Zehute you want to find (notice! must my numbers): "); string eTZ = Console.ReadLine(); while (!(InputCheck.isInt(eTZ))) { Console.WriteLine("Invalid teudat zehute. \n enter again"); eTZ = Console.ReadLine(); } List <object> tehudotList = itsBL.queryByString(Classes.Employee, stringFields.teudatZehute, eTZ); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newDList1 = tehudotList.Cast <Employee>().ToList(); if (newDList1.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterT = 1; foreach (Employee e in newDList1) { Console.WriteLine(+counterT + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterT++; } subMenu whatNext1 = new subMenu(itsBL); whatNext1.Menu("5", counterT, tehudotList); break; case "2": Console.Clear(); Console.WriteLine("Enter the first name you want to find: "); string efirst = Console.ReadLine(); List <object> firstList = itsBL.queryByString(Classes.Employee, stringFields.firstName, efirst); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newDList2 = firstList.Cast <Employee>().ToList(); if (newDList2.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterF = 1; foreach (Employee e in newDList2) { Console.WriteLine(+counterF + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterF++; } subMenu whatNext2 = new subMenu(itsBL); whatNext2.Menu("5", counterF, firstList); break; case "3": Console.Clear(); Console.WriteLine("Enter the last name you want to find: "); string elast = Console.ReadLine(); List <object> lastList = itsBL.queryByString(Classes.Employee, stringFields.lastName, elast); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newDList3 = lastList.Cast <Employee>().ToList(); if (newDList3.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterL = 1; foreach (Employee e in newDList3) { Console.WriteLine(+counterL + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterL++; } subMenu whatNext3 = new subMenu(itsBL); whatNext3.Menu("5", counterL, lastList); break; case "4": Console.Clear(); Console.WriteLine("Enter the department ID you want to find: (notice! must be numbers) "); string edepar = Console.ReadLine(); while (!(InputCheck.isInt(edepar))) { Console.WriteLine("Invalid department ID. \n enter again"); edepar = Console.ReadLine(); } List <object> depList = itsBL.queryByString(Classes.Employee, stringFields.departmentID, edepar); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newList4 = depList.Cast <Employee>().ToList(); if (newList4.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterD = 1; foreach (Employee e in newList4) { Console.WriteLine(+counterD + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterD++; } subMenu whatNext4 = new subMenu(itsBL); whatNext4.Menu("5", counterD, depList); break; case "5": Console.Clear(); Console.WriteLine("Choose an option: "); Console.WriteLine("\t1. Search for specific salary "); Console.WriteLine("\t2. Search range of salary "); string search = Console.ReadLine(); string fromValue = null; string toValue = null; //bool ans = true; //while (ans) //{ switch (search) { case "1": Console.WriteLine("enter salary: "); string salary = Console.ReadLine(); while (!(InputCheck.isDouble(salary))) { Console.WriteLine("invalid salary. \n try again"); salary = Console.ReadLine(); } fromValue = salary; toValue = salary; //ans=false; break; case "2": Console.WriteLine("from which salary to search: "); string fromSalary = Console.ReadLine(); while (!(InputCheck.isDouble(fromSalary))) { Console.WriteLine("invalid salary. \n try again"); fromSalary = Console.ReadLine(); } fromValue = fromSalary; Console.WriteLine("until which salary to search: "); string toSalary = Console.ReadLine(); while (!(InputCheck.isDouble(toSalary))) { Console.WriteLine("invalid salary. \n try again"); toSalary = Console.ReadLine(); } toValue = toSalary; //ans=false; break; default: Console.WriteLine("You perform illegal move, please choose 1 or 2"); break; } // } List <object> salaryList = itsBL.queryByRange(Classes.Employee, rangeFields.salary, fromValue, toValue); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newList5 = salaryList.Cast <Employee>().ToList(); if (newList5.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterS = 1; foreach (Employee e in newList5) { Console.WriteLine(+counterS + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterS++; } subMenu whatNext5 = new subMenu(itsBL); whatNext5.Menu("5", counterS, salaryList); break; case "6": Console.Clear(); Console.WriteLine("Enter the gender you want to find: "); Console.WriteLine("\t1. Male"); Console.WriteLine("\t2. Female"); string cho = Console.ReadLine(); string eGender = "null"; bool gend = true; while (gend) { if (cho == "1") { eGender = "Male"; gend = false; } else if (cho == "2") { eGender = "Female"; gend = false; } else { Console.WriteLine("choose 1 Or 2 only"); cho = Console.ReadLine(); } } List <object> genderList = itsBL.queryByString(Classes.Employee, stringFields.gender, eGender); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newList6 = genderList.Cast <Employee>().ToList(); if (newList6.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterG = 1; foreach (Employee e in newList6) { Console.WriteLine(+counterG + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterG++; } subMenu whatNext6 = new subMenu(itsBL); whatNext6.Menu("5", counterG, genderList); break; case "7": Console.Clear(); Console.WriteLine("Enter the supervisor ID you want to find (notice! must be numbers): "); string eSuper = Console.ReadLine(); while (!(InputCheck.isInt(eSuper))) { Console.WriteLine("Invalid supervisor ID. \n try again"); eSuper = Console.ReadLine(); } List <object> superList = itsBL.queryByString(Classes.Employee, stringFields.supervisorID, eSuper); Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); List <Employee> newList7 = superList.Cast <Employee>().ToList(); if (newList7.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterV = 1; foreach (Employee e in newList7) { Console.WriteLine(+counterV + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterV++; } subMenu whatNext7 = new subMenu(itsBL); whatNext7.Menu("5", counterV, superList); break; case "8": List <Employee> newList8 = itsBL.getAllEmployees().Employeess; Console.Clear(); Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS "); if (newList8.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterA = 1; foreach (Employee e in newList8) { Console.WriteLine(+counterA + ". " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString()); // print the list on the screen counterA++; } List <object> allList = newList8.Cast <object>().ToList(); subMenu whatNext8 = new subMenu(itsBL); whatNext8.Menu("5", counterA, allList); break; case "9": Search back = new Search(itsBL); back.run(); break; case "10": MainMenu moveToMenu = new MainMenu(itsBL); break; default: Console.WriteLine("You have performed an illegal move, please enter a number between 1-10"); Thread.Sleep(2400); break; } } }
public void editEmployee(Employee preEmployee) /////employee { Console.Clear(); Employee newEmployee = new Employee(preEmployee); Console.WriteLine("you choose to edit the next employee: "); Console.WriteLine(preEmployee.toString() + "\n"); bool ans = true; while (ans) { string cmd; Console.WriteLine("Choose the field you want to change: "); Console.WriteLine("\t1. employee first name "); Console.WriteLine("\t2. Employee last name "); Console.WriteLine("\t3. location (department ID) "); Console.WriteLine("\t4. Employee salary "); Console.WriteLine("\t5. supervisor ID "); cmd = Console.ReadLine(); switch (cmd) { case "1": Console.WriteLine("enter the new first name"); string newFirst = Console.ReadLine(); if (newFirst.Length < 1) { throw new Exception("Invalid First Name, Must Have Atleast One Character"); } else { newEmployee.FirstName = newFirst; } break; case "2": Console.WriteLine("enter the new last name"); string newLast = Console.ReadLine(); if (newLast.Length < 1) { throw new Exception("Invalid First Name, Must Have Atleast One Character"); } else { newEmployee.LastName = newLast; } break; case "3": Console.WriteLine("enter the new employee location (notice! department ID must be number "); string newdepar = Console.ReadLine(); while (!(InputCheck.isInt(newdepar))) { Console.WriteLine("department ID must be numbers"); Console.WriteLine("enter again the new employee location"); newdepar = Console.ReadLine(); } newEmployee.DepartmentID = Convert.ToInt32(newdepar); break; case "4": Console.WriteLine("enter the new employee's salary: "); string salaryS = Console.ReadLine(); while (!(InputCheck.isDouble(salaryS))) { Console.WriteLine("The salary must be a posative number"); Console.WriteLine("enter the salary again"); salaryS = Console.ReadLine(); } newEmployee.Salary = Convert.ToDouble(salaryS); break; case "5": Console.WriteLine("the new employee's suprvisor ID is (notice! supervisor ID must be number) : "); string superID = Console.ReadLine(); while (!(InputCheck.isInt(superID))) { Console.WriteLine("supervisor ID must be number bigger then 0"); Console.WriteLine("enter new employee's supervisor ID again: "); superID = Console.ReadLine(); } newEmployee.SupervisorID = Convert.ToInt32(superID); break; default: Console.WriteLine("You have performed an illegal move"); break; } Console.WriteLine("if you want to change more fields press 1"); Console.WriteLine("if you finish press any other key "); string want = Console.ReadLine(); if (want != "1") { ans = false; try { itsBL.edit(newEmployee); Console.WriteLine("Changes have been done"); Thread.Sleep(2000); saveAndBack(); } catch (Exception e) { print(e.Message, "ERROR: "); Console.ReadKey(); } } } }
public SearchProduct(IBL BL) { this.itsBL = BL; string cmd; while (true) { Console.Clear(); Console.WriteLine("search product by :"); Console.WriteLine("\t1. name "); Console.WriteLine("\t2. type "); Console.WriteLine("\t3. product ID "); Console.WriteLine("\t4. location (department ID "); Console.WriteLine("\t5. product in stock "); Console.WriteLine("\t6. stock count "); Console.WriteLine("\t7. price"); Console.WriteLine("\t8. gat all the products "); Console.WriteLine("\t9. back "); Console.WriteLine("\t10. back to main menu "); cmd = Console.ReadLine(); switch (cmd) { case "1": // search product by name Console.WriteLine("Enter product name which you want to search: "); string pName = Console.ReadLine(); // get the name the user want to search List <object> nameList = itsBL.queryByString(Classes.Product, stringFields.name, pName); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList1 = nameList.Cast <Product>().ToList(); if (newList1.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterN = 1; foreach (Product p in newList1) { Console.WriteLine(counterN + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterN++; } subMenu whatNext1 = new subMenu(itsBL); whatNext1.Menu("1", counterN, nameList); break; case "2": // search by type Console.WriteLine("Search for products from this type : "); string pType = Console.ReadLine(); // get the type the user want to search try { InputCheck.isType(pType); } catch (Exception e) { print(e.Message, "\n ERROR: "); // inform the user Console.ReadKey(); } List <object> typeList = itsBL.queryByString(Classes.Product, stringFields.type, pType); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList2 = typeList.Cast <Product>().ToList(); if (newList2.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterT = 1; foreach (Product p in newList2) { Console.WriteLine(counterT + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterT++; } subMenu whatNext2 = new subMenu(itsBL); whatNext2.Menu("1", counterT, typeList); break; case "3": // search by product ID Console.WriteLine("Search products by the ID : (notice! numbers only) "); string pID = Console.ReadLine(); // get the product ID the user want to search while (!(InputCheck.isInt(pID))) { Console.WriteLine("Invalid ID. \n enter again"); pID = Console.ReadLine(); } List <object> iDList = itsBL.queryByString(Classes.Product, stringFields.inventoryID, pID); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList3 = iDList.Cast <Product>().ToList(); if (newList3.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterI = 1; foreach (Product p in newList3) { Console.WriteLine(counterI + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterI++; } subMenu whatNext3 = new subMenu(itsBL); whatNext3.Menu("1", counterI, iDList); break; case "4": // search product by name Console.WriteLine("Search all products in the department (notice! enter ID department- only numbers) : "); string pDepartment = Console.ReadLine(); // get the name the user want to search while (!(InputCheck.isInt(pDepartment))) { Console.WriteLine("Invalid department ID. \n enter again"); pDepartment = Console.ReadLine(); } List <object> departmentList = itsBL.queryByString(Classes.Product, stringFields.location, pDepartment); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList4 = departmentList.Cast <Product>().ToList(); if (newList4.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterD = 1; foreach (Product p in newList4) { Console.WriteLine(counterD + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterD++; } subMenu whatNext4 = new subMenu(itsBL); whatNext4.Menu("1", counterD, departmentList); break; case "5": Console.WriteLine("choose a number: "); Console.WriteLine("\t1. show all the product that in stock "); Console.WriteLine("\t2. show all the product that not in stock "); Console.WriteLine("\t3. show all the product that need to ordered "); string pStock = Console.ReadLine(); string pInStock = ""; switch (pStock) { case "1": pInStock = "True"; break; case "2": pInStock = "False"; break; case "3": pInStock = "NeedToOrder"; break; default: Console.WriteLine("You have performed an illegal move, please enter 1 or 2"); break; } List <object> inStockList = itsBL.queryByString(Classes.Product, stringFields.inStock, pInStock); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList5 = inStockList.Cast <Product>().ToList(); if (newList5.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterS = 1; foreach (Product p in newList5) { Console.WriteLine(+counterS + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterS++; } subMenu whatNext5 = new subMenu(itsBL); whatNext5.Menu("1", counterS, inStockList); break; case "6": Console.WriteLine("Choose an option: "); Console.WriteLine("\t1. Search for specific stock count "); Console.WriteLine("\t2. Search range of stock count "); string search = Console.ReadLine(); string fromValue = Int32.MinValue.ToString(); string toValue = Int32.MaxValue.ToString(); switch (search) { case "1": Console.WriteLine("enter stock count: "); string stockCount = Console.ReadLine(); while (!(InputCheck.isInt(stockCount))) { Console.WriteLine("Invalid stock count. \n try again"); stockCount = Console.ReadLine(); } fromValue = stockCount; toValue = stockCount; break; case "2": Console.WriteLine("from which stock count to search: "); string fromCount = Console.ReadLine(); while (!(InputCheck.isInt(fromCount))) { Console.WriteLine("Invalid stock count. \n try again"); fromCount = Console.ReadLine(); } fromValue = fromCount; Console.WriteLine("until which stock count to search: "); string toCount = Console.ReadLine(); while (!(InputCheck.isInt(toCount))) { Console.WriteLine("Invalid stock count. \n try again"); toCount = Console.ReadLine(); } toValue = toCount; break; default: Console.WriteLine("You perform illegal move, please choose 1 or 2"); Thread.Sleep(2400); break; } List <object> stockList = itsBL.queryByRange(Classes.Product, rangeFields.stockCount, fromValue, toValue); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); int counterC = 1; List <Product> newList6 = stockList.Cast <Product>().ToList(); if (newList6.LongCount() == 0) { Console.WriteLine("There are no items to show"); } foreach (Product p in newList6) { Console.WriteLine(+counterC + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen Console.WriteLine(+counterC + ". " + p.Name + " " + p.Type.ToString() + " " + p.InventoryID.ToString()); // print the list on the screen counterC++; } subMenu whatNext6 = new subMenu(itsBL); whatNext6.Menu("1", counterC, stockList); break; case "7": Console.WriteLine("Choose an option: "); Console.WriteLine("\t1. Search for specific price "); Console.WriteLine("\t2. Search range of prices "); string howSearch = Console.ReadLine(); string fromPrice = Int32.MinValue.ToString(); string toPrice = Int32.MaxValue.ToString(); switch (howSearch) { case "1": Console.WriteLine("enter price: "); string price = Console.ReadLine(); while (!(InputCheck.isDouble(price))) { Console.WriteLine("Invalid price. \n try again"); price = Console.ReadLine(); } fromPrice = price; toPrice = price; break; case "2": Console.WriteLine("from which price to search: "); string price1 = Console.ReadLine(); while (!(InputCheck.isDouble(price1))) { Console.WriteLine("Invalid price. \n try again"); price1 = Console.ReadLine(); } fromPrice = price1; Console.WriteLine("until which price count to search: "); string price2 = Console.ReadLine(); while (!(InputCheck.isDouble(price2))) { Console.WriteLine("Invalid price. \n try again"); price2 = Console.ReadLine(); } toPrice = price2; break; default: Console.WriteLine("You perform illegal move, please choose 1 or 2"); Thread.Sleep(2400); break; } List <object> priceList = itsBL.queryByRange(Classes.Product, rangeFields.price, fromPrice, toPrice); Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); List <Product> newList7 = priceList.Cast <Product>().ToList(); if (newList7.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterP = 1; foreach (Product p in newList7) { Console.WriteLine(+counterP + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterP++; } subMenu whatNext7 = new subMenu(itsBL); whatNext7.Menu("1", counterP, priceList); break; case "8": List <Product> newList8 = itsBL.getAllProducts().Productss; Console.Clear(); Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price"); if (newList8.LongCount() == 0) { Console.WriteLine("There are no items to show"); } int counterA = 1; foreach (Product p in newList8) { Console.WriteLine(+counterA + ". " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen counterA++; } List <object> allList = newList8.Cast <object>().ToList(); subMenu whatNext8 = new subMenu(itsBL); whatNext8.Menu("1", counterA, allList); break; case "9": Search back = new Search(itsBL); back.run(); break; case "10": MainMenu moveToMenu = new MainMenu(itsBL); break; default: Console.WriteLine("You have performed an illegal move, please enter a number between 1-10"); Thread.Sleep(2400); break; } } }
public void editProduct(Product prevproduct) /////product { Console.Clear(); Product newProduct = new Product(prevproduct); Console.WriteLine("you choose to edit the next product: "); Console.WriteLine(prevproduct.toString() + "\n"); bool ans = true; while (ans) { string cmd; Console.WriteLine("Choose the field you want to change: "); Console.WriteLine("\t1. name "); Console.WriteLine("\t2. type "); Console.WriteLine("\t3. location (department ID) "); Console.WriteLine("\t4. stock count "); Console.WriteLine("\t5. price "); Console.WriteLine("\t6. when to order "); cmd = Console.ReadLine(); switch (cmd) { case "1": Console.WriteLine("enter the new name:"); string name = Console.ReadLine(); if (name.Length < 1) { Console.WriteLine("Invalid product Name, Must Have Atleast One Character"); } else { newProduct.Name = name; } break; case "2": Console.WriteLine("enter new type: "); string type = Console.ReadLine(); try { InputCheck.isType(type); newProduct.Type = (Backend.Type)Enum.Parse(typeof(Backend.Type), type); } catch (Exception e) { print(e.Message, "\n ERROR: "); Console.ReadKey(); } break; case "3": Console.WriteLine("enter the new product location (notice! department ID must be numbers): "); string newdepar = Console.ReadLine(); while (!(InputCheck.isInt(newdepar))) { Console.WriteLine("department ID must be numbers"); Console.WriteLine("enter again the new product location"); newdepar = Console.ReadLine(); } newProduct.Location = Convert.ToInt32(newdepar); break; case "4": Console.WriteLine("enter new stock count:"); string stockCountString = Console.ReadLine(); while (!(InputCheck.isInt(stockCountString))) { Console.WriteLine("stock count must be number bigger or equal to 0 "); Console.WriteLine("enter stock count again: "); stockCountString = Console.ReadLine(); } newProduct.StockCount = Convert.ToInt32(stockCountString); break; case "5": Console.WriteLine("enter new price:"); string priceS = Console.ReadLine(); while (!(InputCheck.isDouble(priceS))) { Console.WriteLine("price must be number above 0 (it can be Decimals) "); Console.WriteLine("enter new price again:"); priceS = Console.ReadLine(); } newProduct.Price = Convert.ToDouble(priceS); break; case "6": Console.WriteLine("change whan to order value"); string whenToOrderS = Console.ReadLine(); while (!(InputCheck.isInt(whenToOrderS))) { Console.WriteLine("whan to order must be a number"); Console.WriteLine("enter the whan to order value"); whenToOrderS = Console.ReadLine(); } newProduct.WhenToOrder = Convert.ToInt32(whenToOrderS); break; default: Console.WriteLine("You have performed an illegal move"); break; } Console.WriteLine("if you want to change more fields press 1"); Console.WriteLine("if you finish press any other key "); string want = Console.ReadLine(); if (want != "1") { ans = false; try { itsBL.edit(newProduct); Console.WriteLine("Changes have been done"); Thread.Sleep(2000); saveAndBack(); } catch (Exception e) { print(e.Message, "ERROR: "); Console.ReadKey(); } } } }