Merge branch 'master' of s434739/DINO_SCRUM into master
Jest ok. Dzięki
This commit is contained in:
commit
79cede3b6d
@ -1,4 +1,27 @@
|
|||||||
<Window x:Class="Magazyn.MainWindow"
|
<Window x:Class="Magazyn.MainWindow"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Magazyn"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Magazyn Owoców
|
||||||
|
" Height="400" Width="520">
|
||||||
|
<Grid>
|
||||||
|
<ListBox x:Name="fruitList" Margin="10,35,10,0" Height="239" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
|
<Button Name="sum" Content="Wartość magazynu
|
||||||
|
" HorizontalAlignment="Left" Margin="325,0,0,46" VerticalAlignment="Bottom" Width="163" Height="35" Background="Teal" Click="Button_Click_1"/>
|
||||||
|
<ProgressBar Name="loadingContent" HorizontalAlignment="Left" Height="10" Margin="213,295,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
|
|
||||||
|
<!--<Window x:Class="Magazyn.MainWindow"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
@ -17,4 +40,4 @@
|
|||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>-->
|
||||||
|
@ -43,9 +43,10 @@ namespace Magazyn
|
|||||||
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
|
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
|
||||||
|
|
||||||
Task<HttpResponseMessage> response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
|
Task<HttpResponseMessage> response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
|
||||||
while (response.IsCompleted != true) ;
|
while (response.IsCompleted != true)
|
||||||
|
{
|
||||||
RefreshListOfFruits();
|
RefreshListOfFruits();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +90,11 @@ namespace Magazyn
|
|||||||
|
|
||||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MessageBox.Show("Wartość magazynu to: " + GetWarehousePrice().Price.ToString() + "zł", "Wartość magazynu" );
|
MessageBox.Show("Wartość magazynu to: " + GetWarehousePrice().Price.ToString() + "zł", "Wartość magazynu" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ namespace Magazyn.Views
|
|||||||
|
|
||||||
private void subButton_Click(object sender, RoutedEventArgs e)
|
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.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addButton_Click(object sender, RoutedEventArgs e)
|
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.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Magazyn.Windows"
|
xmlns:local="clr-namespace:Magazyn.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Change Quantity" Height="205" Width="220"
|
Title="Magazyn" Height="100" Width="280">
|
||||||
ResizeMode="NoResize">
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>
|
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>
|
||||||
<TextBlock x:Name="messageBox" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="125" Height="64"/>
|
<TextBlock x:Name="messageBox" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="125" Height="64"/>
|
||||||
|
@ -18,20 +18,30 @@ namespace Magazyn.Windows
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for AmountWindow.xaml
|
/// Interaction logic for AmountWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
|
|
||||||
public partial class AmountWindow : Window
|
public partial class AmountWindow : Window
|
||||||
{
|
{
|
||||||
Fruit fruit;
|
Fruit fruit;
|
||||||
int type;
|
int type;
|
||||||
|
int quantity;
|
||||||
|
|
||||||
public delegate void ChangingAmountOfFruits(int amountChanged);
|
public delegate void ChangingAmountOfFruits(int amountChanged);
|
||||||
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
|
||||||
|
|
||||||
public AmountWindow(Fruit fruit, int type)
|
public AmountWindow(Fruit fruit, int type, int quantity)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.fruit = fruit;
|
this.fruit = fruit;
|
||||||
this.type = type;
|
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;
|
fruitName.Text = fruit.Name;
|
||||||
|
|
||||||
messageBox.Text = String.Format("Jaką ilość produktu chcesz {0} do magazynu?", (type > 0) ? "dodać":"odjąć");
|
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)
|
private void saveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
|
int maxAmount = 2500;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
amount = int.Parse(amountToChange.Text);
|
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) {
|
} catch (Exception ex) {
|
||||||
throw new NotImplementedException(ex.Message);
|
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();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user