diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml b/Magazyn_Client/Magazyn/MainWindow.xaml
index f112e31..12004a5 100644
--- a/Magazyn_Client/Magazyn/MainWindow.xaml
+++ b/Magazyn_Client/Magazyn/MainWindow.xaml
@@ -1,4 +1,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml.cs b/Magazyn_Client/Magazyn/MainWindow.xaml.cs
index fe2bb65..ff7ee50 100644
--- a/Magazyn_Client/Magazyn/MainWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/MainWindow.xaml.cs
@@ -43,9 +43,10 @@ namespace Magazyn
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
Task response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
- while (response.IsCompleted != true) ;
-
- RefreshListOfFruits();
+ while (response.IsCompleted != true)
+ {
+ RefreshListOfFruits();
+ }
}
@@ -89,7 +90,11 @@ namespace Magazyn
private void Button_Click_1(object sender, RoutedEventArgs e)
{
+
+
+
MessageBox.Show("Wartość magazynu to: " + GetWarehousePrice().Price.ToString() + "zł", "Wartość magazynu" );
+
}
diff --git a/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs b/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs
index 51ee28c..932872d 100644
--- a/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs
+++ b/Magazyn_Client/Magazyn/Views/FruitView.xaml.cs
@@ -52,14 +52,14 @@ namespace Magazyn.Views
private void subButton_Click(object sender, RoutedEventArgs e)
{
- AmountWindow window = new AmountWindow(fruit, -1);
+ AmountWindow window = new AmountWindow(fruit, -1, fruit.Quantity);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.ShowDialog();
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
- AmountWindow window = new AmountWindow(fruit, 1);
+ AmountWindow window = new AmountWindow(fruit, 1, fruit.Quantity);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.ShowDialog();
}
diff --git a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml
index dcaf9a6..00e3710 100644
--- a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml
+++ b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml
@@ -5,15 +5,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Magazyn.Windows"
mc:Ignorable="d"
- Title="Change Quantity" Height="205" Width="220"
- ResizeMode="NoResize">
-
+ Title="Magazyn" Height="100" Width="280">
+
+
-
+
-
+
diff --git a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml.cs b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml.cs
index e53c03f..c020dc1 100644
--- a/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/Windows/AmountWindow.xaml.cs
@@ -18,20 +18,30 @@ namespace Magazyn.Windows
///
/// Interaction logic for AmountWindow.xaml
///
+ ///
+
public partial class AmountWindow : Window
{
Fruit fruit;
int type;
+ int quantity;
public delegate void ChangingAmountOfFruits(int amountChanged);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
- public AmountWindow(Fruit fruit, int type)
+ public AmountWindow(Fruit fruit, int type, int quantity)
{
InitializeComponent();
this.fruit = fruit;
this.type = type;
+ this.quantity = quantity;
+ if (type == -1)
+ this.Title = "Zmniejsz ilość " + fruit.Name;
+ else
+ this.Title = "Zwiększ ilość " + fruit.Name;
+ fruitName.Text = fruit.Name;
+
fruitName.Text = fruit.Name;
messageBox.Text = String.Format("Jaką ilość produktu chcesz {0} do magazynu?", (type > 0) ? "dodać":"odjąć");
@@ -44,20 +54,39 @@ namespace Magazyn.Windows
{
}
+
}
private void saveButton_Click(object sender, RoutedEventArgs e)
{
int amount = 0;
-
+ int maxAmount = 2500;
try
{
amount = int.Parse(amountToChange.Text);
+ if (amount < 0)
+ {
+ MessageBox.Show("Podana wartość jest nieprawidłowa, proszę podać wartość dodatnią", "Nieprawidłowa wartość", MessageBoxButton.OK, MessageBoxImage.Error);
+ amountToChange.Text = "0";
+ return;
+ }
+
} catch (Exception ex) {
throw new NotImplementedException(ex.Message);
}
- SaveChangingAmountOfFruits.Invoke((type>0)?amount:-amount);
+ if ((quantity + amount > maxAmount) && amount >= 0 && type == 1)
+ {
+ MessageBox.Show("Przepełnienie magazynu", "Przepełnienie, maxymalnie 2500 sztuk", MessageBoxButton.OK, MessageBoxImage.Error);
+
+ } else if ((quantity - amount < 0) && amount >= 0 && type == -1)
+ {
+ MessageBox.Show("Niedobór magazynu", "Ilość przedmiotów nie możę być mniejsza niz 0", MessageBoxButton.OK, MessageBoxImage.Error);
+ } else
+ {
+ SaveChangingAmountOfFruits.Invoke((type > 0) ? amount : -amount);
+ }
+
this.Close();
}