private void btnDesk_Click(object sender, EventArgs e) { if (_operateType == ButtonOperateType.NONE) { return; } CrystalButton btnDesk = sender as CrystalButton; if (btnDesk == null) { return; } BizDesk tempDesk = btnDesk.Tag as BizDesk; if (tempDesk == null) { return; } _currentFormActivate = false; //重新获取Desk信息 BizDesk desk = DeskService.GetInstance().GetBizDeskByName(tempDesk.DeskName); if (_operateType == ButtonOperateType.ORDER) { if (desk.Status == (int)DeskButtonStatus.IDLE_MODE) { //人数 Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _formOrder.PersonNum = int.Parse(keyForm.KeypadValue); } else { return; } //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { desk.Status = status; btnDesk.BackColor = GetColorByStatus(status, ConstantValuePool.BizSettingConfig.DeviceNo); _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = null; _formOrder.VisibleShow = true; _formOrder.Show(); } } else if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { if (salesOrder.order.Status == 3) //已预结 { //open check out form FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } else { //open order form _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = salesOrder; _formOrder.VisibleShow = true; _formOrder.Show(); } } } } } } } else if (_operateType == ButtonOperateType.CLEAR) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED && !string.IsNullOrEmpty(desk.DeviceNo)) { //更新桌况为非占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, string.Empty, status)) { btnDesk.BackColor = GetColorByStatus(status, string.Empty); } } } else if (_operateType == ButtonOperateType.CHANGE_DESK) { if (string.IsNullOrEmpty(_deskName1St)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { if (orderList.Count > 1) { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { _deskName1St = desk.DeskName; _orderId1St = form.SelectedOrder.OrderID; _firstDeskSingleOrder = false; } else { _currentFormActivate = true; //使线程重新活跃 return; } } else { _deskName1St = desk.DeskName; _orderId1St = orderList[0].OrderID; _firstDeskSingleOrder = true; } } else { _currentFormActivate = true; //使线程重新活跃 return; //空桌 } } else { if (!string.IsNullOrEmpty(_deskName1St)) { if (desk.DeskName == _deskName1St) { _currentFormActivate = true; //使线程重新活跃 return; //点击相同的第一张桌子 } //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList, deskChange); form.ShowDialog(); if (form.SelectedOrder != null) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } else { _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } else { //直接转台 DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; if (OrderService.GetInstance().OrderDeskOperate(deskChange)) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } } } } else if (_operateType == ButtonOperateType.CHECKOUT) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } } } } } } _currentFormActivate = true; }
private void btnDesk_Click(object sender, EventArgs e) { if (_operateType == ButtonOperateType.NONE) { return; } CrystalButton btnDesk = sender as CrystalButton; if (btnDesk == null) return; BizDesk tempDesk = btnDesk.Tag as BizDesk; if (tempDesk == null) return; _currentFormActivate = false; //重新获取Desk信息 BizDesk desk = DeskService.GetInstance().GetBizDeskByName(tempDesk.DeskName); if (_operateType == ButtonOperateType.ORDER) { if (desk.Status == (int)DeskButtonStatus.IDLE_MODE) { //人数 Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _formOrder.PersonNum = int.Parse(keyForm.KeypadValue); } else { return; } //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { desk.Status = status; btnDesk.BackColor = GetColorByStatus(status, ConstantValuePool.BizSettingConfig.DeviceNo); _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = null; _formOrder.VisibleShow = true; _formOrder.Show(); } } else if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { if (salesOrder.order.Status == 3) //已预结 { //open check out form FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } else { //open order form _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = salesOrder; _formOrder.VisibleShow = true; _formOrder.Show(); } } } } } } } else if (_operateType == ButtonOperateType.CLEAR) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED && !string.IsNullOrEmpty(desk.DeviceNo)) { //更新桌况为非占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, string.Empty, status)) { btnDesk.BackColor = GetColorByStatus(status, string.Empty); } } } else if (_operateType == ButtonOperateType.CHANGE_DESK) { if (string.IsNullOrEmpty(_deskName1St)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { if (orderList.Count > 1) { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { _deskName1St = desk.DeskName; _orderId1St = form.SelectedOrder.OrderID; _firstDeskSingleOrder = false; } else { _currentFormActivate = true; //使线程重新活跃 return; } } else { _deskName1St = desk.DeskName; _orderId1St = orderList[0].OrderID; _firstDeskSingleOrder = true; } } else { _currentFormActivate = true; //使线程重新活跃 return; //空桌 } } else { if (!string.IsNullOrEmpty(_deskName1St)) { if (desk.DeskName == _deskName1St) { _currentFormActivate = true; //使线程重新活跃 return; //点击相同的第一张桌子 } //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList, deskChange); form.ShowDialog(); if (form.SelectedOrder != null) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } else { _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } else { //直接转台 DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; if (OrderService.GetInstance().OrderDeskOperate(deskChange)) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } } } } else if (_operateType == ButtonOperateType.CHECKOUT) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } } } } } } _currentFormActivate = true; }