using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities; using Tanshu.Accounts.Repository; namespace Tanshu.Accounts.PointOfSale { public partial class CustomerListForm : Form { private IList _list; public CustomerListForm() { InitializeComponent(); } private void btnAdd_Click(object sender, EventArgs e) { using (var frm = new CustomerForm(null)) frm.ShowDialog(); _list = CustomerBI.List(); bsList.DataSource = _list; } private void CustomerListForm_Load(object sender, EventArgs e) { ShowGrid(); } private void ShowGrid() { _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(); _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(); } } }