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(); }
private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (!(ProductsDgd.SelectedItem is Products product)) { return; } ParentView.Show_NewProductView(product); }
private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (!(DishesDgd.SelectedItem is LocalDishes localDishes)) { return; } var dish = _dishesDb.SingleOrDefault(x => x.Id == localDishes.Id); ParentView.Show_NewDishView(dish); }
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 ); } } }
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 ); } }
private void PrintBtn_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveDialog = new SaveFileDialog { Filter = "PDF file (*.pdf)|*.pdf" }; if (saveDialog.ShowDialog() == true) { var s = saveDialog.FileName; var fileCreated = DocumentsCreator.ProductsList(_productsOc, saveDialog.FileName); if (fileCreated) { ParentView.Show_MessageView("El documento ha sido creado con éxito", //affirmative action delegate { ParentView.Show_ProductsView(); }, "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_ProductsView(); }, "Aceptar", //negative action null, null, FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle ); } } }
private void DeleteBtn_Click(object sender, RoutedEventArgs e) { if (!(ProductsDgd.SelectedItem is Products product)) { return; } try { using (var db = App.DbFactory.Open()) { db.Delete(product); } ParentView.Show_MessageView("El producto se ha eliminado con éxito", //affirmative action delegate { ParentView.Show_ProductsView(); }, "Aceptar", //negative action null, null, FontAwesome.WPF.FontAwesomeIcon.CheckCircle ); } catch (Exception) { ParentView.Show_MessageView("Hubo un problema al eliminar el producto\nComuniquese a soporte técnico", //affirmative action delegate { ParentView.Show_ProductsView(); }, "Aceptar", //negative action null, null, FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle ); } }
private void OnClick_AcceptBtn(object sender, RoutedEventArgs e) { if (NameTxt.Text == "" || NameTxt.Text == " " || NameTxt.Text == string.Empty) { WarningText.Visibility = Visibility.Visible; } else { ParentView.Show_WaitView("Creando platillo"); Dishes dish; using (var db = App.DbFactory.Open()) { db.Save(new Dishes { Name = NameTxt.Text }); dish = db.Select <Dishes>().Where(x => x.Name == NameTxt.Text).FirstOrDefault(); } ParentView.Show_NewDishView(dish); } }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { var lineParsed = Enum.TryParse(LineCmb.Text, out DishesLine dishLine); if (NameTxt.Text == "" || NameTxt.Text == " " || NameTxt.Text == string.Empty) { WarningTbk.Text = "Ingrese el nombre del platillo antes de guardarlo"; WarningTbk.Visibility = Visibility.Visible; } else if (TotalCost <= 0) { WarningTbk.Text = "Ingrese ingredientes antes de guardar el platillo"; WarningTbk.Visibility = Visibility.Visible; } else if (PortionCost <= 0) { WarningTbk.Text = "Ingrese el número de porciones antes de guardar el platillo"; WarningTbk.Visibility = Visibility.Visible; } else if (!lineParsed || LineCmb.Text == "-Seleccione una opción-") { WarningTbk.Text = "Verifique que haya seleccionado la linea a la que pertenece el platillo"; WarningTbk.Visibility = Visibility.Visible; } else { _dish.Instructions = InstructionsTxt.Text; _dish.Name = NameTxt.Text; _dish.Portions = Int32.Parse(PortionsTxt.Text); _dish.Line = dishLine; _dish.Notes = NotesTxt.Text; using (var db = App.DbFactory.Open()) { db.Update(_dish); } ParentView.Show_AddDishPhoto(_dish); } }
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 ); } }
private void CancelBtn_Click(object sender, RoutedEventArgs e) { ParentView.Show_ProductsView(); }
private void AddBtn_Click(object sender, RoutedEventArgs e) { ParentView.Show_AddIngredientsView(_dish); }
private void AddBtn_Click(object sender, RoutedEventArgs e) { ParentView.Show_NewProductView(); }
private void OnClick_CancelBtn(object sender, RoutedEventArgs e) { ParentView.Show_DishesView(); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { var name = ProductTxt.Text; var categoryParsed = Enum.TryParse(CategoryCmb.Text, out ProductCategory category); var priceParsed = decimal.TryParse(PriceTxt.Text, out decimal price); var packageUnitParsed = Enum.TryParse(UnitCmb.Text, out PackageUnit packageUnit); var weightParsed = decimal.TryParse(WeightTxt.Text, out decimal weight); var wasteParsed = decimal.TryParse(WasteTxt.Text, out decimal waste); var yieldParsed = decimal.TryParse(YieldTxt.Text, out decimal yield); if (name == "" || name == string.Empty) { WarningTbk.Text = "Ingrese el nombre del producto"; WarningTbk.Visibility = Visibility.Visible; } else if (!categoryParsed || CategoryCmb.Text == "-Seleccione una opción-") { WarningTbk.Text = "Verifique que haya seleccionado una categoría"; WarningTbk.Visibility = Visibility.Visible; } else if (!priceParsed) { WarningTbk.Text = "Ingrese el precio del producto"; WarningTbk.Visibility = Visibility.Visible; } else if (!packageUnitParsed || UnitCmb.Text == "-Seleccione una opción-") { WarningTbk.Text = "Verifique que haya seleccionado una unidad de medida"; WarningTbk.Visibility = Visibility.Visible; } else if (!weightParsed) { WarningTbk.Text = "Ingrese el peso del producto"; WarningTbk.Visibility = Visibility.Visible; } else if (!wasteParsed) { WarningTbk.Text = "Ingrese el porcentaje de merma"; WarningTbk.Visibility = Visibility.Visible; } else if (!yieldParsed) { WarningTbk.Text = "Verifique que todos los datos se hayan ingresado"; WarningTbk.Visibility = Visibility.Visible; } else if (Cost <= 0) { WarningTbk.Text = "Verifique que todos los datos se hayan ingresado"; WarningTbk.Visibility = Visibility.Visible; } else { if (_product != null) { try { if (weight != 1) { var yieldPercent = yield / 100; var yieldByWeight = 1 / yieldPercent; var priceByOne = Math.Round(price / weight, 2); var costByOne = Math.Round(yieldByWeight * priceByOne, 2); using (var db = App.DbFactory.Open()) { db.Update(new Products { Id = _product.Id, Name = name, Category = category, Price = priceByOne, Unit = packageUnit, Weight = 1, Waste = waste, Yield = yield, Cost = costByOne }); } } else { using (var db = App.DbFactory.Open()) { db.Update(new Products { Id = _product.Id, Name = name, Category = category, Price = price, Unit = packageUnit, Weight = weight, Waste = waste, Yield = yield, Cost = Cost }); } } ParentView.Show_MessageView("El producto se ha actualizado con éxito\n¿Deseas guardar uno nuevo?", //affirmative action delegate { ParentView.Show_NewProductView(); }, null, //negative action delegate { ParentView.Show_ProductsView(); }, null, FontAwesome.WPF.FontAwesomeIcon.CheckCircle ); } catch (Exception) { ParentView.Show_MessageView("Hubo un problema al actualizar el producto\nComuniquese a soporte técnico", //affirmative action delegate { ParentView.Show_NewProductView(); }, "Aceptar", //negative action null, null, FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle ); } } else { Products product; if (weight != 1) { var yieldPercent = yield / 100; var yieldByWeight = 1 / yieldPercent; var priceByOne = Math.Round(price / weight, 2); var costByOne = Math.Round(yieldByWeight * priceByOne, 2); product = new Products { Name = name, Category = category, Price = priceByOne, Unit = packageUnit, Weight = 1, Waste = waste, Yield = yield, Cost = costByOne }; } else { product = new Products { Name = name, Category = category, Price = price, Unit = packageUnit, Weight = weight, Waste = waste, Yield = yield, Cost = Cost }; } try { using (var db = App.DbFactory.Open()) { db.Save(product); } ParentView.Show_MessageView("El producto se ha guardado con éxito\n¿Deseas guardar otro?", //affirmative action delegate { ParentView.Show_NewProductView(); }, null, //negative action delegate { ParentView.Show_ProductsView(); }, null, FontAwesome.WPF.FontAwesomeIcon.CheckCircle ); } catch (Exception) { ParentView.Show_MessageView("Hubo un problema al agregar el producto\nComuniquese a soporte técnico", //affirmative action delegate { ParentView.Show_NewProductView(); }, "Aceptar", //negative action null, null, FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle ); } } } }