0
0
forked from s434786/DINO_SCRUM

Compare commits

..

50 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
3d1be2f568 Dodano sprawdzenie polaczenia 2019-01-27 17:28:29 +01: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
8eb4e0d538 Usuń 'README.md' 2019-01-25 16:47:46 +00:00
9240057242 Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-24 00:36:10 +00:00
Konrad Pierzyński
c73fd4e058 Added caching class to handle images 2019-01-23 23:10:44 +01:00
Konrad Pierzyński
1465eead02 Pagination optymalization, infoWindow about fruits, deleted list of themes, focusing keyboard on value input 2019-01-23 22:39:54 +01:00
2d30f25df0 Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-23 10:08:23 +00:00
Konrad Pierzyński
f16b345bfc Added + zł and names for columns 2019-01-23 11:07:24 +01:00
71a4d4e2ae Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-22 23:36:24 +00:00
Konrad Pierzyński
8e3e2ccc72 Added combo list to change theme 2019-01-23 00:33:41 +01:00
Konrad Pierzyński
93bb0a8e08 Added theme button 2019-01-23 00:13:05 +01:00
231ee392da Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-22 20:42:51 +00:00
Konrad Pierzyński
d1f4178bc1 Added Enter( return key ) handler to AmountWindow 2019-01-22 21:40:46 +01:00
Konrad Pierzyński
3fbea7ec0d Error window, error when quantityMax is touched, pagination, small bugfixs 2019-01-22 21:02:49 +01:00
0a5e4d37fa Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-22 17:16:17 +00:00
Konrad Pierzyński
e2a0994fd2 Fixed bug with loading fruits. Added easy configurable colors in App.xaml. Some small bugs with resizing windows 2019-01-22 17:35:51 +01:00
0f835efe8c Merge branch 'master' of s434739/DINO_SCRUM into master 2019-01-21 20:54:10 +00:00
3a210d9b2b Merge branch 'master' of https://git.wmi.amu.edu.pl/s434786/DINO_SCRUM 2019-01-21 21:47:48 +01:00
9e7aa5b697 Poprawa obslugi komunikatow bledu 2019-01-21 21:14:11 +01:00
07ceab2cb9 Fixed window size 2019-01-21 19:51:08 +00:00
79cede3b6d Merge branch 'master' of s434739/DINO_SCRUM into master
Jest ok. Dzięki
2019-01-21 19:50:33 +00:00
23e1fd4ef7 Zmiany po upstream 2019-01-21 19:48:10 +01:00
701ed8a173 Niedomiar, nadmiar, zmiana na polski, ustalenie max dla kazdego projektu na 2500 szt 2019-01-21 14:43:04 +01:00
cbfd3f6797 Merge branch 'master' of s442333/DINO_SCRUM into master 2019-01-17 15:30:52 +00:00
Konrad Pierzyński
95c46a534e Fixed button 'Wartosc magazynu' 2019-01-16 23:56:24 +01:00
Konrad Pierzyński
c205c3d6ed Task: 51 2019-01-16 23:24:11 +01:00
Konrad Pierzyński
566caf5554 SYSMAG: 40,45,50,54 2019-01-16 19:29:42 +01:00
89d02e0c72 Merge branch 'master' of s434713/DINO_SCRUM into master 2019-01-16 09:08:05 +00:00
8c3e6889da Deleted Fody package. 2019-01-16 02:00:30 +01:00
697fea6289 Merge branch 'master' of s434713/DINO_SCRUM into master 2019-01-16 00:27:00 +00:00
2a0dfe3587 Replaced polish word to english. 2019-01-16 00:52:00 +01:00
811922788a Zaktualizuj 'Magazyn_Client/Magazyn/MainWindow.xaml' 2019-01-15 18:09:20 +00:00
2681918135 Merge branch 'master' of s434739/DINO_SCRUM into master 2019-01-15 18:08:43 +00:00
Mateusz Lesiecki
a6e7cd50f3 Poprawki GUI 2019-01-15 17:53:09 +01:00
20 changed files with 652 additions and 257 deletions

View File

@ -13,8 +13,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Release|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{C50EC6F3-86E6-405C-991F-1B4157C04B34}.Release|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

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

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

@ -5,6 +5,7 @@ using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Magazyn
{
@ -13,5 +14,7 @@ namespace Magazyn
/// </summary>
public partial class App : Application
{
}
}

View File

@ -1,8 +1,11 @@
using System;
using Magazyn.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Magazyn.DataModels
{
@ -11,10 +14,14 @@ namespace Magazyn.DataModels
int id;
string name;
int quantity;
float price;
int quantityMax;
float price;
string imageLink;
public int Id
BitmapImage imageSource;
public int Id
{
get
{
@ -38,7 +45,16 @@ namespace Magazyn.DataModels
}
}
public float Price
public int QuantityMax
{
get
{
return quantityMax;
}
}
public float Price
{
get
{
@ -54,13 +70,26 @@ namespace Magazyn.DataModels
}
}
public Fruit(int id, string name, int quantity, float price, string imageLink)
public BitmapImage ImageSource
{
get
{
return imageSource;
}
}
public Fruit(int id, string name, int quantity, int quantityMax, float price, string imageLink)
{
this.id = id;
this.name = name;
this.quantity = quantity;
this.price = price;
this.quantityMax = quantityMax;
this.price = price;
this.imageLink = imageLink;
}
}
imageSource = CacheImage.GetImageSource(new Uri(imageLink));
}
}
}

View File

@ -13,6 +13,8 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -44,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" />
@ -65,12 +68,22 @@
</ApplicationDefinition>
<Compile Include="DataModels\Fruit.cs" />
<Compile Include="DataModels\WarehousePrice.cs" />
<Compile Include="Tools\CacheImage.cs" />
<Compile Include="Views\FruitView.xaml.cs">
<DependentUpon>FruitView.xaml</DependentUpon>
</Compile>
<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\InfoWindow.xaml.cs">
<DependentUpon>InfoWindow.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>
@ -91,6 +104,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ErrorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\InfoWindow.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">
@ -117,7 +142,9 @@
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\add.png" />

View File

@ -1,22 +1,42 @@
<Window x:Class="Magazyn.MainWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
<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="Fruit Warehouse" Height="400" Width="520">
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
<Grid>
<ListBox x:Name="fruitList" Margin="10,35,10,0" Height="239" VerticalAlignment="Top"/>
<Button Name="sum" Content="Suma" HorizontalAlignment="Left" Margin="414,0,0,46" VerticalAlignment="Bottom" Width="74" Height="35" Background="Teal" Click="Button_Click_1"/>
<TextBox Name="payment" HorizontalAlignment="Left" Margin="404,322,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="84"/>
<Label Content="Do zapłaty:" FontWeight="Bold" HorizontalAlignment="Left" Margin="328,325,0,0" VerticalAlignment="Top" Width="76"/>
<ProgressBar Name="loadingContent" HorizontalAlignment="Left" Height="10" Margin="304,294,0,0" VerticalAlignment="Top" Width="100"/>
<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"/>
<Label Content="Ilość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="283,25,0,0" VerticalAlignment="Top" Width="46"/>
<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,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>
</Window>

View File

@ -16,84 +16,199 @@ 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;
using Magazyn.Tools;
using System.Net.NetworkInformation;
using System.Configuration;
namespace Magazyn
{
public partial class MainWindow : Window
{
public partial class MainWindow : Window
{
public int size = 4;
public int page = 0;
HttpClient client;
bool firstPage;
bool lastPage;
bool netConn;
HttpClient client;
Size windowSize;
string serverUrl;
public MainWindow()
{
InitializeComponent();
serverUrl = ConfigurationManager.AppSettings.Get("serverUrl");
public MainWindow()
{
InitializeComponent();
loadingContent.IsIndeterminate = true;
client = new HttpClient();
this.Loaded += MainWindowLoaded;
netConn = checkInternetConnection();
if (netConn)
netStatus.Text = "Połączony";
else
netStatus.Text = "Rozłączony";
}
private void MainWindowLoaded(object sender, EventArgs e)
{
RefreshListOfFruits();
windowSize = new Size(this.Width, this.Height);
this.SizeChanged += Window_SizeChanged;
}
private void FruitViewSaveChangingAmountOfFruits(int amountChanged, Fruit fruit)
{
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"));
while (response.IsCompleted != true) ;
if (response.Result.StatusCode == HttpStatusCode.BadRequest)
{
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 Button_Click(object sender, RoutedEventArgs e)
{
RefreshListOfFruits();
}
private void FruitViewSaveChangingAmountOfFruits(int amountChanged, Fruit fruit)
{
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();
}
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)
private void RefreshListOfFruits()
{
if (netConn)
{
loadingContent.IsIndeterminate = false;
loadingContent.Visibility = Visibility.Hidden;
pageBlock.Text = (page+1).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.");
window.Owner = this;
window.ShowDialog();
page = 0;
return;
}
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);
}
Fruit[] fruits = JsonConvert.DeserializeObject<Fruit[]>(response.Result.Content.ReadAsStringAsync().Result.ToString());
UpdateListOfFruits(fruits);
}
private void UpdateListOfFruits(Fruit[] list)
{
fruitList.Items.Clear();
private void UpdateListOfFruits(Fruit[] list)
{
fruitList.Items.Clear();
foreach (Fruit item in list)
{
FruitView fruitView = new FruitView(item);
fruitView.SaveChangingAmountOfFruits += FruitViewSaveChangingAmountOfFruits;
fruitList.Items.Add(fruitView);
}
}
foreach (Fruit item in list)
{
FruitView fruitView = new FruitView(item);
fruitView.SaveChangingAmountOfFruits += FruitViewSaveChangingAmountOfFruits;
fruitList.Items.Add(fruitView);
}
}
private WarehousePrice GetWarehousePrice()
{
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
while (response.IsCompleted != true) ;
private WarehousePrice GetWarehousePrice()
{
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());
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
return price;
}
return price;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
payment.Text = GetWarehousePrice().Price.ToString();
//MessageBox.Show("Value of warehouse: " + GetWarehousePrice().Price.ToString() );
}
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();
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size size = e.NewSize;
if( Math.Abs(windowSize.Height - size.Height) >= 64 )
{
this.size = Convert.ToInt32(fruitList.ActualHeight) / 80;
page = 0;
windowSize = size;
RefreshListOfFruits();
}
}
private void fruitListMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (fruitList.SelectedItem != null)
{
InfoWindow window = new InfoWindow((fruitList.SelectedItem as FruitView).fruit);
window.Owner = this;
window.ShowDialog();
}
}
private Boolean checkInternetConnection()
{
try
{
return new Ping().Send("www.google.com").Status == IPStatus.Success;
} catch
{
return false;
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
page = 0;
RefreshListOfFruits();
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace Magazyn.Tools
{
class CacheImage
{
static Dictionary<Uri, BitmapImage> dic = new Dictionary<Uri, BitmapImage>();
static public BitmapImage GetImageSource( Uri url )
{
if (dic.Keys.Contains<Uri>(url)) return dic[url];
else
{
BitmapImage imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.UriSource = url;
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.EndInit();
dic.Add(url, imageSource);
return imageSource;
}
}
}
}

View File

@ -9,14 +9,14 @@
mc:Ignorable="d" Height="64" Width="520">
<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="80,26,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="116"/>
<Image Name="minusImage" HorizontalAlignment="Left" Height="24" Margin="238,25,0,0" VerticalAlignment="Top" Width="24" Source="/Images/minus.png" MouseDown="subButton_Click" />
<Image Name="plusImage" HorizontalAlignment="Left" Height="24" Margin="306,26,0,0" VerticalAlignment="Top" Width="24" Source="/Magazyn;component/Images/plus.png" RenderTransformOrigin="0.208,0.521" MouseDown="addButton_Click"/>
<TextBox Name="fruitAmount" HorizontalAlignment="Left" Height="35" Margin="267,14,0,0" VerticalAlignment="Top" Width="34" TextAlignment="Center"/>
<TextBlock Name="fruitPrice" Margin="362,26,106,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" IsEnabled="False"/>
<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="116"/>
<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="362,26,106,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" IsEnabled="False"/>
<TextBlock x:Name="allPrice" Margin="425,26,43,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
</Grid>

View File

@ -24,7 +24,7 @@ namespace Magazyn.Views
/// </summary>
public partial class FruitView : UserControl
{
Fruit fruit;
public Fruit fruit;
public delegate void ChangingAmountOfFruits(int amountChanged, Fruit fruit);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
@ -37,31 +37,26 @@ namespace Magazyn.Views
fruitName.Text = fruit.Name;
fruitAmount.Text = fruit.Quantity.ToString();
fruitPrice.Text = fruit.Price.ToString();
allPrice.Text = (fruit.Quantity * fruit.Price).ToString();
fruitPrice.Text = fruit.Price.ToString() + "zł";
allPrice.Text = (fruit.Quantity * fruit.Price).ToString() + "zł";
try
{
fruitImage.Source = new BitmapImage(new Uri(fruit.ImageLink));
}
fruitImage.Source = fruit.ImageSource;
}
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);
AmountWindow window = new AmountWindow(fruit, ((sender as Image).Name == "minusImage")?-1:1, fruit.Quantity);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.Show();
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
AmountWindow window = new AmountWindow(fruit, 1);
window.SaveChangingAmountOfFruits += WindowSaveChangingAmountOfFruits;
window.Show();
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
}
private void WindowSaveChangingAmountOfFruits(int amountChanged)

View File

@ -1,15 +1,29 @@
<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="100" Width="280">
Title="" WindowStartupLocation="CenterOwner" Height="205" Width="220" ResizeMode="NoResize" Keyboard.KeyDown="Window_KeyDown">
<Grid>
<TextBlock x:Name="fruitName" HorizontalAlignment="Left" Margin="10,36,0,0" TextWrapping="Wrap" Text="fruitName" VerticalAlignment="Top" Width="64"/>
<TextBox x:Name="amountToChange" HorizontalAlignment="Left" Margin="74,0,0,10" TextWrapping="Wrap" Text="0" Width="64" Height="32" VerticalAlignment="Bottom" RenderTransformOrigin="1.456,0.316"/>
<Button x:Name="saveButton" Content="Save" Margin="175,0,10,10" VerticalAlignment="Bottom" Click="saveButton_Click" />
<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="15,10,0,0" VerticalAlignment="Top" Width="64"/>
</Grid>
</Window>

View File

@ -15,39 +15,107 @@ using System.Windows.Shapes;
namespace Magazyn.Windows
{
/// <summary>
/// Interaction logic for AmountWindow.xaml
/// </summary>
public partial class AmountWindow : Window
{
Fruit fruit;
int type;
/// <summary>
/// Interaction logic for AmountWindow.xaml
/// </summary>
///
public delegate void ChangingAmountOfFruits(int amountChanged);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
public partial class AmountWindow : Window
{
Fruit fruit;
int type;
int quantity;
public AmountWindow(Fruit fruit, int type)
{
InitializeComponent();
this.fruit = fruit;
this.type = type;
public delegate void ChangingAmountOfFruits(int amountChanged);
public event ChangingAmountOfFruits SaveChangingAmountOfFruits;
fruitName.Text = fruit.Name;
}
bool focusLock = false;
private void saveButton_Click(object sender, RoutedEventArgs e)
{
int amount = 0;
public AmountWindow(Fruit fruit, int type, int quantity)
{
InitializeComponent();
this.fruit = fruit;
this.type = type;
try
{
amount = int.Parse(amountToChange.Text);
} catch (Exception ex) {
throw new NotImplementedException(ex.Message);
}
this.quantity = quantity;
SaveChangingAmountOfFruits.Invoke((type>0)?amount:-amount);
this.Close();
}
}
if (type == -1)
this.Title = "Zmniejsz ilość: " + fruit.Name;
else
this.Title = "Zwiększ ilość: " + fruit.Name;
fruitName.Text = fruit.Name;
messageBox.Text = String.Format("Jaką ilość produktu chcesz {0} do magazynu?", (type > 0) ? "dodać" : "odjąć");
try
{
fruitImage.Source = fruit.ImageSource;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
this.Loaded += AmountWindowLoaded;
}
private void AmountWindowLoaded(object sender, RoutedEventArgs e)
{
amountToChange.Focus();
}
private void SendNewQuantity()
{
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)
{
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)
{
throw new NotImplementedException(ex.Message);
}
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" 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"/>
</Grid>
</Window>

View File

@ -0,0 +1,38 @@
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();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) this.Close();
}
}
}

View File

@ -0,0 +1,28 @@
<Window x:Class="Magazyn.Windows.InfoWindow"
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="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"/>
<TextBlock x:Name="fruitQuantity" Margin="79,52,10,0" TextWrapping="Wrap" Text="fruitQuantity" Height="16" VerticalAlignment="Top"/>
<TextBlock x:Name="fruitQuantityMax" Margin="79,73,10,0" TextWrapping="Wrap" Text="fruitQuantityMax" Height="16" VerticalAlignment="Top"/>
<TextBlock x:Name="fruitValue" Margin="79,94,10,0" TextWrapping="Wrap" Text="fruitValue" Height="16" VerticalAlignment="Top"/>
<Button x:Name="okButton" Content="Ok" Margin="0,0,9,10" VerticalAlignment="Bottom" Click="okButton_Click" Width="75" HorizontalAlignment="Right"/>
<Image x:Name="fruitImage" HorizontalAlignment="Left" Height="64" Margin="10,10,0,0" VerticalAlignment="Top" Width="64"/>
</Grid>
</Window>

View File

@ -0,0 +1,58 @@
using Magazyn.DataModels;
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 InfoWindow.xaml
/// </summary>
public partial class InfoWindow : Window
{
Fruit fruit;
public InfoWindow(Fruit fruit)
{
InitializeComponent();
this.fruit = fruit;
fruitName.Text = "Owoc: " + fruit.Name;
this.Title = this.Title + fruit.Name;
fruitPrice.Text = "Cena: " + fruit.Price.ToString() + "zł";
fruitQuantity.Text = "Ilość: " + fruit.Quantity.ToString();
fruitQuantityMax.Text = "Ilość maks: " + fruit.QuantityMax.ToString();
fruitValue.Text = "Wartość: " + (fruit.Price * fruit.Quantity).ToString() + "zł";
try
{
fruitImage.Source = fruit.ImageSource;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) 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" 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>
</Window>

View File

@ -0,0 +1,38 @@
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();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return) this.Close();
}
}
}

118
README.md
View File

@ -1,118 +0,0 @@
# DINO_SCRUM
DINO_SCRUM
## API Endpoints
*POST* **/api/product/change-quantity**
```json
{
"id": Int,
"change": Int
}
```
Return:
```json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"imageLink": String
}
```
This endpoint return editet product.
---
*GET* **/api/get-all**
Return:
```
{
[
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"imageLink": String
},
{...}
]
}
```
---
*GET* **/api/get-price-of-all**
Return:
```json
{
"price-of-all": Float
}
```
---
*POST* **/api/product/add**
```json
{
"name": String,
"price": Float,
"quantity": Int,
"imageLing": String
}
```
Return:
```json
{
    "id": Int,
    "name": String,
    "price": Float,
    "quantity": Int,
    "imageLink": String
}
```
This endpoint return a newly created product.
---
*DELETE* **/api/delete-product**
```json
{
"id": Int
}
```
This endpoint doesn't return any data.
---
*GET* **/api/product/get-by-id**
Return:
```json
{
    "id": Int,
    "name": String,
    "price": Float,
    "quantity": Int,
    "imageLink": String
}
```
----