Major refactor of the Sales Form and Bill controller to make code more readable and less error prone.
The functions now only do one thing.
This commit is contained in:
@ -1,102 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Data;
|
||||
using Tanshu.Accounts.Entities;
|
||||
|
||||
namespace Tanshu.Accounts.Helpers
|
||||
{
|
||||
public class SelectCustomer : Tanshu.Data.BaseSelector<Customer>
|
||||
{
|
||||
public event CustomerEventHandler CustomerEvent;
|
||||
public SelectCustomer(GetData<Customer> getData, bool autoClose) : base(getData, true, "List of Products")
|
||||
{
|
||||
var filters = new List<string> {"Universal"};
|
||||
SetFilterColumns(filters);
|
||||
grid.Columns["CustomerID"].Visible = false;
|
||||
}
|
||||
|
||||
protected override void FilterChanged(Dictionary<string, string> filter)
|
||||
{
|
||||
//data = new CustomerBI().GetFilteredCustomers(filter["Universal"].Split(' ')).ToList();
|
||||
data = getData(filter);
|
||||
bindingSource.DataSource = data;
|
||||
}
|
||||
protected override void UpdateDisplay(Customer item)
|
||||
{
|
||||
DisplayLabel = item == null ? "" : string.Format("Chosen Customer is {0} with phone number {1}", item.Name, item.Phone);
|
||||
}
|
||||
|
||||
protected override Customer HandleKeydown(object sender, ExtendedKeyEventArgs e)
|
||||
{
|
||||
var customer = bindingSource.Current as Customer;
|
||||
|
||||
if (CustomerEvent == null)
|
||||
{
|
||||
e.Handled = false;
|
||||
return customer;
|
||||
}
|
||||
Guid? id = null;
|
||||
if ((customer != null) && (e.KeyCode == Keys.F2))
|
||||
id = customer.CustomerID;
|
||||
|
||||
if ((e.KeyCode == Keys.F1) || (e.KeyCode == Keys.F2))
|
||||
{
|
||||
customer = CustomerEvent(sender, new CustomerEventArgs(id, base.filterColumns["Universal"]));
|
||||
e.Handled = customer != null;
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
#region Designer Code
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
public delegate Customer CustomerEventHandler(object sender, CustomerEventArgs e);
|
||||
public class CustomerEventArgs : EventArgs
|
||||
{
|
||||
public CustomerEventArgs(Guid? customerID, string phone)
|
||||
{
|
||||
CustomerID = customerID;
|
||||
Phone = phone;
|
||||
}
|
||||
public Guid? CustomerID
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public string Phone
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,9 +70,6 @@
|
||||
<Compile Include="SelectVoidReason.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SelectCustomer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user