public void BindGoodsOrderInfo(SalesOrder salesOrder) { this.dgvItemOrder.Rows.Clear(); if (salesOrder.orderDetailsList != null && salesOrder.orderDetailsList.Count > 0) { foreach (OrderDetails orderDetails in salesOrder.orderDetailsList) { int index = this.dgvItemOrder.Rows.Add(new DataGridViewRow()); this.dgvItemOrder.Rows[index].Cells["GoodsNum"].Value = orderDetails.ItemQty; if (orderDetails.ItemType == (int)OrderItemType.Goods) { this.dgvItemOrder.Rows[index].Cells["GoodsName"].Value = orderDetails.GoodsName; } else { string strLevelFlag = string.Empty; int levelCount = orderDetails.ItemLevel * 2; for (int i = 0; i < levelCount; i++) { strLevelFlag += "-"; } this.dgvItemOrder.Rows[index].Cells["GoodsName"].Value = strLevelFlag + orderDetails.GoodsName; } this.dgvItemOrder.Rows[index].Cells["GoodsPrice"].Value = orderDetails.TotalSellPrice; this.dgvItemOrder.Rows[index].Cells["GoodsDiscount"].Value = orderDetails.TotalDiscount; //设置样式 this.dgvItemOrder.Rows[index].Selected = false; this.dgvItemOrder.Rows[index].DefaultCellStyle.ForeColor = Color.Red; this.dgvItemOrder.Rows[index].DefaultCellStyle.BackColor = Color.White; } this.dgvItemOrder.Rows[this.dgvItemOrder.RowCount - 1].Selected = true; BindOrderInfoSum(); } }
public FormBackGoods(SalesOrder salesOrder) { InitializeComponent(); m_SalesOrder = salesOrder; btnPageUp.BackColor = btnPageUp.DisplayColor = Color.Tomato; btnPageDown.BackColor = btnPageDown.DisplayColor = Color.Teal; }
public Int32 UpdateSalesOrder(SalesOrder salesOrder) { string json = JsonConvert.SerializeObject(salesOrder); 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_UPDATE_SALESORDER), 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; int result = 0; 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 = BitConverter.ToInt32(receiveData, ParamFieldLength.PACKAGE_HEAD); } socket.Close(); } return result; }
public FormDeliveryGoods(SalesOrder salesOrder, PrintData printData, string telephone, string customerName, string address) { _salesOrder = salesOrder; _printData = printData; _telephone = telephone; _customerName = customerName; _address = address; InitializeComponent(); }
public FormPayment(SalesOrder salesOrder) { this.m_TotalPrice = salesOrder.order.TotalSellPrice; this.m_ActualPayMoney = salesOrder.order.ActualSellPrice; this.m_Discount = salesOrder.order.DiscountPrice; this.m_CutOff = salesOrder.order.CutOffPrice; this.m_SalesOrder = salesOrder; InitializeComponent(); this.lbTotalPrice.Text = "总金额:" + m_TotalPrice.ToString("f2"); this.lbDiscount.Text = "折扣:" + m_Discount.ToString("f2"); this.lbReceMoney.Text = "应收金额:" + m_ActualPayMoney.ToString("f2"); this.lbPaidInMoney.Text = "实收金额:0.00"; this.lbUnpaidAmount.Text = "未付金额:" + m_ActualPayMoney.ToString("f2"); this.lbNeedChangePay.Text = "找零:0.00"; }
public bool CreateReminderOrder(ReminderOrder reminderOrder) { if (reminderOrder == null || reminderOrder.OrderDetailsIDList == null || reminderOrder.OrderDetailsIDList.Count <= 0) { return false; } bool returnValue = false; try { _daoManager.OpenConnection(); //添加打印任务 SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { Order order = _orderDao.GetOrder(reminderOrder.OrderID); if (order != null) { SalesOrder salesOrder = new SalesOrder { order = order, orderDetailsList = _orderDetailsDao.GetOrderDetailsList(reminderOrder.OrderDetailsIDList) }; IList<PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 3, reminderOrder.ReasonName); foreach (PrintTask printTask in printTaskList) { _printTaskDao.InsertPrintTask(printTask); } } } returnValue = true; } catch (Exception exception) { LogHelper.GetInstance().Error(string.Format("[CreateReminderOrder]参数:reminderOrder_{0}", JsonConvert.SerializeObject(reminderOrder)), exception); } finally { _daoManager.CloseConnection(); } return returnValue; }
private void btnTakeOut_Click(object sender, EventArgs e) { if (dgvGoodsOrder.Rows.Count <= 0) { MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!_haveDailyClose) { MessageBox.Show("上次未日结,不能新增菜单,请先进行日结操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_salesOrder == null || _salesOrder.order.EatType == (int)EatWayType.Takeout) { string deskName; if (_salesOrder == null) { if (ConstantValuePool.BizSettingConfig.CarteMode) { FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入餐牌号"; form.ShowDialog(); if (string.IsNullOrEmpty(form.KeypadValue)) { MessageBox.Show("餐牌号不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (form.KeypadValue.Length > 3) { MessageBox.Show("您输入的餐牌号码过大!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } deskName = "W" + form.KeypadValue.PadLeft(3, '0'); } else { deskName = "W001"; } } else { deskName = _salesOrder.order.DeskName; } int result = SubmitSalesOrder(deskName, EatWayType.Takeout); if (result == 1) { this.lbTotalPrice.Text = "总金额:"; this.lbDiscount.Text = "折扣:"; this.lbNeedPayMoney.Text = "实际应付:"; this.lbCutOff.Text = "去零:"; dgvGoodsOrder.Rows.Clear(); _salesOrder = null; btnDeliveryGoods.Enabled = false; btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor; txtTelephone.Text = string.Empty; txtName.Text = string.Empty; txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; //加载外卖单列表 IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList(); if (deliveryOrderList != null) { _pageIndex = 0; _deliveryOrderList = deliveryOrderList; DisplayDeliveryOrderButton(); } //更新第二屏信息 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled) { if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen) { ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo(); } } } else if (result == 0) { MessageBox.Show("外带提交失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { MessageBox.Show("没有数据可以提交!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (_salesOrder.order.EatType == (int)EatWayType.OutsideOrder) { MessageBox.Show("当前账单状态为[外送],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (_salesOrder.order.EatType == (int)EatWayType.DineIn) { MessageBox.Show("当前账单状态为[堂食],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSplitBill_Click(object sender, EventArgs e) { if (_salesOrder == null) { MessageBox.Show("账单未落单,不允许分单!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } foreach (DataGridViewRow dr in dgvGoodsOrder.Rows) { if (dr.Cells["OrderDetailsID"].Value == null) { MessageBox.Show("账单中包含未落单品项,不允许分单!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } FormSplitBill form = new FormSplitBill(_salesOrder); form.ShowDialog(); if (form.SplitOrderSuccess) { //重新加载 _salesOrder = SalesOrderService.GetInstance().GetSalesOrder(_salesOrder.order.OrderID); BindGoodsOrderInfo(); //绑定订单信息 BindOrderInfoSum(); } this.exTabControl1.SelectedIndex = 0; }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null) { int selectedIndex = dataGridView1.CurrentRow.Index; if (dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value != null) { Guid orderId = new Guid(dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value.ToString()); SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrderByBillSearch(orderId); if (salesOrder != null) { _salesOrder = salesOrder; //更新账单信息 Order order = salesOrder.order; this.lbOrderNo.Text = order.OrderNo; this.lbDeskName.Text = order.DeskName; string billType = string.Empty; if (order.Status == 0 || order.Status == 3) { billType = "未结账"; } else if (order.Status == 1) { billType = "已结账"; } else if (order.Status == 2) { billType = "已删除"; } this.lbBillType.Text = billType; string eatType = string.Empty; if (order.EatType == (int)EatWayType.DineIn) { eatType = "堂食"; } else if (order.EatType == (int)EatWayType.Takeout) { eatType = "外卖"; } else if (order.EatType == (int)EatWayType.OutsideOrder) { eatType = "外送"; } this.lbEatType.Text = eatType; this.lbEmployeeNo.Text = order.EmployeeNo; this.lbCashier.Text = order.PayEmployeeNo; this.lbDeviceNo.Text = order.DeviceNo; int startIndex = selectedIndex + 1; int index = this.lbBillIndex.Text.IndexOf('/'); this.lbBillIndex.Text = startIndex + this.lbBillIndex.Text.Substring(index); BindDataGridView2(salesOrder); BindDataGridView3(salesOrder); } } else { _salesOrder = null; this.lbOrderNo.Text = string.Empty; this.lbBillType.Text = string.Empty; this.lbDeskName.Text = string.Empty; this.lbEatType.Text = string.Empty; this.lbEmployeeNo.Text = string.Empty; this.lbCashier.Text = string.Empty; this.lbDeviceNo.Text = string.Empty; this.dataGridView2.Rows.Clear(); this.dataGridView3.Rows.Clear(); } } }
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 FormSplitBill(SalesOrder salesOrder) { m_SalesOrder = salesOrder; InitializeComponent(); this.btnSave.DisplayColor = this.btnSave.BackColor; }
private void btnBillModify_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null && _salesOrder != null && _salesOrder.order != null) { if (_salesOrder.order.Status == 1) { int selectedIndex = dataGridView1.CurrentRow.Index; FormModifyOrder form = new FormModifyOrder(_salesOrder); form.ShowDialog(); if (form.IsChanged) { Guid orderId = new Guid(dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value.ToString()); SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrderByBillSearch(orderId); _salesOrder = salesOrder; //更新账单信息 dataGridView1.Rows[selectedIndex].Cells["TotalSellPrice"].Value = salesOrder.order.TotalSellPrice.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["ActualSellPrice"].Value = salesOrder.order.ActualSellPrice.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["DiscountPrice"].Value = salesOrder.order.DiscountPrice.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["CutOffPrice"].Value = salesOrder.order.CutOffPrice.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["ServiceFee"].Value = salesOrder.order.ServiceFee.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["PaymentMoney"].Value = salesOrder.order.PaymentMoney.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["NeedChangePay"].Value = salesOrder.order.NeedChangePay.ToString("f2"); dataGridView1.Rows[selectedIndex].Cells["MoreOrLess"].Value = (salesOrder.order.ActualSellPrice + salesOrder.order.ServiceFee - (salesOrder.order.PaymentMoney - salesOrder.order.NeedChangePay)).ToString("f2"); BindDataGridView2(salesOrder); BindDataGridView3(salesOrder); } } } }
private void btnDelivery_Click(object sender, EventArgs e) { CrystalButton btnDelivery = sender as CrystalButton; if (btnDelivery == null) return; if (btnDelivery.Tag != null) { DeliveryOrder deliveryOrder = btnDelivery.Tag as DeliveryOrder; if (deliveryOrder == null) return; if (deliveryOrder.PayTime == null) { if (_prevDeliveryButton == null) { btnDelivery.ForeColor = Color.DodgerBlue; _prevDeliveryButton = btnDelivery; } else { if (btnDelivery.Text != _prevDeliveryButton.Text) { _prevDeliveryButton.ForeColor = Color.White; btnDelivery.ForeColor = Color.DodgerBlue; } _prevDeliveryButton = btnDelivery; } if (deliveryOrder.EatType == (int)EatWayType.OutsideOrder && deliveryOrder.DeliveryTime == null) { btnDeliveryGoods.Enabled = true; btnDeliveryGoods.BackColor = btnDeliveryGoods.DisplayColor; } else { btnDeliveryGoods.Enabled = false; btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor; } if (deliveryOrder.EatType == (int)EatWayType.OutsideOrder && deliveryOrder.DeliveryTime != null) { btnOutsideOrder.Enabled = false; btnOutsideOrder.BackColor = ConstantValuePool.DisabledColor; btnDiscount.Enabled = false; btnDiscount.BackColor = ConstantValuePool.DisabledColor; btnWholeDiscount.Enabled = false; btnWholeDiscount.BackColor = ConstantValuePool.DisabledColor; btnTakeOut.Enabled = false; btnTakeOut.BackColor = ConstantValuePool.DisabledColor; } else { btnOutsideOrder.Enabled = true; btnOutsideOrder.BackColor = btnOutsideOrder.DisplayColor; btnDiscount.Enabled = true; btnDiscount.BackColor = btnDiscount.DisplayColor; btnWholeDiscount.Enabled = true; btnWholeDiscount.BackColor = btnWholeDiscount.DisplayColor; btnTakeOut.Enabled = true; btnTakeOut.BackColor = btnTakeOut.DisplayColor; } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(deliveryOrder.OrderID); if (salesOrder != null) { _salesOrder = salesOrder; BindGoodsOrderInfo(); //绑定订单信息 BindOrderInfoSum(); CustomerOrder customerOrder = CustomersService.GetInstance().GetCustomerOrder(_salesOrder.order.OrderID); if (customerOrder != null) { this.txtTelephone.Text = customerOrder.Telephone; this.txtName.Text = customerOrder.CustomerName; this.txtAddress.Text = customerOrder.Address; txtTelephone.ReadOnly = true; txtName.ReadOnly = true; } else { this.txtTelephone.Text = string.Empty; this.txtName.Text = string.Empty; this.txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; } } else { MessageBox.Show("获取账单信息失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(deliveryOrder.OrderID); if (salesOrder != null) { FormTakeGoods form = new FormTakeGoods(salesOrder); form.ShowDialog(); if (form.HasDeliveried) { IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList(); if (deliveryOrderList != null) { _deliveryOrderList = deliveryOrderList; } btnDelivery.Enabled = false; btnDelivery.BackColor = ConstantValuePool.DisabledColor; } } } } }
public SalesOrder GetSalesOrderByBillSearch(Guid orderId) { SalesOrder salesOrder = null; try { _daoManager.OpenConnection(); Order order = _orderDao.GetOrder(orderId); if (order != null) { salesOrder = new SalesOrder(); salesOrder.order = order; if (order.Status != 4) { IList<OrderDetails> orderDetailsList = null; IList<OrderDiscount> orderDiscountList = null; if (order.Status == 0 || order.Status == 1 || order.Status == 3) { orderDetailsList = _orderDetailsDao.GetOrderDetailsList(orderId); orderDiscountList = _orderDiscountDao.GetOrderDiscountList(orderId); } else if (order.Status == 2) { orderDetailsList = _orderDetailsDao.GetDeletedOrderDetailsList(orderId); orderDiscountList = _orderDiscountDao.GetDeletedOrderDiscountList(orderId); } IList<OrderPayoff> orderPayoffList = null; if (order.Status == 1) { orderPayoffList = _orderPayoffDao.GetOrderPayoffList(orderId); } else if (order.Status == 2) { orderPayoffList = _orderPayoffDao.GetDeletedOrderPayoffList(orderId); } salesOrder.orderDetailsList = orderDetailsList; salesOrder.orderDiscountList = orderDiscountList; salesOrder.orderPayoffList = orderPayoffList; } } } catch (Exception exception) { LogHelper.GetInstance().Error(string.Format("[GetSalesOrderByBillSearch]参数:orderId_{0}", orderId), exception); } finally { _daoManager.CloseConnection(); } return salesOrder; }
/// <summary> /// 更新单据 /// </summary> /// <returns>0:更新失败 1:更新成功 2:单据被其他设备占用</returns> public Int32 UpdateSalesOrder(SalesOrder salesOrder) { int result = 0; _daoManager.BeginTransaction(); try { Order order = salesOrder.order; BizDesk desk = _deskDao.GetBizDeskByName(order.DeskName); if (desk == null || desk.DeviceNo == order.DeviceNo) { if (_orderDao.UpdateOrder(order)) { //日结号 string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo(); //菜单品项序号 int seqNumber = _orderDetailsDao.GetSequenceNum(order.OrderID); foreach (OrderDetails item in salesOrder.orderDetailsList) { item.OrderBy = seqNumber; item.DailyStatementNo = dailyStatementNo; _orderDetailsDao.UpdateOrderDetails(item); seqNumber++; } //折扣信息 if (salesOrder.orderDiscountList != null && salesOrder.orderDiscountList.Count > 0) { foreach (OrderDiscount item in salesOrder.orderDiscountList) { _orderDiscountDao.UpdateOrderDiscount(item); } } result = 1; } } else { result = 2; } _daoManager.CommitTransaction(); } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[UpdateSalesOrder]参数:salesOrder_{0}", JsonConvert.SerializeObject(salesOrder)), exception); result = 0; _daoManager.RollBackTransaction(); } return result; }
public SalesOrder GetSalesOrder(Guid orderId) { SalesOrder salesOrder = null; try { _daoManager.OpenConnection(); Order order = _orderDao.GetOrder(orderId); if (order != null) { IList<OrderDetails> orderDetailsList = _orderDetailsDao.GetOrderDetailsList(orderId); salesOrder = new SalesOrder { order = order, orderDetailsList = orderDetailsList }; } } catch (Exception exception) { LogHelper.GetInstance().Error(string.Format("[GetSalesOrder]参数:orderId_{0}", orderId), exception); } finally { _daoManager.CloseConnection(); } return salesOrder; }
public Int32 CreateSalesOrder(SalesOrder salesOrder) { Int32 tranSequence = 0; _daoManager.BeginTransaction(); try { //日结号 string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo(); if (!string.IsNullOrEmpty(dailyStatementNo)) { Order order = salesOrder.order; order.DailyStatementNo = dailyStatementNo; //分单号 Int32 curSubOrderNo = _orderDao.GetCurrentSubOrderNo(order.DeskName); if (curSubOrderNo > 0) { curSubOrderNo++; } else { curSubOrderNo = 1; } order.SubOrderNo = curSubOrderNo; //流水号 order.TranSequence = tranSequence = _sysDictionary.GetCurrentTranSequence(); string orderNo = _orderDao.CreateOrder(order); order.OrderNo = orderNo; //菜单品项序号 int seqNumber = _orderDetailsDao.GetSequenceNum(order.OrderID); foreach (OrderDetails item in salesOrder.orderDetailsList) { item.DailyStatementNo = dailyStatementNo; item.OrderBy = seqNumber; _orderDetailsDao.CreateOrderDetails(item); seqNumber++; } //折扣信息 if (salesOrder.orderDiscountList != null && salesOrder.orderDiscountList.Count > 0) { foreach (OrderDiscount item in salesOrder.orderDiscountList) { item.DailyStatementNo = dailyStatementNo; _orderDiscountDao.CreateOrderDiscount(item); } } //添加打印任务 SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { IList<PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 1, string.Empty); foreach (PrintTask printTask in printTaskList) { _printTaskDao.InsertPrintTask(printTask); } } } _daoManager.CommitTransaction(); } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[CreateSalesOrder]参数:salesOrder_{0}", JsonConvert.SerializeObject(salesOrder)), exception); tranSequence = 0; _daoManager.RollBackTransaction(); } return tranSequence; }
public bool CreateOrderInAndroid(string deskName, int peopleNum, Guid employeeId, string employeeNo, IList<OrderDetail> orderDetailList) { bool isSuccess = false; if (orderDetailList != null && orderDetailList.Count > 0) { _daoManager.BeginTransaction(); try { //日结号 string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo(); if (!string.IsNullOrEmpty(dailyStatementNo)) { decimal totalPrice = 0, actualPayMoney = 0, totalDiscount = 0; foreach (var orderDetail in orderDetailList) { totalPrice += orderDetail.SellPrice*orderDetail.GoodsQty; actualPayMoney += orderDetail.SellPrice*orderDetail.GoodsQty - orderDetail.TotalDiscount; totalDiscount += orderDetail.TotalDiscount; } const string deviceNo = "AD"; //批量获取品项 List<Guid> goodsIdList = orderDetailList.Select(orderDetail => orderDetail.GoodsId).ToList(); IList<Goods> goodsList = _goodsDao.GetGoodsList(goodsIdList); if (goodsList != null && goodsList.Count > 0) { //订单头部 Order order = new Order { OrderID = Guid.NewGuid(), TotalSellPrice = totalPrice, ActualSellPrice = actualPayMoney, DiscountPrice = totalDiscount, CutOffPrice = 0, ServiceFee = 0, DeviceNo = deviceNo, DeskName = deskName, EatType = (int) EatWayType.DineIn, Status = 0, PeopleNum = peopleNum, EmployeeID = employeeId, EmployeeNo = employeeNo, DailyStatementNo = dailyStatementNo }; //分单号 Int32 curSubOrderNo = _orderDao.GetCurrentSubOrderNo(deskName); if (curSubOrderNo > 0) { curSubOrderNo++; } else { curSubOrderNo = 1; } order.SubOrderNo = curSubOrderNo; //流水号 order.TranSequence = _sysDictionary.GetCurrentTranSequence(); string orderNo = _orderDao.CreateOrder(order); order.OrderNo = orderNo; //菜单品项序号 IList<OrderDetails> orderDetailsList = new List<OrderDetails>(); int seqNumber = _orderDetailsDao.GetSequenceNum(order.OrderID); foreach (OrderDetail item in orderDetailList) { Goods goods = goodsList.FirstOrDefault(g => g.GoodsID.Equals(item.GoodsId)); if (goods != null) { OrderDetails orderDetails = new OrderDetails { OrderDetailsID = Guid.NewGuid(), OrderID = order.OrderID, DeviceNo = deviceNo, TotalSellPrice = item.SellPrice*item.GoodsQty, TotalDiscount = item.TotalDiscount, ItemQty = item.GoodsQty, EmployeeID = employeeId, ItemType = (int) OrderItemType.Goods, GoodsID = item.GoodsId, GoodsNo = goods.GoodsNo, GoodsName = item.GoodsName, Unit = goods.Unit, CanDiscount = goods.CanDiscount, SellPrice = item.SellPrice, PrintSolutionName = goods.PrintSolutionName, DepartID = goods.DepartID, DailyStatementNo = dailyStatementNo, OrderBy = seqNumber }; orderDetailsList.Add(orderDetails); _orderDetailsDao.CreateOrderDetails(orderDetails); seqNumber++; if (!string.IsNullOrEmpty(item.Remark)) { //自定义口味 orderDetails = new OrderDetails { OrderDetailsID = Guid.NewGuid(), OrderID = order.OrderID, DeviceNo = deviceNo, TotalSellPrice = 0, TotalDiscount = 0, ItemLevel = 1, ItemQty = item.GoodsQty, EmployeeID = employeeId, ItemType = (int) OrderItemType.Details, GoodsID = new Guid("77777777-7777-7777-7777-777777777777"), GoodsNo = "7777", GoodsName = item.Remark, Unit = "", CanDiscount = false, SellPrice = 0, PrintSolutionName = goods.PrintSolutionName, DepartID = goods.DepartID, DailyStatementNo = dailyStatementNo, OrderBy = seqNumber }; orderDetailsList.Add(orderDetails); _orderDetailsDao.CreateOrderDetails(orderDetails); seqNumber++; } } } //折扣信息 //if (salesOrder.orderDiscountList != null && salesOrder.orderDiscountList.Count > 0) //{ // foreach (OrderDiscount item in salesOrder.orderDiscountList) // { // item.DailyStatementNo = dailyStatementNo; // _orderDiscountDao.CreateOrderDiscount(item); // } //} SalesOrder salesOrder = new SalesOrder { order = order, orderDetailsList = orderDetailsList }; //salesOrder.orderDiscountList = newOrderDiscountList; //添加打印任务 SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { IList<PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 1, string.Empty); foreach (PrintTask printTask in printTaskList) { _printTaskDao.InsertPrintTask(printTask); } } } } _daoManager.CommitTransaction(); isSuccess = true; } catch(Exception exception) { LogHelper.GetInstance().Error(string.Format("[CreateOrderInAndroid]参数:deskName_{0},peopleNum_{1},employeeId_{2},employeeNo_{3},orderDetailList_{4}", deskName, peopleNum, employeeId, employeeNo, JsonConvert.SerializeObject(orderDetailList)), exception); isSuccess = false; _daoManager.RollBackTransaction(); } } return isSuccess; }
private void btnBeNew_Click(object sender, EventArgs e) { 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; btnDiscount.Enabled = true; btnDiscount.BackColor = btnDiscount.DisplayColor; btnWholeDiscount.Enabled = true; btnWholeDiscount.BackColor = btnWholeDiscount.DisplayColor; btnTakeOut.Enabled = true; btnTakeOut.BackColor = btnTakeOut.DisplayColor; txtTelephone.Text = string.Empty; txtName.Text = string.Empty; txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; if (_prevDeliveryButton != null) { _prevDeliveryButton.ForeColor = Color.White; } }
/// <summary> /// 获取打印任务列表 /// </summary> /// <param name="salesOrder">订单实例</param> /// <param name="printStyle">1 堂吃, 2 外卖, 3 堂吃兼外卖</param> /// <param name="followStyle">1 细跟主, 2 主跟细</param> /// <param name="printType">打印类型(0 一单一切, 1 一菜一切)</param> /// <param name="taskType">任务类别 1,加单 2,删单 3,催单 4,转台</param> /// <param name="reason">原因</param> public IList<PrintTask> GetPrintTaskList(SalesOrder salesOrder, int printStyle, int followStyle, int printType, int taskType, string reason) { if (salesOrder == null || salesOrder.order == null || salesOrder.orderDetailsList.Count == 0) return null; IList<PrintTask> printTaskList = new List<PrintTask>(); DateTime printTime = DateTime.Now; Order order = salesOrder.order; for (int index = 0; index < salesOrder.orderDetailsList.Count; index++) { OrderDetails details = salesOrder.orderDetailsList[index]; if (details.ItemType == (int)OrderItemType.Goods) { //1 细跟主, 2 主跟细 if (followStyle == 1) { if (string.IsNullOrEmpty(details.PrintSolutionName)) { //类似主跟细 for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { break; } else { if (!string.IsNullOrEmpty(nextDetails.PrintSolutionName)) { string[] printerNameArr = nextDetails.PrintSolutionName.Split(','); foreach (string printerName in printerNameArr) { //打印解决方案 //主项 PrintTask printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 1; printTask.GoodsName = details.GoodsName; printTask.Unit = details.Unit; printTask.ItemQty = details.ItemQty; printTaskList.Add(printTask); //细项或者套餐 printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 0; if (nextDetails.ItemType == (int)OrderItemType.Details) { printTask.DetailsName = nextDetails.GoodsName; } if (nextDetails.ItemType == (int)OrderItemType.SetMeal) { printTask.SubGoodsName = nextDetails.GoodsName; } printTask.Unit = nextDetails.Unit; printTask.ItemQty = nextDetails.ItemQty; printTaskList.Add(printTask); } } } } } else { string[] printerNameArr = details.PrintSolutionName.Split(','); foreach (string printerName in printerNameArr) { //打印解决方案 PrintTask printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = printType; printTask.GoodsName = details.GoodsName; printTask.Unit = details.Unit; printTask.ItemQty = details.ItemQty; if (printStyle == 1) //1 堂吃, 2 外卖, 3堂吃兼外卖 { printTaskList.Add(printTask); for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { break; } else { //打印解决方案 printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 0; if (nextDetails.ItemType == (int)OrderItemType.Details) { printTask.DetailsName = nextDetails.GoodsName; } if (nextDetails.ItemType == (int)OrderItemType.SetMeal) { printTask.SubGoodsName = nextDetails.GoodsName; } printTask.Unit = nextDetails.Unit; printTask.ItemQty = nextDetails.ItemQty; printTaskList.Add(printTask); } } } if (printStyle == 2) //1 堂吃, 2 外卖, 3堂吃兼外卖 { string totalDetailsName = string.Empty; for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { break; } else { totalDetailsName += "," + nextDetails.GoodsName + "*" + nextDetails.ItemQty; } } if (!string.IsNullOrEmpty(totalDetailsName)) { totalDetailsName = totalDetailsName.Substring(1); } printTask.TotalDetailsName = totalDetailsName; printTaskList.Add(printTask); } if (printStyle == 3) //1 堂吃, 2 外卖, 3堂吃兼外卖 { if (order.EatType == (int)EatWayType.DineIn) { printTaskList.Add(printTask); for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { break; } else { //打印解决方案 printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 0; if (nextDetails.ItemType == (int)OrderItemType.Details) { printTask.DetailsName = nextDetails.GoodsName; } if (nextDetails.ItemType == (int)OrderItemType.SetMeal) { printTask.SubGoodsName = nextDetails.GoodsName; } printTask.Unit = nextDetails.Unit; printTask.ItemQty = nextDetails.ItemQty; printTaskList.Add(printTask); } } } else { string totalDetailsName = string.Empty; for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { break; } else { totalDetailsName += "," + nextDetails.GoodsName + "*" + nextDetails.ItemQty; } } if (!string.IsNullOrEmpty(totalDetailsName)) { totalDetailsName = totalDetailsName.Substring(1); } printTask.TotalDetailsName = totalDetailsName; printTaskList.Add(printTask); } } } } } //1 细跟主, 2 主跟细 if (followStyle == 2) { bool onlyMainItem = true; for (int i = index + 1; i < salesOrder.orderDetailsList.Count; i++) { OrderDetails nextDetails = salesOrder.orderDetailsList[i]; if (nextDetails.ItemType == (int)OrderItemType.Goods) { if (onlyMainItem) { if (!string.IsNullOrEmpty(details.PrintSolutionName)) { string[] printerNameArr = details.PrintSolutionName.Split(','); foreach (string printerName in printerNameArr) { //打印解决方案 PrintTask printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = printType; printTask.GoodsName = details.GoodsName; printTask.Unit = details.Unit; printTask.ItemQty = details.ItemQty; printTaskList.Add(printTask); } } } break; } else { if (!string.IsNullOrEmpty(nextDetails.PrintSolutionName)) { string[] printerNameArr = nextDetails.PrintSolutionName.Split(','); foreach (string printerName in printerNameArr) { //打印解决方案 //主项 PrintTask printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 1; printTask.GoodsName = details.GoodsName; printTask.Unit = details.Unit; printTask.ItemQty = details.ItemQty; printTaskList.Add(printTask); //细项或者套餐 printTask = new PrintTask(); printTask.OrderNo = order.OrderNo; printTask.PeopleNum = order.PeopleNum; printTask.EmployeeNo = order.EmployeeNo; printTask.EmployeeID = order.EmployeeID; printTask.TranSequence = order.TranSequence; printTask.EatType = order.EatType; printTask.DeskName = order.DeskName; printTask.SubOrderNo = order.SubOrderNo; printTask.TaskType = taskType; printTask.PrintTime = printTime; printTask.Reason = reason; printTask.IsPrinted = false; printTask.PrintSolutionName = printerName; printTask.PrintType = 0; if (nextDetails.ItemType == (int)OrderItemType.Details) { printTask.DetailsName = nextDetails.GoodsName; } if (nextDetails.ItemType == (int)OrderItemType.SetMeal) { printTask.SubGoodsName = nextDetails.GoodsName; } printTask.Unit = nextDetails.Unit; printTask.ItemQty = nextDetails.ItemQty; printTaskList.Add(printTask); } onlyMainItem = false; } } } } } } return printTaskList; }
private void btnOutsideOrder_Click(object sender, EventArgs e) { if (dgvGoodsOrder.Rows.Count <= 0) { MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!_haveDailyClose) { MessageBox.Show("上次未日结,不能新增菜单,请先进行日结操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.IsNullOrEmpty(txtTelephone.Text.Trim())) { if (string.IsNullOrEmpty(txtName.Text.Trim())) { if (DialogResult.Yes == MessageBox.Show("当前订单顾客姓名未填写,是否返回?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) return; } if (string.IsNullOrEmpty(txtAddress.Text.Trim())) { if (DialogResult.Yes == MessageBox.Show("当前订单外送地址未填写,是否返回?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) return; } } if (_salesOrder == null || _salesOrder.order.EatType == (int)EatWayType.OutsideOrder) { string deskName = _salesOrder == null ? "W001" : _salesOrder.order.DeskName; int result = SubmitSalesOrder(deskName, EatWayType.OutsideOrder); if (result == 1) { this.lbTotalPrice.Text = "总金额:"; this.lbDiscount.Text = "折扣:"; this.lbNeedPayMoney.Text = "实际应付:"; this.lbCutOff.Text = "去零:"; dgvGoodsOrder.Rows.Clear(); _salesOrder = null; btnDeliveryGoods.Enabled = false; btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor; txtTelephone.Text = string.Empty; txtName.Text = string.Empty; txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; //加载外卖单列表 IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList(); if (deliveryOrderList != null) { _pageIndex = 0; _deliveryOrderList = deliveryOrderList; DisplayDeliveryOrderButton(); } //更新第二屏信息 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled) { if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen) { ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo(); } } } else if (result == 0) { MessageBox.Show("外送提交失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { MessageBox.Show("没有数据可以提交!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (_salesOrder.order.EatType == (int)EatWayType.Takeout) { MessageBox.Show("当前账单状态为[外带],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (_salesOrder.order.EatType == (int)EatWayType.DineIn) { MessageBox.Show("当前账单状态为[堂食],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void BindOrderInfoSum(SalesOrder salesOrder) { int index = (int)dgvGoodsOrderSum.Rows.Add(new DataGridViewRow()); dgvGoodsOrderSum.Rows[index].Cells[0].Value = "金额合计"; dgvGoodsOrderSum.Rows[index].Cells[1].Value = salesOrder.order.TotalSellPrice; if (Math.Abs(salesOrder.order.DiscountPrice) > 0) { index = (int)dgvGoodsOrderSum.Rows.Add(new DataGridViewRow()); dgvGoodsOrderSum.Rows[index].Cells[0].Value = "折扣合计"; dgvGoodsOrderSum.Rows[index].Cells[1].Value = salesOrder.order.DiscountPrice; } index = (int)dgvGoodsOrderSum.Rows.Add(new DataGridViewRow()); dgvGoodsOrderSum.Rows[index].Cells[0].Value = "实际应付"; dgvGoodsOrderSum.Rows[index].Cells[1].Value = salesOrder.order.ActualSellPrice; }
/// <summary> /// 0:提交失败 1:成功 2:没有可提交的数据 3:沽清失败 /// </summary> private Int32 SubmitSalesOrder(string deskName, EatWayType eatType) { int result = 0; Guid orderId; if (_salesOrder == null) //新增的菜单 { orderId = Guid.NewGuid(); } else { orderId = _salesOrder.order.OrderID; } IList<GoodsCheckStock> temp = new List<GoodsCheckStock>(); IList<OrderDetails> newOrderDetailsList = new List<OrderDetails>(); IList<OrderDiscount> newOrderDiscountList = new List<OrderDiscount>(); foreach (DataGridViewRow dr in dgvGoodsOrder.Rows) { if (dr.Cells["OrderDetailsID"].Value == null) { Guid orderDetailsId = Guid.NewGuid(); int itemType = Convert.ToInt32(dr.Cells["ItemType"].Value); string goodsName = dr.Cells["GoodsName"].Value.ToString(); //填充OrderDetails OrderDetails orderDetails = new OrderDetails(); orderDetails.OrderDetailsID = orderDetailsId; orderDetails.OrderID = orderId; orderDetails.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; orderDetails.TotalSellPrice = Convert.ToDecimal(dr.Cells["GoodsPrice"].Value); orderDetails.TotalDiscount = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value); orderDetails.ItemQty = Convert.ToDecimal(dr.Cells["GoodsNum"].Value); orderDetails.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; if (dr.Cells["Wait"].Value != null) { orderDetails.Wait = Convert.ToInt32(dr.Cells["Wait"].Value); } if (itemType == (int)OrderItemType.Goods) { orderDetails.ItemType = (int)OrderItemType.Goods; Goods goods = dr.Cells["ItemID"].Tag as Goods; if (goods != null) { orderDetails.GoodsID = goods.GoodsID; orderDetails.GoodsNo = goods.GoodsNo; orderDetails.GoodsName = goods.GoodsName; orderDetails.Unit = goods.Unit; orderDetails.CanDiscount = goods.CanDiscount; orderDetails.SellPrice = goods.SellPrice; orderDetails.PrintSolutionName = goods.PrintSolutionName; orderDetails.DepartID = goods.DepartID; if (goods.IsCheckStock) { GoodsCheckStock goodsCheckStock = new GoodsCheckStock(); goodsCheckStock.GoodsID = goods.GoodsID; goodsCheckStock.GoodsName = goods.GoodsName; goodsCheckStock.ReducedQuantity = orderDetails.ItemQty; temp.Add(goodsCheckStock); } } } else if (itemType == (int)OrderItemType.Details) { orderDetails.ItemType = (int)OrderItemType.Details; Details details = dr.Cells["ItemID"].Tag as Details; if (details != null) { orderDetails.GoodsID = details.DetailsID; orderDetails.GoodsNo = details.DetailsNo; orderDetails.GoodsName = details.DetailsName; orderDetails.CanDiscount = details.CanDiscount; orderDetails.Unit = ""; // orderDetails.SellPrice = details.SellPrice; orderDetails.PrintSolutionName = details.PrintSolutionName; orderDetails.DepartID = details.DepartID; } int index = goodsName.LastIndexOf('-'); string itemPrefix = goodsName.Substring(0, index + 1); orderDetails.ItemLevel = itemPrefix.Length / 2; } else if (itemType == (int)OrderItemType.SetMeal) { orderDetails.ItemType = (int)OrderItemType.SetMeal; int index = goodsName.LastIndexOf('-'); string itemPrefix = goodsName.Substring(0, index + 1); orderDetails.ItemLevel = itemPrefix.Length / 2; object item = dr.Cells["ItemID"].Tag; if (item is Goods) { Goods goods = item as Goods; orderDetails.GoodsID = goods.GoodsID; orderDetails.GoodsNo = goods.GoodsNo; orderDetails.GoodsName = goods.GoodsName; orderDetails.CanDiscount = goods.CanDiscount; orderDetails.Unit = goods.Unit; orderDetails.SellPrice = goods.SellPrice; orderDetails.PrintSolutionName = goods.PrintSolutionName; orderDetails.DepartID = goods.DepartID; } else if (item is Details) { Details details = item as Details; orderDetails.GoodsID = details.DetailsID; orderDetails.GoodsNo = details.DetailsNo; orderDetails.GoodsName = details.DetailsName; orderDetails.CanDiscount = details.CanDiscount; orderDetails.Unit = ""; // orderDetails.SellPrice = details.SellPrice; orderDetails.PrintSolutionName = details.PrintSolutionName; orderDetails.DepartID = details.DepartID; } } newOrderDetailsList.Add(orderDetails); //填充OrderDiscount Discount discount = dr.Cells["GoodsDiscount"].Tag as Discount; if (discount != null) { decimal offPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value)); if (offPay > 0) { OrderDiscount orderDiscount = new OrderDiscount(); orderDiscount.OrderDiscountID = Guid.NewGuid(); orderDiscount.OrderID = orderId; orderDiscount.OrderDetailsID = orderDetailsId; orderDiscount.DiscountID = discount.DiscountID; orderDiscount.DiscountName = discount.DiscountName; orderDiscount.DiscountType = discount.DiscountType; orderDiscount.DiscountRate = discount.DiscountRate; orderDiscount.OffFixPay = discount.OffFixPay; orderDiscount.OffPay = offPay; orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; newOrderDiscountList.Add(orderDiscount); } } } else { //修改过折扣的账单 Discount discount = dr.Cells["GoodsDiscount"].Tag as Discount; if (discount != null) { Guid orderDetailsId = new Guid(dr.Cells["OrderDetailsID"].Value.ToString()); //填充OrderDetails OrderDetails orderDetails = new OrderDetails(); orderDetails.OrderDetailsID = orderDetailsId; orderDetails.OrderID = orderId; orderDetails.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; orderDetails.ItemQty = Convert.ToDecimal(dr.Cells["GoodsNum"].Value); orderDetails.ItemType = Convert.ToInt32(dr.Cells["ItemType"].Value); orderDetails.GoodsName = dr.Cells["GoodsName"].Value.ToString(); orderDetails.TotalSellPrice = Convert.ToDecimal(dr.Cells["GoodsPrice"].Value); orderDetails.TotalDiscount = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value); orderDetails.Unit = dr.Cells["ItemUnit"].Value.ToString(); orderDetails.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; if (dr.Cells["Wait"].Value != null) { orderDetails.Wait = Convert.ToInt32(dr.Cells["Wait"].Value); } newOrderDetailsList.Add(orderDetails); //填充OrderDiscount decimal offPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value)); if (offPay > 0) { OrderDiscount orderDiscount = new OrderDiscount(); orderDiscount.OrderDiscountID = Guid.NewGuid(); orderDiscount.OrderID = orderId; orderDiscount.OrderDetailsID = orderDetailsId; orderDiscount.DiscountID = discount.DiscountID; orderDiscount.DiscountName = discount.DiscountName; orderDiscount.DiscountType = discount.DiscountType; orderDiscount.DiscountRate = discount.DiscountRate; orderDiscount.OffFixPay = discount.OffFixPay; orderDiscount.OffPay = offPay; orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; newOrderDiscountList.Add(orderDiscount); } } } } //品项沽清 IList<GoodsCheckStock> tempGoodsStockList = GoodsService.GetInstance().GetGoodsCheckStock(); if (tempGoodsStockList != null && tempGoodsStockList.Count > 0 && temp.Count > 0) { IList<GoodsCheckStock> goodsCheckStockList = new List<GoodsCheckStock>(); foreach (GoodsCheckStock item in temp) { bool isContains = tempGoodsStockList.Any(tempGoodsStock => item.GoodsID.Equals(tempGoodsStock.GoodsID)); if (isContains) { goodsCheckStockList.Add(item); } } if (goodsCheckStockList.Count > 0) { string goodsName = GoodsService.GetInstance().UpdateReducedGoodsQty(goodsCheckStockList); if (!string.IsNullOrEmpty(goodsName)) { MessageBox.Show(string.Format("<{0}> 的剩余数量不足!", goodsName), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return 3; } } } if (_salesOrder == null) //新增的菜单 { Order order = new Order(); order.OrderID = orderId; order.TotalSellPrice = _totalPrice; order.ActualSellPrice = _actualPayMoney; order.DiscountPrice = _discount; order.CutOffPrice = _cutOff; order.ServiceFee = 0; order.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; order.DeskName = deskName; order.EatType = (int)eatType; order.Status = 0; order.PeopleNum = 1; order.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; order.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; SalesOrder salesOrder = new SalesOrder(); salesOrder.order = order; salesOrder.orderDetailsList = newOrderDetailsList; salesOrder.orderDiscountList = newOrderDiscountList; int tranSequence = SalesOrderService.GetInstance().CreateSalesOrder(salesOrder); if (tranSequence > 0) { //重新加载 _salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); BindGoodsOrderInfo(); //绑定订单信息 BindOrderInfoSum(); result = 1; } } else { if (newOrderDetailsList.Count > 0) { Order order = new Order(); order.OrderID = orderId; order.TotalSellPrice = _totalPrice; order.ActualSellPrice = _actualPayMoney; order.DiscountPrice = _discount; order.CutOffPrice = _cutOff; order.ServiceFee = 0; order.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo; order.DeskName = deskName; order.PeopleNum = 1; order.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; order.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; SalesOrder salesOrder = new SalesOrder(); salesOrder.order = order; salesOrder.orderDetailsList = newOrderDetailsList; salesOrder.orderDiscountList = newOrderDiscountList; if (SalesOrderService.GetInstance().UpdateSalesOrder(salesOrder) == 1) { //重新加载 _salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); BindGoodsOrderInfo(); //绑定订单信息 BindOrderInfoSum(); result = 1; } } else { result = 2; } } if (eatType == EatWayType.OutsideOrder) { if (result == 1 || result == 2) { //添加外送信息 CustomerOrder customerOrder = new CustomerOrder { OrderID = orderId, Telephone = txtTelephone.Text.Trim(), CustomerName = txtName.Text.Trim(), Address = txtAddress.Text.Trim() }; if (!string.IsNullOrEmpty(customerOrder.Telephone) && !string.IsNullOrEmpty(customerOrder.CustomerName)) { if (CustomersService.GetInstance().CreateOrUpdateCustomerOrder(customerOrder)) { result = 1; } else { MessageBox.Show("添加外送信息失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } if (eatType == EatWayType.Takeout) { if (result == 1) { if (ConstantValuePool.BizSettingConfig.TakeoutPrint && ConstantValuePool.BizSettingConfig.printConfig.Enabled) { //打印 PrintData printData = new PrintData(); printData.ShopName = ConstantValuePool.CurrentShop.ShopName; printData.DeskName = deskName; printData.PersonNum = "1"; printData.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); printData.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo; printData.TranSequence = _salesOrder.order.TranSequence.ToString(); printData.ShopAddress = ConstantValuePool.CurrentShop.RunAddress; printData.Telephone = ConstantValuePool.CurrentShop.Telephone; printData.GoodsOrderList = new List<GoodsOrder>(); foreach (OrderDetails item in newOrderDetailsList) { string strLevelFlag = string.Empty; if (item.ItemLevel > 0) { int levelCount = item.ItemLevel * 2; for (int i = 0; i < levelCount; i++) { strLevelFlag += "-"; } } GoodsOrder goodsOrder = new GoodsOrder(); goodsOrder.GoodsName = strLevelFlag + item.GoodsName; goodsOrder.GoodsNum = item.ItemQty.ToString("f1"); goodsOrder.SellPrice = (item.TotalSellPrice / item.ItemQty).ToString("f2"); goodsOrder.TotalSellPrice = item.TotalSellPrice.ToString("f2"); goodsOrder.TotalDiscount = item.TotalDiscount.ToString("f2"); goodsOrder.Unit = item.Unit; printData.GoodsOrderList.Add(goodsOrder); } int copies = ConstantValuePool.BizSettingConfig.printConfig.Copies; string paperWidth = ConstantValuePool.BizSettingConfig.printConfig.PaperWidth; if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.DRIVER) { string printerName = ConstantValuePool.BizSettingConfig.printConfig.Name; string paperName = ConstantValuePool.BizSettingConfig.printConfig.PaperName; DriverOrderPrint printer = DriverOrderPrint.GetInstance(printerName, paperName, paperWidth); for (int i = 0; i < copies; i++) { printer.DoPrintOrder(printData); } } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.COM) { string port = ConstantValuePool.BizSettingConfig.printConfig.Name; if (port.Length > 3) { if (port.Substring(0, 3).ToUpper() == "COM") { string portName = port.Substring(0, 4).ToUpper(); InstructionOrderPrint printer = new InstructionOrderPrint(portName, 9600, Parity.None, 8, StopBits.One, paperWidth); for (int i = 0; i < copies; i++) { printer.DoPrintOrder(printData); } } } } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.ETHERNET) { string ipAddress = ConstantValuePool.BizSettingConfig.printConfig.Name; InstructionOrderPrint printer = new InstructionOrderPrint(ipAddress, 9100, paperWidth); for (int i = 0; i < copies; i++) { printer.DoPrintOrder(printData); } } if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.USB) { string vid = ConstantValuePool.BizSettingConfig.printConfig.VID; string pid = ConstantValuePool.BizSettingConfig.printConfig.PID; string endpointId = ConstantValuePool.BizSettingConfig.printConfig.EndpointID; InstructionOrderPrint printer = new InstructionOrderPrint(vid, pid, endpointId, paperWidth); for (int i = 0; i < copies; i++) { printer.DoPrintOrder(printData); } } } } } return result; }
private void BindDataGridView3(SalesOrder salesOrder) { this.dataGridView3.Rows.Clear(); Order order = salesOrder.order; //售价总计 int index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "售价总计"; dataGridView3.Rows[index].Cells[1].Value = string.Empty; dataGridView3.Rows[index].Cells[2].Value = string.Empty; dataGridView3.Rows[index].Cells[3].Value = order.TotalSellPrice.ToString("f2"); //去零金额 if (Math.Abs(order.CutOffPrice) > 0) { index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "去零金额"; dataGridView3.Rows[index].Cells[1].Value = string.Empty; dataGridView3.Rows[index].Cells[2].Value = string.Empty; dataGridView3.Rows[index].Cells[3].Value = string.Empty; dataGridView3.Rows[index].Cells[4].Value = (-order.CutOffPrice).ToString("f2"); } //折扣金额 if (Math.Abs(order.DiscountPrice) > 0) { index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "折扣金额"; dataGridView3.Rows[index].Cells[1].Value = string.Empty; dataGridView3.Rows[index].Cells[2].Value = string.Empty; dataGridView3.Rows[index].Cells[3].Value = order.DiscountPrice.ToString("f2"); dataGridView3.Rows[index].Cells[4].Value = string.Empty; } //实际金额 index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "实际金额"; dataGridView3.Rows[index].Cells[1].Value = string.Empty; dataGridView3.Rows[index].Cells[2].Value = string.Empty; dataGridView3.Rows[index].Cells[3].Value = order.ActualSellPrice.ToString("f2"); dataGridView3.Rows[index].Cells[4].Value = string.Empty; //服务费 if (order.ServiceFee > 0) { index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "服务费"; dataGridView3.Rows[index].Cells[1].Value = string.Empty; dataGridView3.Rows[index].Cells[2].Value = string.Empty; dataGridView3.Rows[index].Cells[3].Value = order.ServiceFee.ToString("f2"); dataGridView3.Rows[index].Cells[4].Value = string.Empty; } IList<OrderPayoff> orderPayoffList = salesOrder.orderPayoffList; if (orderPayoffList != null && orderPayoffList.Count > 0) { //空行 dataGridView3.Rows.Add(); //支付金额 index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = "支付金额"; dataGridView3.Rows[index].Cells[1].Value = (order.ActualSellPrice + order.ServiceFee).ToString("f2"); dataGridView3.Rows[index].Cells[3].Value = (order.PaymentMoney - order.NeedChangePay).ToString("f2"); decimal moreOrLess = order.ActualSellPrice + order.ServiceFee - (order.PaymentMoney - order.NeedChangePay); if (Math.Abs(moreOrLess) > 0) { dataGridView3.Rows[index].Cells[4].Value = (moreOrLess).ToString("f2"); } //空行 dataGridView3.Rows.Add(); //支付方式明细 foreach (OrderPayoff orderPayoff in orderPayoffList) { index = dataGridView3.Rows.Add(); dataGridView3.Rows[index].Cells[0].Value = orderPayoff.PayoffName; if (orderPayoff.PayoffType == (int)PayoffWayMode.GiftVoucher || orderPayoff.PayoffType == (int)PayoffWayMode.Coupon) { dataGridView3.Rows[index].Cells[1].Value = string.Format("{0} 张", orderPayoff.Quantity.ToString("f1")); } else { dataGridView3.Rows[index].Cells[1].Value = (orderPayoff.AsPay * orderPayoff.Quantity).ToString("f2"); } if (orderPayoff.NeedChangePay > 0) { dataGridView3.Rows[index].Cells[2].Value = (-orderPayoff.NeedChangePay).ToString("f2"); } dataGridView3.Rows[index].Cells[3].Value = (orderPayoff.AsPay * orderPayoff.Quantity - orderPayoff.NeedChangePay).ToString("f2"); dataGridView3.Rows[index].Cells[4].Value = string.Empty; } } }
private void btnCheckout_Click(object sender, EventArgs e) { if (dgvGoodsOrder.Rows.Count <= 0) { MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!_haveDailyClose) { bool isContainsNewItem = false; foreach (DataGridViewRow dr in dgvGoodsOrder.Rows) { if (dr.Cells["OrderDetailsID"].Value == null) { isContainsNewItem = true; break; } } if (isContainsNewItem) { MessageBox.Show("上次未日结,不能新增菜单,请先进行日结操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //权限验证 bool hasRights = false; if (RightsItemCode.FindRights(RightsItemCode.CHECKOUT)) { hasRights = true; } else { FormRightsCode form = new FormRightsCode(); form.ShowDialog(); if (form.ReturnValue) { IList<string> rightsCodeList = form.RightsCodeList; if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CHECKOUT)) { hasRights = true; } } } if (!hasRights) { return; } //判断参加限时组合销售 JoinGoodsCombinedSale(this.dgvGoodsOrder); BindOrderInfoSum(); string deskName; if (_salesOrder == null) { if (ConstantValuePool.BizSettingConfig.CarteMode) { FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入餐牌号"; form.ShowDialog(); if (string.IsNullOrEmpty(form.KeypadValue)) { MessageBox.Show("餐牌号不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (form.KeypadValue.Length > 3) { MessageBox.Show("您输入的餐牌号码过大!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } deskName = "W" + form.KeypadValue.PadLeft(3, '0'); } else { deskName = "W001"; } } else { deskName = _salesOrder.order.DeskName; } int result = SubmitSalesOrder(deskName, EatWayType.Takeout); if (result == 0) { MessageBox.Show("提交菜单信息出现异常,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //转入结账页面 FormPayment checkForm = new FormPayment(_salesOrder); checkForm.ShowDialog(); if (checkForm.IsPaidOrder) { this.lbTotalPrice.Text = "总金额:"; this.lbDiscount.Text = "折扣:"; this.lbNeedPayMoney.Text = "实际应付:"; this.lbCutOff.Text = "去零:"; dgvGoodsOrder.Rows.Clear(); _salesOrder = null; btnDeliveryGoods.Enabled = false; btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor; txtTelephone.Text = string.Empty; txtName.Text = string.Empty; txtAddress.Text = string.Empty; txtTelephone.ReadOnly = false; txtName.ReadOnly = false; //加载外卖单列表 IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList(); if (deliveryOrderList != null) { _pageIndex = 0; _deliveryOrderList = deliveryOrderList; DisplayDeliveryOrderButton(); } //更新第二屏信息 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled) { if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen) { ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo(); } } } } }
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 BindGoodsOrderInfo(SalesOrder salesOrder) { if (salesOrder.orderDetailsList != null && salesOrder.orderDetailsList.Count > 0) { foreach (OrderDetails orderDetails in salesOrder.orderDetailsList) { int index = dgvGoodsOrder.Rows.Add(new DataGridViewRow()); dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value = orderDetails.ItemQty; string restOrderFlag = string.Empty; if (orderDetails.Wait == 1) { restOrderFlag = "*"; } if (orderDetails.ItemType == (int)OrderItemType.Goods) { dgvGoodsOrder.Rows[index].Cells["GoodsName"].Value = restOrderFlag + orderDetails.GoodsName; } else { string strLevelFlag = string.Empty; int levelCount = orderDetails.ItemLevel * 2; for (int i = 0; i < levelCount; i++) { strLevelFlag += "-"; } dgvGoodsOrder.Rows[index].Cells["GoodsName"].Value = strLevelFlag + restOrderFlag + orderDetails.GoodsName; } dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value = orderDetails.TotalSellPrice; dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = orderDetails.TotalDiscount; dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Value = orderDetails.OrderDetailsID; dgvGoodsOrder.Rows[index].Cells["ItemType"].Value = orderDetails.ItemType; } } }
public FormCheckOut(SalesOrder salesOrder, string currentDeskName) { InitializeComponent(); m_SalesOrder = salesOrder; m_CurrentDeskName = currentDeskName; btnPageUp.BackColor = btnPageUp.DisplayColor = Color.Tomato; btnPageDown.BackColor = btnPageDown.DisplayColor = Color.Teal; }
public bool DeleteSingleOrder(DeletedSingleOrder deletedSingleOrder) { bool returnValue = false; _daoManager.BeginTransaction(); try { Order order = new Order { OrderID = deletedSingleOrder.OrderID, TotalSellPrice = deletedSingleOrder.TotalSellPrice, ActualSellPrice = deletedSingleOrder.ActualSellPrice, DiscountPrice = deletedSingleOrder.DiscountPrice, CutOffPrice = deletedSingleOrder.CutOffPrice }; if (_orderDao.UpdateOrderPrice(order)) { foreach (DeletedOrderDetails item in deletedSingleOrder.deletedOrderDetailsList) { _orderDetailsDao.DeleteSingleOrderDetails(item); } //获取打印任务列表 Order tempOrder = _orderDao.GetOrder(deletedSingleOrder.OrderID); if (tempOrder != null) { SalesOrder salesOrder = new SalesOrder(); salesOrder.order = tempOrder; IList<OrderDetails> tempOrderDetailsList = new List<OrderDetails>(); string cancelReason = string.Empty; foreach (DeletedOrderDetails item in deletedSingleOrder.deletedOrderDetailsList) { OrderDetails orderDetails = _orderDetailsDao.GetOrderDetails(item.OrderDetailsID); orderDetails.ItemQty = item.DeletedQuantity; tempOrderDetailsList.Add(orderDetails); if (string.IsNullOrEmpty(cancelReason) && !string.IsNullOrEmpty(item.CancelReasonName)) { cancelReason = item.CancelReasonName; } } salesOrder.orderDetailsList = tempOrderDetailsList; //添加打印任务 SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo(); if (systemConfig.IncludeKitchenPrint) { IList<PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 2, cancelReason); foreach (PrintTask printTask in printTaskList) { _printTaskDao.InsertPrintTask(printTask); } } } returnValue = true; } _daoManager.CommitTransaction(); } catch(Exception exception) { _daoManager.RollBackTransaction(); returnValue = false; LogHelper.GetInstance().Error(string.Format("[DeleteSingleOrder]参数:deletedSingleOrder_{0}", JsonConvert.SerializeObject(deletedSingleOrder)), exception); } return returnValue; }
private void BindDataGridView2(SalesOrder salesOrder) { this.dataGridView2.Rows.Clear(); IList<OrderDetails> orderDetailsList = salesOrder.orderDetailsList; if (orderDetailsList != null && orderDetailsList.Count > 0) { foreach (OrderDetails orderDetails in orderDetailsList) { int index = dataGridView2.Rows.Add(); if (orderDetails.ItemType == (int)OrderItemType.Goods) { dataGridView2.Rows[index].Cells["GoodsName"].Value = orderDetails.GoodsName; } else { string strLevelFlag = string.Empty; int levelCount = orderDetails.ItemLevel * 2; for (int i = 0; i < levelCount; i++) { strLevelFlag += "-"; } dataGridView2.Rows[index].Cells["GoodsName"].Value = strLevelFlag + orderDetails.GoodsName; } dataGridView2.Rows[index].Cells["ItemQty"].Value = orderDetails.ItemQty; dataGridView2.Rows[index].Cells["SellPrice"].Value = orderDetails.TotalSellPrice.ToString("f2"); dataGridView2.Rows[index].Cells["Discount"].Value = orderDetails.TotalDiscount.ToString("f2"); } } }