tasks 39, 42, 52, 53

This commit is contained in:
Pat 2019-01-23 00:59:10 +01:00
parent efd2ea76cf
commit cc3e4b5052
13 changed files with 383 additions and 184 deletions

63
Magazyn_Client/.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -8,8 +8,8 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Cyan.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@ -73,6 +73,12 @@
<Compile Include="Windows\AmountWindow.xaml.cs">
<DependentUpon>AmountWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ErrorWindow.xaml.cs">
<DependentUpon>ErrorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ValueWindow.xaml.cs">
<DependentUpon>ValueWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -93,6 +99,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ErrorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ValueWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

View File

@ -1,71 +1,43 @@
<!--<Window x:Class="Magazyn.MainWindow"
Name ="main"
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"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="Fruit Warehouse" Height="469.85" Width="837.599">
<Grid>
<ListBox x:Name="fruitList" Margin="10,99,10.666,69.667" Grid.ColumnSpan="3"/>
--><!--<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="Quantity"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="Price / 1 pc."/>
<ColumnDefinition Width="Auto" SharedSizeGroup="Overall price"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding ...}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>--><!--
<Button Name="sum" Content="Wartość Magazynu" Margin="0,0,9.666,9.667" Height="35" Background="Teal" Click="Button_Click_1" HorizontalAlignment="Right" Width="164" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Column="1"/>
<ProgressBar Name="loadingContent" HorizontalAlignment="Right" Height="10" Margin="0,0,10.666,54.667" Width="100" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Column="1"/>
<Label Content="Fruit list:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
<Grid Height="64" Margin="0,0,-0.334,346.667" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="831" Grid.ColumnSpan="3" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="128*"/>
<ColumnDefinition Width="149*"/>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Left" Margin="125,28,0,0" VerticalAlignment="Top" Name="fruitName" TextWrapping="Wrap" Text="NAZWA" Width="116" FontSize="16" FontWeight="Bold" FontFamily="Segoe UI Black"/>
<TextBlock x:Name="fruitQuantity" Margin="280,28,0,17" HorizontalAlignment="Left" TextWrapping="Wrap" Text="LICZBA" Width="137" FontSize="16" FontWeight="Bold" FontFamily="Segoe UI Black" Grid.ColumnSpan="2"/>
<TextBlock Name="fruitPrice" Margin="54,28,235.333,0" Text="CENA / 1 SZT." VerticalAlignment="Top" IsEnabled="False" Height="20" FontSize="16" FontWeight="Bold" FontFamily="Segoe UI Black" Grid.Column="1"/>
<TextBlock x:Name="allPrice" Margin="217,28,37.333,0" Text="CENA / ŁĄCZNIE" VerticalAlignment="Top" Height="19" FontSize="16" FontWeight="Bold" FontFamily="Segoe UI Black" Grid.Column="1"/>
</Grid>
</Grid>
</Window>-->
<Window x:Class="Magazyn.MainWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
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">
WindowStartupLocation="CenterScreen"
Title="Magazyn Owoców" Height="550" MaxWidth="590" MinWidth="590" Width="590" SizeChanged="Window_SizeChanged">
<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"/>
<ListBox x:Name="fruitList" Margin="10,74,10.333,88.667"/>
<Grid Margin="0,21,-0.667,451.667" HorizontalAlignment="Right" Width="584" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="92*"/>
<ColumnDefinition Width="135*"/>
<ColumnDefinition Width="166*"/>
<ColumnDefinition Width="96*"/>
<ColumnDefinition Width="95*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="10" FontWeight="Bold" FontFamily="Segoe UI Black" TextAlignment="Center" Margin="0,14,7,14" />
<TextBlock Grid.Column="1" Text="NAZWA" FontSize="10" FontWeight="Bold" FontFamily="Segoe UI Black" TextAlignment="Center" Margin="8,14,7.667,14" />
<TextBlock Grid.Column="2" Text="LICZBA" FontSize="10" FontWeight="Bold" FontFamily="Segoe UI Black" TextAlignment="Center" Margin="1.333,14,3.667,14" />
<TextBlock Grid.Column="3" Text="1 SZT." FontSize="10" FontWeight="Bold" FontFamily="Segoe UI Black" TextAlignment="Center" Margin="4.333,14,10.667,14" />
<TextBlock Grid.Column="3" Text="ŁĄCZNIE" FontSize="10" FontWeight="Bold" FontFamily="Segoe UI Black" TextAlignment="Center" Margin="68.333,14,0,14" Grid.ColumnSpan="2" />
</Grid>
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163"/>
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
</Grid>
</Window>

View File

@ -16,25 +16,32 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
using Magazyn.Windows;
namespace Magazyn
{
public partial class MainWindow : Window
{
public int size = 4;
public int page = 0;
bool firstPage;
bool lastPage;
HttpClient client;
public MainWindow()
{
InitializeComponent();
loadingContent.IsIndeterminate = true;
this.Initialized += MainWindow_Initialized; ;
client = new HttpClient();
RefreshListOfFruits();
}
private void Button_Click(object sender, RoutedEventArgs e)
private void MainWindow_Initialized(object sender, EventArgs e)
{
RefreshListOfFruits();
}
@ -44,25 +51,55 @@ 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)
while (response.IsCompleted != true) ;
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
{
RefreshListOfFruits();
JObject data = JObject.Parse(response.Result.Content.ReadAsStringAsync().Result.ToString());
ErrorWindow window;
if (data["message"].ToString().Contains("Too low"))
{
window = new ErrorWindow("Wystąpił błąd niedomiaru. Próbujesz usunąć więcej owoców niż masz w magazynie.");
}
else if (data["message"].ToString().Contains("Over max"))
{
window = new ErrorWindow("Wystąpił błąd nadmiaru. Próbujesz dodać więcej owoców niż pomieści magazyn.");
}
else
{
window = new ErrorWindow("Nieznany błąd.");
}
window.Owner = this;
window.ShowDialog();
}
RefreshListOfFruits();
}
private void RefreshListOfFruits()
{
loadingContent.Visibility = Visibility.Visible;
loadingContent.IsIndeterminate = true;
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all");
while (response.IsCompleted != true)
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.ToString());
while (response.IsCompleted != true) ;
if (response.Result.StatusCode != HttpStatusCode.OK)
{
loadingContent.IsIndeterminate = false;
loadingContent.Visibility = Visibility.Hidden;
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
window.Owner = this;
window.ShowDialog();
return;
}
Fruit[] fruits = JsonConvert.DeserializeObject<Fruit[]>(response.Result.Content.ReadAsStringAsync().Result.ToString());
string responseString = response.Result.Content.ReadAsStringAsync().Result;
JObject replay = JObject.Parse(responseString);
firstPage = bool.Parse(replay["first"].ToString());
lastPage = bool.Parse(replay["last"].ToString());
Fruit[] fruits = JsonConvert.DeserializeObject<Fruit[]>(replay["content"].ToString());
UpdateListOfFruits(fruits);
}
@ -89,13 +126,31 @@ namespace Magazyn
return price;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
private void Value_Click(object sender, RoutedEventArgs e)
{
ValueWindow window = new ValueWindow(GetWarehousePrice().Price);
window.Owner = this;
window.ShowDialog();
}
private void prevButton_Click(object sender, RoutedEventArgs e)
{
if (firstPage != true) page--;
RefreshListOfFruits();
}
private void nextButton_Click(object sender, RoutedEventArgs e)
{
if (lastPage != true) page++;
RefreshListOfFruits();
}
MessageBox.Show("Wartość magazynu to: " + GetWarehousePrice().Price.ToString() + "zł", "Wartość magazynu" );
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size size = e.NewSize;
double height = size.Height - 124;
this.size = (int)(height / 90);
RefreshListOfFruits();
}

View File

@ -6,21 +6,21 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Magazyn.Views"
mc:Ignorable="d" Height="64" Width="782.692">
mc:Ignorable="d" Height="64" Width="575.45">
<!--<materialDesign:Card Height="64" Background="Teal">-->
<Grid Height="64">
<Image Name="fruitImage" HorizontalAlignment="Left" Margin="10,10,0,7" Width="50"/>
<TextBlock Name="fruitName" HorizontalAlignment="Left" Margin="73,28,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="116" TextAlignment="Center"/>
<Image Name="minusImage" HorizontalAlignment="Left" Height="24" Margin="240,25,0,0" VerticalAlignment="Top" Width="24" Source="/Images/minus.png" MouseDown="subButton_Click" />
<Image Name="plusImage" HorizontalAlignment="Left" Height="24" Margin="304,25,0,0" VerticalAlignment="Top" Width="24" Source="/Magazyn;component/Images/plus.png" RenderTransformOrigin="0.208,0.521" MouseDown="addButton_Click"/>
<TextBlock Name="fruitAmount" HorizontalAlignment="Left" Margin="267,29,0,19" Width="34" TextAlignment="Center" RenderTransformOrigin="0.489,-0.623"/>
<TextBlock Name="fruitPrice" Margin="403,25,252.667,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" IsEnabled="False" TextAlignment="Center"/>
<TextBlock x:Name="allPrice" Margin="578,25,80.667,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" TextAlignment="Center"/>
<materialDesign:Card Background="{DynamicResource SecondaryAccentBrush}">
<Grid>
<Image x:Name="fruitImage" HorizontalAlignment="Left" Margin="10,10,0,7" Width="50"/>
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="80,26,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="113" TextAlignment="Center"/>
<Image x:Name="minusImage" HorizontalAlignment="Left" Height="24" Margin="240,25,0,0" VerticalAlignment="Top" Width="24" Source="/Images/minus.png" MouseDown="subaddButton_Click" />
<Image x:Name="plusImage" HorizontalAlignment="Left" Height="24" Margin="304,25,0,0" VerticalAlignment="Top" Width="24" Source="/Magazyn;component/Images/plus.png" RenderTransformOrigin="0.208,0.521" MouseDown="subaddButton_Click"/>
<TextBlock x:Name="fruitAmount" HorizontalAlignment="Left" Margin="267,29,0,19" Width="34" TextAlignment="Center" RenderTransformOrigin="0.489,-0.623"/>
<TextBlock x:Name="fruitPrice" Margin="355,29,112.333,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" IsEnabled="False" TextAlignment="Center"/>
<TextBlock x:Name="allPrice" Margin="444,29,21.333,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" TextAlignment="Center"/>
</Grid>
<!--</materialDesign:Card>-->
</materialDesign:Card>
</UserControl>

View File

@ -46,23 +46,16 @@ namespace Magazyn.Views
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void subButton_Click(object sender, RoutedEventArgs e)
private void subaddButton_Click(object sender, RoutedEventArgs e)
{
AmountWindow window = new AmountWindow(fruit, -1, fruit.Quantity);
AmountWindow window = new AmountWindow(fruit, ((sender as Image).Name == "minusImage")?-1:1, fruit.Quantity);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.ShowDialog();
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
AmountWindow window = new AmountWindow(fruit, 1, fruit.Quantity);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
}

View File

@ -1,30 +1,21 @@
<!--<Window x:Class="Magazyn.Windows.AmountWindow"
<Window x:Class="Magazyn.Windows.AmountWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
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.Windows"
mc:Ignorable="d"
Title="Change Quantity" Height="205" Width="220"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">
<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"/>
</Grid>
</Window>-->
<Window x:Class="Magazyn.Windows.AmountWindow"
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.Windows"
mc:Ignorable="d"
Title="Magazyn" Height="205" Width="220">
Title="Magazyn" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
<Grid>
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,82,0,0" TextWrapping="Wrap" Text="fruitName" Width="64" Height="16" VerticalAlignment="Top"/>

View File

@ -36,11 +36,11 @@ namespace Magazyn.Windows
this.type = type;
this.quantity = quantity;
if (type == -1)
this.Title = "Zmniejsz ilość " + fruit.Name;
this.Title = "Zmniejsz ilość: " + fruit.Name;
else
this.Title = "Zwiększ ilość " + fruit.Name;
fruitName.Text = fruit.Name;
this.Title = "Zwiększ ilość: " + fruit.Name;
fruitName.Text = fruit.Name;
@ -52,51 +52,48 @@ namespace Magazyn.Windows
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void saveButton_Click(object sender, RoutedEventArgs e)
private void SendNewQuantity()
{
int amount = 0;
int maxAmount = 2500;
int amount = int.Parse(amountToChange.Text);
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);
ErrorWindow window = new ErrorWindow("Podana wartość jest nieprawidłowa, proszę podać wartość dodatnią.");
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
amountToChange.Text = "0";
return;
}
} catch (Exception ex) {
}
catch (Exception ex)
{
throw new NotImplementedException(ex.Message);
}
if ((quantity + amount > maxAmount) && amount >= 0 && type == 1)
{
MessageBox.Show("Przepełnienie magazynu", "Przepełnienie, maksymalnie 2500 sztuk", MessageBoxButton.OK, MessageBoxImage.Error);
amountToChange.Text = "0";
return;
} 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);
amountToChange.Text = "0";
return;
} else
{
SaveChangingAmountOfFruits.Invoke((type > 0) ? amount : -amount);
this.Close();
}
private void saveButton_Click(object sender, RoutedEventArgs e)
{
SendNewQuantity();
}
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) SendNewQuantity();
}
}
}

View File

@ -0,0 +1,23 @@
<Window x:Class="Magazyn.Windows.ErrorWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
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.Windows"
mc:Ignorable="d"
Title="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
<Grid>
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/>
<TextBlock x:Name="messageBlock" FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="messageBlock" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
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.Shapes;
namespace Magazyn.Windows
{
/// <summary>
/// Interaction logic for ErrorWindow.xaml
/// </summary>
public partial class ErrorWindow : Window
{
public ErrorWindow(string text)
{
InitializeComponent();
messageBlock.Text = text;
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@ -0,0 +1,25 @@
<Window x:Class="Magazyn.Windows.ValueWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
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.Windows"
mc:Ignorable="d"
Title="Wartość magazynu" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
<Grid>
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/>
<TextBlock FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="Wartość magazynu to:" VerticalAlignment="Top"/>
<TextBlock x:Name="valueBlock" FontSize="16" HorizontalAlignment="Left" Margin="10,34,0,0" TextWrapping="Wrap" Text="NaN zł" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
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.Shapes;
namespace Magazyn.Windows
{
/// <summary>
/// Interaction logic for ValueWindow.xaml
/// </summary>
public partial class ValueWindow : Window
{
public ValueWindow(float value)
{
InitializeComponent();
valueBlock.Text = value.ToString() + " zł";
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}