Exemplo n.º 1
0
        public static void AdaugaPaine()
        {
            Console.WriteLine("Introduceti numarul de produse de tip 'Paine' 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_Paine.json");
            Paine  pPaine     = JsonSerializer.Deserialize <Paine>(jsonString);

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

            int stoc_nou_paine = pPaine._cantInitialaPaine + nrProduse;

            pPaine._cantInitialaPaine = stoc_nou_paine;

            jsonString = JsonSerializer.Serialize(pPaine);
            Console.WriteLine($"Noul stoc de 'Paine' este: {pPaine.GetNewStockPaine} bucati");
            File.WriteAllText("Inventar_Paine.json", jsonString);
        }
Exemplo n.º 2
0
        public static void VindePaine()
        {
            string jsonString = File.ReadAllText("Inventar_Paine.json");
            Paine  pPaine     = JsonSerializer.Deserialize <Paine>(jsonString);

            bool q = true;

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

                if (pPaine.GetNewStockPaine > 0)
                {
                    pPaine._pretPaine = 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 (pPaine.GetNewStockPaine >= nrProduse)
                    {
                        int stoc_nou_paine = pPaine._cantInitialaPaine - nrProduse;
                        pPaine._cantInitialaPaine = stoc_nou_paine;
                        Console.WriteLine($"Noul stoc de 'Paine' este: {pPaine.GetNewStockPaine} bucati");
                        Console.WriteLine($"Pret Paine / bucata: {pPaine.GetNewPricePaine} RON");
                        Console.WriteLine($"Total: {pPaine.GetNewPricePaine * nrProduse} RON");
                    }
                    else
                    {
                        int pretTotal = pPaine.GetNewPricePaine * pPaine._cantInitialaPaine;

                        Console.WriteLine($"In stoc au fost doar {pPaine.GetNewStockPaine} produse care s-au putut vinde.");
                        int stoc_nou_paine = pPaine._cantInitialaPaine - pPaine._cantInitialaPaine;
                        pPaine._cantInitialaPaine = stoc_nou_paine;
                        Console.WriteLine($"Noul stoc de 'Paine' este: {pPaine.GetNewStockPaine} bucati");
                        Console.WriteLine($"Pret Paine / bucata: {pPaine.GetNewPricePaine} RON");
                        Console.WriteLine($"Total: {pretTotal} RON");
                    }

                    jsonString = JsonSerializer.Serialize(pPaine);
                    File.WriteAllText("Inventar_Paine.json", jsonString);
                    break;
                }
                else
                {
                    Console.WriteLine("Produsul ales nu exista in stoc.");
                    break;
                }
            }
        }
        public static void AfiseazaStocPanificatie()
        {
            string jsonString_P = File.ReadAllText("Inventar_Paine.json");
            Paine  pPaine       = JsonSerializer.Deserialize <Paine>(jsonString_P);

            Console.WriteLine($"Stoc curent Paine:{pPaine.GetNewStockPaine}");

            string   jsonString_F = File.ReadAllText("Inventar_Franzela.json");
            Franzela pFranzela    = JsonSerializer.Deserialize <Franzela>(jsonString_F);

            Console.WriteLine($"Stoc curent Franzela:{pFranzela.GetNewStockFranzela}");

            string  jsonString_B = File.ReadAllText("Inventar_Bagheta.json");
            Bagheta pBagheta     = JsonSerializer.Deserialize <Bagheta>(jsonString_B);

            Console.WriteLine($"Stoc curent Bagheta:{pBagheta.GetNewStockBagheta}");
        }
        public static void AfiseazaInventarPanificatie()
        {
            string   jsonString_P = File.ReadAllText("Inventar_Paine.json");
            Paine    pPaine       = JsonSerializer.Deserialize <Paine>(jsonString_P);
            string   jsonString_F = File.ReadAllText("Inventar_Franzela.json");
            Franzela pFranzela    = JsonSerializer.Deserialize <Franzela>(jsonString_F);
            string   jsonString_B = File.ReadAllText("Inventar_Bagheta.json");
            Bagheta  pBagheta     = JsonSerializer.Deserialize <Bagheta>(jsonString_B);

            int valPaine    = pPaine.GetNewStockPaine * pPaine.GetNewPricePaine;
            int valFranzela = pFranzela.GetNewStockFranzela * pFranzela.GetNewPriceFranzela;
            int valBagheta  = pBagheta.GetNewStockBagheta * pBagheta.GetNewPriceBagheta;

            Console.WriteLine($"\nStoc curent Paine:{pPaine.GetNewStockPaine} bucati");
            Console.WriteLine($"Valoare:{valPaine} RON");
            Console.WriteLine($"\nStoc curent Franzela:{pFranzela.GetNewStockFranzela} bucati");
            Console.WriteLine($"Valoare:{valFranzela} RON");
            Console.WriteLine($"\nStoc curent Bagheta:{pBagheta.GetNewStockBagheta} bucati");
            Console.WriteLine($"Valoare:{valBagheta} RON");
            Console.WriteLine($"\nStoc total produse Panificatie:{pPaine.GetNewStockPaine + pFranzela.GetNewStockFranzela + pBagheta.GetNewStockBagheta} bucati");
            Console.WriteLine($"Valoare totala produse Panificatie:{valPaine + valFranzela + valBagheta} RON");
        }
Exemplo 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:");
                }
            }
        }