1
0
forked from s434786/DINO_SCRUM

Compare commits

..

17 Commits

Author SHA1 Message Date
05ad2441ec Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-29 15:47:04 +00:00
Konrad Pierzyński
50411cbea6 Bug fix with pagination 2019-01-29 16:42:26 +01:00
ec73d5949c Merge branch 'master' of s434713/DINO_SCRUM into master 2019-01-28 23:53:59 +00:00
313540f4d8 Merge remote-tracking branch 'upstream/master' 2019-01-29 00:49:03 +01:00
f2c34d7e0f Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-28 23:30:10 +00:00
Konrad Pierzyński
8504165b13 Added small bugfix with windows [closing on enter] 2019-01-29 00:12:51 +01:00
Konrad Pierzyński
9b3344aa72 Added searching, added server address to app.config 2019-01-28 23:58:03 +01:00
Konrad Pierzyński
1be5d1f7c0 Added serverURL to config, set up box for searching 2019-01-27 21:17:23 +01:00
3afd03e84c Usunięto zmianę wielkości czcionki. Zmieniono nieznacznie ułożenie napisu i obrazka. 2019-01-27 21:16:28 +01:00
4ed58fb34a Merge branch 'master' of s434713/DINO_SCRUM into master 2019-01-27 19:11:14 +00:00
9e5a1bde5b Usuniece konfliktu 2019-01-27 19:31:58 +01:00
3c332a07ea Merge branch 'master' of s434739/DINO_SCRUM into master 2019-01-27 18:16:05 +00:00
63d9a5f3ca Zmieniono sposób numeracji stron, od teraz strona pierwsza to 1, druga to 2 itp. 2019-01-27 14:32:39 +01:00
40be2adfd7 Dodano obsługę wyjątku, który wyświetla błąd, gdy w polu dodania/odjęcia ilości owoców wpiszemy tekst zamiast liczby dodatniej. 2019-01-27 13:59:15 +01:00
ef026afe00 Wyśrodkowanie tekstu w okienku Wartość Magazynu. 2019-01-27 13:42:41 +01:00
ae474cec63 Dostosowano wielkość czcionki w okienku Wartość Magazynu, aby była tej samej wielkość co tekst w reszcie aplikacji 2019-01-27 13:32:54 +01:00
d145e46a4a Wyśrodkowanie nazwy owocu pod obrazkiem w okienku dodanie/odjęcie od ilości. 2019-01-27 13:18:38 +01:00
12 changed files with 78 additions and 38 deletions

View File

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

View File

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

View File

@ -17,13 +17,9 @@
mc:Ignorable="d"
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="435*"/>
<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"/>
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,87"/>
<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"/>
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
@ -32,11 +28,13 @@
<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"/>
<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,18" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
<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="4,0,0,14" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
<TextBlock Name="netStatus" HorizontalAlignment="Left" Margin="50,0,0,19" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,50" 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"/>
<TextBlock x:Name="pageBlock" FontSize="16" Margin="271,0,276,10" 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" />
<TextBlock Name="netStatus" HorizontalAlignment="Left" Margin="63,0,0,14" TextWrapping="Wrap" Text="error" VerticalAlignment="Bottom"/>
<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>

View File

@ -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<HttpResponseMessage> response = client.PostAsync("https://sysmag.herokuapp.com/api/product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
Task<HttpResponseMessage> response = client.PostAsync(serverUrl+"product/change-quantity", new StringContent(json, Encoding.UTF8, "application/json"));
while (response.IsCompleted != true) ;
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
@ -94,11 +100,11 @@ namespace Magazyn
{
if (netConn)
{
pageBlock.Text = page.ToString();
pageBlock.Text = (page+1).ToString();
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-all?page=" + page.ToString() + "&size=" + size.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) );
while (response.IsCompleted != true) ;
if (response.Result.StatusCode != HttpStatusCode.OK)
{
ErrorWindow window = new ErrorWindow("Nastąpił błąd połączenia z serwerem.");
@ -106,7 +112,6 @@ namespace Magazyn
window.ShowDialog();
page = 0;
size = 0;
return;
}
@ -138,7 +143,7 @@ namespace Magazyn
private WarehousePrice GetWarehousePrice()
{
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
Task<HttpResponseMessage> response = client.GetAsync(serverUrl+"get-price-of-all");
while (response.IsCompleted != true) ;
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
@ -169,10 +174,9 @@ 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);
this.size = Convert.ToInt32(fruitList.ActualHeight) / 80;
page = 0;
windowSize = size;
RefreshListOfFruits();
@ -199,6 +203,12 @@ namespace Magazyn
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">
<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"/>
<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="messageBox" HorizontalAlignment="Left" Margin="84,10,0,0" TextWrapping="Wrap" Text="messageBox" VerticalAlignment="Top" Width="121" 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"/>
<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" />
<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="15,10,0,0" VerticalAlignment="Top" Width="64"/>
</Grid>
</Window>

View File

@ -68,7 +68,20 @@ namespace Magazyn.Windows
private void SendNewQuantity()
{
int amount = int.Parse(amountToChange.Text);
int amount;
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
{
if (amount < 0)

View File

@ -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">
<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"/>

View File

@ -29,5 +29,10 @@ namespace Magazyn.Windows
{
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: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">
<Grid>
<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"/>

View File

@ -49,5 +49,10 @@ namespace Magazyn.Windows
{
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: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"/>
Title="Wartość magazynu" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
<Grid>
<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 x:Name="valueBlock" Margin="67,49,69,0" TextWrapping="Wrap" Text="NaN zł" VerticalAlignment="Top" TextAlignment="Center" RenderTransformOrigin="2.405,0.629"/>
</Grid>
</Grid>
</Window>

View File

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