Initial commit

Initial commit til Git.
V2 er deployed
This commit is contained in:
2026-06-13 17:31:50 +02:00
parent 9fcd2b145e
commit 41e23b6184
375 changed files with 15956 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "5.0.9",
"commands": [
"dotnet-ef"
]
}
}
}

View File

@@ -0,0 +1,9 @@
<Application x:Class="Pos.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Pos"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="ResourceDictionaries/Resource.xaml"></ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Pos
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
//Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDk1NTE0QDMxMzkyZTMyMmUzMFI1bUkyeWZBZngydzlUaHJpUEdiNmtnWnhFUytPYUVvYnQvZFErWXdkN3c9");
}
}
}

View File

@@ -0,0 +1,10 @@
using System.Windows;
[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)
)]

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Json
{
public class BodyModel
{
public ProductModel[] products { get; set; }
public float totalPrice { get; set; }
public float totalVat { get; set; }
public int receiptNumber { get; set; }
public string receiptTime { get; set; }
public string staff { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Json
{
public class FooterModel
{
public string value { get; set; }
public PrintStylesModel printStyles { get; set; }
public int textAlignment { get; set; }
public int feedingLines { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Json
{
public class HeaderModel
{
public string value { get; set; }
public PrintStylesModel printStyles { get; set; }
public int textAlignment { get; set; }
public int feedingLines { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EpsonPrinter.Model;
namespace Pos.Json
{
public class PosReceipt
{
public string logoBase64 { get; set; }
public HeaderModel[] header { get; set; }
public BodyModel bodyModel { get; set; } = new();
public FooterModel[] footer { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Json
{
public class PrintStylesModel
{
public bool fontB { get; set; }
public bool bold { get; set; }
public bool doubleHeight { get; set; }
public bool doubleWidth { get; set; }
public bool underline { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Json
{
public class ProductModel
{
public string product { get; set; }
public string noOfProduct { get; set; }
public float price { get; set; }
public float totalPrice { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
<Window
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:Pos"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="Pos.MainWindow"
mc:Ignorable="d"
Title="Blomster POS" Height="450" Width="800" Icon="Icons/cashier.png">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" >
<Button Style="{StaticResource MenuButtons}" Content="Kassesalg" Name="btnSale" Click="btnSale_Click"/>
<Button Style="{StaticResource MenuButtons}" Content="Indstillinger" Name="btnSettings" Click="btnSettings_Click" />
<Button Style="{StaticResource MenuButtons}" Content="Print bon" Name="btnPrintReceipt" Click="btnPrintReceipt_Click" />
<Button Style="{StaticResource MenuButtons}" Content="Dagens salg" Name="btnTodaySale" Click="BtnTodaySale_OnClick" />
</WrapPanel>
</Window>

View File

@@ -0,0 +1,53 @@
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.Navigation;
using System.Windows.Shapes;
using Pos.Setting;
namespace Pos
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnSettings_Click(object sender, RoutedEventArgs e)
{
SettingWindow settingWindow = new SettingWindow();
settingWindow.Show();
}
private void btnSale_Click(object sender, RoutedEventArgs e)
{
SalesWindow salesWindow = new SalesWindow();
salesWindow.Show();
}
private void btnPrintReceipt_Click(object sender, RoutedEventArgs e)
{
PrintReceiptWindow printReceiptWindow = new PrintReceiptWindow();
printReceiptWindow.Show();
}
private void BtnTodaySale_OnClick(object sender, RoutedEventArgs e)
{
SaleOfDay saleOfDay = new SaleOfDay();
saleOfDay.Show();
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class AmountGridModel
{
public string PaymentMethodText { get; set; }
public decimal Amount { get; set; }
public string AmountText { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Pos.Models;
public enum PaymentMethod
{
Cash,
Card,
GiftCard,
MobilePay
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class PriceLineModel
{
public string Name { get; set; }
public int NumberProducts { get; set; }
public decimal Price { get; set; }
public int Id { get; set; }
public bool IsProductGroup { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class SaleGridInternalModel
{
public decimal InternPrice { get; set; }
public int InternPieces { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class SaleGridModel
{
public string Navn { get; set; }
public string Stk { get; set; }
public string Pris { get; set; }
public string Total { get; set; }
public SaleGridInternalModel SaleGridInternalModel { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class TotalSaleCategory
{
public string Category { get; set; }
public decimal Sale { get; set; }
public string SaleString { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Models
{
public class TotalSaleDetail
{
public decimal TotalSale { get; set; }
public int TotalCustomer { get; set; }
public List<TotalSaleCategory> TotalSaleCategories { get; set; } = new();
}
}

View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.SfSkinManager.WPF">
<HintPath>C:\Program Files (x86)\Syncfusion\Essential Studio\WPF\19.2.0.44\precompiledassemblies\net5.0\Syncfusion.SfSkinManager.WPF.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Shared.WPF">
<HintPath>C:\Program Files (x86)\Syncfusion\Essential Studio\WPF\19.2.0.44\precompiledassemblies\net5.0\Syncfusion.Shared.WPF.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Themes.FluentLight.WPF">
<HintPath>C:\Program Files (x86)\Syncfusion\Essential Studio\WPF\19.2.0.44\precompiledassemblies\net5.0\Syncfusion.Themes.FluentLight.WPF.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Tools.Wpf">
<HintPath>C:\Program Files (x86)\Syncfusion\Essential Studio\WPF\19.2.0.44\precompiledassemblies\net5.0\Syncfusion.Tools.WPF.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Update="Icons\pos.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Icons\settings.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,82 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="Icons\cashier.png" />
<None Remove="Icons\category.png" />
<None Remove="Icons\employee.png" />
<None Remove="Icons\employees.png" />
<None Remove="Icons\exchange.png" />
<None Remove="Icons\pos.png" />
<None Remove="Icons\product.png" />
<None Remove="Icons\receipt.png" />
<None Remove="Icons\settings.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="108.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Database\Database.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Syncfusion.SfSkinManager.WPF">
</Reference>
<Reference Include="Syncfusion.Shared.WPF">
</Reference>
<Reference Include="Syncfusion.Themes.FluentLight.WPF">
</Reference>
<Reference Include="Syncfusion.Tools.Wpf">
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\cashier.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\category.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\employee.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\employees.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\exchange.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\pos.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\product.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\receipt.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Icons\settings.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.production.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,34 @@
<Window x:Class="Pos.PrintReceiptWindow"
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:Pos"
mc:Ignorable="d"
Title="Print bon" Height="600" Width="500" Icon="Icons/receipt.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1.6*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0" Grid.ColumnSpan="2">
<DatePicker Name="StartDatePicker" FirstDayOfWeek="Monday" IsTodayHighlighted="True"/>
<DatePicker Name="EndDatePicker" FirstDayOfWeek="Monday" IsTodayHighlighted="True"/>
<Button Name="Search" Content="Vis bon" Style="{StaticResource SmallButtons}" Click="Search_OnClick"/>
</WrapPanel>
<WrapPanel Grid.Row="1" Grid.Column="0">
<ListBox Name="ListReciept" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionChanged="ListReciept_OnSelectionChanged"
IsSynchronizedWithCurrentItem="true">
</ListBox>
</WrapPanel>
<WrapPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical">
<TextBox IsReadOnly="True" Name="SaleLines" BorderThickness="0" />
<Button Name="PrintReceipt" Content="Print bon" Visibility="Hidden" Click="PrintReceipt_OnClick" Style="{StaticResource SmallButtons}"/>
</WrapPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,109 @@
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 Database.Models;
using Database.Repository;
using Pos.Service;
namespace Pos
{
/// <summary>
/// Interaction logic for PrintReceiptWindow.xaml
/// </summary>
public partial class PrintReceiptWindow : Window
{
private List<ListReceiptModel> _receiptList = new List<ListReceiptModel>();
private bool _init = false;
private int _saleId = 0;
public PrintReceiptWindow()
{
InitializeComponent();
StartDatePicker.DisplayDate = DateTime.Now.AddDays(-7);
StartDatePicker.SelectedDate = DateTime.Now.AddDays(-7);
EndDatePicker.DisplayDate = DateTime.Now;
EndDatePicker.SelectedDate = DateTime.Now;
}
private void Search_OnClick(object sender, RoutedEventArgs e)
{
DateTime startDate = (DateTime)StartDatePicker.SelectedDate;
DateTime endDate = (DateTime)EndDatePicker.SelectedDate;
SaleRepository saleRepository = new SaleRepository();
List<SaleEntity> saleEntities = saleRepository.GetByDateRange(startDate, endDate);
foreach (SaleEntity entity in saleEntities)
{
List<SaleLineEntity> saleLineBySaleId = saleRepository.GetSaleLineBySaleId(entity.Id);
decimal total = 0;
foreach (SaleLineEntity lineEntity in saleLineBySaleId)
{
total += lineEntity.Total;
}
ListReceiptModel receiptModel = new ListReceiptModel
{
Id = entity.Id,
Content = $"{entity.Time:dd-MM-yyyy HH:mm} - Pris: {total:0.00}"
};
_receiptList.Add(receiptModel);
}
_init = true;
ListReciept.ItemsSource = _receiptList;
_init = false;
}
public class ListReceiptModel
{
public int Id { get; set; }
public string Content { get; set; }
public override string ToString()
{
return Content;
}
}
private void ListReciept_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (_init)
return;
ListReceiptModel data = (ListReceiptModel) e.AddedItems[0];
_saleId = data.Id;
SaleRepository saleRepository = new SaleRepository();
List<SaleLineEntity> saleLineBySaleId = saleRepository.GetSaleLineBySaleId(data.Id);
StringBuilder sb = new StringBuilder();
decimal total = 0;
foreach (SaleLineEntity saleLine in saleLineBySaleId)
{
total += saleLine.Total;
sb.AppendLine(
$"{saleLine.Product} - {saleLine.Pieces} stk. a' {saleLine.Price.ToString("0.00")} = {saleLine.Total.ToString("0.00")}");
}
sb.AppendLine($"Total: {total.ToString("0.00")} kr.");
PrintReceipt.Visibility = Visibility.Visible;
SaleLines.Clear();
SaleLines.Text = sb.ToString();
}
private void PrintReceipt_OnClick(object sender, RoutedEventArgs e)
{
SaleService saleService = new SaleService();
saleService.PrintReceipt(_saleId);
}
}
}

View File

@@ -0,0 +1,117 @@
<ResourceDictionary x:Class="Pos.ResourceDictionaries.MenuButtonResource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Pos.ResourceDictionaries">
<Style TargetType="Button">
<Setter Property="Margin" Value="4"/>
<Setter Property="FontSize" Value="24"/>
</Style>
<Style x:Key="MenuButtons">
<Setter Property="Control.Width" Value="250" />
<Setter Property="Control.Height" Value="100" />
<Setter Property="Control.FontSize" Value="40" />
<Setter Property="Control.Margin" Value="15" />
</Style>
<Style x:Key="Buttons">
<Setter Property="Control.HorizontalAlignment" Value="Stretch"/>
<Setter Property="Control.Height" Value="50" />
<Setter Property="Control.FontSize" Value="35" />
<Setter Property="Control.Margin" Value="10" />
</Style>
<Style x:Key="ButtonsNoLeftRightMargin">
<Setter Property="Control.HorizontalAlignment" Value="Stretch"/>
<Setter Property="Control.Height" Value="50" />
<Setter Property="Control.FontSize" Value="35" />
<Setter Property="Control.Margin" Value="0,10,0,10" />
</Style>
<Style x:Key="SaleButtons">
<Setter Property="Control.FontSize" Value="15" />
<Setter Property="Control.Margin" Value="10,2,0,2" />
<Setter Property="Control.Padding" Value="10,5,10,5" />
</Style>
<Style x:Key="SaleButtonsActive">
<Setter Property="Control.FontSize" Value="15" />
<Setter Property="Control.Margin" Value="10,2,0,2" />
<Setter Property="Control.Padding" Value="10,5,10,5" />
<Setter Property="Control.BorderBrush" Value="DarkBlue" />
<Setter Property="Control.Background" Value="DeepSkyBlue"/>
</Style>
<Style x:Key="MaxButtons">
<Setter Property="Control.FontSize" Value="50" />
<Setter Property="Control.Margin" Value="10" />
<Setter Property="Control.Padding" Value="10" />
</Style>
<Style x:Key="MediumButtons">
<Setter Property="Control.FontSize" Value="20" />
<Setter Property="Control.Margin" Value="10" />
<Setter Property="Control.Padding" Value="5" />
</Style>
<Style x:Key="SmallButtons">
<Setter Property="Control.FontSize" Value="15" />
<Setter Property="Control.Margin" Value="5" />
<Setter Property="Control.Padding" Value="3,1,3,1" />
</Style>
<Style x:Key="TextBox">
<Setter Property="Control.Height" Value="40"/>
<Setter Property="Control.HorizontalAlignment" Value="Stretch"/>
<Setter Property="Control.FontSize" Value="25" />
<Setter Property="Control.Margin" Value="10,5,10,0" />
</Style>
<Style x:Key="ListBox">
<Setter Property="Control.FontSize" Value="25" />
<Setter Property="Control.Margin" Value="0" />
</Style>
<Style x:Key="ComboBox">
<Setter Property="Control.FontSize" Value="25" />
<Setter Property="Control.Margin" Value="10" />
</Style>
<Style x:Key="GroupBox">
<Setter Property="Control.FontSize" Value="18"/>
<Setter Property="Control.FontWeight" Value="Bold"/>
<Setter Property="Border.BorderThickness" Value="3"/>
<Setter Property="Border.BorderBrush" Value="DarkGray"/>
<Setter Property="Border.CornerRadius" Value="5"/>
</Style>
<Style x:Key="StandardBigText">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Margin" Value="0,0,0,0"/>
</Style>
<Style x:Key="StandardBoldBigText">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Margin" Value="0,0,0,0"/>
<Setter Property="Control.FontWeight" Value="Bold"/>
</Style>
<Style x:Key="StandardLabel">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Margin" Value="10,0,0,0"/>
</Style>
<Style x:Key="StandardLabelWarning">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Foreground" Value="Red"></Setter>
<Setter Property="Control.Margin" Value="10,0,0,0"/>
</Style>
<Style x:Key="BoldLabelNoMargin">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.FontWeight" Value="Bold"/>
</Style>
<Style x:Key="BoldLabelWarningNoMargin">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Foreground" Value="Red"></Setter>
<Setter Property="Control.FontWeight" Value="Bold"/>
</Style>
<Style x:Key="BoldSuccess">
<Setter Property="Control.FontSize" Value="20"/>
<Setter Property="Control.Foreground" Value="Green"></Setter>
<Setter Property="Control.FontWeight" Value="Bold"/>
</Style>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Text" Value="Vælg en dato" />
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,44 @@
<Window x:Class="Pos.SaleOfDay"
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:Pos"
mc:Ignorable="d"
Title="Dagens salg" Height="600" Width="350" Icon="Icons/cashier.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DatePicker Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Name="StartDatePicker" FirstDayOfWeek="Monday" IsTodayHighlighted="True" SelectedDateChanged="StartDatePicker_SelectedDateChanged"/>
<Label Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Name="TotalSale" Style="{StaticResource BoldLabelNoMargin}"/>
<DataGrid Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Name="GridSaleDetail" AutoGenerateColumns="False" GridLinesVisibility="None" HeadersVisibility="None" CanUserAddRows="False" BorderThickness="0" Style="{StaticResource StandardBigText}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Category }">
<DataGridTextColumn.ElementStyle>
<Style>
<Setter Property="TextBlock.Margin" Value="4,0,0,0"></Setter>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Path=SaleString}">
<DataGridTextColumn.ElementStyle>
<Style>
<Setter Property="TextBlock.TextAlignment" Value="Right" />
<Setter Property="TextBlock.Margin" Value="10,0,0,0"></Setter>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<Button Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Style="{StaticResource Buttons}" Click="PrintSale_OnClick">Print salg</Button>
</Grid>
</Window>

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Data;
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 EpsonPrinter.Model;
using Pos.Models;
using Pos.Service;
namespace Pos
{
/// <summary>
/// Interaction logic for SaleOfDay.xaml
/// </summary>
public partial class SaleOfDay : Window
{
private bool _initialLoad = true;
private TotalSaleDetail totalSaleDetail;
public SaleOfDay()
{
InitializeComponent();
SaleService saleService = new SaleService();
totalSaleDetail = saleService.TotalSale(DateTime.Now);
TotalSale.Content = $"Dagens salg: kr. {totalSaleDetail.TotalSale:0.00}";
StartDatePicker.SelectedDate = DateTime.Now;
GridSaleDetail.ItemsSource = totalSaleDetail.TotalSaleCategories;
_initialLoad = false;
}
private void StartDatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
if (_initialLoad)
return;
_initialLoad = false;
DateTime selectedDate = DateTime.Parse(sender.ToString());
SaleService saleService = new SaleService();
totalSaleDetail = saleService.TotalSale(selectedDate);
TotalSale.Content = $"Dagens salg: kr. {totalSaleDetail.TotalSale:0.00}";
GridSaleDetail.ItemsSource = totalSaleDetail.TotalSaleCategories;
}
private void PrintSale_OnClick(object sender, RoutedEventArgs e)
{
SaleService saleService = new SaleService();
saleService.PrintSaleOfDay(StartDatePicker.SelectedDate.Value,totalSaleDetail);
}
}
}

View File

@@ -0,0 +1,115 @@
<Window x:Class="Pos.SalesWindow"
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:Pos"
mc:Ignorable="d"
WindowState="Maximized"
SizeToContent="Manual"
Title="Salg" Height="450" Width="800" Icon="Icons/cashier.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="2.5*"/>
<RowDefinition Height="1.4*"/>
<RowDefinition Height="1.2*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<GroupBox Name="GrpEmployee" Grid.Row="0" Grid.Column="1" Style="{StaticResource GroupBox}">
<GroupBox.Header>
<Label>Medarbejder</Label>
</GroupBox.Header>
<StackPanel VerticalAlignment="Top">
<DockPanel Name="DockEmployee" Dock="Top" LastChildFill="False"/>
</StackPanel>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="1" Style="{StaticResource GroupBox}">
<GroupBox.Header>
<Label>Varer</Label>
</GroupBox.Header>
<WrapPanel VerticalAlignment="Top" Name="DockProductGroup">
</WrapPanel>
</GroupBox>
<!--<GroupBox Grid.Row="2" Grid.Column="1" Style="{StaticResource GroupBox}">
<GroupBox.Header>
<Label>Vare</Label>
</GroupBox.Header>
<StackPanel VerticalAlignment="Top">
<WrapPanel Name="DockProduct" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
</StackPanel>
</GroupBox>-->
<GroupBox Grid.Row="2" Grid.Column="1" Name="PriceSection" Style="{StaticResource GroupBox}">
<GroupBox.Header>
<Label>Pris</Label>
</GroupBox.Header>
<WrapPanel Name="PricePanel" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<Label Name="LblStk" Content="Stk:" Style="{StaticResource StandardLabel}"/>
<TextBox Name="NumberOfProducts" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="50" Text="1" Margin="10,0,0,0" FontSize="20" GotFocus="NumberOfProducts_GotFocus" LostFocus="NumberOfProducts_LostFocus"/>
<Label Name="LblPrice" Content="Pris:" Style="{StaticResource StandardLabel}"/>
<TextBox Name="Price" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="130" Margin="10,0,0,0" FontSize="20" KeyUp="Price_KeyUp"/>
<Button Name="BtnBuy" Content="Køb" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,0,0,0" Click="Buy_Click"/>
<Label Name="LblTotal" Content="Total pris: Kr." VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Style="{StaticResource StandardLabel}" Padding="30,0,0,0"/>
<Label Name="TotalPrice" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Style="{StaticResource StandardLabel}" Content="0,-" />
</WrapPanel>
</GroupBox>
<GroupBox Grid.Row="3" Grid.Column="1" Name="PaymentSection" Style="{StaticResource GroupBox}" Header="Betaling">
<WrapPanel Name="PaymentPanel" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<Label Name="LblAmount" Style="{StaticResource StandardLabel}">Beløb:</Label>
<TextBox Name="Amount" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="130" Margin="10,0,0,0" FontSize="20"/>
<Button Name="BtnCash" Content="Kontant" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,0,0,0" Click="Payment_Click" Tag="PaymentMethod.Cash"/>
<Button Name="BtnCard" Content="Kort" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,0,0,0" Click="Payment_Click" Tag="PaymentMethod.Card"/>
<Button Name="BtnMb" Content="MobilePay" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,0,0,0" Click="Payment_Click" Tag="PaymentMethod.MobilePay"/>
<Button Name="BtnBuyGiftCard" Content="Gavekort" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,0,0,0" Click="Payment_Click" Tag="PaymentMethod.GiftCard"/>
</WrapPanel>
</GroupBox>
<StackPanel Width="Auto" Height="Auto" Grid.Row="0" Grid.RowSpan="6" Grid.Column="0" VerticalAlignment="Top" CanVerticallyScroll="True" >
<Label Content="Salg:" Style="{StaticResource StandardBoldBigText}"/>
<Grid>
<DataGrid VerticalScrollBarVisibility="Auto" x:Name="SaleGrid" SelectionChanged="SaleGrid_OnSelectionChanged" AutoGenerateColumns="False" Style="{StaticResource StandardBigText}" GridLinesVisibility="None" BorderThickness="0" HeadersVisibility="None" KeyUp="SaleGrid_KeyUp">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" >
<Setter Property="Margin" Value="0,5,4,0"></Setter>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Navn }"></DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Path=Stk }"></DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Path=Pris }"></DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Path=Total }"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<Label Name="Total" Style="{StaticResource StandardBoldBigText}"/>
<Separator/>
<Label Content="Betalt:" Style="{StaticResource StandardBoldBigText}"/>
<Grid>
<DataGrid Name="PaymentGrid" Style="{StaticResource StandardBigText}" AutoGenerateColumns="False" GridLinesVisibility="None" BorderThickness="0" HeadersVisibility="None">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" >
<Setter Property="Margin" Value="0,5,4,0"></Setter>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="120" Binding="{Binding Path=PaymentMethodText}" />
<DataGridTextColumn Width="100" Binding="{Binding Path=AmountText}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<Label Name="lblRecived" Style="{StaticResource StandardBoldBigText}"/>
<Button Name="btnFinish" Content="Afslut" IsEnabled="False" Click="btnFinish_Click"/>
</StackPanel>
<GroupBox Grid.Column="1" Grid.Row="4" Name="Misc" Style="{StaticResource GroupBox}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Header="Diverse">
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Top">
<Button Name="BtnPrint" Content="Print bon" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="10,0,10,0" Margin="10,10,10,10" Click="BtnPrint_Click" />
</WrapPanel>
</GroupBox>
</Grid>
</Window>

View File

@@ -0,0 +1,513 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup.Localizer;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Database.Models;
using Pos.Models;
using Pos.Service;
namespace Pos
{
/// <summary>
/// Interaction logic for SalesWindow.xaml
/// </summary>
public partial class SalesWindow : Window
{
private ObservableCollection<EmployeeEntity> _employees;
private ObservableCollection<ProductGroupEntity> _productGroups;
private ObservableCollection<SaleGridModel> _saleGridModels;
private ObservableCollection<AmountGridModel> _paymentGridModels;
private List<PriceLineModel> _priceLineModels;
private ProductEntity _selectedProduct;
private ProductGroupEntity _selectedProductGroup;
private int _employeeId = -1;
private int _productGroupId = -1;
private int _productId = -1;
private int _numberOfProducts = 1;
private int _selectedSaleGridIndex = -1;
private int _maxCharOfName = 0;
private decimal _price = 0;
private decimal _totalPrice = 0;
private Button _prevEmpButton = new Button();
private Button _prevProductGroupButton = new Button();
private Button _prevProduct = new Button();
public SalesWindow()
{
InitializeComponent();
InitialLoad();
}
private void InitialLoad()
{
CacheService.Invalidate();
_employees = CacheService.GetEmployee() as ObservableCollection<EmployeeEntity>;
_productGroups = CacheService.GetProductGroupsIncludeProducts() as ObservableCollection<ProductGroupEntity>;
_saleGridModels = new ObservableCollection<SaleGridModel>();
_priceLineModels = new List<PriceLineModel>();
_paymentGridModels = new ObservableCollection<AmountGridModel>();
SaleGrid.ItemsSource = _saleGridModels;
PaymentGrid.ItemsSource = _paymentGridModels;
BuildEmployee();
BuildProductGroup();
ManipulateBuySection();
UpdateWindowTitle();
foreach (var productGroup in _productGroups)
{
if (_maxCharOfName < productGroup.Name.Length)
_maxCharOfName = productGroup.Name.Length;
foreach (ProductEntity product in productGroup.Products)
{
if (_maxCharOfName < product.Name.Length)
_maxCharOfName = product.Name.Length;
}
}
}
private void BtnPrGr_Click(object sender, RoutedEventArgs e)
{
_productId = -1;
_prevProductGroupButton.Style = (Style)FindResource("SaleButtons");
Button button = sender as Button;
_prevProductGroupButton = button;
button.Style = (Style)FindResource("SaleButtonsActive");
_productGroupId = (int)button.Tag;
_selectedProductGroup = _productGroups.Single(c => c.Id == _productGroupId);
BuildProducts(_selectedProductGroup.Products);
ManipulateBuySection();
}
private void BtnProduct_Click(object sender, RoutedEventArgs e)
{
_prevProduct.Style = (Style)FindResource("SaleButtons");
Button button = sender as Button;
_prevProduct = button;
button.Style = (Style)FindResource("SaleButtonsActive");
_productId = (int)button.Tag;
_selectedProduct = _selectedProductGroup.Products.Single(c => c.Id == _productId);
ManipulateBuySection();
}
private void BtnEmp_Click(object sender, RoutedEventArgs e)
{
_prevEmpButton.Style = (Style)FindResource("SaleButtons");
_prevProductGroupButton.Style = (Style)FindResource("SaleButtons");
//DockProduct.Children.Clear();
Button button = sender as Button;
_prevEmpButton = button;
button.Style = (Style)FindResource("SaleButtonsActive");
_employeeId = (int) button.Tag;
UIElementCollection employees = DockProductGroup.Children;
foreach (UIElement emp in employees)
{
button = (Button)emp;
button.IsEnabled = true;
}
}
private void SaleGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid dg = (DataGrid)sender;
_selectedSaleGridIndex = dg.SelectedIndex;
}
private void NumberOfProducts_GotFocus(object sender, RoutedEventArgs e)
{
NumberOfProducts.Text = string.Empty;
}
private void Buy_Click(object sender, RoutedEventArgs e)
{
bool isValid = ValidatePriceInput();
if (!isValid)
return;
isValid = ValidateNumberOfProductsInput();
if (!isValid)
return;
decimal price = Convert.ToDecimal(Price.Text);
int number = Convert.ToInt32(NumberOfProducts.Text);
NumberOfProducts.Text = "1";
Price.Text = string.Empty;
TotalPrice.Content = "0";
BuildPrice(false);
_productId = -1;
_productGroupId = -1;
ManipulateBuySection();
}
private void Payment_Click(object sender, RoutedEventArgs e)
{
//bool isValid = ValidateAmountInput();
//if (!isValid)
// return;
decimal amount = -1;
if (!string.IsNullOrEmpty(Amount.Text))
amount = Convert.ToDecimal(Amount.Text);
Amount.Text = string.Empty;
Button button = sender as Button;
BuildAmuntDataGrid(amount,(string)button.Tag);
}
private void NumberOfProducts_LostFocus(object sender, RoutedEventArgs e)
{
bool isValid = ValidateNumberOfProductsInput();
if (!isValid)
return;
CalculateSubPrice();
}
private void Price_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Buy_Click(null,null);
}
else
{
CalculateSubPrice();
}
}
private void BuildEmployee()
{
DockProductGroup.Children.Clear();
//DockProduct.Children.Clear();
DockEmployee.Children.Clear();
bool firstEmployee = true;
foreach (EmployeeEntity employee in _employees)
{
Button btnEmp = new Button();
btnEmp.Style = (Style)FindResource("SaleButtons");
btnEmp.Content = employee.Name;
btnEmp.Tag = employee.Id;
btnEmp.Click += BtnEmp_Click;
DockEmployee.Children.Add(btnEmp);
if (firstEmployee)
{
firstEmployee = false;
btnEmp.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
}
}
}
private void BuildProductGroup()
{
DockProductGroup.Children.Clear();
foreach (ProductGroupEntity productGroup in _productGroups)
{
Button btnPrGr = new Button();
btnPrGr.Style = (Style)FindResource("SaleButtons");
btnPrGr.Content = productGroup.Name;
btnPrGr.Tag = productGroup.Id;
btnPrGr.Click += BtnPrGr_Click;
if (_employeeId == -1)
btnPrGr.IsEnabled = false;
DockProductGroup.Children.Add(btnPrGr);
}
}
private void BuildProducts(ICollection<ProductEntity> products)
{
// DockProduct.Children.Clear();
foreach (ProductEntity product in products)
{
Button btnProduct = new Button();
btnProduct.Style = (Style)FindResource("SaleButtons");
btnProduct.Content = product.Name;
btnProduct.Tag = product.Id;
btnProduct.Click += BtnProduct_Click;
// DockProduct.Children.Add(btnProduct);
}
}
private void BuildPrice(bool returnProduct)
{
PriceLineModel pModel = new PriceLineModel();
pModel.NumberProducts = _numberOfProducts;
pModel.Price = _price;
if (_selectedProduct != null)
{
pModel.Id = _selectedProduct.Id;
pModel.Name = _selectedProduct.Name;
pModel.IsProductGroup = false;
}
else
{
pModel.Id = _selectedProductGroup.Id;
pModel.Name = _selectedProductGroup.Name;
pModel.IsProductGroup = true;
}
BuildPriceDataGrid(pModel);
//BuildEmployee();
BuildProductGroup();
}
private void CalculateSubPrice()
{
_price = 0;
bool isValid = decimal.TryParse(Price.Text, out _price);
if (!isValid)
return;
isValid = Int32.TryParse(NumberOfProducts.Text, out _numberOfProducts);
if (!isValid)
return;
TotalPrice.Content = _price * _numberOfProducts;
}
private void CalculateTotalLine()
{
_totalPrice = 0;
foreach (PriceLineModel model in _priceLineModels)
{
_totalPrice += model.Price * model.NumberProducts;
}
Total.Content = $"At betale: Kr. {_totalPrice}";
}
private void BuildPriceDataGrid(PriceLineModel priceLineModel)
{
_selectedProduct = null;
_selectedProductGroup = null;
_numberOfProducts = 1;
_priceLineModels.Add(priceLineModel);
CalculateTotalLine();
SaleGridModel model = new SaleGridModel();
model.Navn = priceLineModel.Name;
model.Pris = $"kr. {priceLineModel.Price}";
model.Stk = $"- {priceLineModel.NumberProducts} stk. à";
model.Total = $"= Kr. {priceLineModel.NumberProducts * priceLineModel.Price}";
SaleGridInternalModel saleGridInternalModel = new SaleGridInternalModel();
saleGridInternalModel.InternPrice = priceLineModel.Price;
saleGridInternalModel.InternPieces = priceLineModel.NumberProducts;
model.SaleGridInternalModel = saleGridInternalModel;
//model.InternPrice = priceLineModel.Price;
//model.InternPieces = priceLineModel.NumberProducts;
_saleGridModels.Add(model);
}
private bool ValidateNumberOfProductsInput()
{
int notUsed;
bool isValid = Int32.TryParse(NumberOfProducts.Text, out notUsed);
if (!isValid)
{
MessageBox.Show($"{NumberOfProducts.Text} er ikke en gyldig værdi! \nSætter 1 som standard værdi ", "Ikke gyldig værdi",
MessageBoxButton.OK, MessageBoxImage.Error);
NumberOfProducts.Text = "1";
return false;
}
return true;
}
private bool ValidatePriceInput()
{
decimal p = 0;
bool isValid = Decimal.TryParse(Price.Text, out p);
if (!isValid)
{
string msg = "";
if (string.IsNullOrEmpty(Price.Text))
{
msg = "En tom pris er ikke en gyldig værdi!";
}
else
{
msg = $"{Price.Text} er ikke en gyldig pris!";
}
MessageBox.Show(msg, "Ugyldig pris", MessageBoxButton.OK,
MessageBoxImage.Error);
return false;
}
return true;
}
private bool ValidateAmountInput()
{
decimal p = 0;
bool isValid = Decimal.TryParse(Amount.Text, out p);
if (!isValid)
{
string msg = "";
if (string.IsNullOrEmpty(Amount.Text))
{
msg = "Et tomt beløb er ikke en gyldig værdi!";
}
else
{
msg = $"{Amount.Text} er ikke et gyldigt beløb!";
}
MessageBox.Show(msg, "Ugyldigt beløb", MessageBoxButton.OK,
MessageBoxImage.Error);
return false;
}
return true;
}
private void ManipulateBuySection()
{
bool enabled = _productGroupId > 0 || _productId > 0;
PricePanel.IsEnabled = enabled;
NumberOfProducts.IsEnabled = enabled;
Price.IsEnabled = enabled;
Price.Focus();
BtnBuy.IsEnabled = enabled;
LblStk.IsEnabled = enabled;
LblPrice.IsEnabled = enabled;
LblTotal.IsEnabled = enabled;
TotalPrice.IsEnabled = enabled;
}
private void BuildAmuntDataGrid(decimal amount, string paymentMethod)
{
if (amount == -1)
{
amount = 0;
foreach (PriceLineModel lineModel in _priceLineModels)
{
amount += (lineModel.Price * lineModel.NumberProducts);
}
}
AmountGridModel amountGridModel = new AmountGridModel();
amountGridModel.Amount = amount;
amountGridModel.AmountText = $"Kr. {amount}";
switch (paymentMethod)
{
case "PaymentMethod.Card":
amountGridModel.PaymentMethodText = "Kort";
break;
case "PaymentMethod.Cash":
amountGridModel.PaymentMethodText = "Kontant";
break;
case "PaymentMethod.GiftCard":
amountGridModel.PaymentMethodText = "Gavekort";
break;
case "PaymentMethod.MobilePay":
amountGridModel.PaymentMethodText = "MobilePay";
break;
}
_paymentGridModels.Add(amountGridModel);
AmountPayed();
}
private void AmountPayed()
{
decimal amountPayed = 0;
foreach (AmountGridModel paymentGridModel in _paymentGridModels)
{
amountPayed += paymentGridModel.Amount;
}
if (amountPayed == _totalPrice)
{
btnFinish_Click(null,null);
return;
}
if (amountPayed > _totalPrice)
{
lblRecived.Content = $"Byttepenge: Kr. {amountPayed - _totalPrice}";
Style style = this.FindResource("BoldLabelWarningNoMargin") as Style;
lblRecived.Style = style;
btnFinish.IsEnabled = true;
}
else
{
lblRecived.Content = $"At betale: Kr. {_totalPrice - amountPayed}";
Style style = this.FindResource("BoldLabelNoMargin") as Style;
lblRecived.Style = style;
}
}
private void SaleGrid_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete)
{
if (_selectedSaleGridIndex == -1)
return;
int index = _selectedSaleGridIndex;
//_saleGridModels.RemoveAt(_selectedSaleGridIndex);
_priceLineModels.RemoveAt(index);
_selectedSaleGridIndex = -1;
CalculateTotalLine();
}
}
private void btnFinish_Click(object sender, RoutedEventArgs e)
{
SaleService saleService = new SaleService();
saleService.Save(_saleGridModels.ToList(),_paymentGridModels.ToList(),_employeeId);
_paymentGridModels.Clear();
_priceLineModels.Clear();
UpdateWindowTitle();
_totalPrice = 0;
_saleGridModels.Clear();
lblRecived.Content = string.Empty;
_selectedSaleGridIndex = -1;
btnFinish.IsEnabled = false;
CalculateTotalLine();
BuildEmployee();
BuildProductGroup();
ManipulateBuySection();
}
private void BtnPrint_Click(object sender, RoutedEventArgs e)
{
SaleService saleService = new SaleService();
saleService.PrintReceipt();
}
private void UpdateWindowTitle()
{
SaleService saleService = new SaleService();
Title = saleService.LastAndTotalSale();
}
}
}

View File

@@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Database.Models;
using Database.Repository;
namespace Pos.Service
{
public static class CacheService
{
private static bool _invalidEmployee = false;
private static bool _invalidProductGroup = false;
private static List<EmployeeEntity> _employees;
private static List<ProductGroupEntity> _productGroups;
public static void Invalidate()
{
_invalidEmployee = true;
_invalidProductGroup = true;
}
public static ObservableCollection<EmployeeEntity> GetEmployee()
{
ObservableCollection<EmployeeEntity> obsEmployees = new ObservableCollection<EmployeeEntity>();
if (_invalidEmployee)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
_employees = employeeRepository.GetAll();
foreach (EmployeeEntity employee in _employees)
{
obsEmployees.Add(employee);
}
_invalidEmployee = false;
}
return obsEmployees;
}
public static ObservableCollection<ProductGroupEntity> GetProductGroupsIncludeProducts()
{
ObservableCollection<ProductGroupEntity> obsProductGroups = new ObservableCollection<ProductGroupEntity>();
if(_invalidProductGroup)
{
ProductGroupRepository productGroupRepository = new ProductGroupRepository();
_productGroups = productGroupRepository.GetAll();
_invalidProductGroup = false;
foreach (ProductGroupEntity productGroup in _productGroups)
{
obsProductGroups.Add(productGroup);
}
}
return obsProductGroups;
}
}
}

View File

@@ -0,0 +1,293 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Database.Models;
using Database.Repository;
using EpsonPrinter.Model;
using EpsonPrinter.Services;
using Microsoft.Extensions.Configuration;
using Pos.Json;
using Pos.Models;
using RestSharp;
using SixLabors.ImageSharp;
using BodyModel = Pos.Json.BodyModel;
using FooterModel = Pos.Json.FooterModel;
using HeaderModel = Pos.Json.HeaderModel;
namespace Pos.Service
{
public class SaleService
{
private float _totalPrice = 0;
private SaleRepository _saleRepository = new SaleRepository();
public void Save(List<SaleGridModel> saleGridModels, List<AmountGridModel> amountGridModels, int employeeNo)
{
SaleRepository saleRepository = new SaleRepository();
SaleEntity saleEntity = saleRepository.New(employeeNo);
foreach (SaleGridModel model in saleGridModels)
{
if(String.IsNullOrEmpty(model.Navn))
continue;
SaleLineEntity saleLineEntity = new SaleLineEntity();
saleLineEntity.SaleId = saleEntity.Id;
saleLineEntity.Price = model.SaleGridInternalModel.InternPrice;
saleLineEntity.Product = model.Navn;
saleLineEntity.Pieces = model.SaleGridInternalModel.InternPieces;
saleLineEntity.Total = saleLineEntity.Pieces * saleLineEntity.Price;
saleRepository.SaveSaleLine(saleLineEntity);
}
foreach (AmountGridModel model in amountGridModels)
{
PaymentEntity payment = new PaymentEntity();
payment.Amount = model.Amount;
payment.Type = model.PaymentMethodText;
payment.SaleId = saleEntity.Id;
saleRepository.SavePayment(payment);
}
}
public void PrintReceipt()
{
SaleEntity sale = _saleRepository.GetLatest();
if (sale == null)
return;
BuildSaleReceipt(sale);
}
public void PrintReceipt(int saleId)
{
SaleEntity sale = _saleRepository.Get(saleId);
BuildSaleReceipt(sale);
}
public void PrintSaleOfDay(DateTime selectedDate, TotalSaleDetail totalSaleDetail)
{
SaleOfDayModel saleOfDayModel = new SaleOfDayModel();
saleOfDayModel.Date = selectedDate;
saleOfDayModel.TotalSale = totalSaleDetail.TotalSale;
saleOfDayModel.TotalCustomers = totalSaleDetail.TotalCustomer;
foreach (TotalSaleCategory category in totalSaleDetail.TotalSaleCategories)
{
SaleOfDayDetail saleOfDayDetail = new SaleOfDayDetail();
saleOfDayDetail.TotalSale = category.Sale;
saleOfDayDetail.Category = category.Category;
saleOfDayModel.SaleOfDayDetail.Add(saleOfDayDetail);
}
LoadConfig loadConfig = new LoadConfig();
IConfiguration config = loadConfig.ByEnvironment();
string url = config["API:URL"];
RestClient restClient = new RestClient($"{url}/api/PosPrinter/SaleOfDay");
RestRequest request = new RestRequest();
request.AddJsonBody(saleOfDayModel);
request.Method = Method.Post;
restClient.Post(request);
}
public TotalSaleDetail TotalSale(DateTime selectedDate)
{
List<SaleEntity> sales = _saleRepository.GetByDateRange(selectedDate);
TotalSaleDetail totalSaleDetail = new TotalSaleDetail();
totalSaleDetail.TotalCustomer = sales.Count;
foreach (SaleEntity sale in sales)
{
List<SaleLineEntity> saleLineBySaleId = _saleRepository.GetSaleLineBySaleId(sale.Id);
foreach (SaleLineEntity saleLine in saleLineBySaleId)
{
if (totalSaleDetail.TotalSaleCategories.Any(c => c.Category.Contains(saleLine.Product)))
{
TotalSaleCategory totalSaleCategory = totalSaleDetail.TotalSaleCategories.Single(c => c.Category.Contains(saleLine.Product));
totalSaleCategory.Sale += saleLine.Total;
totalSaleCategory.SaleString = "Kr. " + totalSaleCategory.Sale.ToString("0.00");
}
else
{
TotalSaleCategory totalSaleCategory = new TotalSaleCategory();
totalSaleCategory.Sale = saleLine.Total;
totalSaleCategory.SaleString ="Kr. " + totalSaleCategory.Sale.ToString("0.00");
totalSaleCategory.Category = saleLine.Product;
totalSaleDetail.TotalSaleCategories.Add(totalSaleCategory);
}
totalSaleDetail.TotalSale += saleLine.Total;
}
}
return totalSaleDetail;
}
public string LastAndTotalSale()
{
SaleEntity saleEntity = _saleRepository.GetLatest();
List<SaleLineEntity> saleLineBySaleId = _saleRepository.GetSaleLineBySaleId(saleEntity.Id);
decimal lastSale = 0;
foreach (SaleLineEntity saleLine in saleLineBySaleId)
{
lastSale += saleLine.Total;
}
TotalSaleDetail totalSale = TotalSale(DateTime.Now);
string todaySale = $"Sidste salg: kr. {lastSale.ToString("N")} - Dagens salg: kr. {totalSale.TotalSale.ToString("N")}";
return todaySale;
}
private void BuildSaleReceipt(SaleEntity sale)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
EmployeeEntity employee = employeeRepository.Get(sale.EmployeeId);
List<SaleLineEntity> salesLines = _saleRepository.GetSaleLineBySaleId(sale.Id);
List<PaymentEntity> payments = _saleRepository.GetPaymentBySaleId(sale.Id);
PosReceipt posReceipt = new PosReceipt();
posReceipt.header = BuildReceiptHeader().ToArray();
ProductModel[] productModels = BuildSaleLines(salesLines).ToArray();
posReceipt.bodyModel = BuildBody(sale, employee.Name);
posReceipt.bodyModel.products = productModels;
posReceipt.footer = BuildFooter().ToArray();
posReceipt.logoBase64 = String.Empty;
LoadConfig loadConfig = new LoadConfig();
IConfiguration config = loadConfig.ByEnvironment();
string url = $"{config["API:URL"]}/api/PosPrinter/Receipt";
RestClient restClient = new RestClient(url);
RestRequest request = new RestRequest();
request.AddJsonBody(posReceipt);
request.Method = Method.Post;
restClient.Post(request);
}
private List<FooterModel> BuildFooter()
{
List<FooterModel> footerModels = new List<FooterModel>();
FooterModel model = new FooterModel();
model.value = "Tak for handlen";
model.printStyles = new PrintStylesModel
{
bold = false,
fontB = false,
doubleHeight = false,
doubleWidth = false,
underline = false
};
model.feedingLines = 0;
model.textAlignment = 0;
footerModels.Add(model);
return footerModels;
}
private List<ProductModel> BuildSaleLines(List<SaleLineEntity> salesLines)
{
List<ProductModel> products = new List<ProductModel>();
foreach (SaleLineEntity salesLine in salesLines)
{
ProductModel productModel = new ProductModel();
productModel.noOfProduct = salesLine.Pieces.ToString();
productModel.price = (float)salesLine.Price;
productModel.totalPrice = salesLine.Pieces * productModel.price;
_totalPrice += productModel.totalPrice;
productModel.product = salesLine.Product;
products.Add(productModel);
}
return products;
}
private BodyModel BuildBody(SaleEntity sale, string employeeName)
{
BodyModel body = new BodyModel
{
receiptNumber = sale.Id,
receiptTime = sale.Time.ToString("HH:mm dd-MM-yyyy"),
staff = employeeName,
totalPrice = _totalPrice,
totalVat = (_totalPrice / 100) * 25
};
return body;
}
private List<HeaderModel> BuildReceiptHeader()
{
List<HeaderModel> headerModels = new List<HeaderModel>();
HeaderModel headerModel = new HeaderModel
{
feedingLines = 1,
textAlignment = 1,
value = "Blomster Til Alt"
};
PrintStylesModel printStylesModel = new PrintStylesModel
{
bold = true,
fontB = false,
doubleHeight = true,
doubleWidth = true,
underline = false
};
headerModel.printStyles = printStylesModel;
headerModels.Add(headerModel);
printStylesModel = new PrintStylesModel
{
bold = false,
fontB = false,
doubleHeight = false,
doubleWidth = false,
underline = false
};
headerModel = new HeaderModel
{
feedingLines = 0,
textAlignment = 1,
value = "Adelgade 91",
printStyles = printStylesModel
};
headerModels.Add(headerModel);
headerModel = new HeaderModel
{
feedingLines = 0,
textAlignment = 1,
value = "5400 Bogense",
printStyles = printStylesModel
};
headerModels.Add(headerModel);
headerModel = new HeaderModel
{
feedingLines = 0,
textAlignment = 1,
value = "Tlf: 41 82 71 66",
printStyles = printStylesModel
};
headerModels.Add(headerModel);
headerModel = new HeaderModel
{
feedingLines = 0,
textAlignment = 1,
value = "CVR: 37 14 44 36",
printStyles = printStylesModel
};
headerModels.Add(headerModel);
return headerModels;
}
}
}

View File

@@ -0,0 +1,13 @@
<Window x:Class="Pos.Setting.AddEmployeeWindow"
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:Pos.Setting"
mc:Ignorable="d"
Title="Tilføj medarbejder" Height="150" Width="200" Icon="../../Icons/employees.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBox Name="txtStaff" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Ret" Name="btnAdd" Style="{StaticResource Buttons}" Click="btnAdd_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,35 @@
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 Database.Repository;
namespace Pos.Setting
{
/// <summary>
/// Interaction logic for AddEmployeeWindow.xaml
/// </summary>
public partial class AddEmployeeWindow : Window
{
public AddEmployeeWindow()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
employeeRepository.Add(txtStaff.Text);
this.Close();
}
}
}

View File

@@ -0,0 +1,15 @@
<Window x:Class="Pos.Setting.DeleteEmployeeWindow"
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:Pos.Setting"
mc:Ignorable="d"
Title="Arkivere medarbejder" Height="300" Width="300" Icon="../../Icons/employee.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBlock Text="Ønsker du at arkivere:" Style="{StaticResource TextBox}"/>
<TextBlock Name="txtDelEmployee" Style="{StaticResource TextBox}" Foreground="Red" FontWeight="ExtraBold" />
<Button Content="Ja" Name="btnYes" Style="{StaticResource Buttons}" Margin="10,10,10,30" Click="btnYes_Click"></Button>
<Button Content="Nej" Name="btnNo" Style="{StaticResource Buttons}" Click="btnNo_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,44 @@
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 Database.Repository;
namespace Pos.Setting
{
/// <summary>
/// Interaction logic for DeleteEmployeeWindow.xaml
/// </summary>
public partial class DeleteEmployeeWindow : Window
{
private int _employeeId;
public DeleteEmployeeWindow(int employeeId, string staffName)
{
InitializeComponent();
_employeeId = employeeId;
txtDelEmployee.Text = staffName;
}
private void btnYes_Click(object sender, RoutedEventArgs e)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
employeeRepository.Delete(_employeeId);
this.Close();
}
private void btnNo_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,13 @@
<Window x:Class="Pos.Setting.EditEmployeeWindow"
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:Pos.Setting"
mc:Ignorable="d"
Title="Ret medarbejder" Height="150" Width="200" Icon="../../Icons/employee.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBox Name="txtEmployee" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Ret" Name="btnEdit" Style="{StaticResource Buttons}" Click="btnEdit_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,39 @@
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 Database.Repository;
namespace Pos.Setting
{
/// <summary>
/// Interaction logic for EditEmployeeWindow.xaml
/// </summary>
public partial class EditEmployeeWindow : Window
{
private int _employeeId;
public EditEmployeeWindow(int employeeId, string staffName)
{
_employeeId = employeeId;
InitializeComponent();
txtEmployee.Text = staffName;
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
employeeRepository.Edit(_employeeId,txtEmployee.Text);
this.Close();
}
}
}

View File

@@ -0,0 +1,22 @@
<Window x:Class="Pos.Setting.EmployeeWindow"
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:Pos.Setting"
mc:Ignorable="d"
Title="Medarbejder" Height="400" Width="450" Icon="../../Icons/employees.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox Name="LstStaff" Grid.Row="0" Grid.Column="0" Style="{StaticResource ListBox}">
</ListBox>
<StackPanel Grid.Row="0" Grid.Column="1">
<Button Content="Opret" Style="{StaticResource Buttons}" Name="btnCreate" Click="btnCreate_Click" />
<Button Content="Redigere" Style="{StaticResource Buttons}" Name="btnEdit" IsEnabled="False" Click="btnEdit_Click" />
<Button Content="Arkivere" Style="{StaticResource Buttons}" Name="btnDelete" IsEnabled="False" Click="btnDelete_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Database.Models;
using Database.Repository;
namespace Pos.Setting
{
/// <summary>
/// Interaction logic for EmployeeWindow.xaml
/// </summary>
public partial class EmployeeWindow : Window
{
private int _selectedEmployee = -1;
private string _employeeName = string.Empty;
public EmployeeWindow()
{
InitializeComponent();
LoadData();
}
private void Item_Selected(object sender, RoutedEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
_selectedEmployee = Convert.ToInt32(item.Tag);
_employeeName = item.Content.ToString();
btnDelete.IsEnabled = true;
btnEdit.IsEnabled = true;
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
EditEmployeeWindow editEmployeeWindow = new EditEmployeeWindow(_selectedEmployee, _employeeName);
editEmployeeWindow.Closed += WindowClosed;
editEmployeeWindow.Show();
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
AddEmployeeWindow addEmployeeWindow = new AddEmployeeWindow();
addEmployeeWindow.Closed += WindowClosed;
addEmployeeWindow.Show();
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
DeleteEmployeeWindow deleteEmployeeWindow = new DeleteEmployeeWindow(_selectedEmployee,_employeeName);
deleteEmployeeWindow.Closed += WindowClosed;
deleteEmployeeWindow.Show();
}
private void WindowClosed(object? sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
using EmployeeRepository employeeRepository = new EmployeeRepository();
List<EmployeeEntity> allStaff = employeeRepository.GetAll();
LstStaff.Items.Clear();
foreach (EmployeeEntity staff in allStaff)
{
ListBoxItem item = new ListBoxItem();
item.Content = staff.Name;
item.Tag = staff.Id;
item.Selected += Item_Selected;
LstStaff.Items.Add(item);
}
}
}
}

View File

@@ -0,0 +1,14 @@
<Window x:Class="Pos.Setting.ProductGroup.AddProductWindow"
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:Pos.Setting.ProductGroup"
mc:Ignorable="d"
Title="Tilføj vare" Height="220" Width="200" Icon="../../Icons/product.png">
<StackPanel HorizontalAlignment="Stretch" >
<ComboBox Name="cmbProductGroup" Style="{StaticResource ComboBox}" />
<TextBox Name="txtProduct" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Opret" Name="btnAdd" Style="{StaticResource Buttons}" Click="btnAdd_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,45 @@
using Database.Repository;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace Pos.Setting.ProductGroup
{
/// <summary>
/// Interaction logic for AddProductWindow.xaml
/// </summary>
public partial class AddProductWindow : Window
{
public AddProductWindow()
{
InitializeComponent();
LoadData(0);
}
private void LoadData(int selectedIndex)
{
ProductGroupRepository productGroupRepository = new ProductGroupRepository();
List<Database.Models.ProductGroupEntity> products = productGroupRepository.GetAll();
foreach (Database.Models.ProductGroupEntity productGroup in products)
{
ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.Tag = productGroup.Id;
comboBoxItem.Content = productGroup.Name;
cmbProductGroup.Items.Add(comboBoxItem);
}
cmbProductGroup.SelectedIndex = selectedIndex;
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
ComboBoxItem item = (ComboBoxItem) cmbProductGroup.SelectedItem;
string name = txtProduct.Text;
int id = Convert.ToInt32(item.Tag);
ProductRepository productRepository = new ProductRepository();
productRepository.Add(name,id);
this.Close();
}
}
}

View File

@@ -0,0 +1,15 @@
<Window x:Class="Pos.Setting.Product.ArchiveProductWindow"
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:Pos.Setting.Product"
mc:Ignorable="d"
Title="Arkivere vare" Height="300" Width="300" Icon="../../Icons/product.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBlock Text="Ønsker du at arkivere:" Style="{StaticResource TextBox}"/>
<TextBlock Name="txtDelProduct" Style="{StaticResource TextBox}" Foreground="Red" FontWeight="ExtraBold" />
<Button Content="Ja" Name="btnYes" Style="{StaticResource Buttons}" Margin="10,10,10,30" Click="btnYes_Click"></Button>
<Button Content="Nej" Name="btnNo" Style="{StaticResource Buttons}" Click="btnNo_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,45 @@
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 Database.Repository;
namespace Pos.Setting.Product
{
/// <summary>
/// Interaction logic for ArchiveProductWindow.xaml
/// </summary>
public partial class ArchiveProductWindow : Window
{
private int _productId;
public ArchiveProductWindow(int productId)
{
InitializeComponent();
_productId = productId;
ProductRepository productRepository = new ProductRepository();
Database.Models.ProductEntity product = productRepository.GetById(_productId);
txtDelProduct.Text = product.Name;
}
private void btnYes_Click(object sender, RoutedEventArgs e)
{
ProductRepository productRepository = new ProductRepository();
productRepository.Archive(_productId);
this.Close();
}
private void btnNo_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,14 @@
<Window x:Class="Pos.Setting.Product.ChangeProductOrderWindow"
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:Pos.Setting.Product"
mc:Ignorable="d"
Title="Rækkefølge" Height="450" Width="300" Icon="../../Icons/settings.png">
<DockPanel>
<ListBox Name="lstProduct" Style="{StaticResource ListBox}" DockPanel.Dock="Top" >
</ListBox>
<Button Style="{StaticResource Buttons}" Name="btnSave" Content="Gem rækkefølge" VerticalAlignment="Bottom" Click="btnSave_Click"></Button>
</DockPanel>
</Window>

View File

@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 Database.Repository;
namespace Pos.Setting.Product
{
/// <summary>
/// Interaction logic for ChangeProductOrderWindow.xaml
/// </summary>
public partial class ChangeProductOrderWindow : Window
{
ObservableCollection<Database.Models.ProductEntity> _productList = new ObservableCollection<Database.Models.ProductEntity>();
private int _productGroupId;
public ChangeProductOrderWindow(int productGroupId)
{
InitializeComponent();
_productGroupId = productGroupId;
LoadData();
}
private void LoadData()
{
ProductRepository productRepository = new ProductRepository();
List<Database.Models.ProductEntity> products = productRepository.GetByProductGroup(_productGroupId);
foreach (Database.Models.ProductEntity product in products)
{
_productList.Add(product);
}
lstProduct.Items.Clear();
lstProduct.DisplayMemberPath = "Name";
lstProduct.ItemsSource = _productList;
Style itemContainerStyle = new Style(typeof(ListBoxItem));
itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(s_PreviewMouseLeftButtonDown)));
itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent, new DragEventHandler(lstCategory_Drop)));
lstProduct.ItemContainerStyle = itemContainerStyle;
}
void s_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is ListBoxItem)
{
ListBoxItem draggedItem = sender as ListBoxItem;
DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move);
draggedItem.IsSelected = true;
}
}
void lstCategory_Drop(object sender, DragEventArgs e)
{
Database.Models.ProductEntity droppedData = e.Data.GetData(typeof(Database.Models.ProductEntity)) as Database.Models.ProductEntity;
Database.Models.ProductEntity target = ((ListBoxItem)(sender)).DataContext as Database.Models.ProductEntity;
int removedIdx = lstProduct.Items.IndexOf(droppedData);
int targetIdx = lstProduct.Items.IndexOf(target);
if (removedIdx < targetIdx)
{
_productList.Insert(targetIdx + 1, droppedData);
_productList.RemoveAt(removedIdx);
}
else
{
int remIdx = removedIdx + 1;
if (_productList.Count + 1 > remIdx)
{
_productList.Insert(targetIdx, droppedData);
_productList.RemoveAt(remIdx);
}
}
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
ProductRepository productRepository = new ProductRepository();
for (int i = 0; i < _productList.Count; i++)
{
Database.Models.ProductEntity product = _productList[i];
productRepository.SetIndex(product.Id, i);
}
this.Close();
}
}
}

View File

@@ -0,0 +1,14 @@
<Window x:Class="Pos.Setting.Product.EditProductWindow"
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:Pos.Setting.Product"
mc:Ignorable="d"
Title="Ret vare" Height="220" Width="200" Icon="../../Icons/product.png">
<StackPanel HorizontalAlignment="Stretch" >
<ComboBox Name="cmbProductGroup" Style="{StaticResource ComboBox}" />
<TextBox Name="txtProduct" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Ret" Name="btnEdit" Style="{StaticResource Buttons}" Click="btnEdit_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,62 @@
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 Database.Repository;
namespace Pos.Setting.Product
{
/// <summary>
/// Interaction logic for EditProductWindow.xaml
/// </summary>
public partial class EditProductWindow : Window
{
private int _productId;
private int _selectedProductGroupId;
private Database.Models.ProductEntity _product;
public EditProductWindow(int productId, int selectedProductGroupId)
{
InitializeComponent();
_productId = productId;
_selectedProductGroupId = selectedProductGroupId;
Init();
}
private void Init()
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
List<Database.Models.ProductGroupEntity> productGroups = categoryRepository.GetAll();
foreach (Database.Models.ProductGroupEntity productGroup in productGroups)
{
ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.Tag = productGroup.Id;
comboBoxItem.Content = productGroup.Name;
cmbProductGroup.Items.Add(comboBoxItem);
}
cmbProductGroup.SelectedIndex = _selectedProductGroupId;
ProductRepository productRepository = new ProductRepository();
_product = productRepository.GetById(_productId);
txtProduct.Text = _product.Name;
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
ComboBoxItem item = (ComboBoxItem)cmbProductGroup.SelectedItem;
ProductRepository productRepository = new ProductRepository();
productRepository.Update(_product.Id,(int)item.Tag,txtProduct.Text);
this.Close();
}
}
}

View File

@@ -0,0 +1,26 @@
<Window x:Class="Pos.Setting.ProductGroup.ProductWindow"
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:Pos.Setting.ProductGroup"
mc:Ignorable="d"
Icon="../../Icons/product.png"
Title="Produkt grupper" Height="600" Width="450">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox Name="lstProductGroup" Grid.Row="0" Grid.Column="0" Style="{StaticResource ListBox}" SelectionChanged="LstProductGroup_SelectionChanged">
</ListBox>
<StackPanel Grid.Row="0" Grid.Column="1">
<ComboBox Name="cmbCat" Style="{StaticResource ComboBox}" SelectionChanged="cmbCat_SelectionChanged"/>
<Button Content="Opret" Style="{StaticResource Buttons}" Name="btnCreate" Click="btnCreate_Click"/>
<Button Content="Redigere" Style="{StaticResource Buttons}" Name="btnEdit" IsEnabled="False" Click="btnEdit_Click"/>
<Button Content="Arkivere" Style="{StaticResource Buttons}" Name="btnDelete" IsEnabled="False" Click="btnDelete_Click"/>
<Button Content="Rækkefølge" Style="{StaticResource Buttons}" Name="btnOrder" Click="btnOrder_Click"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using Database.Repository;
using Pos.Setting.Product;
namespace Pos.Setting.ProductGroup
{
/// <summary>
/// Interaction logic for ProductWindow.xaml
/// </summary>
public partial class ProductWindow : Window
{
private List<Database.Models.ProductGroupEntity> _productGroups;
private int _productId;
public ProductWindow()
{
InitializeComponent();
Init();
LoadData();
}
private void Init()
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
_productGroups = categoryRepository.GetAll();
cmbCat.Items.Clear();
foreach (Database.Models.ProductGroupEntity productGroup in _productGroups)
{
ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.Tag = productGroup.Id;
comboBoxItem.Content = productGroup.Name;
cmbCat.Items.Add(comboBoxItem);
}
cmbCat.SelectedIndex = 0;
}
private void LoadData()
{
ProductRepository productRepository = new ProductRepository();
List<Database.Models.ProductEntity> products = productRepository.GetByProductGroup(_productGroups[cmbCat.SelectedIndex].Id);
lstProductGroup.Items.Clear();
foreach (Database.Models.ProductEntity product in products)
{
ListBoxItem item = new ListBoxItem();
item.Content = product.Name;
item.Tag = product.Id;
lstProductGroup.Items.Add(item);
}
btnEdit.IsEnabled = false;
btnDelete.IsEnabled = false;
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
AddProductWindow addProductWindow = new AddProductWindow();
addProductWindow.Closed += AddProductWindow_Closed;
addProductWindow.Show();
}
private void AddProductWindow_Closed(object sender, EventArgs e)
{
LoadData();
}
private void cmbCat_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LoadData();
}
private void LstProductGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
btnEdit.IsEnabled = true;
btnDelete.IsEnabled = true;
//ListBoxItem item = (ListBoxItem)sender;
//_productId = (int)item.Tag;
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
ListBoxItem selectedItem = lstProductGroup.SelectedItem as ListBoxItem;
EditProductWindow editProductWindow = new EditProductWindow((int)selectedItem.Tag, cmbCat.SelectedIndex);
editProductWindow.Closed += EditProductWindow_Closed;
editProductWindow.Show();
}
private void EditProductWindow_Closed(object sender, EventArgs e)
{
LoadData();
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
ListBoxItem selectedItem = lstProductGroup.SelectedItem as ListBoxItem;
ArchiveProductWindow archiveProductWindow = new ArchiveProductWindow((int)selectedItem.Tag);
archiveProductWindow.Closed += ArchiveProductWindow_Closed;
archiveProductWindow.Show();
}
private void ArchiveProductWindow_Closed(object sender, EventArgs e)
{
LoadData();
}
private void btnOrder_Click(object sender, RoutedEventArgs e)
{
ChangeProductOrderWindow changeProductOrderWindow = new ChangeProductOrderWindow(_productGroups[cmbCat.SelectedIndex].Id);
changeProductOrderWindow.Closed += ChangeProductOrderWindow_Closed;
changeProductOrderWindow.Show();
}
private void ChangeProductOrderWindow_Closed(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@@ -0,0 +1,13 @@
<Window x:Class="Pos.Setting.Category.AddProductGroupWindow"
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:Pos.Setting.Category"
mc:Ignorable="d"
Title="Tilføj varegruppe" Height="150" Width="200" Icon="../../Icons/category.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBox Name="txtProductGroup" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Opret" Name="btnAdd" Style="{StaticResource Buttons}" Click="btnAdd_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,35 @@
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 Database.Repository;
namespace Pos.Setting.Category
{
/// <summary>
/// Interaction logic for AddProductGroupWindow.xaml
/// </summary>
public partial class AddProductGroupWindow : Window
{
public AddProductGroupWindow()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
categoryRepository.Add(txtProductGroup.Text);
this.Close();
}
}
}

View File

@@ -0,0 +1,15 @@
<Window x:Class="Pos.Setting.Category.ArchiveProductGroupWindow"
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:Pos.Setting.Category"
mc:Ignorable="d"
Title="Arkivere varegruppe" Height="300" Width="300" Icon="../../Icons/category.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBlock Text="Ønsker du at arkivere:" Style="{StaticResource TextBox}"/>
<TextBlock Name="txtDelProductGroup" Style="{StaticResource TextBox}" Foreground="Red" FontWeight="ExtraBold" />
<Button Content="Ja" Name="btnYes" Style="{StaticResource Buttons}" Margin="10,10,10,30" Click="btnYes_Click"></Button>
<Button Content="Nej" Name="btnNo" Style="{StaticResource Buttons}" Click="btnNo_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,44 @@
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 Database.Repository;
namespace Pos.Setting.Category
{
/// <summary>
/// Interaction logic for ArchiveProductGroupWindow.xaml
/// </summary>
public partial class ArchiveProductGroupWindow : Window
{
private readonly int _id;
public ArchiveProductGroupWindow(string name, int id)
{
InitializeComponent();
_id = id;
txtDelProductGroup.Text = name;
}
private void btnNo_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btnYes_Click(object sender, RoutedEventArgs e)
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
categoryRepository.Archive(_id);
this.Close();
}
}
}

View File

@@ -0,0 +1,14 @@
<Window x:Class="Pos.Setting.Category.ChangeProductGroupOrderWindow"
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:Pos.Setting.Category"
mc:Ignorable="d"
Title="Rækkefølge" Height="450" Width="300" Icon="../../Icons/settings.png">
<DockPanel>
<ListBox Name="lstCategory" Style="{StaticResource ListBox}" DockPanel.Dock="Top" >
</ListBox>
<Button Style="{StaticResource Buttons}" Name="btnSave" Content="Gem rækkefølge" VerticalAlignment="Bottom" Click="btnSave_Click"></Button>
</DockPanel>
</Window>

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 Database.Repository;
namespace Pos.Setting.Category
{
/// <summary>
/// Interaction logic for ChangeProductGroupOrderWindow.xaml
/// </summary>
public partial class ChangeProductGroupOrderWindow : Window
{
ObservableCollection<Database.Models.ProductGroupEntity> _prodGroupList = new ObservableCollection<Database.Models.ProductGroupEntity>();
public ChangeProductGroupOrderWindow()
{
InitializeComponent();
LoadData();
}
private void LoadData()
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
List<Database.Models.ProductGroupEntity> categories = categoryRepository.GetAll();
foreach (Database.Models.ProductGroupEntity category in categories)
{
_prodGroupList.Add(category);
}
lstCategory.Items.Clear();
lstCategory.DisplayMemberPath = "Name";
lstCategory.ItemsSource = _prodGroupList;
Style itemContainerStyle = new Style(typeof(ListBoxItem));
itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));
itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(s_PreviewMouseLeftButtonDown)));
itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent, new DragEventHandler(lstCategory_Drop)));
lstCategory.ItemContainerStyle = itemContainerStyle;
}
void s_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is ListBoxItem)
{
ListBoxItem draggedItem = sender as ListBoxItem;
DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move);
draggedItem.IsSelected = true;
}
}
void lstCategory_Drop(object sender, DragEventArgs e)
{
Database.Models.ProductGroupEntity droppedData = e.Data.GetData(typeof(Database.Models.ProductGroupEntity)) as Database.Models.ProductGroupEntity;
Database.Models.ProductGroupEntity target = ((ListBoxItem)(sender)).DataContext as Database.Models.ProductGroupEntity;
int removedIdx = lstCategory.Items.IndexOf(droppedData);
int targetIdx = lstCategory.Items.IndexOf(target);
if (removedIdx < targetIdx)
{
_prodGroupList.Insert(targetIdx + 1, droppedData);
_prodGroupList.RemoveAt(removedIdx);
}
else
{
int remIdx = removedIdx + 1;
if (_prodGroupList.Count + 1 > remIdx)
{
_prodGroupList.Insert(targetIdx, droppedData);
_prodGroupList.RemoveAt(remIdx);
}
}
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
for (int i = 0; i < _prodGroupList.Count; i++)
{
Database.Models.ProductGroupEntity productGroup = _prodGroupList[i];
categoryRepository.SetIndex(productGroup.Id,i);
}
this.Close();
}
}
}

View File

@@ -0,0 +1,13 @@
<Window x:Class="Pos.Setting.Category.EditProductGroupWindow"
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:Pos.Setting.Category"
mc:Ignorable="d"
Title="Ret varegruppe" Height="150" Width="200" Icon="../../Icons/category.png">
<StackPanel HorizontalAlignment="Stretch" >
<TextBox Name="txtProductGroup" Style="{StaticResource TextBox}"></TextBox>
<Button Content="Ret" Name="btnEdit" Style="{StaticResource Buttons}" Click="btnEdit_Click"></Button>
</StackPanel>
</Window>

View File

@@ -0,0 +1,39 @@
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 Database.Repository;
namespace Pos.Setting.Category
{
/// <summary>
/// Interaction logic for EditProductGroupWindow.xaml
/// </summary>
public partial class EditProductGroupWindow : Window
{
private readonly int _id;
public EditProductGroupWindow(string name, int id)
{
InitializeComponent();
_id = id;
txtProductGroup.Text = name;
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
categoryRepository.Edit(txtProductGroup.Text,_id);
this.Close();
}
}
}

View File

@@ -0,0 +1,23 @@
<Window x:Class="Pos.Category.ProductGroupWindow"
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:Pos.Category"
mc:Ignorable="d"
Title="Varegrupper" Height="400" Width="450" Icon="../../Icons/category.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox Name="LstCategory" Grid.Row="0" Grid.Column="0" Style="{StaticResource ListBox}">
</ListBox>
<StackPanel Grid.Row="0" Grid.Column="1">
<Button Content="Opret" Style="{StaticResource Buttons}" Name="btnCreate" Click="btnCreate_Click"/>
<Button Content="Redigere" Style="{StaticResource Buttons}" Name="btnEdit" IsEnabled="False" Click="btnEdit_Click"/>
<Button Content="Arkivere" Style="{StaticResource Buttons}" Name="btnDelete" IsEnabled="False" Click="btnDelete_Click"/>
<Button Content="Rækkefølge" Style="{StaticResource Buttons}" Name="btnOrder" Click="btnOrder_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,92 @@
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 Database.Repository;
using Pos.Setting.Category;
namespace Pos.Category
{
/// <summary>
/// Interaction logic for ProductGroupWindow.xaml
/// </summary>
public partial class ProductGroupWindow : Window
{
private int _id = -1;
private string _name = string.Empty;
public ProductGroupWindow()
{
InitializeComponent();
LoadData();
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
AddProductGroupWindow addProductGroupWindow = new AddProductGroupWindow();
addProductGroupWindow.Closed += WindowClosed;
addProductGroupWindow.Show();
}
private void WindowClosed(object sender, EventArgs e)
{
LoadData();
}
private void ItemOnSelected(object sender, RoutedEventArgs e)
{
ListBoxItem item = (ListBoxItem)sender;
_id = Convert.ToInt32(item.Tag);
_name = item.Content.ToString();
btnDelete.IsEnabled = true;
btnEdit.IsEnabled = true;
}
private void LoadData()
{
ProductGroupRepository categoryRepository = new ProductGroupRepository();
List<Database.Models.ProductGroupEntity> categories = categoryRepository.GetAll();
LstCategory.Items.Clear();
foreach (Database.Models.ProductGroupEntity category in categories)
{
ListBoxItem item = new ListBoxItem();
item.Tag = category.Id;
item.Content = category.Name;
item.Selected += ItemOnSelected;
LstCategory.Items.Add(item);
}
}
private void btnEdit_Click(object sender, RoutedEventArgs e)
{
EditProductGroupWindow editProductGroupWindow = new EditProductGroupWindow(_name,_id);
editProductGroupWindow.Closed += WindowClosed;
editProductGroupWindow.Show();
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
ArchiveProductGroupWindow archiveProductGroupWindow = new ArchiveProductGroupWindow(_name, _id);
archiveProductGroupWindow.Closed += WindowClosed;
archiveProductGroupWindow.Show();
}
private void btnOrder_Click(object sender, RoutedEventArgs e)
{
ChangeProductGroupOrderWindow changeProductGroupOrderWindow = new ChangeProductGroupOrderWindow();
changeProductGroupOrderWindow.Closed += WindowClosed;
changeProductGroupOrderWindow.Show();
}
}
}

View File

@@ -0,0 +1,14 @@
<Window x:Class="Pos.Setting.SettingWindow"
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:Pos.Setting"
mc:Ignorable="d"
Title="Indstillinger" Height="450" Width="800" Icon="../Icons/settings.png">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Style="{StaticResource MenuButtons}" x:Name="btnClerks" Content="Medarbejder" Click="btnClerks_Click"/>
<Button Style="{StaticResource MenuButtons}" x:Name="btnCategories" Content="Varegrupper" Click="btnCategories_Click" />
<!--<Button Style="{StaticResource MenuButtons}" x:Name="btnProductGroups" Content="Varer" Click="btnProductGroups_Click" />-->
</WrapPanel>
</Window>

View File

@@ -0,0 +1,60 @@
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 Database.Repository;
using Pos.Category;
using Pos.Setting.ProductGroup;
namespace Pos.Setting
{
/// <summary>
/// Interaction logic for SettingWindow.xaml
/// </summary>
public partial class SettingWindow : Window
{
public SettingWindow()
{
InitializeComponent();
}
private void btnClerks_Click(object sender, RoutedEventArgs e)
{
EmployeeWindow employeeWindow = new EmployeeWindow();
employeeWindow.Show();
}
private void btnCategories_Click(object sender, RoutedEventArgs e)
{
ProductGroupWindow productGroupWindow = new ProductGroupWindow();
productGroupWindow.Show();
}
private void btnProductGroups_Click(object sender, RoutedEventArgs e)
{
ProductWindow productWindow = new ProductWindow();
//Check if there is any categories, if not close this window with a message.
ProductGroupRepository categoryRepository = new ProductGroupRepository();
bool anyExist = categoryRepository.Any();
if (!anyExist)
{
MessageBox.Show("Der er ingen kategorier, opret dem først", "Kategorier", MessageBoxButton.OK,
MessageBoxImage.Warning);
}
else
{
productWindow.Show();
}
}
}
}

View File

@@ -0,0 +1,11 @@
{
"MariaSqlServer": "Data Source=localhost;Initial Catalog=PointOfSale;Persist Security Info=False;User ID=root;Password=Maxbp6703",
"PrintSettings": {
"ComPort": "COM5",
"BaudRate": 115200,
"PrintWidth": 48
},
"API": {
"Url": "https://localhost:44334"
}
}

View File

@@ -0,0 +1,11 @@
{
"MariaSqlServer": "Data Source=localhost;Initial Catalog=PointOfSale;Persist Security Info=False;User ID=root;Password=Maxbp6703",
"PrintSettings": {
"ComPort": "COM5",
"BaudRate": 115200,
"PrintWidth": 48
},
"API": {
"Url": "https://localhost:44334"
}
}

View File

@@ -0,0 +1,11 @@
{
"MariaSqlServer": "Data Source=localhost;Initial Catalog=PointOfSale;Persist Security Info=False;User ID=root;Password=Maxbp6703",
"PrintSettings": {
"ComPort": "COM5",
"BaudRate": 115200,
"PrintWidth": 48
},
"API": {
"Url": "https://localhost:44334"
}
}

View File

@@ -0,0 +1,60 @@
//public class Rootobject
//{
// public string logoBase64 { get; set; }
// public Header[] header { get; set; }
// public Bodymodel bodyModel { get; set; }
// public Footer[] footer { get; set; }
//}
//public class Bodymodel
//{
// public Product[] products { get; set; }
// public int totalPrice { get; set; }
// public int totalVat { get; set; }
// public int receiptNumber { get; set; }
// public string receiptTime { get; set; }
// public string staff { get; set; }
//}
//public class Product
//{
// public string product { get; set; }
// public string noOfProduct { get; set; }
// public float price { get; set; }
// public float totalPrice { get; set; }
//}
//public class Header
//{
// public string value { get; set; }
// public Printstyles printStyles { get; set; }
// public int textAlignment { get; set; }
// public int feedingLines { get; set; }
//}
//public class Printstyles
//{
// public bool fontB { get; set; }
// public bool bold { get; set; }
// public bool doubleHeight { get; set; }
// public bool doubleWidth { get; set; }
// public bool underline { get; set; }
//}
//public class Footer
//{
// public string value { get; set; }
// public Printstyles1 printStyles { get; set; }
// public int textAlignment { get; set; }
// public int feedingLines { get; set; }
//}
//public class Printstyles1
//{
// public bool fontB { get; set; }
// public bool bold { get; set; }
// public bool doubleHeight { get; set; }
// public bool doubleWidth { get; set; }
// public bool underline { get; set; }
//}