forked from s434786/DINO_SCRUM
Niedomiar, nadmiar, zmiana na polski, ustalenie max dla kazdego projektu na 2500 szt
This commit is contained in:
parent
a6e7cd50f3
commit
701ed8a173
@ -7,13 +7,14 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Magazyn"
|
xmlns:local="clr-namespace:Magazyn"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Fruit Warehouse" Height="400" Width="520">
|
Title="Magazyn Owoców
|
||||||
|
" Height="400" Width="520">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ListBox x:Name="fruitList" Margin="10,35,10,0" Height="239" VerticalAlignment="Top"/>
|
<ListBox x:Name="fruitList" Margin="10,35,10,0" Height="239" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
<Button Name="sum" Content="Suma" HorizontalAlignment="Left" Margin="414,0,0,46" VerticalAlignment="Bottom" Width="74" Height="35" Background="Teal" Click="Button_Click_1"/>
|
<Button Name="sum" Content="Wartość magazynu
|
||||||
<TextBlock Name="payment" HorizontalAlignment="Left" Margin="404,322,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="84"/>
|
" 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="304,294,0,0" VerticalAlignment="Top" Width="100"/>
|
<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"/>
|
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,8 +90,7 @@ namespace Magazyn
|
|||||||
|
|
||||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
payment.Text = GetWarehousePrice().Price.ToString();
|
MessageBox.Show("Wartość magazynu: " + GetWarehousePrice().Price.ToString() );
|
||||||
//MessageBox.Show("Value of warehouse: " + GetWarehousePrice().Price.ToString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
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="100" Width="280">
|
Title="Magazyn" Height="100" Width="280">
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,36,0,0" TextWrapping="Wrap" Text="fruitName" VerticalAlignment="Top" Width="64"/>
|
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,36,0,0" TextWrapping="Wrap" Text="fruitName" VerticalAlignment="Top" Width="64"/>
|
||||||
<TextBox x:Name="amountToChange" HorizontalAlignment="Left" Margin="74,0,0,10" TextWrapping="Wrap" Text="0" Width="64" Height="32" VerticalAlignment="Bottom" RenderTransformOrigin="1.456,0.316"/>
|
<TextBox x:Name="amountToChange" HorizontalAlignment="Left" Margin="85,0,0,10" TextWrapping="Wrap" Text="0" Width="64" Height="32" VerticalAlignment="Bottom" RenderTransformOrigin="1.456,0.316"/>
|
||||||
<Button x:Name="saveButton" Content="Save" Margin="175,0,10,10" VerticalAlignment="Bottom" Click="saveButton_Click" />
|
<Button x:Name="saveButton" Content="Zapisz" Margin="175,0,10,10" VerticalAlignment="Bottom" Click="saveButton_Click" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -18,35 +18,60 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
SaveChangingAmountOfFruits.Invoke((type > 0) ? amount : -amount);
|
||||||
|
}
|
||||||
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user