Print problemer

Har muligvis rettet den print fejl der er - men mangler at få det testet.
Der er slettet en masse projekter som ikke bliver brugt mere.
Og flyttet rundt på de få projekter som er tilbage.
Dette er V2 og i sit eget repo, så dette er initial commit
This commit is contained in:
2026-07-15 22:40:53 +02:00
commit 170a03e7df
330 changed files with 14118 additions and 0 deletions

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();
}
}
}
}