Пример #1
0
        static void Main(string[] args)
        {
            bool         continuare = true;
            int          nr;
            IStocareData admin = StocareFactory.GetAdministratorStocare();

            Pharmacy[] vect;
            vect = admin.GetM(out nr);



            while (continuare)
            {
                Console.Clear();
                Console.WriteLine("                          PHARMALIFE-APLICATIE MOBILA\n              ");
                Console.WriteLine("A.Adaugare medicament de la tastatura in baza de date.");
                Console.WriteLine("I.Info Medicamente(Afisare)");
                Console.WriteLine("V.Verificare valabilitate medicamente.");
                Console.WriteLine("L.Verificati locatiile unde se gasesc medicamentele.");
                Console.WriteLine("C.Comparare Pret ");
                Console.WriteLine("T.Tipul medicamentului.");
                Console.WriteLine("E.Exit.");
                Console.WriteLine("Alegeti o optiune: ");

                string opt = Console.ReadLine();



                switch (opt.ToUpper())
                {
                case "A":
                {
                    Console.WriteLine("Introduceti un medicament de la tastatura.\n");
                    Pharmacy med = citireTastatura();
                    vect[nr] = med;
                    nr++;
                    admin.AddM(med);

                    Console.ReadKey();
                    break;
                }

                case "I":
                {
                    for (int i = 0; i < nr; i++)
                    {
                        Console.WriteLine(vect[i].Info());
                    }
                    Console.WriteLine("Nu s-a adaugat niciun alt medicament.\n");
                    Console.ReadKey();
                    break;
                }

                case "V":
                {
                    for (int i = 0; i < nr; i++)
                    {
                        Console.WriteLine(vect[i].Valabil());
                    }

                    Console.ReadKey();
                    break;
                }

                case "L":
                {
                    for (int i = 0; i < nr; i++)
                    {
                        Console.WriteLine(vect[i].map());
                    }
                    Console.ReadKey();
                    break;
                }

                case "C":
                {
                    if (vect[0].CompararePret(vect[1]) == Pharmacy.higher)
                    {
                        Console.WriteLine("Pretul este mai avantajos in farmacia {0}", vect[1].Locatie);
                    }
                    else

                    {
                        if (vect[0].CompararePret(vect[1]) == Pharmacy.less)
                        {
                            Console.WriteLine("Prestul este mai avantajos in farmacia {0}", vect[0].Locatie);
                        }
                        else
                        {
                            Console.WriteLine("Pretul este egal in ambele farmacii.");
                        }
                    }
                    Console.ReadKey();
                    break;
                }

                case "T":
                {
                    for (int i = 0; i < nr; i++)
                    {
                        Console.WriteLine(vect[i].TipMedicament());
                    }
                    Console.ReadKey();
                    break;
                }

                case "E":
                {
                    continuare = false;

                    break;
                }
                }
            }
        }
        static void Main(string[] args)
        {
            IStocareData adminMed = StocareFactory.GetAdministratorStocare();

            Medicament[] medicamente;
            string       opt;
            int          nrMed;

            medicamente    = adminMed.GetMed(out nrMed);
            Medicament.NID = nrMed;
            bool ok = true;

            while (ok == true)
            {
                Console.Clear();
                Console.WriteLine("A: Adaugare medicament ");
                Console.WriteLine("E: Editare medicament");
                Console.WriteLine("D: Stergere medicament");
                Console.WriteLine("O: Afisare lista medicamente");
                Console.WriteLine("S: Cautare medicament");
                Console.WriteLine("C: Comparare");
                Console.WriteLine("X: Iesire");
                opt = Console.ReadLine();
                switch (opt.ToUpper())
                {
                case "A":
                    Console.Clear();
                    Medicament t = CitireTast();
                    medicamente[nrMed] = t;
                    nrMed++;
                    adminMed.AddMed(t);
                    Console.WriteLine("--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "E":
                    Console.Clear();
                    int    z = 0;
                    string mod;
                    Console.WriteLine("Introduceti medicamentul pe care doriti sa-l modificati: ");
                    string demodificat = Console.ReadLine();
                    Console.WriteLine("Ce anume doriti sa modificati?");
                    string modificare = Console.ReadLine();
                    if (String.Compare(modificare, "pret") == 0)
                    {
                        Console.WriteLine("Nu puteti modifica pretul!");
                    }
                    else
                    {
                        for (int i = 0; i < nrMed; i++)
                        {
                            if ((medicamente[i].Nume_med.CompareTo(demodificat)) == 0)
                            {
                                z = 1;
                                if (String.Compare(modificare, "nume") == 0)
                                {
                                    Console.WriteLine("Medicament gasit! Introduceti noua denumire:");
                                    mod = Console.ReadLine();
                                    medicamente[i].Nume_med = mod;
                                    adminMed.ModifMed(medicamente, nrMed);
                                }
                                if (String.Compare(modificare, "data") == 0)
                                {
                                    Console.WriteLine("Medicament gasit! Introduceti noua data de expirare:");
                                    mod = Console.ReadLine();
                                    medicamente[i].Data_exp = mod;
                                    adminMed.ModifMed(medicamente, nrMed);
                                }
                                if (String.Compare(modificare, "Cantitate") == 0)
                                {
                                    Console.WriteLine("Medicament gasit! Introduceti noua Cantitate:");
                                    mod = Console.ReadLine();
                                    medicamente[i].Cantitate = Convert.ToInt32(mod);
                                    adminMed.ModifMed(medicamente, nrMed);
                                }
                            }
                            if (z == 1)
                            {
                                i = nrMed;
                            }
                        }

                        if (z == 0)
                        {
                            Console.WriteLine(" Medicamentul nu exista!");
                        }
                    }
                    Console.WriteLine("--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "D":
                    Console.Clear();
                    Console.WriteLine("--------  METODA ESTE IN CURS DE IMPLEMENTARE --------");
                    Console.WriteLine("\t--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "O":
                    Console.Clear();
                    for (int i = 0; i < nrMed; i++)
                    {
                        Console.WriteLine(medicamente[i].ConversieLaSir());
                        Console.WriteLine("\n");
                    }
                    Console.WriteLine("--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "S":
                    Console.Clear();
                    int k = 0;
                    Info();
                    string decautat = Console.ReadLine();
                    for (int i = 0; i < nrMed; i++)
                    {
                        if ((medicamente[i].Nume_med.CompareTo(decautat)) == 0)
                        {
                            k = 1;
                        }
                    }
                    if (k == 1)
                    {
                        Info1();
                    }
                    else
                    {
                        Info2();
                    }

                    Console.WriteLine("--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "C":
                    Console.Clear();
                    if (medicamente[0].Compara(medicamente[1]) == 1)
                    {
                        Console.WriteLine("OK");
                    }
                    Console.WriteLine("--------  PRESS ANY KEY --------");
                    Console.ReadKey();
                    break;

                case "X":
                    Console.Clear();
                    ok = false;
                    break;
                }
            }
            Console.WriteLine("\n \n \n \n \n \n \n \n \t \t \t \t \t --------  Sfarit program --------\n \n ");
            Console.WriteLine("\t \t \t \t \t --------  PRESS ANY KEY --------");
            Console.ReadKey();
        }