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

70 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.SqlDAO;
using Tanshu.Accounts.Helpers;
using Tanshu.Common.KeyboardControl;
namespace Tanshu.Accounts.PointOfSale
{
public partial class frmMoveTable : Form
{
private IList<FoodTable> source;
private FoodTable selection;
private bool allowMerge;
public frmMoveTable(IList<FoodTable> source, bool allowMerge)
{
InitializeComponent();
this.source = source;
selection = null;
this.allowMerge = allowMerge;
}
public FoodTable Selection
{
get
{
return selection;
}
}
private void frmMoveTable_Load(object sender, EventArgs e)
{
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, source, new ButtonClickDelegate(tableButton_Click));
}
private void tableButton_Click(object sender, EventArgs e)
{
Button button = sender as Button;
if (button == null)
return;
var item = button.Tag as FoodTable;
if (item.Name == "Previous" || item.Name == "Next")
{
int start = item.FoodTableID;
if (start < 0)
start = 0;
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, source, new ButtonClickDelegate(tableButton_Click));
}
else
{
if (item.Status != null && item.Status != string.Empty && !allowMerge)
{
MessageBox.Show("Cannot move to a running table", "Cannot Move", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (MessageBox.Show(string.Format("Move selected table to table {0}", item.Name), "Move", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
selection = item;
this.Close();
}
}
}
}
}