Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

12 changed files with 38 additions and 78 deletions

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<appSettings>
<add key="serverUrl" value="https://sysmag.herokuapp.com/api/"/>
</appSettings>
</configuration> </configuration>

View File

@ -46,7 +46,6 @@
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -17,9 +17,13 @@
mc:Ignorable="d" mc:Ignorable="d"
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" > Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
<Grid> <Grid>
<Grid.RowDefinitions>
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,87"/> <RowDefinition Height="435*"/>
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163"/> <RowDefinition Height="0*"/>
<RowDefinition Height="34*"/>
</Grid.RowDefinitions>
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,55"/>
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163" Grid.RowSpan="3"/>
<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"/>
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/> <Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
@ -28,13 +32,11 @@
<Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/> <Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/>
<Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/> <Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/>
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,50" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/> <Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,18" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,50" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/> <Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,18" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
<TextBlock x:Name="pageBlock" FontSize="16" Margin="271,0,276,10" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/> <TextBlock x:Name="pageBlock" FontSize="16" Margin="274,0,273,25" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/>
<Label Content="Status:" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" RenderTransformOrigin="0.75,0.423" /> <Label Content="Status:" HorizontalAlignment="Left" Margin="4,0,0,14" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
<TextBlock Name="netStatus" HorizontalAlignment="Left" Margin="63,0,0,14" TextWrapping="Wrap" Text="error" VerticalAlignment="Bottom"/> <TextBlock Name="netStatus" HorizontalAlignment="Left" Margin="50,0,0,19" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
<TextBox x:Name="searchBox" TextWrapping="Wrap" Text="" HorizontalAlignment="Right" Width="120" Height="23" VerticalAlignment="Top" TextChanged="TextBox_TextChanged" />
<materialDesign:PackIcon Kind="Search" Height="23" Width="23" Margin="0,0,121,0" VerticalAlignment="Top" HorizontalAlignment="Right"/>
</Grid> </Grid>

View File

@ -22,7 +22,6 @@ using System.Net;
using Magazyn.Windows; using Magazyn.Windows;
using Magazyn.Tools; using Magazyn.Tools;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Configuration;
namespace Magazyn namespace Magazyn
{ {
@ -40,14 +39,9 @@ namespace Magazyn
Size windowSize; Size windowSize;
string serverUrl;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
serverUrl = ConfigurationManager.AppSettings.Get("serverUrl");
client = new HttpClient(); client = new HttpClient();
this.Loaded += MainWindowLoaded; this.Loaded += MainWindowLoaded;
netConn = checkInternetConnection(); netConn = checkInternetConnection();
@ -68,7 +62,7 @@ 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(serverUrl+"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) ;
if (response.Result.StatusCode == HttpStatusCode.BadRequest) if (response.Result.StatusCode == HttpStatusCode.BadRequest)
@ -100,11 +94,11 @@ namespace Magazyn
{ {
if (netConn) if (netConn)
{ {
pageBlock.Text = (page+1).ToString(); pageBlock.Text = page.ToString();
Task<HttpResponseMessage> response = client.GetAsync(serverUrl+"get-all?page=" + page.ToString() + "&size=" + size.ToString() + "&search=" + ((string.IsNullOrEmpty(searchBox.Text) || string.IsNullOrWhiteSpace(searchBox.Text)) ? "none" : searchBox.Text) ); Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.ToString());
while (response.IsCompleted != true) ; while (response.IsCompleted != true) ;
if (response.Result.StatusCode != HttpStatusCode.OK) if (response.Result.StatusCode != HttpStatusCode.OK)
{ {
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem."); ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
@ -112,6 +106,7 @@ namespace Magazyn
window.ShowDialog(); window.ShowDialog();
page = 0; page = 0;
size = 0;
return; return;
} }
@ -143,7 +138,7 @@ namespace Magazyn
private WarehousePrice GetWarehousePrice() private WarehousePrice GetWarehousePrice()
{ {
Task<HttpResponseMessage> response = client.GetAsync(serverUrl+"get-price-of-all"); Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
while (response.IsCompleted != true) ; while (response.IsCompleted != true) ;
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString()); WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
@ -174,9 +169,10 @@ namespace Magazyn
{ {
Size size = e.NewSize; Size size = e.NewSize;
if( Math.Abs(windowSize.Height - size.Height) >= 64 ) if( Math.Abs(windowSize.Height - size.Height) >= 40 )
{ {
this.size = Convert.ToInt32(fruitList.ActualHeight) / 80; //size -> number of elementy by page
this.size = (int)((size.Height - 124) / 80);
page = 0; page = 0;
windowSize = size; windowSize = size;
RefreshListOfFruits(); RefreshListOfFruits();
@ -203,12 +199,6 @@ namespace Magazyn
return false; return false;
} }
} }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
page = 0;
RefreshListOfFruits();
}
} }
} }

View File

@ -18,12 +18,12 @@
Title="" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown"> Title="" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
<Grid> <Grid>
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,87,0,0" TextWrapping="Wrap" Text="fruitName" Width="76" Height="16" VerticalAlignment="Top" TextAlignment="Center"/> <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="84,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="121" Height="64"/> <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="" RenderTransformOrigin="1.456,0.316" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="64"/> <TextBox x:Name="amountToChange" Margin="0,71,9,0" TextWrapping="Wrap" Text="" RenderTransformOrigin="1.456,0.316" Height="32" VerticalAlignment="Top" HorizontalAlignment="Right" Width="64"/>
<Button x:Name="saveButton" Content="Zastosuj" Margin="0,0,9,10" VerticalAlignment="Bottom" Click="saveButton_Click" Width="90" HorizontalAlignment="Right"/> <Button x:Name="saveButton" Content="Zastosuj" Margin="0,0,9,10" VerticalAlignment="Bottom" Click="saveButton_Click" Width="90" HorizontalAlignment="Right"/>
<Button x:Name="cancelButton" Content="Anuluj" Margin="10,0,0,10" VerticalAlignment="Bottom" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" /> <Button x:Name="cancelButton" Content="Anuluj" Margin="10,0,0,10" VerticalAlignment="Bottom" Click="cancelButton_Click" Width="90" HorizontalAlignment="Left" />
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="15,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> </Window>

View File

@ -68,20 +68,7 @@ namespace Magazyn.Windows
private void SendNewQuantity() private void SendNewQuantity()
{ {
int amount; int amount = int.Parse(amountToChange.Text);
try
{
amount = int.Parse(amountToChange.Text);
}
catch
{
ErrorWindow window = new ErrorWindow("Podana wartość jest nieprawidłowa, proszę podać liczbę dodatnią.");
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
amountToChange.Text = "0";
return;
}
try try
{ {
if (amount < 0) if (amount < 0)

View File

@ -15,7 +15,7 @@
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="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown"> Title="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
<Grid> <Grid>
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/> <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"/> <TextBlock x:Name="messageBlock" FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="messageBlock" VerticalAlignment="Top"/>

View File

@ -29,10 +29,5 @@ namespace Magazyn.Windows
{ {
this.Close(); this.Close();
} }
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) this.Close();
}
}
} }

View File

@ -15,7 +15,7 @@
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="Informacje o: " WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown"> Title="Informacje o: " WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
<Grid> <Grid>
<TextBlock x:Name="fruitName" Margin="79,10,9,0" TextWrapping="Wrap" Text="fruitName" Height="16" VerticalAlignment="Top"/> <TextBlock x:Name="fruitName" Margin="79,10,9,0" TextWrapping="Wrap" Text="fruitName" Height="16" VerticalAlignment="Top"/>
<TextBlock x:Name="fruitPrice" Margin="79,31,10,0" TextWrapping="Wrap" Text="fruitPrice" Height="16" VerticalAlignment="Top"/> <TextBlock x:Name="fruitPrice" Margin="79,31,10,0" TextWrapping="Wrap" Text="fruitPrice" Height="16" VerticalAlignment="Top"/>

View File

@ -49,10 +49,5 @@ namespace Magazyn.Windows
{ {
this.Close(); this.Close();
} }
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) this.Close();
}
} }
} }

View File

@ -15,11 +15,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="Wartość magazynu" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown"> Title="Wartość magazynu" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
<Grid> <Grid>
<Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/> <Button x:Name="okButton" Content="Ok" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" Click="okButton_Click"/>
<TextBlock Margin="10,28,10,0" TextWrapping="Wrap" Text="Wartość magazynu to:" VerticalAlignment="Top" TextAlignment="Center" RenderTransformOrigin="0.495,1.734" /> <TextBlock FontSize="16" Margin="10,10,10,0" TextWrapping="Wrap" Text="Wartość magazynu to:" VerticalAlignment="Top"/>
<TextBlock x:Name="valueBlock" Margin="67,49,69,0" TextWrapping="Wrap" Text="NaN zł" VerticalAlignment="Top" TextAlignment="Center" RenderTransformOrigin="2.405,0.629"/> <TextBlock x:Name="valueBlock" FontSize="16" HorizontalAlignment="Left" Margin="10,34,0,0" TextWrapping="Wrap" Text="NaN zł" VerticalAlignment="Top"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -29,10 +29,5 @@ namespace Magazyn.Windows
{ {
this.Close(); this.Close();
} }
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) this.Close();
}
}
} }