public void InsertDeskOperatePrint(DeskChange deskChange) { Hashtable htParam = new Hashtable(); htParam["SrcOrderID"] = deskChange.OrderID1st; htParam["DeskName"] = deskChange.DeskName; ExecuteInsert("InsertDeskPrint", htParam); }
public bool OrderDeskOperate(DeskChange deskChange) { string json = JsonConvert.SerializeObject(deskChange); byte[] jsonByte = Encoding.UTF8.GetBytes(json); int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length; byte[] sendByte = new byte[cByte]; int byteOffset = 0; Array.Copy(BitConverter.GetBytes((int)Command.ID_ORDER_DESKOPERATE), sendByte, BasicTypeLength.INT32); byteOffset = BasicTypeLength.INT32; Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32); byteOffset += BasicTypeLength.INT32; Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length); byteOffset += jsonByte.Length; bool result = false; using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port)) { Byte[] receiveData = null; Int32 operCode = socket.SendReceive(sendByte, out receiveData); if (operCode == (int)RET_VALUE.SUCCEEDED) { result = true; } socket.Close(); } return result; }
public bool OrderDeskOperate(DeskChange deskChange) { bool returnValue = false; _daoManager.BeginTransaction(); try { SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { //添加打印任务 _printTaskDao.InsertDeskOperatePrint(deskChange); } // 转台 if (deskChange.OrderID1st != Guid.Empty && deskChange.OrderID2nd == Guid.Empty) { //分单号 Int32 curSubOrderNo = _orderDao.GetCurrentSubOrderNo(deskChange.DeskName); if (curSubOrderNo > 0) { curSubOrderNo++; } else { curSubOrderNo = 1; } Order order = new Order(); order.OrderID = deskChange.OrderID1st; order.DeskName = deskChange.DeskName; order.SubOrderNo = curSubOrderNo; returnValue = _orderDao.UpdateOrderDeskName(order); } // 合并 if (deskChange.OrderID1st != Guid.Empty && deskChange.OrderID2nd != Guid.Empty) { returnValue = _orderDao.MergeSalesOrder(deskChange); } _daoManager.CommitTransaction(); } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[OrderDeskOperate]参数:deskChange_{0}", JsonConvert.SerializeObject(deskChange)), exception); _daoManager.RollBackTransaction(); returnValue = false; } return returnValue; }
public bool MergeSalesOrder(DeskChange deskChange) { bool result = false; Hashtable htParam = new Hashtable(); htParam["OrderID1st"] = deskChange.OrderID1st; htParam["OrderID2nd"] = deskChange.OrderID2nd; htParam["ReturnValue"] = 0; ExecuteQueryForObject("MergeSalesOrder", htParam); int i = (int)htParam["ReturnValue"]; //返回值 if (i == 1) { result = true; } return result; }
public FormChoseMultiOrder(IList<Order> orderList, DeskChange deskChange) { m_OrderList = orderList; m_DeskChange = deskChange; InitializeComponent(); }
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; }