forked from s434786/DINO_SCRUM
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"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
@ -17,4 +40,4 @@
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>-->
|
||||
|
@ -43,9 +43,10 @@ namespace Magazyn
|
||||
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"));
|
||||
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" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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">
|
||||
<Grid>
|
||||
Title="Magazyn" Height="100" Width="280">
|
||||
|
||||
<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="messageBox" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="125" Height="64"/>
|
||||
<TextBox x:Name="amountToChange" Margin="0,71,9,0" TextWrapping="Wrap" Text="0" RenderTransformOrigin="1.456,0.316" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="64"/>
|
||||
<Button x:Name="saveButton" Content="Zastosuj" Margin="105,122,0,0" VerticalAlignment="Top" Click="saveButton_Click" Width="90" HorizontalAlignment="Left"/>
|
||||
<Button x:Name="cancelButton" Content="Anuluj" Margin="10,122,0,0" VerticalAlignment="Top" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" />
|
||||
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
|
||||
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -18,20 +18,30 @@ namespace Magazyn.Windows
|
||||
/// <summary>
|
||||
/// Interaction logic for AmountWindow.xaml
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user