Example #1
0
 private static void DeleteSale(Deleter deleter, Reader reader)
 {
     if (Lawyer.GetYesNo("Do you want to delete a sale by Sale Id?"))
     {
         int saleid = Lawyer.GetInt("What Sale Id do you want to delete?");
         while (!(reader.DoesSaleIDExist(saleid)))
         {
             Console.WriteLine("Sorry but no sale with that id exist, try again.");
             saleid = Lawyer.GetInt("What Sale Id do you want to delete?");
         }
         if (Lawyer.GetYesNo("Are you sure you want to delete sale with id:" + saleid))
         {
             deleter.DeleteSaleByID(saleid.ToString());
         }
     }
     else if (Lawyer.GetYesNo("Do you to delete a sale by Product Id?"))
     {
         int prodid = Lawyer.GetInt("By what Product id do you wnat to delete sales?");
         while (!(reader.DoesSaleByProdIdExist(prodid)))
         {
             Console.WriteLine("Sorry but no sale with that product id exist, try again.");
             prodid = Lawyer.GetInt("By what Product id do you want to delete sales?");
         }
         string productid = reader.GetProductName(prodid);
         if (Lawyer.GetYesNo("Are you sure you want to delete sales associated with the product: " + productid))
         {
             deleter.DeleteSalesByProductId(prodid);
         }
     }
     else if (Lawyer.GetYesNo("Do you want to delete a sale by quantity?"))
     {
         int salequantity = Lawyer.GetInt("What quantity do you want to delete all sales of?");
         while (!(reader.DoesSaleByQuantityExist(salequantity)))
         {
             Console.WriteLine("Sorry there are no sales with that quantity, try again.");
             salequantity = Lawyer.GetInt("What quantity do you want to delete all sales of?");
         }
         if (Lawyer.GetYesNo("Are you sure you want to delete sales with quantity of: " + salequantity + "?"))
         {
             deleter.DeleteSaleByQuantity(salequantity);
         }
     }
     else if (Lawyer.GetYesNo("Do you want to delete a sale by a date?"))
     {
         int      month = Lawyer.GetMonth("What month do you want to delete sales by?");
         int      year  = Lawyer.GetYear("What year do you want to delete sales by?");
         int      day   = Lawyer.GetDay("What day do you want to delete sales by?", month, year);
         DateTime date  = new DateTime(year, month, day);
         while (!(reader.DoesSaleByDateExist(date)))
         {
             Console.WriteLine("Sorry but there are no sales with that date?");
             month = Lawyer.GetMonth("What month do you want to delete sales by?");
             year  = Lawyer.GetYear("What year do you want to delete sales by?");
             day   = Lawyer.GetDay("What day do you want to delete sales by?", month, year);
             DateTime dt = new DateTime(year, month, day);
             date = dt;
         }
         if (Lawyer.GetYesNo("Are you sure you want to delete sales of date : Year " + date.Year.ToString() + " Month " + date.Month.ToString() + " Day " + date.Day.ToString() + "?"))
         {
             deleter.DeleteSaleByDate(date);
         }
     }
     else if (Lawyer.GetYesNo("Do you want to delete sales by a certain price?"))
     {
         decimal price = Lawyer.GetDecimal("What is the price you want to delete sales by?");
         while (!(reader.DoesSaleByPriceExist(price)))
         {
             Console.WriteLine("There are no sales with that price, try again.");
             price = Lawyer.GetDecimal("What is the price you want to delete sales by?");
         }
         if (Lawyer.GetYesNo("Are you sure you want to delete sales with price: " + price))
         {
             deleter.DeleteSaleByPrice(price);
         }
     }
 }