Completed Exercise 1 and added Exercise 2

This commit is contained in:
Matteo Pagani 2019-01-11 19:33:43 +01:00
Родитель 35ce6d2652
Коммит 719098f986
118 изменённых файлов: 4717 добавлений и 5 удалений

Просмотреть файл

@ -21,7 +21,7 @@
Loaded="Window_Loaded"
xmlns:local="clr-namespace:ContosoExpenses"
mc:Ignorable="d"
Title="Expense Detail" Height="500" Width="600"
Title="Expense Detail" Height="500" Width="800"
Background="{StaticResource HorizontalBackground}">
<Grid Margin="12">

Просмотреть файл

@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContosoExpenses", "ContosoExpenses\ContosoExpenses.csproj", "{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.Build.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.ActiveCfg = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.Build.0 = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.Deploy.0 = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.ActiveCfg = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.Build.0 = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.Deploy.0 = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.Build.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.Deploy.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.ActiveCfg = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.Build.0 = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.Deploy.0 = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.ActiveCfg = Release|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.Build.0 = Release|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3BADFBD9-C57F-40A7-B058-D6B067196030}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,35 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AboutView"
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"
mc:Ignorable="d" MinHeight="500" MinWidth="700" Height="500" Width="700">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" Margin="10">
Contoso Expenses is a 'modern application of yesterday tomorrow' from Contoso Corp.
</TextBlock>
<WebBrowser Grid.Row="1"
Source="https://contosocorpwebsite.azurewebsites.net/" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,27 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Linq;
using System.Linq.Expressions;
namespace ContosoExpenses
{
public partial class AboutView
{
public AboutView()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AddNewExpense"
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:ContosoExpenses"
mc:Ignorable="d"
Title="Add new expense" Height="450" Width="800"
Background="{StaticResource AddNewExpenseBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="24" Text="Add new expense" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" Grid.Row="1" Grid.Column="0" />
<TextBox x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="1" Grid.Column="1" />
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" Grid.Row="2" Grid.Column="0" />
<TextBox x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" Width="400" Height="200" AcceptsReturn="True" Grid.Row="2" Grid.Column="1" />
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" Grid.Row="3" Grid.Column="0" />
<TextBox x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="3" Grid.Column="1" />
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" Grid.Row="4" Grid.Column="0" />
<TextBox x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="4" Grid.Column="1" />
<TextBlock Text="City:" FontSize="16" FontWeight="Bold" Grid.Row="5" Grid.Column="0" />
<TextBox x:Name="txtCity" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="5" Grid.Column="1" />
<TextBlock Text="Date:" FontSize="16" FontWeight="Bold" Grid.Row="6" Grid.Column="0" />
<DatePicker x:Name="txtDate" Grid.Row="6" Grid.Column="1" Margin="5, 0, 0, 0" Width="400" />
<Button Content="Save" Grid.Row="7" Grid.Column="0" Click="OnSaveExpense" Margin="5, 12, 0, 0" HorizontalAlignment="Left" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,59 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using ContosoExpenses.Models;
using ContosoExpenses.Services;
using System;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for AddNewExpense.xaml
/// </summary>
public partial class AddNewExpense : Window
{
public int EmployeeId { get; set; }
public AddNewExpense()
{
InitializeComponent();
}
private void OnSaveExpense(object sender, RoutedEventArgs e)
{
try
{
Expense expense = new Expense
{
Address = txtAmount.Text,
City = txtCity.Text,
Cost = Convert.ToDouble(txtAmount.Text),
Description = txtDescription.Text,
Type = txtType.Text,
Date = txtDate.SelectedDate.GetValueOrDefault(),
EmployeeId = EmployeeId
};
DatabaseService service = new DatabaseService();
service.SaveExpense(expense);
this.Close();
}
catch (Exception exc)
{
MessageBox.Show("Validation error. Please check your data.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Просмотреть файл

@ -0,0 +1,55 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Application x:Class="ContosoExpenses.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ContosoExpenses"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!--Background images-->
<ImageBrush x:Key="MainBackground"
ImageSource="Images\ExpensesBackground.jpg"
Stretch="UniformToFill" />
<ImageBrush x:Key="HorizontalBackground"
ImageSource="Images\HorizontalBackground.png"
Stretch="UniformToFill" />
<ImageBrush x:Key="ExpensesListBackground"
ImageSource="Images\ExpensesListBackground.png"
Stretch="Fill" />
<ImageBrush x:Key="AddNewExpenseBackground"
ImageSource="Images\AddNewExpense.png"
Stretch="UniformToFill" />
<!--Styles for DataGrid-->
<Style x:Key="DataGridHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Foreground" Value="Black" />
</Style>
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Cursor" Value="Hand" />
</Style>
<SolidColorBrush x:Key="SemiTransparentBackground"
Color="#0073CF"
Opacity=".6" />
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ContosoExpenses</RootNamespace>
<AssemblyName>ContosoExpenses</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Images\contoso.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Bogus, Version=25.0.3.0, Culture=neutral, PublicKeyToken=fa1bb3f3f218129a, processorArchitecture=MSIL">
<HintPath>..\packages\Bogus.25.0.3\lib\net40\Bogus.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.4.1.4\lib\net40\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.Controls, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.Controls.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.XamlHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.XamlHost.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.XamlHost.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddNewExpense.xaml.cs">
<DependentUpon>AddNewExpense.xaml</DependentUpon>
</Compile>
<Compile Include="ExpensesList.xaml.cs">
<DependentUpon>ExpensesList.xaml</DependentUpon>
</Compile>
<Compile Include="Services\DatabaseService.cs" />
<Page Include="AboutView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="AddNewExpense.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpenseDetail.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpensesList.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpenseDetail.xaml.cs">
<DependentUpon>ExpenseDetail.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Employee.cs" />
<Compile Include="Models\Expense.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\contoso.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\HorizontalBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\AddNewExpense.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesBackground.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesListBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,146 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpenseDetail"
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:toolkit="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
Loaded="Window_Loaded"
Closed="Window_Closed"
xmlns:local="clr-namespace:ContosoExpenses"
mc:Ignorable="d"
Title="Expense Detail" Height="500" Width="800"
Background="{StaticResource HorizontalBackground}">
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Expense detail -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expense" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4">
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<toolkit:MapControl Grid.Row="5" x:Name="ExpenseMap" />
<TextBlock Text="Signature:" FontSize="16" FontWeight="Bold" Grid.Row="6" />
<toolkit:InkCanvas x:Name="Signature" Grid.Row="7" />
</Grid>
<!-- Chart -->
<DockPanel Grid.Column="1" VerticalAlignment="Bottom" Margin="20,0,0,0" MinHeight="420">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="Chart" Width="50" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#4E87D4" Offset="0" />
<GradientStop Color="#73B2F5" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFFFFF" Offset="0" />
<GradientStop Color="#4E87D4" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Grid Grid.Column="1" Width="20" Height="400" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
<TextBlock Grid.Column="2" Text="1000$ limit" Margin="0,20,0,0"></TextBlock>
</DockPanel>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,51 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Linq;
using System.Windows;
using ContosoExpenses.Models;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpenseDetail.xaml
/// </summary>
public partial class ExpenseDetail : Window
{
public Expense SelectedExpense { get; set; }
public ExpenseDetail()
{
InitializeComponent();
Signature.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
txtType.Text = SelectedExpense.Type;
txtDescription.Text = SelectedExpense.Description;
txtLocation.Text = SelectedExpense.Address;
txtAmount.Text = SelectedExpense.Cost.ToString();
Chart.Height = (SelectedExpense.Cost * 400) / 1000;
}
private void Window_Closed(object sender, EventArgs e)
{
Signature.Dispose();
ExpenseMap.Dispose();
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpensesList"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Activated="Window_Activated"
Title="Expenses List" Height="450" Width="800"
Background="{StaticResource ExpensesListBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expenses List" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Employee Id:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmployeeId" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Full name:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtFullName" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="E-mail:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmail" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<DataGrid x:Name="ExpensesGrid"
Grid.Row="4"
SelectionChanged="OnSelectedExpense"
AutoGenerateColumns="False"
IsReadOnly="True"
Margin="0, 12, 0, 0"
SelectionMode="Single"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Date" Binding="{Binding Path=Date}" />
<DataGridTextColumn Header="Type" Binding="{Binding Path=Type}" />
<DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" />
<DataGridTextColumn Header="Cost" Binding="{Binding Path=Cost}" />
<DataGridTextColumn Header="City" Binding="{Binding Path=City}" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Add new expense" Click="OnAddNewExpense" Grid.Row="5" HorizontalAlignment="Left" Margin="0, 12, 0, 0" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,89 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
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;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpensesList.xaml
/// </summary>
public partial class ExpensesList : Window
{
public int EmployeeId { get; set; }
private Employee selectedEmployee;
public ExpensesList()
{
InitializeComponent();
}
private void OnSelectedExpense(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var expense = e.AddedItems[0] as Expense;
if (expense != null && expense.ExpenseId != 0)
{
ExpenseDetail detail = new ExpenseDetail();
detail.SelectedExpense = expense;
detail.ShowDialog();
}
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DatabaseService databaseService = new DatabaseService();
selectedEmployee = databaseService.GetEmployee(EmployeeId);
txtEmployeeId.Text = selectedEmployee.EmployeeId.ToString();
txtFullName.Text = $"{selectedEmployee.FirstName} {selectedEmployee.LastName}";
txtEmail.Text = selectedEmployee.Email;
}
private void OnAddNewExpense(object sender, RoutedEventArgs e)
{
AddNewExpense newExpense = new AddNewExpense();
newExpense.EmployeeId = EmployeeId;
newExpense.ShowDialog();
}
public void LoadData()
{
DatabaseService databaseService = new DatabaseService();
ExpensesGrid.ItemsSource = databaseService.GetExpenses(EmployeeId);
}
private void Window_Activated(object sender, EventArgs e)
{
LoadData();
}
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 320 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 65 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 27 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 133 KiB

Просмотреть файл

@ -0,0 +1,57 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.MainWindow"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="Contoso Expenses" Height="450" Width="800"
Background="{StaticResource MainBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu IsMainMenu="True" Grid.Row="0">
<MenuItem Header="_About" FontSize="12" Click="OnOpenAbout" />
</Menu>
<DataGrid x:Name="CustomersGrid"
Grid.Row="1"
SelectionChanged="OnSelectedEmployee"
AutoGenerateColumns="False"
SelectionMode="Single"
IsReadOnly="True"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Employee Id" Binding="{Binding Path=EmployeeId}" />
<DataGridTextColumn Header="Name" Binding="{Binding Path=FirstName}" />
<DataGridTextColumn Header="Surname" Binding="{Binding Path=LastName}" />
<DataGridTextColumn Header="E-mail" Binding="{Binding Path=Email}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,67 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LoadData();
}
private void LoadData()
{
List<Employee> customers = new List<Employee>();
DatabaseService db = new DatabaseService();
db.InitializeDatabase();
CustomersGrid.ItemsSource = db.GetEmployees();
}
private void OnSelectedEmployee(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var employee = e.AddedItems[0] as Employee;
if (employee != null && employee.EmployeeId != 0)
{
ExpensesList detail = new ExpensesList();
detail.EmployeeId = employee.EmployeeId;
detail.Show();
}
}
}
private void OnOpenAbout(object sender, RoutedEventArgs e)
{
AboutView about = new AboutView();
about.ShowDialog();
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@

namespace ContosoExpenses.Models
{
public class Employee
{
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using System;
namespace ContosoExpenses.Models
{
public class Expense
{
public int ExpenseId { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public double Cost { get; set; }
public string Address { get; set; }
public string City { get; set; }
public DateTime Date { get; set; }
public int EmployeeId { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XamlIslandDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XamlIslandDemo")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ContosoExpenses.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Bogus;
using LiteDB;
using ContosoExpenses.Models;
namespace ContosoExpenses.Services
{
public class DatabaseService
{
readonly int numberOfEmployees = 10;
readonly int numberOfExpenses = 5;
string filePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\data.db";
string directoryPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\";
public Employee GetEmployee(int employeeId)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindById(employeeId);
}
}
public List<Employee> GetEmployees()
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindAll().ToList();
}
}
public List<Expense> GetExpenses(int employeedId)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
return expenses.Find(x => x.EmployeeId == employeedId).ToList();
}
}
public void SaveExpense(Expense expense)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
expenses.Insert(expense);
}
}
public void InitializeDatabase()
{
if (!File.Exists(filePath))
{
Directory.CreateDirectory(directoryPath);
}
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
int result = employees.Count();
if (result == 0)
{
GenerateFakeData(numberOfEmployees, numberOfExpenses);
}
}
}
private void GenerateFakeData(int numberOfEmployees, int numberOfExpenses)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
for (int cont = 0; cont < numberOfEmployees; cont++)
{
var employee = new Faker<Employee>()
.RuleFor(x => x.FirstName, (f, u) => f.Name.FirstName())
.RuleFor(x => x.LastName, (f, u) => f.Name.LastName())
.RuleFor(x => x.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName, "contoso.com"))
.Generate();
int employeeId = employees.Insert(employee).AsInt32;
for (int contExpenses = 0; contExpenses < numberOfExpenses; contExpenses++)
{
var expense = new Faker<Expense>()
.RuleFor(x => x.Description, (f, u) => f.Commerce.ProductName())
.RuleFor(x => x.Type, (f, u) => f.Finance.TransactionType())
.RuleFor(x => x.Cost, (f, u) => (double)f.Finance.Amount())
.RuleFor(x => x.Address, (f, u) => f.Address.FullAddress())
.RuleFor(x => x.City, (f, u) => f.Address.City())
.RuleFor(x => x.Date, (f, u) => f.Date.Past())
.Generate();
expense.EmployeeId = employeeId;
expenses.Insert(expense);
}
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bogus" version="25.0.3" targetFramework="net472" />
<package id="LiteDB" version="4.1.4" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.Controls" version="5.0.1" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.XamlHost" version="5.0.1" targetFramework="net472" />
</packages>

Просмотреть файл

@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContosoExpenses", "ContosoExpenses\ContosoExpenses.csproj", "{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.Build.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.ActiveCfg = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.Build.0 = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x64.Deploy.0 = Debug|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.ActiveCfg = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.Build.0 = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Debug|x86.Deploy.0 = Debug|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.Build.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|Any CPU.Deploy.0 = Release|Any CPU
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.ActiveCfg = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.Build.0 = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x64.Deploy.0 = Release|x64
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.ActiveCfg = Release|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.Build.0 = Release|x86
{F0388F05-ADDF-498A-B87F-62C88AA49022}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3BADFBD9-C57F-40A7-B058-D6B067196030}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,35 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AboutView"
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"
mc:Ignorable="d" MinHeight="500" MinWidth="700" Height="500" Width="700">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" Margin="10">
Contoso Expenses is a 'modern application of yesterday tomorrow' from Contoso Corp.
</TextBlock>
<WebBrowser Grid.Row="1"
Source="https://contosocorpwebsite.azurewebsites.net/" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,27 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Linq;
using System.Linq.Expressions;
namespace ContosoExpenses
{
public partial class AboutView
{
public AboutView()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AddNewExpense"
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:ContosoExpenses"
mc:Ignorable="d"
Title="Add new expense" Height="450" Width="800"
Background="{StaticResource AddNewExpenseBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="24" Text="Add new expense" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" Grid.Row="1" Grid.Column="0" />
<TextBox x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="1" Grid.Column="1" />
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" Grid.Row="2" Grid.Column="0" />
<TextBox x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" Width="400" Height="200" AcceptsReturn="True" Grid.Row="2" Grid.Column="1" />
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" Grid.Row="3" Grid.Column="0" />
<TextBox x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="3" Grid.Column="1" />
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" Grid.Row="4" Grid.Column="0" />
<TextBox x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="4" Grid.Column="1" />
<TextBlock Text="City:" FontSize="16" FontWeight="Bold" Grid.Row="5" Grid.Column="0" />
<TextBox x:Name="txtCity" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="5" Grid.Column="1" />
<TextBlock Text="Date:" FontSize="16" FontWeight="Bold" Grid.Row="6" Grid.Column="0" />
<DatePicker x:Name="txtDate" Grid.Row="6" Grid.Column="1" Margin="5, 0, 0, 0" Width="400" />
<Button Content="Save" Grid.Row="7" Grid.Column="0" Click="OnSaveExpense" Margin="5, 12, 0, 0" HorizontalAlignment="Left" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,59 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using ContosoExpenses.Models;
using ContosoExpenses.Services;
using System;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for AddNewExpense.xaml
/// </summary>
public partial class AddNewExpense : Window
{
public int EmployeeId { get; set; }
public AddNewExpense()
{
InitializeComponent();
}
private void OnSaveExpense(object sender, RoutedEventArgs e)
{
try
{
Expense expense = new Expense
{
Address = txtAmount.Text,
City = txtCity.Text,
Cost = Convert.ToDouble(txtAmount.Text),
Description = txtDescription.Text,
Type = txtType.Text,
Date = txtDate.SelectedDate.GetValueOrDefault(),
EmployeeId = EmployeeId
};
DatabaseService service = new DatabaseService();
service.SaveExpense(expense);
this.Close();
}
catch (Exception exc)
{
MessageBox.Show("Validation error. Please check your data.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Просмотреть файл

@ -0,0 +1,55 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Application x:Class="ContosoExpenses.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ContosoExpenses"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!--Background images-->
<ImageBrush x:Key="MainBackground"
ImageSource="Images\ExpensesBackground.jpg"
Stretch="UniformToFill" />
<ImageBrush x:Key="HorizontalBackground"
ImageSource="Images\HorizontalBackground.png"
Stretch="UniformToFill" />
<ImageBrush x:Key="ExpensesListBackground"
ImageSource="Images\ExpensesListBackground.png"
Stretch="Fill" />
<ImageBrush x:Key="AddNewExpenseBackground"
ImageSource="Images\AddNewExpense.png"
Stretch="UniformToFill" />
<!--Styles for DataGrid-->
<Style x:Key="DataGridHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Foreground" Value="Black" />
</Style>
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Cursor" Value="Hand" />
</Style>
<SolidColorBrush x:Key="SemiTransparentBackground"
Color="#0073CF"
Opacity=".6" />
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ContosoExpenses</RootNamespace>
<AssemblyName>ContosoExpenses</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Images\contoso.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Bogus, Version=25.0.3.0, Culture=neutral, PublicKeyToken=fa1bb3f3f218129a, processorArchitecture=MSIL">
<HintPath>..\packages\Bogus.25.0.3\lib\net40\Bogus.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.4.1.4\lib\net40\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.Controls, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.Controls.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.XamlHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.XamlHost.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.XamlHost.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddNewExpense.xaml.cs">
<DependentUpon>AddNewExpense.xaml</DependentUpon>
</Compile>
<Compile Include="ExpensesList.xaml.cs">
<DependentUpon>ExpensesList.xaml</DependentUpon>
</Compile>
<Compile Include="Services\DatabaseService.cs" />
<Page Include="AboutView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="AddNewExpense.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpenseDetail.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpensesList.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpenseDetail.xaml.cs">
<DependentUpon>ExpenseDetail.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Employee.cs" />
<Compile Include="Models\Expense.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\contoso.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\HorizontalBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\AddNewExpense.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesBackground.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesListBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,146 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpenseDetail"
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:toolkit="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
Loaded="Window_Loaded"
Closed="Window_Closed"
xmlns:local="clr-namespace:ContosoExpenses"
mc:Ignorable="d"
Title="Expense Detail" Height="500" Width="800"
Background="{StaticResource HorizontalBackground}">
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Expense detail -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expense" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4">
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<toolkit:MapControl Grid.Row="5" x:Name="ExpenseMap" />
<TextBlock Text="Signature:" FontSize="16" FontWeight="Bold" Grid.Row="6" />
<toolkit:InkCanvas x:Name="Signature" Grid.Row="7" />
</Grid>
<!-- Chart -->
<DockPanel Grid.Column="1" VerticalAlignment="Bottom" Margin="20,0,0,0" MinHeight="420">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="Chart" Width="50" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#4E87D4" Offset="0" />
<GradientStop Color="#73B2F5" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFFFFF" Offset="0" />
<GradientStop Color="#4E87D4" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Grid Grid.Column="1" Width="20" Height="400" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
<TextBlock Grid.Column="2" Text="1000$ limit" Margin="0,20,0,0"></TextBlock>
</DockPanel>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,51 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Linq;
using System.Windows;
using ContosoExpenses.Models;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpenseDetail.xaml
/// </summary>
public partial class ExpenseDetail : Window
{
public Expense SelectedExpense { get; set; }
public ExpenseDetail()
{
InitializeComponent();
Signature.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
txtType.Text = SelectedExpense.Type;
txtDescription.Text = SelectedExpense.Description;
txtLocation.Text = SelectedExpense.Address;
txtAmount.Text = SelectedExpense.Cost.ToString();
Chart.Height = (SelectedExpense.Cost * 400) / 1000;
}
private void Window_Closed(object sender, EventArgs e)
{
Signature.Dispose();
ExpenseMap.Dispose();
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpensesList"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Activated="Window_Activated"
Title="Expenses List" Height="450" Width="800"
Background="{StaticResource ExpensesListBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expenses List" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Employee Id:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmployeeId" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Full name:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtFullName" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="E-mail:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmail" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<DataGrid x:Name="ExpensesGrid"
Grid.Row="4"
SelectionChanged="OnSelectedExpense"
AutoGenerateColumns="False"
IsReadOnly="True"
Margin="0, 12, 0, 0"
SelectionMode="Single"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Date" Binding="{Binding Path=Date}" />
<DataGridTextColumn Header="Type" Binding="{Binding Path=Type}" />
<DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" />
<DataGridTextColumn Header="Cost" Binding="{Binding Path=Cost}" />
<DataGridTextColumn Header="City" Binding="{Binding Path=City}" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Add new expense" Click="OnAddNewExpense" Grid.Row="5" HorizontalAlignment="Left" Margin="0, 12, 0, 0" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,89 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
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;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpensesList.xaml
/// </summary>
public partial class ExpensesList : Window
{
public int EmployeeId { get; set; }
private Employee selectedEmployee;
public ExpensesList()
{
InitializeComponent();
}
private void OnSelectedExpense(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var expense = e.AddedItems[0] as Expense;
if (expense != null && expense.ExpenseId != 0)
{
ExpenseDetail detail = new ExpenseDetail();
detail.SelectedExpense = expense;
detail.ShowDialog();
}
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DatabaseService databaseService = new DatabaseService();
selectedEmployee = databaseService.GetEmployee(EmployeeId);
txtEmployeeId.Text = selectedEmployee.EmployeeId.ToString();
txtFullName.Text = $"{selectedEmployee.FirstName} {selectedEmployee.LastName}";
txtEmail.Text = selectedEmployee.Email;
}
private void OnAddNewExpense(object sender, RoutedEventArgs e)
{
AddNewExpense newExpense = new AddNewExpense();
newExpense.EmployeeId = EmployeeId;
newExpense.ShowDialog();
}
public void LoadData()
{
DatabaseService databaseService = new DatabaseService();
ExpensesGrid.ItemsSource = databaseService.GetExpenses(EmployeeId);
}
private void Window_Activated(object sender, EventArgs e)
{
LoadData();
}
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 320 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 65 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 27 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 133 KiB

Просмотреть файл

@ -0,0 +1,57 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.MainWindow"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="Contoso Expenses" Height="450" Width="800"
Background="{StaticResource MainBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu IsMainMenu="True" Grid.Row="0">
<MenuItem Header="_About" FontSize="12" Click="OnOpenAbout" />
</Menu>
<DataGrid x:Name="CustomersGrid"
Grid.Row="1"
SelectionChanged="OnSelectedEmployee"
AutoGenerateColumns="False"
SelectionMode="Single"
IsReadOnly="True"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Employee Id" Binding="{Binding Path=EmployeeId}" />
<DataGridTextColumn Header="Name" Binding="{Binding Path=FirstName}" />
<DataGridTextColumn Header="Surname" Binding="{Binding Path=LastName}" />
<DataGridTextColumn Header="E-mail" Binding="{Binding Path=Email}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,67 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LoadData();
}
private void LoadData()
{
List<Employee> customers = new List<Employee>();
DatabaseService db = new DatabaseService();
db.InitializeDatabase();
CustomersGrid.ItemsSource = db.GetEmployees();
}
private void OnSelectedEmployee(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var employee = e.AddedItems[0] as Employee;
if (employee != null && employee.EmployeeId != 0)
{
ExpensesList detail = new ExpensesList();
detail.EmployeeId = employee.EmployeeId;
detail.Show();
}
}
}
private void OnOpenAbout(object sender, RoutedEventArgs e)
{
AboutView about = new AboutView();
about.ShowDialog();
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@

namespace ContosoExpenses.Models
{
public class Employee
{
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using System;
namespace ContosoExpenses.Models
{
public class Expense
{
public int ExpenseId { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public double Cost { get; set; }
public string Address { get; set; }
public string City { get; set; }
public DateTime Date { get; set; }
public int EmployeeId { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XamlIslandDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XamlIslandDemo")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ContosoExpenses.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Bogus;
using LiteDB;
using ContosoExpenses.Models;
namespace ContosoExpenses.Services
{
public class DatabaseService
{
readonly int numberOfEmployees = 10;
readonly int numberOfExpenses = 5;
string filePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\data.db";
string directoryPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\";
public Employee GetEmployee(int employeeId)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindById(employeeId);
}
}
public List<Employee> GetEmployees()
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindAll().ToList();
}
}
public List<Expense> GetExpenses(int employeedId)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
return expenses.Find(x => x.EmployeeId == employeedId).ToList();
}
}
public void SaveExpense(Expense expense)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
expenses.Insert(expense);
}
}
public void InitializeDatabase()
{
if (!File.Exists(filePath))
{
Directory.CreateDirectory(directoryPath);
}
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
int result = employees.Count();
if (result == 0)
{
GenerateFakeData(numberOfEmployees, numberOfExpenses);
}
}
}
private void GenerateFakeData(int numberOfEmployees, int numberOfExpenses)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
for (int cont = 0; cont < numberOfEmployees; cont++)
{
var employee = new Faker<Employee>()
.RuleFor(x => x.FirstName, (f, u) => f.Name.FirstName())
.RuleFor(x => x.LastName, (f, u) => f.Name.LastName())
.RuleFor(x => x.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName, "contoso.com"))
.Generate();
int employeeId = employees.Insert(employee).AsInt32;
for (int contExpenses = 0; contExpenses < numberOfExpenses; contExpenses++)
{
var expense = new Faker<Expense>()
.RuleFor(x => x.Description, (f, u) => f.Commerce.ProductName())
.RuleFor(x => x.Type, (f, u) => f.Finance.TransactionType())
.RuleFor(x => x.Cost, (f, u) => (double)f.Finance.Amount())
.RuleFor(x => x.Address, (f, u) => f.Address.FullAddress())
.RuleFor(x => x.City, (f, u) => f.Address.City())
.RuleFor(x => x.Date, (f, u) => f.Date.Past())
.Generate();
expense.EmployeeId = employeeId;
expenses.Insert(expense);
}
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bogus" version="25.0.3" targetFramework="net472" />
<package id="LiteDB" version="4.1.4" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.Controls" version="5.0.1" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.XamlHost" version="5.0.1" targetFramework="net472" />
</packages>

Просмотреть файл

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>2d8fd114-a304-45b1-bca2-16949103603e</ProjectGuid>
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>ContosoExpenses.Package_TemporaryKey.pfx</PackageCertificateKeyFile>
<EntryPointProjectUniqueName>..\ContosoExpenses\ContosoExpenses.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="ContosoExpenses.Package_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ContosoExpenses\ContosoExpenses.csproj" />
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

Просмотреть файл

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="5dde7e45-3be3-4273-a57d-93a49bbb14b2"
Publisher="CN=mpagani"
Version="1.0.0.0" />
<Properties>
<DisplayName>ContosoExpenses.Package</DisplayName>
<PublisherDisplayName>mpagani</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="ContosoExpenses.Package"
Description="ContosoExpenses.Package"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile
Wide310x150Logo="Images\Wide310x150Logo.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Просмотреть файл

@ -0,0 +1,57 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContosoExpenses", "ContosoExpenses\ContosoExpenses.csproj", "{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "ContosoExpenses.Package", "ContosoExpenses.Package\ContosoExpenses.Package.wapproj", "{2D8FD114-A304-45B1-BCA2-16949103603E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x64.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Debug|x86.Build.0 = Debug|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|Any CPU.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x64.Build.0 = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.ActiveCfg = Release|Any CPU
{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}.Release|x86.Build.0 = Release|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x64.ActiveCfg = Debug|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x64.Build.0 = Debug|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x64.Deploy.0 = Debug|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x86.ActiveCfg = Debug|x86
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x86.Build.0 = Debug|x86
{2D8FD114-A304-45B1-BCA2-16949103603E}.Debug|x86.Deploy.0 = Debug|x86
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|Any CPU.Build.0 = Release|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|Any CPU.Deploy.0 = Release|Any CPU
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x64.ActiveCfg = Release|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x64.Build.0 = Release|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x64.Deploy.0 = Release|x64
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x86.ActiveCfg = Release|x86
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x86.Build.0 = Release|x86
{2D8FD114-A304-45B1-BCA2-16949103603E}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3BADFBD9-C57F-40A7-B058-D6B067196030}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,35 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AboutView"
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"
mc:Ignorable="d" MinHeight="500" MinWidth="700" Height="500" Width="700">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" Margin="10">
Contoso Expenses is a 'modern application of yesterday tomorrow' from Contoso Corp.
</TextBlock>
<WebBrowser Grid.Row="1"
Source="https://contosocorpwebsite.azurewebsites.net/" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,27 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Linq;
using System.Linq.Expressions;
namespace ContosoExpenses
{
public partial class AboutView
{
public AboutView()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.AddNewExpense"
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:ContosoExpenses"
mc:Ignorable="d"
Title="Add new expense" Height="450" Width="800"
Background="{StaticResource AddNewExpenseBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="24" Text="Add new expense" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" Grid.Row="1" Grid.Column="0" />
<TextBox x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="1" Grid.Column="1" />
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" Grid.Row="2" Grid.Column="0" />
<TextBox x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" Width="400" Height="200" AcceptsReturn="True" Grid.Row="2" Grid.Column="1" />
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" Grid.Row="3" Grid.Column="0" />
<TextBox x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="3" Grid.Column="1" />
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" Grid.Row="4" Grid.Column="0" />
<TextBox x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="4" Grid.Column="1" />
<TextBlock Text="City:" FontSize="16" FontWeight="Bold" Grid.Row="5" Grid.Column="0" />
<TextBox x:Name="txtCity" FontSize="16" Margin="5, 0, 0, 0" Width="400" Grid.Row="5" Grid.Column="1" />
<TextBlock Text="Date:" FontSize="16" FontWeight="Bold" Grid.Row="6" Grid.Column="0" />
<DatePicker x:Name="txtDate" Grid.Row="6" Grid.Column="1" Margin="5, 0, 0, 0" Width="400" />
<Button Content="Save" Grid.Row="7" Grid.Column="0" Click="OnSaveExpense" Margin="5, 12, 0, 0" HorizontalAlignment="Left" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,59 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using ContosoExpenses.Models;
using ContosoExpenses.Services;
using System;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for AddNewExpense.xaml
/// </summary>
public partial class AddNewExpense : Window
{
public int EmployeeId { get; set; }
public AddNewExpense()
{
InitializeComponent();
}
private void OnSaveExpense(object sender, RoutedEventArgs e)
{
try
{
Expense expense = new Expense
{
Address = txtAmount.Text,
City = txtCity.Text,
Cost = Convert.ToDouble(txtAmount.Text),
Description = txtDescription.Text,
Type = txtType.Text,
Date = txtDate.SelectedDate.GetValueOrDefault(),
EmployeeId = EmployeeId
};
DatabaseService service = new DatabaseService();
service.SaveExpense(expense);
this.Close();
}
catch (Exception exc)
{
MessageBox.Show("Validation error. Please check your data.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Просмотреть файл

@ -0,0 +1,55 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Application x:Class="ContosoExpenses.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ContosoExpenses"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!--Background images-->
<ImageBrush x:Key="MainBackground"
ImageSource="Images\ExpensesBackground.jpg"
Stretch="UniformToFill" />
<ImageBrush x:Key="HorizontalBackground"
ImageSource="Images\HorizontalBackground.png"
Stretch="UniformToFill" />
<ImageBrush x:Key="ExpensesListBackground"
ImageSource="Images\ExpensesListBackground.png"
Stretch="Fill" />
<ImageBrush x:Key="AddNewExpenseBackground"
ImageSource="Images\AddNewExpense.png"
Stretch="UniformToFill" />
<!--Styles for DataGrid-->
<Style x:Key="DataGridHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Foreground" Value="Black" />
</Style>
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Cursor" Value="Hand" />
</Style>
<SolidColorBrush x:Key="SemiTransparentBackground"
Color="#0073CF"
Opacity=".6" />
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3E7CBAC-2DFE-463B-B7F9-0B6477EA7A37}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ContosoExpenses</RootNamespace>
<AssemblyName>ContosoExpenses</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Images\contoso.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Bogus, Version=25.0.3.0, Culture=neutral, PublicKeyToken=fa1bb3f3f218129a, processorArchitecture=MSIL">
<HintPath>..\packages\Bogus.25.0.3\lib\net40\Bogus.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.4.1.4\lib\net40\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.Controls, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.Controls.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Toolkit.Wpf.UI.XamlHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Toolkit.Wpf.UI.XamlHost.5.0.1\lib\net462\Microsoft.Toolkit.Wpf.UI.XamlHost.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="Windows">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\Windows.winmd</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddNewExpense.xaml.cs">
<DependentUpon>AddNewExpense.xaml</DependentUpon>
</Compile>
<Compile Include="ExpensesList.xaml.cs">
<DependentUpon>ExpensesList.xaml</DependentUpon>
</Compile>
<Compile Include="Services\DatabaseService.cs" />
<Page Include="AboutView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="AddNewExpense.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpenseDetail.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExpensesList.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpenseDetail.xaml.cs">
<DependentUpon>ExpenseDetail.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Employee.cs" />
<Compile Include="Models\Expense.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\contoso.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\HorizontalBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\AddNewExpense.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesBackground.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\ExpensesListBackground.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,146 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpenseDetail"
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:toolkit="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
Loaded="Window_Loaded"
Closed="Window_Closed"
xmlns:local="clr-namespace:ContosoExpenses"
mc:Ignorable="d"
Title="Expense Detail" Height="500" Width="800"
Background="{StaticResource HorizontalBackground}">
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Expense detail -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<!--<RowDefinition Height="*"/>-->
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expense" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Type:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtType" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Description:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtDescription" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="Amount:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtAmount" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4">
<TextBlock Text="Location:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtLocation" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<!--<toolkit:MapControl Grid.Row="5" x:Name="ExpenseMap" />-->
<TextBlock Text="Signature:" FontSize="16" FontWeight="Bold" Grid.Row="5" />
<toolkit:InkCanvas x:Name="Signature" Grid.Row="6" />
</Grid>
<!-- Chart -->
<DockPanel Grid.Column="1" VerticalAlignment="Bottom" Margin="20,0,0,0" MinHeight="420">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="Chart" Width="50" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#4E87D4" Offset="0" />
<GradientStop Color="#73B2F5" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFFFFF" Offset="0" />
<GradientStop Color="#4E87D4" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Grid Grid.Column="1" Width="20" Height="400" VerticalAlignment="Bottom">
<Rectangle StrokeThickness="1" RadiusX="2" RadiusY="2">
<Rectangle.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#4CFF00" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
<TextBlock Grid.Column="2" Text="1000$ limit" Margin="0,20,0,0"></TextBlock>
</DockPanel>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,61 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Linq;
using System.Windows;
using ContosoExpenses.Models;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
using Windows.Services.Maps;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpenseDetail.xaml
/// </summary>
public partial class ExpenseDetail : Window
{
public Expense SelectedExpense { get; set; }
public ExpenseDetail()
{
InitializeComponent();
Signature.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen;
MapService.ServiceToken = "IFFAI5SFOtHV9VBKF8Ea~3FS1XamCV2NM0IqlfoQo6A~AguqcUboJvnqWU1H9E-6MVThouJoCrM4wpv_1R_KX_oQLV_e59vyoK42470JvLsU";
}
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
txtType.Text = SelectedExpense.Type;
txtDescription.Text = SelectedExpense.Description;
txtLocation.Text = SelectedExpense.Address;
txtAmount.Text = SelectedExpense.Cost.ToString();
Chart.Height = (SelectedExpense.Cost * 400) / 1000;
var result = await MapLocationFinder.FindLocationsAsync(SelectedExpense.Address, null);
var location = result.Locations.FirstOrDefault();
if (location != null)
{
await ExpenseMap.TrySetViewAsync(location.Point, 13);
}
}
private void Window_Closed(object sender, EventArgs e)
{
Signature.Dispose();
ExpenseMap.Dispose();
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.ExpensesList"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Activated="Window_Activated"
Title="Expenses List" Height="450" Width="800"
Background="{StaticResource ExpensesListBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="24" Text="Expenses List" Grid.Row="0" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Employee Id:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmployeeId" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="Full name:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtFullName" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock Text="E-mail:" FontSize="16" FontWeight="Bold" />
<TextBlock x:Name="txtEmail" FontSize="16" Margin="5, 0, 0, 0" />
</StackPanel>
<DataGrid x:Name="ExpensesGrid"
Grid.Row="4"
SelectionChanged="OnSelectedExpense"
AutoGenerateColumns="False"
IsReadOnly="True"
Margin="0, 12, 0, 0"
SelectionMode="Single"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Date" Binding="{Binding Path=Date}" />
<DataGridTextColumn Header="Type" Binding="{Binding Path=Type}" />
<DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" />
<DataGridTextColumn Header="Cost" Binding="{Binding Path=Cost}" />
<DataGridTextColumn Header="City" Binding="{Binding Path=City}" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Add new expense" Click="OnAddNewExpense" Grid.Row="5" HorizontalAlignment="Left" Margin="0, 12, 0, 0" Width="180" />
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,89 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
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;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for ExpensesList.xaml
/// </summary>
public partial class ExpensesList : Window
{
public int EmployeeId { get; set; }
private Employee selectedEmployee;
public ExpensesList()
{
InitializeComponent();
}
private void OnSelectedExpense(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var expense = e.AddedItems[0] as Expense;
if (expense != null && expense.ExpenseId != 0)
{
ExpenseDetail detail = new ExpenseDetail();
detail.SelectedExpense = expense;
detail.ShowDialog();
}
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DatabaseService databaseService = new DatabaseService();
selectedEmployee = databaseService.GetEmployee(EmployeeId);
txtEmployeeId.Text = selectedEmployee.EmployeeId.ToString();
txtFullName.Text = $"{selectedEmployee.FirstName} {selectedEmployee.LastName}";
txtEmail.Text = selectedEmployee.Email;
}
private void OnAddNewExpense(object sender, RoutedEventArgs e)
{
AddNewExpense newExpense = new AddNewExpense();
newExpense.EmployeeId = EmployeeId;
newExpense.ShowDialog();
}
public void LoadData()
{
DatabaseService databaseService = new DatabaseService();
ExpensesGrid.ItemsSource = databaseService.GetExpenses(EmployeeId);
}
private void Window_Activated(object sender, EventArgs e)
{
LoadData();
}
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 320 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 65 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 27 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 133 KiB

Просмотреть файл

@ -0,0 +1,57 @@
<!--
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
-->
<Window x:Class="ContosoExpenses.MainWindow"
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:ContosoExpenses"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="Contoso Expenses" Height="450" Width="800"
Background="{StaticResource MainBackground}">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu IsMainMenu="True" Grid.Row="0">
<MenuItem Header="_About" FontSize="12" Click="OnOpenAbout" />
</Menu>
<DataGrid x:Name="CustomersGrid"
Grid.Row="1"
SelectionChanged="OnSelectedEmployee"
AutoGenerateColumns="False"
SelectionMode="Single"
IsReadOnly="True"
Background="{StaticResource SemiTransparentBackground}"
RowBackground="{StaticResource SemiTransparentBackground}"
ColumnHeaderStyle="{StaticResource DataGridHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
Foreground="White"
FontSize="14">
<DataGrid.Columns>
<DataGridTextColumn Header="Employee Id" Binding="{Binding Path=EmployeeId}" />
<DataGridTextColumn Header="Name" Binding="{Binding Path=FirstName}" />
<DataGridTextColumn Header="Surname" Binding="{Binding Path=LastName}" />
<DataGridTextColumn Header="E-mail" Binding="{Binding Path=Email}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,67 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using ContosoExpenses.Models;
using ContosoExpenses.Services;
namespace ContosoExpenses
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LoadData();
}
private void LoadData()
{
List<Employee> customers = new List<Employee>();
DatabaseService db = new DatabaseService();
db.InitializeDatabase();
CustomersGrid.ItemsSource = db.GetEmployees();
}
private void OnSelectedEmployee(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var employee = e.AddedItems[0] as Employee;
if (employee != null && employee.EmployeeId != 0)
{
ExpensesList detail = new ExpensesList();
detail.EmployeeId = employee.EmployeeId;
detail.Show();
}
}
}
private void OnOpenAbout(object sender, RoutedEventArgs e)
{
AboutView about = new AboutView();
about.ShowDialog();
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@

namespace ContosoExpenses.Models
{
public class Employee
{
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using System;
namespace ContosoExpenses.Models
{
public class Expense
{
public int ExpenseId { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public double Cost { get; set; }
public string Address { get; set; }
public string City { get; set; }
public DateTime Date { get; set; }
public int EmployeeId { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XamlIslandDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XamlIslandDemo")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ContosoExpenses.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ContosoExpenses.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Bogus;
using LiteDB;
using ContosoExpenses.Models;
namespace ContosoExpenses.Services
{
public class DatabaseService
{
readonly int numberOfEmployees = 10;
readonly int numberOfExpenses = 5;
string filePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\data.db";
string directoryPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ExpenseIt\\";
public Employee GetEmployee(int employeeId)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindById(employeeId);
}
}
public List<Employee> GetEmployees()
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
return employees.FindAll().ToList();
}
}
public List<Expense> GetExpenses(int employeedId)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
return expenses.Find(x => x.EmployeeId == employeedId).ToList();
}
}
public void SaveExpense(Expense expense)
{
using (var connection = new LiteDatabase(filePath))
{
var expenses = connection.GetCollection<Expense>();
expenses.Insert(expense);
}
}
public void InitializeDatabase()
{
if (!File.Exists(filePath))
{
Directory.CreateDirectory(directoryPath);
}
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
int result = employees.Count();
if (result == 0)
{
GenerateFakeData(numberOfEmployees, numberOfExpenses);
}
}
}
private void GenerateFakeData(int numberOfEmployees, int numberOfExpenses)
{
using (var connection = new LiteDatabase(filePath))
{
var employees = connection.GetCollection<Employee>();
var expenses = connection.GetCollection<Expense>();
for (int cont = 0; cont < numberOfEmployees; cont++)
{
var employee = new Faker<Employee>()
.RuleFor(x => x.FirstName, (f, u) => f.Name.FirstName())
.RuleFor(x => x.LastName, (f, u) => f.Name.LastName())
.RuleFor(x => x.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName, "contoso.com"))
.Generate();
int employeeId = employees.Insert(employee).AsInt32;
for (int contExpenses = 0; contExpenses < numberOfExpenses; contExpenses++)
{
var expense = new Faker<Expense>()
.RuleFor(x => x.Description, (f, u) => f.Commerce.ProductName())
.RuleFor(x => x.Type, (f, u) => f.Finance.TransactionType())
.RuleFor(x => x.Cost, (f, u) => (double)f.Finance.Amount())
.RuleFor(x => x.Address, (f, u) => f.Address.FullAddress())
.RuleFor(x => x.City, (f, u) => f.Address.City())
.RuleFor(x => x.Date, (f, u) => f.Date.Past())
.Generate();
expense.EmployeeId = employeeId;
expenses.Insert(expense);
}
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bogus" version="25.0.3" targetFramework="net472" />
<package id="LiteDB" version="4.1.4" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.Controls" version="5.0.1" targetFramework="net472" />
<package id="Microsoft.Toolkit.Wpf.UI.XamlHost" version="5.0.1" targetFramework="net472" />
</packages>

Двоичные данные
Manual/AddNewProject.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 19 KiB

Двоичные данные
Manual/BingDevCreateKey.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 11 KiB

Двоичные данные
Manual/BingDevCreateNewKey.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 9.2 KiB

Двоичные данные
Manual/BingDevKeyInfo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.3 KiB

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше