/// <summary> /// Drops product quantity /// </summary> public static void DropProduct() { int input = -1; bool correctInput = false; int quantity = -1; int actionChoice = -1; int prod = 0; Console.Clear(); ProductsDatabase products = new ProductsDatabase(); Console.WriteLine(products.ShowAdmin()); do { Console.WriteLine("Wybierz produkt którego ilość chcesz zmniejszyć " + adminName); try { input = int.Parse(Console.ReadLine()); if (input > 0) { prod = input; correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } } while (!correctInput); do { Console.WriteLine("Ile sztuk chcesz wyjąć? " + adminName); try { quantity = int.Parse(Console.ReadLine()); if (quantity > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } } while (!correctInput); long productQuantity = (products.Products[prod - 1].Quantity); if (quantity <= productQuantity) { Console.WriteLine(adminName + " Czy chcesz wyjąć " + quantity + " sztuk produktu numer " + input + "?\n" + "1 - Tak\n" + "2 - Nie\n" + "3 - Chce wyjąć inny produkt"); do { try { actionChoice = int.Parse(Console.ReadLine()); if (actionChoice > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } } while (!correctInput); switch (actionChoice) { case 1: ProductsDatabase.DropQuantity(input, quantity, products); Console.WriteLine("Wyjęto"); Thread.Sleep(2500); StartAdminLogic(); break; case 2: StartAdminLogic(); break; case 3: DropProduct(); break; default: Console.WriteLine("Coś poszło nie tak!"); Thread.Sleep(2500); StartAdminLogic(); break; } } else { Console.WriteLine("Nie możesz wyjąć więcej produktów niż jest dostępne"); Thread.Sleep(2500); DropProduct(); } }
/// <summary> /// Delete product record from database /// </summary> public static void DeleteProduct() { int input = -1; bool correctInput = false; int actionChoice = -1; Console.Clear(); ProductsDatabase products = new ProductsDatabase(); Console.WriteLine(products.ShowAdmin()); do { Console.WriteLine("Wybierz produkt który chcesz usunąć " + adminName); try { input = int.Parse(Console.ReadLine()); if (input > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } } while (!correctInput); Console.WriteLine(adminName + " Czy chcesz usunąć produkt numer " + input + "?\n" + "1 - Tak\n" + "2 - Nie\n" + "3 - Chce usunąć inny produkt"); do { try { actionChoice = int.Parse(Console.ReadLine()); if (actionChoice > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } }while (!correctInput); switch (actionChoice) { case 1: ProductsDatabase.DeleteProduct(input, products); Console.WriteLine("Skasowano"); Thread.Sleep(2500); StartAdminLogic(); break; case 2: StartAdminLogic(); break; case 3: DropProduct(); break; default: Console.WriteLine("Coś poszło nie tak!"); Thread.Sleep(2500); StartAdminLogic(); break; } }
/// <summary> /// Updates product quantity in database /// </summary> public static void AddProduct() { int input = -1; bool correctInput = false; int quantity = -1; Console.Clear(); ProductsDatabase products = new ProductsDatabase(); Console.WriteLine(products.ShowAdmin()); do { Console.WriteLine("Wybierz produkt który chcesz uzupełnić " + adminName); try { input = int.Parse(Console.ReadLine()); if (input > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; Thread.Sleep(3000); Console.Clear(); } } while (!correctInput); do { Console.WriteLine("Ile sztuk chcesz dodać? " + adminName); try { quantity = int.Parse(Console.ReadLine()); if (quantity > 0) { correctInput = true; } else { correctInput = false; } } catch (System.FormatException) { correctInput = false; } } while (!correctInput); Console.WriteLine(adminName + " Czy chcesz dodać " + quantity + " sztuk produktu numer " + input + "?\n" + "1 - Tak\n" + "2 - Nie\n" + "3 - Chce dodać inny produkt"); int actionChoice = int.Parse(Console.ReadLine()); switch (actionChoice) { case 1: ProductsDatabase.Increment(input, quantity, products); Console.WriteLine("Dodano"); Thread.Sleep(2500); StartAdminLogic(); break; case 2: StartAdminLogic(); break; case 3: AddProduct(); break; default: Console.WriteLine("Coś poszło nie tak!"); Thread.Sleep(2500); StartAdminLogic(); break; } }