Пример #1
0
        public bool SplitSalesOrder(SalesSplitOrder salesSplitOrder)
        {
            string json = JsonConvert.SerializeObject(salesSplitOrder);
            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_SPLIT_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;

            bool result = false;
            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32 operCode = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    result = true;
                }
                socket.Close();
            }
            return result;
        }
Пример #2
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();
         }
     }
 }
Пример #3
0
 public bool SplitSalesOrder(SalesSplitOrder salesSplitOrder)
 {
     bool returnValue = false;
     _daoManager.BeginTransaction();
     try
     {
         //更新账单表头价格
         if (_orderDao.UpdateSplitOrderPrice(salesSplitOrder.OriginalOrder))
         {
             //减去分单出去的主体以及折扣
             foreach (OrderDetails item in salesSplitOrder.SubOrderDetailsList)
             {
                 _orderDetailsDao.SubtractSalesSplitOrder(item);
             }
             //新增账单
             //日结号
             string serialNumber = _dailyStatementDao.GetCurrentDailyStatementNo();
             Order order = salesSplitOrder.NewOrder;
             order.DailyStatementNo = serialNumber;
             //分单号
             Int32 curSubOrderNo = _orderDao.GetCurrentSubOrderNo(order.DeskName);
             if (curSubOrderNo > 0)
             {
                 curSubOrderNo++;
             }
             else
             {
                 curSubOrderNo = 1;
             }
             order.SubOrderNo = curSubOrderNo;
             //流水号
             order.TranSequence = _sysDictionary.GetCurrentTranSequence();
             _orderDao.CreateOrder(order);
             //菜单品项序号
             int seqNumber = _orderDetailsDao.GetSequenceNum(order.OrderID);
             foreach (OrderDetails item in salesSplitOrder.NewOrderDetailsList)
             {
                 item.OrderBy = seqNumber;
                 _orderDetailsDao.CreateOrderDetails(item);
                 seqNumber++;
             }
             returnValue = true;
         }
         _daoManager.CommitTransaction();
     }
     catch(Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[SplitSalesOrder]参数:salesSplitOrder_{0}", JsonConvert.SerializeObject(salesSplitOrder)), exception);
         _daoManager.RollBackTransaction();
         returnValue = false;
     }
     return returnValue;
 }