2019-01-13 16:36:26 +01:00
|
|
|
|
using Magazyn.DataModels;
|
|
|
|
|
using Magazyn.Windows;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
namespace Magazyn.Views
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for FruitView.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FruitView : UserControl
|
|
|
|
|
{
|
2019-01-23 22:39:54 +01:00
|
|
|
|
public Fruit fruit;
|
2019-01-13 16:36:26 +01:00
|
|
|
|
|
|
|
|
|
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
|
|
|
|
|
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
|
|
|
|
|
|
|
|
|
public FruitView(Fruit fruit)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.fruit = fruit;
|
|
|
|
|
|
2019-01-14 20:10:05 +01:00
|
|
|
|
fruitName.Text = fruit.Name;
|
|
|
|
|
fruitAmount.Text = fruit.Quantity.ToString();
|
2019-01-23 11:07:24 +01:00
|
|
|
|
fruitPrice.Text = fruit.Price.ToString() + "zł";
|
|
|
|
|
allPrice.Text = (fruit.Quantity * fruit.Price).ToString() + "zł";
|
2019-01-13 16:36:26 +01:00
|
|
|
|
|
2019-01-14 20:10:05 +01:00
|
|
|
|
try
|
2019-01-13 16:36:26 +01:00
|
|
|
|
{
|
2019-01-23 22:39:54 +01:00
|
|
|
|
fruitImage.Source = fruit.ImageSource;
|
|
|
|
|
}
|
2019-01-13 16:36:26 +01:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2019-01-22 21:02:49 +01:00
|
|
|
|
MessageBox.Show(ex.Message);
|
2019-01-13 16:36:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 22:39:54 +01:00
|
|
|
|
}
|
2019-01-13 16:36:26 +01:00
|
|
|
|
|
2019-01-23 22:39:54 +01:00
|
|
|
|
private void subaddButton_Click(object sender, RoutedEventArgs e)
|
2019-01-13 16:36:26 +01:00
|
|
|
|
{
|
2019-01-23 22:39:54 +01:00
|
|
|
|
AmountWindow window = new AmountWindow(fruit, ((sender as Image).Name == "minusImage")?-1:1, fruit.Quantity);
|
2019-01-13 16:36:26 +01:00
|
|
|
|
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
2019-01-22 17:35:51 +01:00
|
|
|
|
window.Owner = Application.Current.MainWindow;
|
2019-01-16 23:24:11 +01:00
|
|
|
|
window.ShowDialog();
|
2019-01-13 16:36:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WindowSaveChangingAmountOfFruits(int amountChanged)
|
|
|
|
|
{
|
|
|
|
|
SaveChangingAmountOfFruits.Invoke(amountChanged, fruit);
|
|
|
|
|
}
|
2019-01-14 20:10:05 +01:00
|
|
|
|
}
|
2019-01-13 16:36:26 +01:00
|
|
|
|
}
|