diff --git a/Magazyn_Client/Magazyn/App.config b/Magazyn_Client/Magazyn/App.config
index 00bfd11..89cc1e3 100644
--- a/Magazyn_Client/Magazyn/App.config
+++ b/Magazyn_Client/Magazyn/App.config
@@ -1,6 +1,9 @@
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Magazyn_Client/Magazyn/Magazyn.csproj b/Magazyn_Client/Magazyn/Magazyn.csproj
index d2a77ae..1a1ddbf 100644
--- a/Magazyn_Client/Magazyn/Magazyn.csproj
+++ b/Magazyn_Client/Magazyn/Magazyn.csproj
@@ -46,6 +46,7 @@
..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
+
diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml b/Magazyn_Client/Magazyn/MainWindow.xaml
index 5c211dd..be605e2 100644
--- a/Magazyn_Client/Magazyn/MainWindow.xaml
+++ b/Magazyn_Client/Magazyn/MainWindow.xaml
@@ -37,6 +37,8 @@
+
+
diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml.cs b/Magazyn_Client/Magazyn/MainWindow.xaml.cs
index 7c540c0..a158137 100644
--- a/Magazyn_Client/Magazyn/MainWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/MainWindow.xaml.cs
@@ -22,6 +22,7 @@ using System.Net;
using Magazyn.Windows;
using Magazyn.Tools;
using System.Net.NetworkInformation;
+using System.Configuration;
namespace Magazyn
{
@@ -39,9 +40,14 @@ namespace Magazyn
Size windowSize;
+ string serverUrl;
+
public MainWindow()
{
InitializeComponent();
+
+ serverUrl = ConfigurationManager.AppSettings.Get("serverUrl");
+
client = new HttpClient();
this.Loaded += MainWindowLoaded;
netConn = checkInternetConnection();
@@ -62,7 +68,7 @@ namespace Magazyn
{
string json = "{\"id\": " + fruit.Id.ToString() + ", \"change\": " + amountChanged.ToString() + " }";
- Task response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
+ Task response = client.PostAsync(serverUrl+"product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
while (response.IsCompleted != true) ;
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
@@ -92,14 +98,13 @@ namespace Magazyn
private void RefreshListOfFruits()
{
-
if (netConn)
{
pageBlock.Text = (page+1).ToString();
- Task response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.ToString());
+ Task response = client.GetAsync(serverUrl+"get-all?page=" + page.ToString() + "&size=" + size.ToString() + "&search=" + ((string.IsNullOrEmpty(searchBox.Text) || string.IsNullOrWhiteSpace(searchBox.Text)) ? "none" : searchBox.Text) );
while (response.IsCompleted != true) ;
-
+
if (response.Result.StatusCode != HttpStatusCode.OK)
{
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
@@ -107,7 +112,6 @@ namespace Magazyn
window.ShowDialog();
page = 0;
- size = 0;
return;
}
@@ -139,7 +143,7 @@ namespace Magazyn
private WarehousePrice GetWarehousePrice()
{
- Task response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
+ Task response = client.GetAsync(serverUrl+"get-price-of-all");
while (response.IsCompleted != true) ;
WarehousePrice price = JsonConvert.DeserializeObject(response.Result.Content.ReadAsStringAsync().Result.ToString());
@@ -170,7 +174,7 @@ namespace Magazyn
{
Size size = e.NewSize;
- if( Math.Abs(windowSize.Height - size.Height) >= 40 )
+ if( Math.Abs(windowSize.Height - size.Height) >= 64 )
{
//size -> number of elementy by page
this.size = (int)((size.Height - 124) / 80);
@@ -200,6 +204,12 @@ namespace Magazyn
return false;
}
}
+
+ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ page = 0;
+ RefreshListOfFruits();
+ }
}
}
diff --git a/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml b/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml
index 599811e..4a7c743 100644
--- a/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml
+++ b/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml
@@ -15,7 +15,7 @@
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">
+ Title="Błąd" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
diff --git a/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs b/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs
index fc75bc0..ffe8b53 100644
--- a/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs
@@ -29,5 +29,10 @@ namespace Magazyn.Windows
{
this.Close();
}
- }
+
+ private void Window_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Return) this.Close();
+ }
+ }
}
diff --git a/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml b/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
index a627cc5..ce465fd 100644
--- a/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
+++ b/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
@@ -15,7 +15,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Magazyn.Windows"
mc:Ignorable="d"
- Title="Informacje o: " WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize">
+ Title="Informacje o: " WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
diff --git a/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs b/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
index cb7de38..0234a90 100644
--- a/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
@@ -49,5 +49,10 @@ namespace Magazyn.Windows
{
this.Close();
}
+
+ private void Window_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Return) this.Close();
+ }
}
}
diff --git a/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml b/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml
index cb0402a..26be3a2 100644
--- a/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml
+++ b/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml
@@ -15,7 +15,7 @@
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">
+ Title="Wartość magazynu" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
diff --git a/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs b/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs
index 79c8666..d0d7483 100644
--- a/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs
+++ b/Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs
@@ -29,5 +29,10 @@ namespace Magazyn.Windows
{
this.Close();
}
- }
+
+ private void Window_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Return) this.Close();
+ }
+ }
}