public static void AfiseazaInventarCofetarie()
        {
            string jsonString_E = File.ReadAllText("Inventar_Ecler.json");
            Ecler  pEcler       = JsonSerializer.Deserialize <Ecler>(jsonString_E);
            int    valEcler     = pEcler.GetNewStockEcler * pEcler.GetNewPriceEcler;

            Console.WriteLine($"\nStoc curent Ecler:{pEcler.GetNewStockEcler} bucati");
            Console.WriteLine($"Valoare:{valEcler} RON");

            string   jsonString_A = File.ReadAllText("Inventar_Amandina.json");
            Amandina pAmandina    = JsonSerializer.Deserialize <Amandina>(jsonString_A);
            int      valAmandina  = pAmandina.GetNewStockAmandina * pAmandina.GetNewPriceAmandina;

            Console.WriteLine($"\nStoc curent Amandina:{pAmandina.GetNewStockAmandina} bucati");
            Console.WriteLine($"Valoare:{valAmandina} RON");

            string   jsonString_S = File.ReadAllText("Inventar_Savarina.json");
            Savarina pSavarina    = JsonSerializer.Deserialize <Savarina>(jsonString_S);
            int      valSavarina  = pSavarina.GetNewStockSavarina * pSavarina.GetNewPriceSavarina;

            Console.WriteLine($"\nStoc curent Savarina:{pSavarina.GetNewStockSavarina} bucati");
            Console.WriteLine($"Valoare:{valSavarina} RON");


            string jsonString_T = File.ReadAllText("Inventar_Tort.json");
            Tort   pTort        = JsonSerializer.Deserialize <Tort>(jsonString_T);
            int    valTort      = pTort.GetNewStockTort * pTort.GetNewPriceTort;

            Console.WriteLine($"\nStoc curent Tort:{pTort.GetNewStockTort} bucati");
            Console.WriteLine($"Valoare:{valTort} RON");

            Console.WriteLine($"\nStoc total produse Cofetarie:{pEcler.GetNewStockEcler + pAmandina.GetNewStockAmandina + pSavarina.GetNewStockSavarina + pTort.GetNewStockTort} bucati");
            Console.WriteLine($"Valoare totala produse Cofetarie:{valEcler + valAmandina + valSavarina + valTort} RON");
        }
        public static void AdaugaEcler()
        {
            Console.WriteLine("Introduceti numarul de produse de tip 'Ecler' pe care doriti sa le adaugati in inventar:");
            int    nrProduse;
            string s      = Console.ReadLine();
            bool   result = int.TryParse(s, out nrProduse);

            while (result == false || nrProduse < 0 || nrProduse % 1 != 0)
            {
                Console.WriteLine("Introduceti din nou un numar valabil:");
                s      = Console.ReadLine();
                result = int.TryParse(s, out nrProduse);
            }

            string jsonString = File.ReadAllText("Inventar_Ecler.json");
            Ecler  pEcler     = JsonSerializer.Deserialize <Ecler>(jsonString);

            Console.WriteLine("Numarul produselor introduse este: " + nrProduse + " bucati");

            int stoc_nou_Ecler = pEcler._cantInitialaEcler + nrProduse;

            pEcler._cantInitialaEcler = stoc_nou_Ecler;

            jsonString = JsonSerializer.Serialize(pEcler);
            Console.WriteLine($"Noul stoc de 'Ecler' este: {pEcler.GetNewStockEcler} bucati");
            File.WriteAllText("Inventar_Ecler.json", jsonString);
        }
        public static void VindeEcler()
        {
            string jsonString = File.ReadAllText("Inventar_Ecler.json");
            Ecler  pEcler     = JsonSerializer.Deserialize <Ecler>(jsonString);

            bool q = true;

            while (q)
            {
                Console.WriteLine("Introduceti numarul de produse de tip 'Ecler' pe care doriti sa le vindeti:");
                int    nrProduse;
                string s      = Console.ReadLine();
                bool   result = int.TryParse(s, out nrProduse);

                if (pEcler.GetNewStockEcler > 0)
                {
                    pEcler._pretEcler = 3;

                    while (result == false || nrProduse < 0 || nrProduse % 1 != 0)
                    {
                        Console.WriteLine("Introduceti din nou un numar valabil:");
                        s      = Console.ReadLine();
                        result = int.TryParse(s, out nrProduse);
                    }

                    Console.WriteLine("Numarul produselor introduse este: " + nrProduse + " bucati");

                    if (pEcler.GetNewStockEcler >= nrProduse)
                    {
                        int stoc_nou_Ecler = pEcler._cantInitialaEcler - nrProduse;
                        pEcler._cantInitialaEcler = stoc_nou_Ecler;
                        Console.WriteLine($"Noul stoc de 'Ecler' este: {pEcler.GetNewStockEcler} bucati");
                        Console.WriteLine($"Pret Ecler / bucata: {pEcler.GetNewPriceEcler} RON");
                        Console.WriteLine($"Total: {pEcler.GetNewPriceEcler * nrProduse} RON");
                    }
                    else
                    {
                        int pretTotal = pEcler.GetNewPriceEcler * pEcler._cantInitialaEcler;

                        Console.WriteLine($"In stoc au fost doar {pEcler.GetNewStockEcler} produse care s-au putut vinde.");
                        int stoc_nou_Ecler = pEcler._cantInitialaEcler - pEcler._cantInitialaEcler;
                        pEcler._cantInitialaEcler = stoc_nou_Ecler;
                        Console.WriteLine($"Noul stoc de 'Ecler' este: {pEcler.GetNewStockEcler} bucati");
                        Console.WriteLine($"Pret Ecler / bucata: {pEcler.GetNewPriceEcler} RON");
                        Console.WriteLine($"Total: {pretTotal} RON");
                    }

                    jsonString = JsonSerializer.Serialize(pEcler);
                    File.WriteAllText("Inventar_Ecler.json", jsonString);
                    break;
                }
                else
                {
                    Console.WriteLine("Produsul ales nu exista in stoc.");
                    break;
                }
            }
        }
        public static void AfiseazaStocCofetarie()
        {
            string jsonString_E = File.ReadAllText("Inventar_Ecler.json");
            Ecler  pEcler       = JsonSerializer.Deserialize <Ecler>(jsonString_E);

            Console.WriteLine($"\nStoc curent Ecler:{pEcler.GetNewStockEcler}");

            string   jsonString_A = File.ReadAllText("Inventar_Amandina.json");
            Amandina pAmandina    = JsonSerializer.Deserialize <Amandina>(jsonString_A);

            Console.WriteLine($"Stoc curent Amandina:{pAmandina.GetNewStockAmandina}");

            string   jsonString_S = File.ReadAllText("Inventar_Savarina.json");
            Savarina pSavarina    = JsonSerializer.Deserialize <Savarina>(jsonString_S);

            Console.WriteLine($"Stoc curent Savarina:{pSavarina.GetNewStockSavarina}");

            string jsonString_T = File.ReadAllText("Inventar_Tort.json");
            Tort   pTort        = JsonSerializer.Deserialize <Tort>(jsonString_T);

            Console.WriteLine($"Stoc curent Tort:{pTort.GetNewStockTort}");
        }
Esempio n. 5
0
        public void Run()
        {
            bool q = true;

            while (q)
            {
                Meniu.AfiseazaMeniuPrincipal();
                int input_1st_menu = int.Parse(Console.ReadLine());

                if (input_1st_menu == 1 || input_1st_menu == 2 || input_1st_menu == 3 || input_1st_menu == 4 || input_1st_menu == 5)
                {
                    if (input_1st_menu == 1)
                    {
                        Console.Clear();
                        Meniu.MeniuAdaugatiProduse();
                        Meniu.AfiseazaMeniuCategoriiProduse();

                        bool q2 = true;

                        while (q2)
                        {
                            int input_2nd_menu = int.Parse(Console.ReadLine());
                            if (input_2nd_menu == 0)
                            {
                                break;
                            }
                            else if (input_2nd_menu == 1)
                            {
                                Console.Clear();
                                Panificatie.AfiseazaStocPanificatie();
                                Console.WriteLine("Alege produsul pe care doresti sa il adaugi in stoc:");
                                Meniu.ProcesarePanificatie();
                                int input_panificatie = int.Parse(Console.ReadLine());

                                if (input_panificatie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_panificatie == 1)
                                {
                                    Paine.AdaugaPaine();
                                    break;
                                }

                                else if (input_panificatie == 2)
                                {
                                    Franzela.AdaugaFranzela();
                                    break;
                                }
                                else if (input_panificatie == 3)
                                {
                                    Bagheta.AdaugaBagheta();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_panificatie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 2)
                            {
                                Console.Clear();
                                Patiserie.AfiseazaStocPatiserie();
                                Console.WriteLine("Alege produsul pe care doresti sa il adaugi in stoc:");
                                Meniu.ProcesarePatiserie();
                                int input_patiserie = int.Parse(Console.ReadLine());

                                if (input_patiserie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_patiserie == 1)
                                {
                                    Pateu.AdaugaPateu();
                                    break;
                                }

                                else if (input_patiserie == 2)
                                {
                                    Merdenea.AdaugaMerdenea();
                                    break;
                                }
                                else if (input_patiserie == 3)
                                {
                                    Covrig.AdaugaCovrig();
                                    break;
                                }
                                else if (input_patiserie == 4)
                                {
                                    Corn.AdaugaCorn();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_patiserie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 3)
                            {
                                Console.Clear();
                                Cofetarie.AfiseazaStocCofetarie();
                                Console.WriteLine("Alege produsul pe care doresti sa il adaugi in stoc:");
                                Meniu.ProcesareCofetarie();
                                int input_cofetarie = int.Parse(Console.ReadLine());

                                if (input_cofetarie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_cofetarie == 1)
                                {
                                    Ecler.AdaugaEcler();
                                    break;
                                }

                                else if (input_cofetarie == 2)
                                {
                                    Amandina.AdaugaAmandina();
                                    break;
                                }
                                else if (input_cofetarie == 3)
                                {
                                    Savarina.AdaugaSavarina();
                                    break;
                                }
                                else if (input_cofetarie == 4)
                                {
                                    Tort.AdaugaTort();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_cofetarie = int.Parse(Console.ReadLine());
                                }
                            }
                            else
                            {
                                Console.WriteLine("Optiunea nu corespunde cu nici un obiect din lista. Alege din nou:");
                            }
                        }
                    }
                    else if (input_1st_menu == 2)
                    {
                        Console.Clear();
                        Meniu.MeniuVindetiProduse();
                        Meniu.AfiseazaMeniuCategoriiProduse();

                        bool q2 = true;

                        while (q2)
                        {
                            int input_2nd_menu = int.Parse(Console.ReadLine());
                            if (input_2nd_menu == 0)
                            {
                                break;
                            }
                            else if (input_2nd_menu == 1)
                            {
                                Console.Clear();
                                Panificatie.AfiseazaStocPanificatie();
                                Console.WriteLine("Alege produsul pe care doresti sa il vinzi:");
                                Meniu.ProcesarePanificatie();
                                int input_panificatie = int.Parse(Console.ReadLine());

                                if (input_panificatie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_panificatie == 1)
                                {
                                    Paine.VindePaine();
                                    break;
                                }
                                else if (input_panificatie == 2)
                                {
                                    Franzela.VindeFranzela();
                                    break;
                                }
                                else if (input_panificatie == 3)
                                {
                                    Bagheta.VindeBagheta();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_panificatie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 2)
                            {
                                Console.Clear();
                                Patiserie.AfiseazaStocPatiserie();
                                Console.WriteLine("Alege produsul pe care doresti sa il vinzi:");
                                Meniu.ProcesarePatiserie();
                                int input_patiserie = int.Parse(Console.ReadLine());

                                if (input_patiserie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_patiserie == 1)
                                {
                                    Pateu.VindePateu();
                                    break;
                                }
                                else if (input_patiserie == 2)
                                {
                                    Merdenea.VindeMerdenea();
                                    break;
                                }
                                else if (input_patiserie == 3)
                                {
                                    Covrig.VindeCovrig();
                                    break;
                                }
                                else if (input_patiserie == 4)
                                {
                                    Corn.VindeCorn();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_patiserie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 3)
                            {
                                Console.Clear();
                                Cofetarie.AfiseazaStocCofetarie();
                                Console.WriteLine("Alege produsul pe care doresti sa il vinzi:");
                                Meniu.ProcesareCofetarie();
                                int input_cofetarie = int.Parse(Console.ReadLine());

                                if (input_cofetarie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_cofetarie == 1)
                                {
                                    Ecler.VindeEcler();
                                    break;
                                }
                                else if (input_cofetarie == 2)
                                {
                                    Amandina.VindeAmandina();
                                    break;
                                }
                                else if (input_cofetarie == 3)
                                {
                                    Savarina.VindeSavarina();
                                    break;
                                }
                                else if (input_cofetarie == 4)
                                {
                                    Tort.VindeTort();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_cofetarie = int.Parse(Console.ReadLine());
                                }
                            }
                        }
                    }
                    else if (input_1st_menu == 3)
                    {
                        Console.Clear();
                        Meniu.MeniuEliminatiProduse();
                        Meniu.AfiseazaMeniuCategoriiProduse();

                        bool q2 = true;

                        while (q2)
                        {
                            int input_2nd_menu = int.Parse(Console.ReadLine());
                            if (input_2nd_menu == 0)
                            {
                                break;
                            }
                            else if (input_2nd_menu == 1)
                            {
                                Console.Clear();
                                Panificatie.AfiseazaStocPanificatie();
                                Console.WriteLine("Alege produsul pe care doresti sa il elimini din stoc:");
                                Meniu.ProcesarePanificatie();
                                int input_panificatie = int.Parse(Console.ReadLine());

                                if (input_panificatie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_panificatie == 1)
                                {
                                    Paine.EliminaPaine();
                                    break;
                                }
                                else if (input_panificatie == 2)
                                {
                                    Franzela.EliminaFranzela();
                                    break;
                                }
                                else if (input_panificatie == 3)
                                {
                                    Bagheta.EliminaBagheta();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_panificatie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 2)
                            {
                                Console.Clear();
                                Patiserie.AfiseazaStocPatiserie();
                                Console.WriteLine("Alege produsul pe care doresti sa il elimini din stoc:");
                                Meniu.ProcesarePatiserie();
                                int input_patiserie = int.Parse(Console.ReadLine());

                                if (input_patiserie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_patiserie == 1)
                                {
                                    Pateu.EliminaPateu();
                                    break;
                                }
                                else if (input_patiserie == 2)
                                {
                                    Merdenea.EliminaMerdenea();
                                    break;
                                }
                                else if (input_patiserie == 3)
                                {
                                    Covrig.EliminaCovrig();
                                    break;
                                }
                                else if (input_patiserie == 4)
                                {
                                    Corn.EliminaCorn();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_patiserie = int.Parse(Console.ReadLine());
                                }
                            }
                            else if (input_2nd_menu == 3)
                            {
                                Console.Clear();
                                Cofetarie.AfiseazaStocCofetarie();
                                Console.WriteLine("Alege produsul pe care doresti sa il elimini din stoc:");
                                Meniu.ProcesareCofetarie();
                                int input_cofetarie = int.Parse(Console.ReadLine());

                                if (input_cofetarie == 0)
                                {
                                    Meniu.AfiseazaMeniuCategoriiProduse();
                                }
                                else if (input_cofetarie == 1)
                                {
                                    Ecler.EliminaEcler();
                                    break;
                                }
                                else if (input_cofetarie == 2)
                                {
                                    Amandina.EliminaAmandina();
                                    break;
                                }
                                else if (input_cofetarie == 3)
                                {
                                    Savarina.EliminaSavarina();
                                    break;
                                }
                                else if (input_cofetarie == 4)
                                {
                                    Tort.EliminaTort();
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Invalid input, please select again!");
                                    input_cofetarie = int.Parse(Console.ReadLine());
                                }
                            }
                        }
                    }
                    else if (input_1st_menu == 4)
                    {
                        Console.Clear();
                        Meniu.MeniuComandatiProduse();
                    }
                    else if (input_1st_menu == 5)
                    {
                        Console.Clear();
                        Meniu.MeniuAfiseazaInventar();
                        Panificatie.AfiseazaInventarPanificatie();
                        Patiserie.AfiseazaInventarPatiserie();
                        Cofetarie.AfiseazaInventarCofetarie();
                    }
                }
                else if (input_1st_menu == 0)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Optiunea nu corespunde cu nici un obiect din lista. Alege din nou:");
                }
            }
        }