forked from s434786/DINO_SCRUM
Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
05ad2441ec | |||
![]() |
50411cbea6 | ||
ec73d5949c | |||
313540f4d8 | |||
f2c34d7e0f | |||
![]() |
8504165b13 | ||
![]() |
9b3344aa72 | ||
![]() |
1be5d1f7c0 | ||
3afd03e84c | |||
4ed58fb34a | |||
9e5a1bde5b | |||
3c332a07ea | |||
3d1be2f568 | |||
63d9a5f3ca | |||
40be2adfd7 | |||
ef026afe00 | |||
ae474cec63 | |||
d145e46a4a | |||
8eb4e0d538 | |||
9240057242 | |||
![]() |
c73fd4e058 | ||
![]() |
1465eead02 | ||
2d30f25df0 | |||
![]() |
f16b345bfc | ||
71a4d4e2ae | |||
![]() |
8e3e2ccc72 | ||
![]() |
93bb0a8e08 | ||
231ee392da | |||
![]() |
d1f4178bc1 | ||
![]() |
3fbea7ec0d | ||
0a5e4d37fa | |||
![]() |
e2a0994fd2 | ||
0f835efe8c | |||
3a210d9b2b | |||
9e7aa5b697 | |||
07ceab2cb9 | |||
79cede3b6d | |||
23e1fd4ef7 | |||
701ed8a173 | |||
cbfd3f6797 | |||
![]() |
95c46a534e | ||
![]() |
c205c3d6ed | ||
![]() |
566caf5554 | ||
89d02e0c72 | |||
8c3e6889da | |||
697fea6289 | |||
2a0dfe3587 | |||
811922788a | |||
2681918135 | |||
![]() |
a6e7cd50f3 |
@ -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
|
||||
|
@ -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>
|
@ -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>
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
29
Magazyn_Client/Magazyn/Tools/CacheImage.cs
Normal file
29
Magazyn_Client/Magazyn/Tools/CacheImage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
@ -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)
|
||||
|
@ -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>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml
Normal file
23
Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml
Normal 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>
|
38
Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs
Normal file
38
Magazyn_Client/Magazyn/Windows/ErrorWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
28
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
Normal file
28
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml
Normal 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>
|
58
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
Normal file
58
Magazyn_Client/Magazyn/Windows/InfoWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
25
Magazyn_Client/Magazyn/Windows/ValueWindow.xaml
Normal file
25
Magazyn_Client/Magazyn/Windows/ValueWindow.xaml
Normal 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>
|
38
Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs
Normal file
38
Magazyn_Client/Magazyn/Windows/ValueWindow.xaml.cs
Normal 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
118
README.md
@ -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
|
||||
}
|
||||
```
|
||||
|
||||
----
|
Loading…
Reference in New Issue
Block a user