2011-02-18 16:54:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using Tanshu.Accounts.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public partial class MoveTableForm : Form
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private readonly IList<FoodTable> _source;
|
|
|
|
|
private readonly bool _allowMerge;
|
|
|
|
|
public MoveTableForm(IList<FoodTable> source, bool allowMerge)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2011-06-23 12:47:48 +00:00
|
|
|
|
_source = source;
|
|
|
|
|
Selection = null;
|
|
|
|
|
_allowMerge = allowMerge;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public FoodTable Selection { get; private set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private void MoveTableForm_Load(object sender, EventArgs e)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _source, new ButtonClickDelegate(tableButton_Click));
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void tableButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var button = sender as Button;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var item = button.Tag as FoodTable;
|
|
|
|
|
if (item.Name == "Previous" || item.Name == "Next")
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var start = item.FoodTableID;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click));
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.Status) && !_allowMerge)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
Selection = item;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|