Example #1
0
 private static void ShowCMD(Raport raport, string[] commandSplited)
 {
     if (commandSplited[1] == "Medicines")
     {
         raport.ShowMedicines();
     }
     else if (commandSplited[1] == "Orders")
     {
         raport.ShowOrders();
     }
     else if (commandSplited[1] == "Prescriptions")
     {
         raport.ShowPrescriptions();
     }
     else if (commandSplited[1] == "Sales")
     {
         raport.Reload();
     }
     else
     {
         Console.WriteLine("Niepoprawna komenda.");
     }
 }
Example #2
0
        private static void Main(string[] args)
        {
            Raport raport = new Raport();

            try
            {
                DeleteOldLogs();

                //DeleteAllOldDataInDB();

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Dostępne komendy:");
                Console.WriteLine(@"Metody typu add przy podaniu ID = 0 dodają nowy rekord. W przypadku podania ID > 0 dane podane w poleceniu Add modyfikują dany rekord o podanym ID.");
                Console.ForegroundColor = ConsoleColor.White;


                string command = "";
                do
                {
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.WriteLine(@"AddMedicine     [int id],[string name],[string manufacturer],[decimal price],[int amount],[bool withPrescription]");
                    Console.WriteLine(@"AddPrescription [int id],[string customerName],[string pesel],[int prescriptionNumber]");
                    Console.WriteLine(@"AddOrder        [int id],[Prescription prescriptionID],[Medicine medicineID],[string date],[int amount]");
                    Console.WriteLine(@"Remove Medicine/Prescription/Order");
                    Console.WriteLine(@"Show Medicines/Prescriptions/Orders/Sales");
                    Console.WriteLine(@"Select [Medicine/Prescription/Order] [int id]");
                    Console.ForegroundColor = ConsoleColor.White;

                    command = Console.ReadLine();

                    string[] commandSplited = command.Split(' ');

                    if (commandSplited.Length == 2)
                    {
                        if (commandSplited[0].Contains("Add"))
                        {
                            string   commandType   = commandSplited[0];
                            string[] commandValues = commandSplited[1].Split(',');
                            AddCMD(commandType, commandValues, LastPrescription, LastMedicine);
                        }
                        else if (commandSplited[0] == "Show")
                        {
                            ShowCMD(raport, commandSplited);
                        }
                        else if (commandSplited[0] == "Remove")
                        {
                            RemoveCMD(commandSplited);
                        }
                    }
                    else if (commandSplited.Length == 3)
                    {
                        SelectCMD(commandSplited);
                    }
                    else
                    {
                        Console.WriteLine("Niepoprawna komenda.");
                    }
                } while (command.ToLower() != "exit");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message, ex.StackTrace);
            }
            Console.ReadLine();
        }