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;
|
2014-10-16 11:11:55 +00:00
|
|
|
|
using System.Diagnostics;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2014-10-16 11:11:55 +00:00
|
|
|
|
private readonly IList<FoodTable> _tableList;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private readonly bool _allowMerge;
|
2014-10-16 11:11:55 +00:00
|
|
|
|
public MoveTableForm(IList<FoodTable> tableList, bool allowMerge)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-10-16 11:11:55 +00:00
|
|
|
|
_tableList = tableList;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
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
|
|
|
|
{
|
2014-10-16 11:11:55 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_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;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.Status) && !_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)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
Selection = item;
|
|
|
|
|
this.Close();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private void tablePage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button == null)
|
|
|
|
|
return;
|
|
|
|
|
var start = (int)button.Tag;
|
|
|
|
|
if (start < 0)
|
|
|
|
|
start = 0;
|
2014-10-16 11:11:55 +00:00
|
|
|
|
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _tableList, new ButtonClickDelegate(tableButton_Click), new ButtonClickDelegate(tablePage_Click));
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|