public bool DeleteWholeOrder(DeletedOrder deletedOrder) { string json = JsonConvert.SerializeObject(deletedOrder); 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_DELETE_WHOLEORDER), 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 DeleteWholeOrder(DeletedOrder deletedOrder) { int result = ExecuteUpdate("UpdateDeletedOrder", deletedOrder); return result > 0; }
private void btnCancelOrder_Click(object sender, EventArgs e) { if (_salesOrder != null) { //权限验证 bool hasRights = false; if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL)) { hasRights = true; } else { FormRightsCode formRightsCode = new FormRightsCode(); formRightsCode.ShowDialog(); if (formRightsCode.ReturnValue) { IList<string> rightsCodeList = formRightsCode.RightsCodeList; if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL)) { hasRights = true; } } } if (!hasRights) { return; } FormCancelOrder form = new FormCancelOrder(); form.ShowDialog(); if (form.CurrentReason != null) { //删除订单 DeletedOrder deletedOrder = new DeletedOrder(); deletedOrder.OrderID = _salesOrder.order.OrderID; deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID; deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; deletedOrder.CancelReasonName = form.CurrentReason.ReasonName; if (DeletedOrderService.GetInstance().DeleteWholeOrder(deletedOrder)) { //加载外卖单列表 IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList(); if (deliveryOrderList != null) { _pageIndex = 0; _deliveryOrderList = deliveryOrderList; DisplayDeliveryOrderButton(); } } else { MessageBox.Show("删除账单失败!"); return; } } else { return; } } this.lbTotalPrice.Text = "总金额:"; this.lbDiscount.Text = "折扣:"; this.lbNeedPayMoney.Text = "实际应付:"; this.lbCutOff.Text = "去零:"; dgvGoodsOrder.Rows.Clear(); _salesOrder = null; btnDeliveryGoods.Enabled = false; btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor; btnOutsideOrder.Enabled = true; btnOutsideOrder.BackColor = btnOutsideOrder.DisplayColor; txtTelephone.Text = string.Empty; txtName.Text = string.Empty; txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; //更新第二屏信息 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled) { if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen) { ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo(); } } }
public bool DeletePaidWholeOrder(DeletedOrder deletedOrder) { bool returnValue = false; _daoManager.BeginTransaction(); try { if (_orderDao.DeleteWholeOrder(deletedOrder)) { if (_orderDetailsDao.DeleteWholeOrderDetails(deletedOrder)) { _orderDiscountDao.DeleteOrderDiscount(deletedOrder.OrderID); _orderPayoffDao.DeleteOrderPayoff(deletedOrder.OrderID); returnValue = true; } } _daoManager.CommitTransaction(); } catch(Exception exception) { _daoManager.RollBackTransaction(); returnValue = false; LogHelper.GetInstance().Error(string.Format("[DeletePaidWholeOrder]参数:deletedOrder_{0}", JsonConvert.SerializeObject(deletedOrder)), exception); } return returnValue; }
public bool DeleteWholeOrder(DeletedOrder deletedOrder) { bool returnValue = false; _daoManager.BeginTransaction(); try { SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { //获取打印任务列表 Order order = _orderDao.GetOrder(deletedOrder.OrderID); IList<OrderDetails> orderDetailsList = _orderDetailsDao.GetOrderDetailsList(deletedOrder.OrderID); SalesOrder salesOrder = new SalesOrder { order = order, orderDetailsList = orderDetailsList }; IList<PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 2, deletedOrder.CancelReasonName); foreach (PrintTask printTask in printTaskList) { printTask.ItemQty = -printTask.ItemQty; //数量应该为负数 _printTaskDao.InsertPrintTask(printTask); } } //删除账单 if (_orderDao.DeleteWholeOrder(deletedOrder)) { if (_orderDetailsDao.DeleteWholeOrderDetails(deletedOrder)) { //该订单可能不包含折扣 _orderDiscountDao.DeleteOrderDiscount(deletedOrder.OrderID); returnValue = true; } } _daoManager.CommitTransaction(); } catch(Exception exception) { _daoManager.RollBackTransaction(); returnValue = false; LogHelper.GetInstance().Error(string.Format("[DeleteWholeOrder]参数:deletedOrder_{0}", JsonConvert.SerializeObject(deletedOrder)), exception); } return returnValue; }
private void btnCancelOrder_Click(object sender, EventArgs e) { if (_salesOrder != null) { //权限验证 bool hasRights = false; if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL)) { hasRights = true; } else { FormRightsCode formRightsCode = new FormRightsCode(); formRightsCode.ShowDialog(); if (formRightsCode.ReturnValue) { IList<string> rightsCodeList = formRightsCode.RightsCodeList; if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL)) { hasRights = true; } } } if (!hasRights) { return; } FormCancelOrder form = new FormCancelOrder(); form.ShowDialog(); if (form.CurrentReason != null) { //删除订单 DeletedOrder deletedOrder = new DeletedOrder(); deletedOrder.OrderID = _salesOrder.order.OrderID; deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID; deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; deletedOrder.CancelReasonName = form.CurrentReason.ReasonName; if (!DeletedOrderService.GetInstance().DeleteWholeOrder(deletedOrder)) { MessageBox.Show("删除账单失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);; return; } } else { return; } } //更新桌况为空闲状态 int status = (int)DeskButtonStatus.IDLE_MODE; if (DeskService.GetInstance().UpdateDeskStatus(_currentDeskName, string.Empty, status)) { //更新第二屏信息 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled) { if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen) { ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo(); } } _onShow = false; this.Hide(); } else { MessageBox.Show("更新桌况状态错误 !"); return; } }
private void btnWholeDelete_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null && _salesOrder != null && _salesOrder.order != null) { if (_salesOrder.order.Status == 1) { int selectedIndex = dataGridView1.CurrentRow.Index; if (dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value != null) { //权限验证 bool hasRights = false; if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL)) { hasRights = true; } else { FormRightsCode formRightsCode = new FormRightsCode(); formRightsCode.ShowDialog(); if (formRightsCode.ReturnValue) { IList<string> rightsCodeList = formRightsCode.RightsCodeList; if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL)) { hasRights = true; } } } if (!hasRights) { return; } FormCancelOrder form = new FormCancelOrder(); form.ShowDialog(); if (form.CurrentReason != null) { //删除订单 DeletedOrder deletedOrder = new DeletedOrder(); deletedOrder.OrderID = _salesOrder.order.OrderID; deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID; deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; deletedOrder.CancelReasonName = form.CurrentReason.ReasonName; if (DeletedOrderService.GetInstance().DeletePaidWholeOrder(deletedOrder)) { dataGridView1.Rows[selectedIndex].Cells["BillType"].Value = "已删除"; _salesOrder.order.Status = 2; } else { MessageBox.Show("删除账单失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } }