narsil/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs

58 lines
1.7 KiB
C#

using System;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class ProductListForm : Form
{
public ProductListForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
using (var frm = new ProductForm(null))
frm.ShowDialog();
using (var bi = new ProductBI())
bsList.DataSource = bi.List();
}
private void ProductGroupListForm_Load(object sender, EventArgs e)
{
using (var bi = new ProductBI())
bsList.DataSource = bi.List();
}
private void btnEdit_Click(object sender, EventArgs e)
{
var id = ((Product)bsList.Current).ProductID;
using (var frm = new ProductForm(id))
frm.ShowDialog();
using (var bi = new ProductBI())
bsList.DataSource = bi.List();
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void dgvProductTypes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.Value == null)
return;
if (e.Value.ToString() == "Castle.Proxies.TaxProxy")
{
e.Value = ((Product)bsList[e.RowIndex]).Tax.Name;
}
else if (e.Value.ToString() == "Castle.Proxies.ProductGroupProxy")
{
e.Value = ((Product)bsList[e.RowIndex]).ProductGroup.Name;
}
}
}
}