0f323f8fab
Signed-off-by: unknown <tanshu@.(none)>
140 lines
4.2 KiB
C#
140 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Linq;
|
|
using Tanshu.Accounts.Contracts;
|
|
using Tanshu.Data;
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
namespace Tanshu.Accounts.Helpers
|
|
{
|
|
public class SelectWaiter : Tanshu.Data.BaseSelector<Waiter>
|
|
{
|
|
public event WaiterEventHandler waiterEvent;
|
|
public SelectWaiter(GetData<Waiter> getData, bool autoClose) : base(getData, true, "Select a Waiter")
|
|
{
|
|
List<string> filters = new List<string>();
|
|
filters.Add("Name");
|
|
SetFilterColumns(filters);
|
|
grid.Columns["WaiterID"].Visible = false;
|
|
}
|
|
|
|
protected override void FilterChanged(Dictionary<string, string> filter)
|
|
{
|
|
//data = originalData.Where(d => d.Name.ToLower().Contains(filter["Name"].ToLower())).ToList();
|
|
data = getData(filter);
|
|
bindingSource.DataSource = data;
|
|
}
|
|
protected override void UpdateDisplay(Waiter item)
|
|
{
|
|
if (item == null)
|
|
DisplayLabel = "";
|
|
else
|
|
DisplayLabel = string.Format("Waiter Name: {0}", item.Name);
|
|
}
|
|
protected override Waiter HandleKeydown(object sender, ExtendedKeyEventArgs e)
|
|
{
|
|
Waiter waiter = bindingSource.Current as Waiter;
|
|
|
|
if (waiterEvent == null)
|
|
{
|
|
e.Handled = false;
|
|
return waiter;
|
|
}
|
|
|
|
WaiterEventArgs eventArgs = new WaiterEventArgs(null, 1);
|
|
switch (e.KeyCode)
|
|
{
|
|
case Keys.F1:
|
|
{
|
|
waiter = new Waiter { Name = base.filterColumns["Name"].Trim() };
|
|
eventArgs = new WaiterEventArgs(waiter, 1);
|
|
break;
|
|
}
|
|
case Keys.F2:
|
|
{
|
|
if (waiter != null)
|
|
waiter.Name = base.filterColumns["Name"].Trim();
|
|
eventArgs = new WaiterEventArgs(waiter, 2);
|
|
break;
|
|
}
|
|
case Keys.F8:
|
|
{
|
|
if (waiter != null)
|
|
eventArgs = new WaiterEventArgs(waiter, 3);
|
|
break;
|
|
}
|
|
}
|
|
if ((waiter != null) && ((e.KeyCode == Keys.F1) || (e.KeyCode == Keys.F2) || (e.KeyCode == Keys.F8)))
|
|
waiter = waiterEvent(sender, eventArgs);
|
|
|
|
e.Handled = eventArgs.Handled;
|
|
return waiter;
|
|
}
|
|
#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 Waiter WaiterEventHandler(object sender, WaiterEventArgs e);
|
|
public class WaiterEventArgs : EventArgs
|
|
{
|
|
public WaiterEventArgs(Waiter waiter, int action)
|
|
{
|
|
Waiter = waiter;
|
|
Action = action;
|
|
Handled = false;
|
|
}
|
|
|
|
public Waiter Waiter
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public int Action
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public bool Handled
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
}
|
|
}
|