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