Rework so employee dont use repos but servies
This commit is contained in:
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting
|
||||
{
|
||||
@@ -20,6 +20,9 @@ namespace Pos.Setting
|
||||
/// </summary>
|
||||
public partial class AddEmployeeWindow : Window
|
||||
{
|
||||
private readonly EmployeeService _employeeService =
|
||||
new EmployeeService();
|
||||
|
||||
public AddEmployeeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -27,9 +30,19 @@ namespace Pos.Setting
|
||||
|
||||
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EmployeeRepository employeeRepository = new EmployeeRepository();
|
||||
employeeRepository.Add(txtStaff.Text);
|
||||
this.Close();
|
||||
try
|
||||
{
|
||||
_employeeService.AddEmployee(txtStaff.Text);
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldig medarbejder",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting
|
||||
{
|
||||
@@ -21,6 +21,8 @@ namespace Pos.Setting
|
||||
public partial class DeleteEmployeeWindow : Window
|
||||
{
|
||||
private int _employeeId;
|
||||
private readonly EmployeeService _employeeService =
|
||||
new EmployeeService();
|
||||
|
||||
public DeleteEmployeeWindow(int employeeId, string staffName)
|
||||
{
|
||||
@@ -31,9 +33,8 @@ namespace Pos.Setting
|
||||
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EmployeeRepository employeeRepository = new EmployeeRepository();
|
||||
employeeRepository.Delete(_employeeId);
|
||||
this.Close();
|
||||
_employeeService.ArchiveEmployee(_employeeId);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnNo_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting
|
||||
{
|
||||
@@ -21,6 +21,8 @@ namespace Pos.Setting
|
||||
public partial class EditEmployeeWindow : Window
|
||||
{
|
||||
private int _employeeId;
|
||||
private readonly EmployeeService _employeeService =
|
||||
new EmployeeService();
|
||||
|
||||
public EditEmployeeWindow(int employeeId, string staffName)
|
||||
{
|
||||
@@ -31,9 +33,21 @@ namespace Pos.Setting
|
||||
|
||||
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EmployeeRepository employeeRepository = new EmployeeRepository();
|
||||
employeeRepository.Edit(_employeeId,txtEmployee.Text);
|
||||
this.Close();
|
||||
try
|
||||
{
|
||||
_employeeService.RenameEmployee(
|
||||
_employeeId,
|
||||
txtEmployee.Text);
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldig medarbejder",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Models;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting
|
||||
{
|
||||
@@ -24,6 +24,8 @@ namespace Pos.Setting
|
||||
{
|
||||
private int _selectedEmployee = -1;
|
||||
private string _employeeName = string.Empty;
|
||||
private readonly EmployeeService _employeeService =
|
||||
new EmployeeService();
|
||||
public EmployeeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -62,15 +64,14 @@ namespace Pos.Setting
|
||||
deleteEmployeeWindow.Show();
|
||||
}
|
||||
|
||||
private void WindowClosed(object? sender, EventArgs e)
|
||||
private void WindowClosed(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
using EmployeeRepository employeeRepository = new EmployeeRepository();
|
||||
List<EmployeeEntity> allStaff = employeeRepository.GetAll();
|
||||
List<EmployeeEntity> allStaff = _employeeService.GetEmployees();
|
||||
LstStaff.Items.Clear();
|
||||
foreach (EmployeeEntity staff in allStaff)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Database.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.ProductGroup
|
||||
{
|
||||
@@ -11,6 +11,11 @@ namespace Pos.Setting.ProductGroup
|
||||
/// </summary>
|
||||
public partial class AddProductWindow : Window
|
||||
{
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
private readonly ProductService _productService =
|
||||
new ProductService();
|
||||
|
||||
public AddProductWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -19,13 +24,16 @@ namespace Pos.Setting.ProductGroup
|
||||
|
||||
private void LoadData(int selectedIndex)
|
||||
{
|
||||
ProductGroupRepository productGroupRepository = new ProductGroupRepository();
|
||||
List<Database.Models.ProductGroupEntity> products = productGroupRepository.GetAll();
|
||||
foreach (Database.Models.ProductGroupEntity productGroup in products)
|
||||
List<Database.Models.ProductGroupEntity> productGroups =
|
||||
_productGroupService.GetProductGroups();
|
||||
|
||||
foreach (Database.Models.ProductGroupEntity productGroup in productGroups)
|
||||
{
|
||||
ComboBoxItem comboBoxItem = new ComboBoxItem();
|
||||
comboBoxItem.Tag = productGroup.Id;
|
||||
comboBoxItem.Content = productGroup.Name;
|
||||
ComboBoxItem comboBoxItem = new ComboBoxItem
|
||||
{
|
||||
Tag = productGroup.Id,
|
||||
Content = productGroup.Name
|
||||
};
|
||||
cmbProductGroup.Items.Add(comboBoxItem);
|
||||
}
|
||||
|
||||
@@ -34,12 +42,23 @@ namespace Pos.Setting.ProductGroup
|
||||
|
||||
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();
|
||||
ComboBoxItem item = (ComboBoxItem)cmbProductGroup.SelectedItem;
|
||||
|
||||
try
|
||||
{
|
||||
_productService.AddProduct(
|
||||
txtProduct.Text,
|
||||
Convert.ToInt32(item.Tag));
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldigt produkt",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Product
|
||||
{
|
||||
@@ -21,20 +21,21 @@ namespace Pos.Setting.Product
|
||||
public partial class ArchiveProductWindow : Window
|
||||
{
|
||||
private int _productId;
|
||||
private readonly ProductService _productService =
|
||||
new ProductService();
|
||||
public ArchiveProductWindow(int productId)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productId = productId;
|
||||
ProductRepository productRepository = new ProductRepository();
|
||||
Database.Models.ProductEntity product = productRepository.GetById(_productId);
|
||||
Database.Models.ProductEntity product =
|
||||
_productService.GetProduct(_productId);
|
||||
txtDelProduct.Text = product.Name;
|
||||
}
|
||||
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProductRepository productRepository = new ProductRepository();
|
||||
productRepository.Archive(_productId);
|
||||
this.Close();
|
||||
_productService.ArchiveProduct(_productId);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnNo_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Product
|
||||
{
|
||||
@@ -23,6 +23,8 @@ namespace Pos.Setting.Product
|
||||
{
|
||||
ObservableCollection<Database.Models.ProductEntity> _productList = new ObservableCollection<Database.Models.ProductEntity>();
|
||||
private int _productGroupId;
|
||||
private readonly ProductService _productService =
|
||||
new ProductService();
|
||||
public ChangeProductOrderWindow(int productGroupId)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -32,8 +34,8 @@ namespace Pos.Setting.Product
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
ProductRepository productRepository = new ProductRepository();
|
||||
List<Database.Models.ProductEntity> products = productRepository.GetByProductGroup(_productGroupId);
|
||||
List<Database.Models.ProductEntity> products =
|
||||
_productService.GetProducts(_productGroupId);
|
||||
foreach (Database.Models.ProductEntity product in products)
|
||||
{
|
||||
_productList.Add(product);
|
||||
@@ -86,13 +88,10 @@ namespace Pos.Setting.Product
|
||||
|
||||
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();
|
||||
_productService.UpdateOrder(
|
||||
_productGroupId,
|
||||
_productList.Select(product => product.Id).ToList());
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Product
|
||||
{
|
||||
@@ -23,6 +23,10 @@ namespace Pos.Setting.Product
|
||||
private int _productId;
|
||||
private int _selectedProductGroupId;
|
||||
private Database.Models.ProductEntity _product;
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
private readonly ProductService _productService =
|
||||
new ProductService();
|
||||
|
||||
public EditProductWindow(int productId, int selectedProductGroupId)
|
||||
{
|
||||
@@ -34,8 +38,8 @@ namespace Pos.Setting.Product
|
||||
|
||||
private void Init()
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
List<Database.Models.ProductGroupEntity> productGroups = categoryRepository.GetAll();
|
||||
List<Database.Models.ProductGroupEntity> productGroups =
|
||||
_productGroupService.GetProductGroups();
|
||||
foreach (Database.Models.ProductGroupEntity productGroup in productGroups)
|
||||
{
|
||||
|
||||
@@ -46,17 +50,29 @@ namespace Pos.Setting.Product
|
||||
}
|
||||
cmbProductGroup.SelectedIndex = _selectedProductGroupId;
|
||||
|
||||
ProductRepository productRepository = new ProductRepository();
|
||||
_product = productRepository.GetById(_productId);
|
||||
_product = _productService.GetProduct(_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();
|
||||
try
|
||||
{
|
||||
_productService.UpdateProduct(
|
||||
_product.Id,
|
||||
(int)item.Tag,
|
||||
txtProduct.Text);
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldigt produkt",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
using Pos.Setting.Product;
|
||||
|
||||
namespace Pos.Setting.ProductGroup
|
||||
@@ -14,7 +14,10 @@ namespace Pos.Setting.ProductGroup
|
||||
public partial class ProductWindow : Window
|
||||
{
|
||||
private List<Database.Models.ProductGroupEntity> _productGroups;
|
||||
private int _productId;
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
private readonly ProductService _productService =
|
||||
new ProductService();
|
||||
|
||||
public ProductWindow()
|
||||
{
|
||||
@@ -26,8 +29,7 @@ namespace Pos.Setting.ProductGroup
|
||||
|
||||
private void Init()
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
_productGroups = categoryRepository.GetAll();
|
||||
_productGroups = _productGroupService.GetProductGroups();
|
||||
cmbCat.Items.Clear();
|
||||
foreach (Database.Models.ProductGroupEntity productGroup in _productGroups)
|
||||
{
|
||||
@@ -38,14 +40,19 @@ namespace Pos.Setting.ProductGroup
|
||||
cmbCat.Items.Add(comboBoxItem);
|
||||
}
|
||||
|
||||
cmbCat.SelectedIndex = 0;
|
||||
if (_productGroups.Count > 0)
|
||||
cmbCat.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
|
||||
ProductRepository productRepository = new ProductRepository();
|
||||
List<Database.Models.ProductEntity> products = productRepository.GetByProductGroup(_productGroups[cmbCat.SelectedIndex].Id);
|
||||
if (cmbCat.SelectedIndex < 0)
|
||||
return;
|
||||
|
||||
List<Database.Models.ProductEntity> products =
|
||||
_productService.GetProducts(
|
||||
_productGroups[cmbCat.SelectedIndex].Id);
|
||||
lstProductGroup.Items.Clear();
|
||||
foreach (Database.Models.ProductEntity product in products)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Category
|
||||
{
|
||||
@@ -20,6 +20,9 @@ namespace Pos.Setting.Category
|
||||
/// </summary>
|
||||
public partial class AddProductGroupWindow : Window
|
||||
{
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
|
||||
public AddProductGroupWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -27,9 +30,19 @@ namespace Pos.Setting.Category
|
||||
|
||||
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
categoryRepository.Add(txtProductGroup.Text);
|
||||
this.Close();
|
||||
try
|
||||
{
|
||||
_productGroupService.AddProductGroup(txtProductGroup.Text);
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldig produktgruppe",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Category
|
||||
{
|
||||
@@ -21,6 +21,8 @@ namespace Pos.Setting.Category
|
||||
public partial class ArchiveProductGroupWindow : Window
|
||||
{
|
||||
private readonly int _id;
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
public ArchiveProductGroupWindow(string name, int id)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -36,9 +38,8 @@ namespace Pos.Setting.Category
|
||||
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
categoryRepository.Archive(_id);
|
||||
this.Close();
|
||||
_productGroupService.ArchiveProductGroup(_id);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Category
|
||||
{
|
||||
@@ -22,6 +22,8 @@ namespace Pos.Setting.Category
|
||||
public partial class ChangeProductGroupOrderWindow : Window
|
||||
{
|
||||
ObservableCollection<Database.Models.ProductGroupEntity> _prodGroupList = new ObservableCollection<Database.Models.ProductGroupEntity>();
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
public ChangeProductGroupOrderWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -30,8 +32,8 @@ namespace Pos.Setting.Category
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
List<Database.Models.ProductGroupEntity> categories = categoryRepository.GetAll();
|
||||
List<Database.Models.ProductGroupEntity> categories =
|
||||
_productGroupService.GetProductGroups();
|
||||
foreach (Database.Models.ProductGroupEntity category in categories)
|
||||
{
|
||||
_prodGroupList.Add(category);
|
||||
@@ -84,13 +86,9 @@ namespace Pos.Setting.Category
|
||||
|
||||
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();
|
||||
_productGroupService.UpdateOrder(
|
||||
_prodGroupList.Select(productGroup => productGroup.Id).ToList());
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
|
||||
namespace Pos.Setting.Category
|
||||
{
|
||||
@@ -21,6 +21,8 @@ namespace Pos.Setting.Category
|
||||
public partial class EditProductGroupWindow : Window
|
||||
{
|
||||
private readonly int _id;
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
|
||||
public EditProductGroupWindow(string name, int id)
|
||||
{
|
||||
@@ -31,9 +33,21 @@ namespace Pos.Setting.Category
|
||||
|
||||
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
categoryRepository.Edit(txtProductGroup.Text,_id);
|
||||
this.Close();
|
||||
try
|
||||
{
|
||||
_productGroupService.RenameProductGroup(
|
||||
_id,
|
||||
txtProductGroup.Text);
|
||||
Close();
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
MessageBox.Show(
|
||||
exception.Message,
|
||||
"Ugyldig produktgruppe",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Database.Repository;
|
||||
using Pos.Service;
|
||||
using Pos.Setting.Category;
|
||||
|
||||
namespace Pos.Category
|
||||
@@ -23,6 +23,8 @@ namespace Pos.Category
|
||||
{
|
||||
private int _id = -1;
|
||||
private string _name = string.Empty;
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
|
||||
public ProductGroupWindow()
|
||||
{
|
||||
@@ -53,8 +55,8 @@ namespace Pos.Category
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
ProductGroupRepository categoryRepository = new ProductGroupRepository();
|
||||
List<Database.Models.ProductGroupEntity> categories = categoryRepository.GetAll();
|
||||
List<Database.Models.ProductGroupEntity> categories =
|
||||
_productGroupService.GetProductGroups();
|
||||
LstCategory.Items.Clear();
|
||||
foreach (Database.Models.ProductGroupEntity category in categories)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ 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.Service;
|
||||
using Pos.Setting.ProductGroup;
|
||||
|
||||
namespace Pos.Setting
|
||||
@@ -22,6 +22,9 @@ namespace Pos.Setting
|
||||
/// </summary>
|
||||
public partial class SettingWindow : Window
|
||||
{
|
||||
private readonly ProductGroupService _productGroupService =
|
||||
new ProductGroupService();
|
||||
|
||||
public SettingWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -42,10 +45,8 @@ namespace Pos.Setting
|
||||
|
||||
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();
|
||||
bool anyExist = _productGroupService.HasProductGroups();
|
||||
if (!anyExist)
|
||||
{
|
||||
MessageBox.Show("Der er ingen kategorier, opret dem først", "Kategorier", MessageBoxButton.OK,
|
||||
@@ -53,6 +54,7 @@ namespace Pos.Setting
|
||||
}
|
||||
else
|
||||
{
|
||||
ProductWindow productWindow = new ProductWindow();
|
||||
productWindow.Show();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user