Esempio n. 1
0
        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            ParentView.Show_WaitView("Cancelando platillo");
            List <Ingredients> ingredientsList = new List <Ingredients>();

            if (_dish.Ingredients != null)
            {
                ingredientsList = _dish.Ingredients.ToList();
            }


            var selectedIngredients = ingredientsList.Where(x => x.Dish == _dish.Id);

            using (var db = App.DbFactory.Open())
            {
                foreach (var ingredient in selectedIngredients)
                {
                    db.Delete(ingredient);
                }
                _dish.Ingredients = null;
                db.Delete(_dish);
            }

            ParentView.Show_DishesView();
        }
Esempio n. 2
0
        private void PrintBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!(DishesDgd.SelectedItem is LocalDishes localDishes))
            {
                return;
            }
            var dish = _dishesDb.SingleOrDefault(x => x.Id == localDishes.Id);

            SaveFileDialog saveDialog = new SaveFileDialog
            {
                Filter = "PDF file (*.pdf)|*.pdf"
            };

            if (saveDialog.ShowDialog() == true)
            {
                var s           = saveDialog.FileName;
                var fileCreated = DocumentsCreator.Dish(dish, saveDialog.FileName);
                if (fileCreated)
                {
                    ParentView.Show_MessageView("El documento ha sido creado con éxito",
                                                //affirmative action
                                                delegate
                    {
                        ParentView.Show_DishesView();
                    },
                                                "Aceptar",
                                                //negative action
                                                null,
                                                null,
                                                FontAwesome.WPF.FontAwesomeIcon.CheckCircle
                                                );
                }
                else
                {
                    ParentView.Show_MessageView("Hubo un problema al crear el documento\nComuniquese a soporte técnico",
                                                //affirmative action
                                                delegate
                    {
                        ParentView.Show_DishesView();
                    },
                                                "Aceptar",
                                                //negative action
                                                null,
                                                null,
                                                FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle
                                                );
                }
            }
        }
Esempio n. 3
0
        private void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!(DishesDgd.SelectedItem is LocalDishes localDishes))
            {
                return;
            }
            var dish = _dishesDb.SingleOrDefault(x => x.Id == localDishes.Id);

            try
            {
                using (var db = App.DbFactory.Open())
                {
                    var ingredients = db.Select <Ingredients>().Where(x => x.Dish == dish.Id).ToArray();
                    foreach (var i in ingredients)
                    {
                        db.Delete(i);
                    }
                    db.Delete(dish);
                }
                ParentView.Show_MessageView("El platillo se ha eliminado con éxito",
                                            //affirmative action
                                            delegate
                {
                    ParentView.Show_DishesView();
                },
                                            "Aceptar",
                                            //negative action
                                            null,
                                            null,
                                            FontAwesome.WPF.FontAwesomeIcon.CheckCircle
                                            );
            }
            catch (Exception)
            {
                ParentView.Show_MessageView("Hubo un problema al eliminar el platillo\nComuniquese a soporte técnico",
                                            //affirmative action
                                            delegate
                {
                    ParentView.Show_DishesView();
                },
                                            "Aceptar",
                                            //negative action
                                            null,
                                            null,
                                            FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle
                                            );
            }
        }
Esempio n. 4
0
 private void AddBtn_Click(object sender, RoutedEventArgs e)
 {
     if (App.HasProducts())
     {
         ParentView.Show_CreateNewDishView();
     }
     else
     {
         ParentView.Show_MessageView("No hay productos registrados\nRegistre productos para poder crear platillos",
                                     //affirmative action
                                     delegate
         {
             ParentView.Show_DishesView();
         },
                                     "Aceptar",
                                     //negative action
                                     null,
                                     null,
                                     FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle
                                     );
     }
 }
 private void OnClick_NegativeBtn(object sender, RoutedEventArgs e)
 {
     if (NegativeBtn.Content as string == "No")
     {
         ParentView.Show_MessageView("El platillo se ha guardado con éxito",
                                     //affirmative action
                                     delegate
         {
             ParentView.Show_DishesView();
         },
                                     "Aceptar",
                                     //negative action
                                     null,
                                     null,
                                     FontAwesome.WPF.FontAwesomeIcon.CheckCircle
                                     );
     }
     else
     {
         ParentView.Show_AddDishPhoto(_dish);
     }
 }
 private void OnClick_AffirmativeBtn(object sender, RoutedEventArgs e)
 {
     if (AffirmativeBtn.Content as string == "Si")
     {
         OpenFileDialog openFileDialog = new OpenFileDialog
         {
             Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"
         };
         if (openFileDialog.ShowDialog() == true)
         {
             var ImageBytes = File.ReadAllBytes(openFileDialog.FileName);
             PhotoImg.Source        = App.ByteToImage(ImageBytes);
             Icon.Visibility        = Visibility.Hidden;
             _dish.Draw             = ImageBytes;
             AffirmativeBtn.Content = "Guardar";
             NegativeBtn.Content    = "Recargar";
         }
     }
     else
     {
         using (var db = App.DbFactory.Open())
         {
             db.Update(_dish);
         }
         ParentView.Show_MessageView("El platillo se ha guardado con éxito",
                                     //affirmative action
                                     delegate
         {
             ParentView.Show_DishesView();
         },
                                     "Aceptar",
                                     //negative action
                                     null,
                                     null,
                                     FontAwesome.WPF.FontAwesomeIcon.CheckCircle
                                     );
     }
 }
Esempio n. 7
0
 private void OnClick_CancelBtn(object sender, RoutedEventArgs e)
 {
     ParentView.Show_DishesView();
 }