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

54 lines
1.9 KiB
C#
Raw Normal View History

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
{
public partial class MoveTableForm : Form
{
private readonly IList<FoodTable> _source;
private readonly bool _allowMerge;
public MoveTableForm(IList<FoodTable> source, bool allowMerge)
{
InitializeComponent();
_source = source;
Selection = null;
_allowMerge = allowMerge;
}
public FoodTable Selection { get; private set; }
private void MoveTableForm_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)
{
var button = sender as Button;
if (button == null)
return;
var item = button.Tag as FoodTable;
if (item.Name == "Previous" || item.Name == "Next")
{
var start = item.FoodTableID;
if (start < 0)
start = 0;
ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click));
}
else
{
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)
{
Selection = item;
this.Close();
}
}
}
}
}