You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.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 POSV.Entity;
using POSV.Utils;
namespace POSV.Forms
{
public partial class OpenTableForm : BusinessForm
{
/// <summary>
/// 当前桌台
/// </summary>
private Table _table = null;
public OpenTableForm(Table table)
{
InitializeComponent();
this._table = table;
this.controlBoxExt.CloseClick += OnCloseClick;
this.controlBoxExt.Text = string.Format("开台—{0}({1})",this._table.Name,this._table.No);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.DesignMode) return;
//座位数
this.lblTableNumber.Text = string.Format(this.lblTableNumber.Tag.ToString() , this._table.Number);
//最低消费
this.lblMinimumCharge.Text = string.Format(this.lblMinimumCharge.Tag.ToString() , "-");
//就餐时段
this.lblPeriodOfTime.Text = string.Format(this.lblPeriodOfTime.Tag.ToString() , "[早市 6:00-11:00]");
this.txtTableNumber.Multiline = false;
this.txtServicer.Multiline = false;
this.txtAliasName.Multiline = false;
this.txtMemo.Multiline = false;
this.txtTableNumber.Text = this._table.Number.ToString();
this.txtTableNumber.Focus();
this.txtTableNumber.SelectAll();
}
private void OnCloseClick(object sender , EventArgs e)
{
if(this.Owner != null)
{
this.Owner.Close();
}
this.Close();
}
private void OnButtonOpenTableClick(object sender , EventArgs e)
{
bool isSuccess = false;
try
{
var entity = new TableExt();
entity.Id = IdWorkerUtils.Instance.NextId();
entity.TableId = this._table.Id;
entity.TableStatus = TableStatus.;
entity.OpenTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
entity.OpenUser = Global.Instance.Worker.No;
entity.TableNumber = string.IsNullOrEmpty(this.txtTableNumber.Text.Trim()) ? this._table.Number : this.txtTableNumber.IntegerValue;
using (var db = Global.Instance.OpenDataBase)
{
using (var trans = db.GetTransaction())
{
db.Save(entity);
trans.Complete();
}
}
isSuccess = true;
this._table.TableExt = entity;
//通知主界面更新
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept , "accept" , this._table));
}
catch(Exception ex)
{
isSuccess = false;
LOGGER.Error(ex,"开台操作发生异常");
}
finally
{
if (isSuccess)
{
this.OnCloseClick(this , EventArgs.Empty);
}
}
}
}
}