Esempio n. 1
0
 public string CreateOrder(Order order)
 {
     object result = ExecuteInsert("InsertOrder", order);
     if (result != null)
     {
         return result.ToString();
     }
     return string.Empty;
 }
Esempio n. 2
0
 public void CreateOrder(Order order)
 {
     try
     {
         _daoManager.OpenConnection();
         _orderDao.CreateOrder(order);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[CreateOrder]参数:order_{0}", JsonConvert.SerializeObject(order)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public bool UpdateSplitOrderPrice(Order order)
 {
     int result = ExecuteUpdate("UpdateSplitOrderPrice", order);
     return result > 0;
 }
Esempio n. 5
0
 public bool UpdatePrePayOrder(Order order)
 {
     int result = ExecuteUpdate("UpdatePrePayOrder", order);
     return result > 0;
 }
Esempio n. 6
0
 public bool UpdateOrderDeskName(Order order)
 {
     int result = ExecuteUpdate("UpdateOrderDeskName", order);
     return result > 0;
 }
Esempio n. 7
0
 private void btnPreCheck_Click(object sender, EventArgs e)
 {
     CrystalButton btn = sender as CrystalButton;
     Order order = m_SalesOrder.order;
     if (order.Status == 0)
     {
         //存在整单折扣则先提交
         //填充Order
         Order submitOrder = new Order();
         submitOrder.OrderID = order.OrderID;
         submitOrder.TotalSellPrice = m_TotalPrice;
         submitOrder.ActualSellPrice = m_ActualPayMoney;
         submitOrder.DiscountPrice = m_Discount;
         submitOrder.CutOffPrice = m_CutOff;
         submitOrder.ServiceFee = m_ServiceFee;
         submitOrder.MembershipCard = m_MembershipCard;
         submitOrder.MemberDiscount = m_MemberDiscountRate;
         //填充OrderDetails\OrderDiscount
         List<OrderDetails> orderDetailsList = new List<OrderDetails>();
         List<OrderDiscount> newOrderDiscountList = new List<OrderDiscount>();
         foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
         {
             OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
             if (orderDetails != null)
             {
                 Discount itemDiscount = dr.Cells["GoodsDiscount"].Tag as Discount;
                 decimal itemDiscountPrice = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
                 if (orderDetails.CanDiscount && itemDiscount != null && Math.Abs(itemDiscountPrice) > 0)
                 {
                     orderDetailsList.Add(orderDetails);
                     //OrderDiscount
                     OrderDiscount orderDiscount = new OrderDiscount();
                     orderDiscount.OrderDiscountID = Guid.NewGuid();
                     orderDiscount.OrderID = order.OrderID;
                     orderDiscount.OrderDetailsID = orderDetails.OrderDetailsID;
                     orderDiscount.DiscountID = itemDiscount.DiscountID;
                     orderDiscount.DiscountName = itemDiscount.DiscountName;
                     orderDiscount.DiscountType = itemDiscount.DiscountType;
                     orderDiscount.DiscountRate = itemDiscount.DiscountRate;
                     orderDiscount.OffFixPay = itemDiscount.OffFixPay;
                     orderDiscount.OffPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value));
                     orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
                     newOrderDiscountList.Add(orderDiscount);
                 }
             }
         }
         if (orderDetailsList.Count > 0 && newOrderDiscountList.Count > 0)
         {
             PayingOrder payingOrder = new PayingOrder();
             payingOrder.order = submitOrder;
             payingOrder.orderDetailsList = orderDetailsList;
             payingOrder.orderDiscountList = newOrderDiscountList;
             bool result = PayingOrderService.GetInstance().CreatePrePayOrder(payingOrder);
             if (result)
             {
                 btn.Text = "解锁";
                 order.Status = 3;   //预结
                 m_IsPreCheckOut = true;
             }
             else
             {
                 MessageBox.Show("预结账单失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         else
         {
             int status = 3;   //预结
             if (OrderService.GetInstance().UpdateOrderStatus(order.OrderID, status))
             {
                 btn.Text = "解锁";
                 order.Status = status;
                 m_IsPreCheckOut = true;
             }
             else
             {
                 MessageBox.Show("预结账单失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         //打印预结小票
         PrintData printData = new PrintData();
         printData.ShopName = ConstantValuePool.CurrentShop.ShopName;
         printData.DeskName = m_CurrentDeskName;
         printData.PersonNum = m_SalesOrder.order.PeopleNum.ToString();
         printData.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
         printData.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
         printData.TranSequence = m_SalesOrder.order.TranSequence.ToString();
         printData.ShopAddress = ConstantValuePool.CurrentShop.RunAddress;
         printData.Telephone = ConstantValuePool.CurrentShop.Telephone;
         printData.ReceivableMoney = this.lbReceMoney.Text;
         printData.ServiceFee = m_ServiceFee.ToString("f2");
         printData.TotalAmount = (m_ActualPayMoney + m_ServiceFee).ToString("f2");
         printData.GoodsOrderList = new List<GoodsOrder>();
         foreach (OrderDetails item in m_SalesOrder.orderDetailsList)
         {
             string strLevelFlag = string.Empty;
             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.SellPrice.ToString("f2");
             goodsOrder.TotalSellPrice = item.TotalSellPrice.ToString("f2");
             goodsOrder.TotalDiscount = item.TotalDiscount.ToString("f2");
             goodsOrder.Unit = item.Unit;
             printData.GoodsOrderList.Add(goodsOrder);
         }
         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);
             printer.DoPrintPrePayOrder(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);
                     printer.DoPrintPrePayOrder(printData);
                 }
             }
         }
         if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.ETHERNET)
         {
             string ipAddress = ConstantValuePool.BizSettingConfig.printConfig.Name;
             InstructionOrderPrint printer = new InstructionOrderPrint(ipAddress, 9100, paperWidth);
             printer.DoPrintPrePayOrder(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);
             printer.DoPrintPrePayOrder(printData);
         }
     }
     else if (order.Status == 3)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.PRECHECKOUT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.PRECHECKOUT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         int status = 0;
         if (OrderService.GetInstance().UpdateOrderStatus(order.OrderID, status))
         {
             btn.Text = "预结";
             order.Status = status;
             m_IsPreCheckOut = false;
         }
         else
         {
             MessageBox.Show("预结状态解锁失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
 }
Esempio n. 8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder2.Rows.Count > 0)
     {
         string personNum = this.btnPeopleNum.Text;
         if (personNum.IndexOf(':') > 0)
         {
             personNum = personNum.Substring(personNum.IndexOf(':') + 1);
         }
         //原先单子的价格
         decimal totalPrice, actualPayMoney, discountPrice, cutOff;
         if (dgvGoodsOrderSum.Rows.Count == 2)
         {
             totalPrice = Convert.ToDecimal(dgvGoodsOrderSum.Rows[0].Cells[1].Value);
             actualPayMoney = Convert.ToDecimal(dgvGoodsOrderSum.Rows[1].Cells[1].Value);
             discountPrice = 0;
             cutOff = totalPrice - actualPayMoney - discountPrice;
         }
         else
         {
             totalPrice = Convert.ToDecimal(dgvGoodsOrderSum.Rows[0].Cells[1].Value);
             discountPrice = Convert.ToDecimal(dgvGoodsOrderSum.Rows[1].Cells[1].Value);
             actualPayMoney = Convert.ToDecimal(dgvGoodsOrderSum.Rows[2].Cells[1].Value);
             cutOff = totalPrice - actualPayMoney - Math.Abs(discountPrice);
         }
         Order originalOrder = new Order();
         originalOrder.OrderID = m_SalesOrder.order.OrderID;
         originalOrder.TotalSellPrice = totalPrice;
         originalOrder.ActualSellPrice = actualPayMoney;
         originalOrder.DiscountPrice = discountPrice;
         originalOrder.CutOffPrice = cutOff;
         int remainPeopleNum = m_SalesOrder.order.PeopleNum - int.Parse(personNum);
         if (remainPeopleNum <= 0) remainPeopleNum = 1;
         originalOrder.PeopleNum = remainPeopleNum;
         List<OrderDetails> subOrderDetailsList = new List<OrderDetails>();
         foreach (DataGridViewRow dr in dgvGoodsOrder2.Rows)
         {
             string orderDetailsID = dr.Cells[4].Value.ToString();
             //填充OrderDetails
             OrderDetails orderDetails = new OrderDetails();
             orderDetails.OrderDetailsID = new Guid(orderDetailsID);
             orderDetails.TotalSellPrice = Convert.ToDecimal(dr.Cells[2].Value);
             orderDetails.TotalDiscount = GetDiscountFromDic(orderDetailsID);
             orderDetails.ItemQty = Convert.ToDecimal(dr.Cells[0].Value);
             subOrderDetailsList.Add(orderDetails);
         }
         //新单子
         decimal newTotalPrice, newActualPayMoney, newDiscountPrice, newCutOff;
         if (dgvGoodsOrderSum2.Rows.Count == 2)
         {
             newTotalPrice = Convert.ToDecimal(dgvGoodsOrderSum2.Rows[0].Cells[1].Value);
             newActualPayMoney = Convert.ToDecimal(dgvGoodsOrderSum2.Rows[1].Cells[1].Value);
             newDiscountPrice = 0;
             newCutOff = newTotalPrice - newActualPayMoney - newDiscountPrice;
         }
         else
         {
             newTotalPrice = Convert.ToDecimal(dgvGoodsOrderSum2.Rows[0].Cells[1].Value);
             newDiscountPrice = Convert.ToDecimal(dgvGoodsOrderSum2.Rows[1].Cells[1].Value);
             newActualPayMoney = Convert.ToDecimal(dgvGoodsOrderSum2.Rows[2].Cells[1].Value);
             newCutOff = newTotalPrice - newActualPayMoney - Math.Abs(newDiscountPrice);
         }
         Order newOrder = new Order();
         newOrder.OrderID = Guid.NewGuid();
         newOrder.TotalSellPrice = newTotalPrice;
         newOrder.ActualSellPrice = newActualPayMoney;
         newOrder.DiscountPrice = newDiscountPrice;
         newOrder.CutOffPrice = newCutOff;
         newOrder.ServiceFee = 0;
         newOrder.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo;
         newOrder.DeskName = m_SalesOrder.order.DeskName;
         newOrder.EatType = m_SalesOrder.order.EatType;
         newOrder.Status = 0;
         newOrder.PeopleNum = int.Parse(personNum);
         newOrder.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
         newOrder.EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
         List<OrderDetails> newOrderDetailsList = new List<OrderDetails>();
         foreach (DataGridViewRow dr in dgvGoodsOrder2.Rows)
         {
             string goodsName = dr.Cells[1].Value.ToString();
             string orderDetailsID = dr.Cells[4].Value.ToString();
             int itemType = Convert.ToInt32(dr.Cells[5].Value);
             //填充OrderDetails
             OrderDetails orderDetails = new OrderDetails();
             orderDetails.OrderDetailsID = Guid.NewGuid();
             orderDetails.OrderID = newOrder.OrderID;
             orderDetails.DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo;
             orderDetails.TotalSellPrice = Convert.ToDecimal(dr.Cells[2].Value);
             orderDetails.TotalDiscount = 0;
             orderDetails.ItemQty = Convert.ToDecimal(dr.Cells[0].Value);
             orderDetails.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
             foreach (OrderDetails item in m_SalesOrder.orderDetailsList)
             {
                 if (item.OrderDetailsID.ToString() == orderDetailsID)
                 {
                     orderDetails.Wait = item.Wait;
                     orderDetails.ItemType = item.ItemType;
                     orderDetails.GoodsID = item.GoodsID;
                     orderDetails.GoodsNo = item.GoodsNo;
                     orderDetails.GoodsName = item.GoodsName;
                     orderDetails.CanDiscount = item.CanDiscount;
                     orderDetails.Unit = item.Unit;
                     orderDetails.SellPrice = item.SellPrice;
                     orderDetails.PrintSolutionName = item.PrintSolutionName;
                     orderDetails.DepartID = item.DepartID;
                     orderDetails.ItemLevel = item.ItemLevel;
                     break;
                 }
             }
             newOrderDetailsList.Add(orderDetails);
         }
         SalesSplitOrder salesSplitOrder = new SalesSplitOrder();
         salesSplitOrder.OriginalOrder = originalOrder;
         salesSplitOrder.SubOrderDetailsList = subOrderDetailsList;
         salesSplitOrder.NewOrder = newOrder;
         salesSplitOrder.NewOrderDetailsList = newOrderDetailsList;
         if (SalesOrderService.GetInstance().SplitSalesOrder(salesSplitOrder))
         {
             m_SplitOrderSuccess = true;
             this.Close();
         }
     }
 }
 private void btnMerge_Click(object sender, EventArgs e)
 {
     if (m_OrderList.Count == 1)
     {
         m_Order = m_OrderList[0];
     }
     if (m_Order != null)
     {
         m_DeskChange.OrderID2nd = m_Order.OrderID;
         if (OrderService.GetInstance().OrderDeskOperate(m_DeskChange))
         {
             this.Close();
         }
     }
 }
Esempio n. 10
0
 private void btnMoveBill_Click(object sender, EventArgs e)
 {
     if (OrderService.GetInstance().OrderDeskOperate(m_DeskChange))
     {
         //通过m_Order是否为null判断转台是否成功
         m_Order = new Order();
         this.Close();
     }
 }
Esempio n. 11
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     m_Order = null;
     this.Close();
 }
Esempio n. 12
0
 private void btnOrder_Click(object sender, EventArgs e)
 {
     CrystalButton btnOrder = sender as CrystalButton;
     m_Order = btnOrder.Tag as Order;
     if (m_PreviousBtn == null)
     {
         btnOrder.BackColor = ConstantValuePool.PressedColor;
         m_PreviousBtn = btnOrder;
     }
     else
     {
         m_PreviousBtn.BackColor = m_PreviousBtn.DisplayColor;
         btnOrder.BackColor = ConstantValuePool.PressedColor;
         m_PreviousBtn = btnOrder;
     }
 }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
        private bool ModifyForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay)
        {
            //填充Order
            Order order = new Order();
            order.OrderID = m_SalesOrder.order.OrderID;
            order.TotalSellPrice = m_TotalPrice;
            order.ActualSellPrice = m_ActualPayMoney;
            order.DiscountPrice = m_Discount;
            order.CutOffPrice = m_CutOff;
            order.ServiceFee = m_ServiceFee;
            order.PaymentMoney = paymentMoney;
            order.NeedChangePay = needChangePay;
            order.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
            //填充OrderDetails\OrderDiscount
            List<OrderDetails> orderDetailsList = new List<OrderDetails>();
            List<OrderDiscount> orderDiscountList = new List<OrderDiscount>();
            for (int i = 0; i < dgvGoodsOrder.RowCount; i++)
            {
                Discount itemDiscount = dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Tag as Discount;
                if (itemDiscount != null)
                {
                    decimal itemDiscountPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);

                    OrderDetails orderDetails = CopyExtension.Clone<OrderDetails>(m_SalesOrder.orderDetailsList[i]);
                    orderDetails.TotalDiscount = itemDiscountPrice;
                    orderDetailsList.Add(orderDetails);
                    //OrderDiscount
                    OrderDiscount orderDiscount = new OrderDiscount();
                    orderDiscount.OrderDiscountID = Guid.NewGuid();
                    orderDiscount.OrderID = m_SalesOrder.order.OrderID;
                    orderDiscount.OrderDetailsID = orderDetails.OrderDetailsID;
                    orderDiscount.DiscountID = itemDiscount.DiscountID;
                    orderDiscount.DiscountName = itemDiscount.DiscountName;
                    orderDiscount.DiscountType = itemDiscount.DiscountType;
                    orderDiscount.DiscountRate = itemDiscount.DiscountRate;
                    orderDiscount.OffFixPay = itemDiscount.OffFixPay;
                    orderDiscount.OffPay = Math.Abs(itemDiscountPrice);
                    orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
                    orderDiscountList.Add(orderDiscount);
                }
            }
            ModifiedPaidOrder modifiedPaidOrder = new ModifiedPaidOrder();
            modifiedPaidOrder.order = order;
            modifiedPaidOrder.orderDetailsList = orderDetailsList;
            modifiedPaidOrder.orderDiscountList = orderDiscountList;
            modifiedPaidOrder.orderPayoffList = orderPayoffList;
            return ModifyOrderService.GetInstance().ModifyForOrder(modifiedPaidOrder);
        }
Esempio n. 16
0
 public bool UpdateOrder(Order order)
 {
     bool result = false;
     try
     {
         _daoManager.OpenConnection();
         result = _orderDao.UpdateOrder(order);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[UpdateOrder]参数:order_{0}", JsonConvert.SerializeObject(order)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }
Esempio n. 17
0
 private void btnCheckOut_Click(object sender, EventArgs e)
 {
     decimal refundAmount = decimal.Parse(txtRefundAmount.Text);
     decimal realReturnAmount = 0;
     if (!string.IsNullOrEmpty(txtRealReturnAmount.Text))
     {
         realReturnAmount = decimal.Parse(txtRealReturnAmount.Text);
     }
     if (refundAmount == realReturnAmount)
     {
         //判断支付方式是否正确
         bool IsPayoffWayRight = true;
         IList<OrderPayoff> _orderPayoffList = new List<OrderPayoff>();
         foreach (KeyValuePair<string, OrderPayoff> item in dic)
         {
             if (item.Value.Quantity > 0)
             {
                 _orderPayoffList.Add(item.Value);
             }
         }
         foreach (OrderPayoff orderPayoff in _orderPayoffList)
         {
             bool IsContains = false;
             OrderPayoff temp = null;
             foreach (OrderPayoff item in m_SalesOrder.orderPayoffList)
             {
                 if (item.PayoffID.Equals(orderPayoff.PayoffID))
                 {
                     IsContains = true;
                     temp = item;
                     break;
                 }
             }
             if (IsContains)
             {
                 decimal tempAmount = temp.AsPay * temp.Quantity - temp.NeedChangePay;
                 decimal payAmount = orderPayoff.AsPay * orderPayoff.Quantity - orderPayoff.NeedChangePay;
                 if (tempAmount < payAmount)
                 {
                     IsPayoffWayRight = false;
                     break;
                 }
             }
             else
             {
                 IsPayoffWayRight = false;
                 break;
             }
         }
         if (IsPayoffWayRight)
         {
             IList<OrderPayoff> orderPayoffList = new List<OrderPayoff>();
             foreach (OrderPayoff item in m_SalesOrder.orderPayoffList)
             {
                 bool IsContains = false;
                 foreach (OrderPayoff orderPayoff in _orderPayoffList)
                 {
                     if (item.PayoffID.Equals(orderPayoff.PayoffID))
                     {
                         decimal remainQty = ((item.AsPay * item.Quantity - item.NeedChangePay) - (orderPayoff.AsPay * orderPayoff.Quantity - orderPayoff.NeedChangePay)) / orderPayoff.AsPay;
                         if (remainQty > 0)
                         {
                             OrderPayoff temp = new OrderPayoff();
                             temp.OrderPayoffID = Guid.NewGuid();
                             temp.OrderID = m_SalesOrder.order.OrderID;
                             temp.PayoffID = item.PayoffID;
                             temp.PayoffName = item.PayoffName;
                             temp.PayoffType = item.PayoffType;
                             temp.AsPay = item.AsPay;
                             temp.Quantity = remainQty;
                             temp.NeedChangePay = 0;
                             temp.CardNo = item.CardNo;
                             temp.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
                             orderPayoffList.Add(temp);
                         }
                         IsContains = true;
                         break;
                     }
                 }
                 if (!IsContains)
                 {
                     OrderPayoff temp = CopyExtension.Clone<OrderPayoff>(item);
                     temp.OrderID = m_SalesOrder.order.OrderID;
                     temp.OrderPayoffID = Guid.NewGuid();
                     temp.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
                     orderPayoffList.Add(temp);
                 }
             }
             List<DeletedOrderDetails> deletedOrderDetailsList = new List<DeletedOrderDetails>();
             for (int i = 0; i < dgvGoodsOrder.RowCount; i++)
             {
                 OrderDetails tempOrderDetails = dgvGoodsOrder.Rows[i].Cells["OrderDetailsID"].Tag as OrderDetails;
                 decimal tempGoodsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsNum"].Value);
                 decimal tempGoodsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);
                 decimal tempDeletedNum = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["DelFlag"].Value);
                 if (Math.Abs(tempDeletedNum) > 0)
                 {
                     decimal remainQty = tempGoodsNum - Math.Abs(tempDeletedNum);
                     DeletedOrderDetails orderDetails = new DeletedOrderDetails();
                     orderDetails.OrderDetailsID = tempOrderDetails.OrderDetailsID;
                     orderDetails.DeletedQuantity = tempDeletedNum;
                     orderDetails.RemainQuantity = remainQty;
                     orderDetails.OffPay = Math.Round(-tempGoodsDiscount / tempGoodsNum * remainQty, 4);
                     orderDetails.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                     orderDetails.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                     orderDetails.CancelReasonName = dgvGoodsOrder.Rows[i].Cells["DelReasonName"].Value.ToString(); ;
                     deletedOrderDetailsList.Add(orderDetails);
                 }
             }
             //构造DeletedPaidOrder对象
             decimal paymentMoney = 0;
             foreach (OrderPayoff item in orderPayoffList)
             {
                 paymentMoney += item.AsPay * item.Quantity;
             }
             Order order = new Order();
             order.OrderID = m_SalesOrder.order.OrderID;
             order.TotalSellPrice = m_TotalPrice;
             order.ActualSellPrice = m_ActualPayMoney;
             order.DiscountPrice = m_Discount;
             order.CutOffPrice = m_CutOff;
             order.ServiceFee = m_ServiceFee;
             order.PaymentMoney = paymentMoney;
             order.NeedChangePay = 0;
             order.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
             DeletedPaidOrder deletedPaidOrder = new DeletedPaidOrder();
             deletedPaidOrder.order = order;
             deletedPaidOrder.deletedOrderDetailsList = deletedOrderDetailsList;
             deletedPaidOrder.orderPayoffList = orderPayoffList;
             if (DeletedOrderService.GetInstance().DeletePaidSingleOrder(deletedPaidOrder))
             {
                 m_IsChanged = true;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("单品删除失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         else
         {
             MessageBox.Show("退款支付方式不属于原结账支付方式,请重新支付!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else
     {
         MessageBox.Show("应退金额与实退金额不一致,请重新支付!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Esempio n. 18
0
        /// <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;
        }
Esempio n. 19
0
 private bool PayForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay, string tradePayNo)
 {
     //填充Order
     Order order = new Order();
     order.OrderID = m_SalesOrder.order.OrderID;
     order.TotalSellPrice = m_TotalPrice;
     order.ActualSellPrice = m_ActualPayMoney;
     order.DiscountPrice = m_Discount;
     order.CutOffPrice = m_CutOff;
     order.ServiceFee = 0;
     order.PaymentMoney = paymentMoney;
     order.NeedChangePay = needChangePay;
     order.MembershipCard = string.Empty;
     order.MemberDiscount = 0;
     order.PayEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
     order.PayEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
     order.CheckoutDeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo;
     order.TradePayNo = tradePayNo;
     PayingOrder payingOrder = new PayingOrder();
     payingOrder.order = order;
     payingOrder.orderPayoffList = orderPayoffList;
     return PayingOrderService.GetInstance().PayForOrder(payingOrder);
 }
Esempio n. 20
0
 private bool PayForOrder(List<OrderPayoff> orderPayoffList, decimal paymentMoney, decimal needChangePay, string tradePayNo)
 {
     //填充Order
     Order order = new Order();
     order.OrderID = m_SalesOrder.order.OrderID;
     order.TotalSellPrice = m_TotalPrice;
     order.ActualSellPrice = m_ActualPayMoney;
     order.DiscountPrice = m_Discount;
     order.CutOffPrice = m_CutOff;
     order.ServiceFee = m_ServiceFee;
     order.PaymentMoney = paymentMoney;
     order.NeedChangePay = needChangePay;
     order.MembershipCard = m_MembershipCard;
     order.MemberDiscount = m_MemberDiscountRate;
     order.PayEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
     order.PayEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
     order.CheckoutDeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo;
     order.TradePayNo = tradePayNo;
     //填充OrderDetails\OrderDiscount
     List<OrderDetails> orderDetailsList = new List<OrderDetails>();
     List<OrderDiscount> newOrderDiscountList = new List<OrderDiscount>();
     foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
     {
         OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
         if (orderDetails != null)
         {
             Discount itemDiscount = dr.Cells["GoodsDiscount"].Tag as Discount;
             decimal itemDiscountPrice = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
             if (orderDetails.CanDiscount && itemDiscount != null && Math.Abs(itemDiscountPrice) > 0)
             {
                 orderDetailsList.Add(orderDetails);
                 //OrderDiscount
                 OrderDiscount orderDiscount = new OrderDiscount();
                 orderDiscount.OrderDiscountID = Guid.NewGuid();
                 orderDiscount.OrderID = m_SalesOrder.order.OrderID;
                 orderDiscount.OrderDetailsID = orderDetails.OrderDetailsID;
                 orderDiscount.DiscountID = itemDiscount.DiscountID;
                 orderDiscount.DiscountName = itemDiscount.DiscountName;
                 orderDiscount.DiscountType = itemDiscount.DiscountType;
                 orderDiscount.DiscountRate = itemDiscount.DiscountRate;
                 orderDiscount.OffFixPay = itemDiscount.OffFixPay;
                 orderDiscount.OffPay = Math.Abs(Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value));
                 orderDiscount.EmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID;
                 newOrderDiscountList.Add(orderDiscount);
             }
         }
     }
     PayingOrder payingOrder = new PayingOrder();
     payingOrder.order = order;
     payingOrder.orderDetailsList = orderDetailsList;
     payingOrder.orderDiscountList = newOrderDiscountList;
     payingOrder.orderPayoffList = orderPayoffList;
     return PayingOrderService.GetInstance().PayForOrder(payingOrder);
 }