Esempio n. 1
0
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            AngajatVM angajat = value as AngajatVM;

            object[] result = new object[8] {
                angajat.Id, angajat.Denumire, angajat.Categorie, angajat.Pret, angajat.CantitatePortie, angajat.CantitateTotala, angajat.Fotografie, angajat.Alergeni
            };
            return(result);
        }
Esempio n. 2
0
        public void DeleteMethod(object obj)
        {
            AngajatVM             angajatVM       = obj as AngajatVM;
            List <Meniu_Preparat> meniu_preparate = restaurant.Meniu_Preparat.ToList();
            List <int>            id = new List <int>();

            if (angajatVM != null)
            {
                if (angajatVM.Categorie.ToLower() == "meniu")
                {
                    restaurant.DeleteMeniu_Preparat(angajatVM.IdPreparat);
                    restaurant.DeleteMeniu(angajatVM.IdPreparat);
                }
                else
                {
                    foreach (var mp in meniu_preparate)
                    {
                        if (mp.id_preparat == angajatVM.IdPreparat)
                        {
                            id.Add(mp.id_meinu);
                        }
                    }
                    restaurant.DeleteFotografie(angajatVM.IdPreparat);
                    restaurant.DeletePreparat_Alergen(angajatVM.IdPreparat);
                    restaurant.DeletePreparatMeniu(angajatVM.IdPreparat);
                    restaurant.DeletePreparat(angajatVM.IdPreparat);
                    foreach (var i in id)
                    {
                        restaurant.DeleteMeniu(i);
                    }
                }
                MessageBox.Show("Stergerea s-a realizat cu succes!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("Va rugam selectati un preparat pentru a-l sterge!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 3
0
        public void ModifyMethod(object obj)
        {
            AngajatVM angajatVM = obj as AngajatVM;

            if (angajatVM != null)
            {
                List <Categorie_preparat> categorii = restaurant.Categorie_preparat.ToList();
                List <Alergen>            alergeni  = restaurant.Alergens.ToList();
                List <int> id_alg       = new List <int>();
                int        id_categorie = 0;
                foreach (var categorie in categorii)
                {
                    if (angajatVM.Categorie.ToLower() == categorie.tip_preparat)
                    {
                        id_categorie = categorie.id;
                    }
                }

                if (id_categorie != 0)
                {
                    if (Double.Parse(angajatVM.Pr) >= 0 && Int32.Parse(angajatVM.CantitateP) >= 0 && Int32.Parse(angajatVM.CantitateT) >= 0)
                    {
                        if (angajatVM.Categorie == "meniu")
                        {
                            restaurant.ModifyMeniu(Int32.Parse(angajatVM.Id), angajatVM.Denumire, angajatVM.Fotografie, id_categorie);
                        }
                        else
                        {
                            restaurant.ModifyPreparat(Int32.Parse(angajatVM.Id), angajatVM.Denumire, Double.Parse(angajatVM.Pr)
                                                      , Int32.Parse(angajatVM.CantitateP), Int32.Parse(angajatVM.CantitateT), id_categorie);
                            restaurant.ModifyFotografie(Int32.Parse(angajatVM.Id), angajatVM.Fotografie);
                            if (angajatVM.Alergeni.Count() != 0)
                            {
                                restaurant.DeletePreparat_Alergen(Int32.Parse(angajatVM.Id));

                                foreach (var alg in angajatVM.Alergeni)
                                {
                                    foreach (var alergen in alergeni)
                                    {
                                        if (alg == alergen.denumire_alergen)
                                        {
                                            restaurant.AddPreparat_Alergen(Int32.Parse(angajatVM.Id), alergen.id_alergen);
                                        }
                                    }
                                }
                            }
                        }
                        MessageBox.Show("Modificarea s-a realizat cu succes!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Pretul sau cantitatile preparatului nu pot fi negative!\nVa rugam introduceti pret sau cantitati valide!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Aceasta categorie nu exista!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Va rugam selectati un preparat pentru a-l modifica!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 4
0
 public AngajatActions(AngajatVM angajatVM)
 {
     this.angajatContext = angajatVM;
 }
Esempio n. 5
0
        public void AddMethod(object obj)
        {
            AngajatVM                 angajatVM = obj as AngajatVM;
            List <string>             alg       = new List <string>();
            List <Categorie_preparat> categorii = restaurant.Categorie_preparat.ToList();
            List <Preparat>           preparate = restaurant.Preparats.ToList();
            List <Alergen>            alergeni  = restaurant.Alergens.ToList();

            if (angajatVM != null)
            {
                foreach (var alergen in angajatVM.Alergeni)
                {
                    if (alergen != "")
                    {
                        alg.Add(alergen);
                    }
                }
                if (alg.Count() != 0)
                {
                    int id_categorie = 0;
                    foreach (var categorie in categorii)
                    {
                        if (angajatVM.Categorie.ToLower() == categorie.tip_preparat)
                        {
                            id_categorie = categorie.id;
                        }
                    }

                    if (id_categorie != 0)
                    {
                        if (Double.Parse(angajatVM.Pr.ToString()) >= 0)
                        {
                            if (Int32.Parse(angajatVM.CantitateP) >= 0 && Int32.Parse(angajatVM.CantitateP) >= 0)
                            {
                                restaurant.AddPreparat(angajatVM.Denumire, id_categorie, Double.Parse(angajatVM.Pr), Int32.Parse(angajatVM.CantitateP), Int32.Parse(angajatVM.CantitateT));
                                int             id_preparat = 0;
                                List <Preparat> preparatele = restaurant.Preparats.ToList();
                                foreach (var preparat in preparatele)
                                {
                                    id_preparat = preparat.idPreparat;
                                }

                                foreach (var aleg in angajatVM.Alergeni)
                                {
                                    foreach (var alergen in alergeni)
                                    {
                                        if (aleg == alergen.denumire_alergen)
                                        {
                                            restaurant.AddPreparat_Alergen(id_preparat, alergen.id_alergen);
                                        }
                                    }
                                }
                                restaurant.AddFotografie(id_preparat, angajatVM.Fotografie);
                                MessageBox.Show("Ati adaugat cu succes produsul!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            else
                            {
                                MessageBox.Show("Va rugam sa bagati cantitati valide nenegative!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Va rugam sa bagati un pret valid!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Aceasta categorie nu exista, va rugam introduceti o categorie valida!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Va rugam selectati daca contine sau nu alergeni preparatul!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Va rugam introduceti date in toate casutele!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }