![](https://yydgew.bay.livefilestore.com/y1p_cx2jnFQRzjpFqhZK8Nymbk-S9NVDE7MZZGX72FWy232m9njw5jFwvcLTAc563aFFQHBHKREVJC7uDiq28KHscx9omCQtot6/AntiqueCashRegister.gif)
Let’s start implementing the SalesModule! This is a pretty big and complicated module and will most probably be split into multiple parts (and be refactored n times)! Before I can really start, let me show you my data model.
Everything revolves round a product.
public class Product
{
public Guid ID { get; set; }
public string Refrence { get; set; }
public string Name { get; set; }
public string Barcode { get; set; }
public double BuyPrice { get; set; }
public double SellPrice { get; set; }
public Guid CategoryID { get; set; }
public Guid TaxID { get; set; }
}
Each Product
can also belong to a category
(used to filter product
s):
public class Category
{
public Guid ID { get; set; }
public string Name { get; set; }
}
And a Tax
type:
public class Tax
{
public Guid ID { get; set; }
public string Name { get; set; }
public double Rate { get; set; }
}
I also created a mocked repository to fetch the products:
public interface IProductRepository
{
Product[] GetProducts();
Product GetProduct(Guid productID);
Category[] GetCategories();
Product[] GetProductsByCategory(Category category);
}
Currently only serving dummy data though!!!
One of the up front design decisions was to use the MVVM pattern. My SalesView_Main
view has a ViewModel
behind it that looks like this:
public class SalesViewModel : INotifyPropertyChanged
{
private readonly IProductRepository _productRepository;
public List<Category> Categories { get; set; }
public Category SelectedCategories { get; set; }
public ObservableCollection<Product> Products { get; set; }
}
The UI binds to the collection of Categories
, as the current item changes, re-creating the list of products
to show! This creates the illusion of product
filtering!
Here is the XAML:
<ListBox ItemsSource="{Binding Categories}"
DisplayMemberPath="Name"
SelectedValue="{Binding SelectedCategories, Mode=TwoWay}" />
<ListBox ItemsSource="{Binding Products}" />
Here is a screen capture of all the products:
![](https://yydgew.bay.livefilestore.com/y1p_1Sic4OmTYxd-JalFl8O_hpS_GpA6juQCEd9GhonaTUE_kOLH4iwRi-JreeZFfDLQRX1SQvid5ISkn5izL_7j-nfZHnP_-Jl/OpenPOS_FilteredProducts.png)
And here is the list filtered by hardware:
![](https://yydgew.bay.livefilestore.com/y1p3ZEMpVyp9Czg0t72Cv04cbLYPhp3VK0Nbsd_jPCnRE-VQJtwK2KBhFMlt6RYWeyS6YO094xCmllgGMAVMzjqLLab6cLl9HyJ/OpenPOS_AllProducts.png)
In the next part, I will cover how I did the adding of products into a current transaction!
![](https://yydgew.bay.livefilestore.com/y1pPEgyDHz_w0wNZH10W5UhP4EPCSwdZgt2GgOoeFLjTzlWQQvYgpKEHwH9o3WAvanduBLo1DYs0JDKfII5AMPqq0DTOkg0XaIT/OpenPOS_SalesModule.png)
Here is the latest version of OpenPOS source:
CodeProject
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.