narsil/Tanshu.Accounts.PointOfSale/Sales/CustomerListForm.cs

71 lines
1.8 KiB
C#
Raw Permalink Normal View History

using System;
2018-08-24 10:41:33 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
2018-08-24 10:41:33 +00:00
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Repository;
namespace Tanshu.Accounts.PointOfSale
{
public partial class CustomerListForm : Form
{
private IList<Customer> _list;
public CustomerListForm()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
using (var frm = new CustomerForm(null))
frm.ShowDialog();
2018-08-24 10:41:33 +00:00
_list = CustomerBI.List();
bsList.DataSource = _list;
}
private void CustomerListForm_Load(object sender, EventArgs e)
{
ShowGrid();
}
private void ShowGrid()
{
2018-08-24 10:41:33 +00:00
_list = CustomerBI.List();
bsList.DataSource = _list;
}
private void btnEdit_Click(object sender, EventArgs e)
{
var id = ((Customer)bsList.Current).CustomerID;
using (var frm = new CustomerForm(id))
frm.ShowDialog();
2018-08-24 10:41:33 +00:00
_list = CustomerBI.List();
bsList.DataSource = _list;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
public Customer SelectedItem
{
get
{
if (bsList.Position >= 0)
{
var item = _list[bsList.Position];
if (item != null)
return item;
}
return _list.First(x => x.CustomerID == Constants.CASH_CUSTOMER);
}
}
private void dgvCustomers_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.Close();
}
}
}