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); } } } }
public static byte[] GetSalesOrder(byte[] itemBuffer) { byte[] objRet = null; string orderID = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, ParamFieldLength.ORDER_ID).Trim('\0'); SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(new Guid(orderID)); if (salesOrder == null || salesOrder.orderDetailsList == null || salesOrder.orderDetailsList.Count == 0) { //获取单子失败 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } else { //成功 string json = JsonConvert.SerializeObject(salesOrder); byte[] jsonByte = Encoding.UTF8.GetBytes(json); int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + jsonByte.Length; objRet = new byte[transCount]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); Array.Copy(jsonByte, 0, objRet, 2 * BasicTypeLength.INT32, jsonByte.Length); } return(objRet); }
public static byte[] CreateSalesOrder(byte[] itemBuffer) { byte[] objRet = null; string strReceive = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0'); SalesOrder salesOrder = JsonConvert.DeserializeObject <SalesOrder>(strReceive); //返回流水号 Int32 tranSequence = SalesOrderService.GetInstance().CreateSalesOrder(salesOrder); int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + BasicTypeLength.INT32; objRet = new byte[transCount]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(tranSequence), 0, objRet, 2 * BasicTypeLength.INT32, BasicTypeLength.INT32); return(objRet); }
public static byte[] SubmitOrderInAndroid(byte[] itemBuffer) { byte[] objRet = null; string strReceive = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0'); OrderInAndroid orderInAndroid = JsonConvert.DeserializeObject <OrderInAndroid>(strReceive); //返回操作结果 Employee employee = null; int result = EmployeeService.GetInstance().GetEmployee(orderInAndroid.EmployeeNo, orderInAndroid.Password, out employee); if (result == 1) { bool isSuccess = SalesOrderService.GetInstance().CreateOrderInAndroid(orderInAndroid.DeskName, orderInAndroid.PeopleNum, employee.EmployeeID, employee.EmployeeNo, orderInAndroid.OrderDetailList); if (isSuccess) { //成功 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } else { //创建Android订单失败 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } } else if (result == 2) { //账号或者密码错误 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_AUTHENTICATION), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } else { //数据库操作失败 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } return(objRet); }
public static byte[] SplitSalesOrder(byte[] itemBuffer) { byte[] objRet = null; string strReceive = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0'); SalesSplitOrder salesSplitOrder = JsonConvert.DeserializeObject <SalesSplitOrder>(strReceive); bool result = SalesOrderService.GetInstance().SplitSalesOrder(salesSplitOrder); if (result) { //成功 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } else { //分单操作失败 objRet = new byte[ParamFieldLength.PACKAGE_HEAD]; Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32); Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32); } return(objRet); }
private void btnDesk_Click(object sender, EventArgs e) { if (_operateType == ButtonOperateType.NONE) { return; } CrystalButton btnDesk = sender as CrystalButton; if (btnDesk == null) { return; } BizDesk tempDesk = btnDesk.Tag as BizDesk; if (tempDesk == null) { return; } _currentFormActivate = false; //重新获取Desk信息 BizDesk desk = DeskService.GetInstance().GetBizDeskByName(tempDesk.DeskName); if (_operateType == ButtonOperateType.ORDER) { if (desk.Status == (int)DeskButtonStatus.IDLE_MODE) { //人数 Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _formOrder.PersonNum = int.Parse(keyForm.KeypadValue); } else { return; } //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { desk.Status = status; btnDesk.BackColor = GetColorByStatus(status, ConstantValuePool.BizSettingConfig.DeviceNo); _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = null; _formOrder.VisibleShow = true; _formOrder.Show(); } } else if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { if (salesOrder.order.Status == 3) //已预结 { //open check out form FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } else { //open order form _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = salesOrder; _formOrder.VisibleShow = true; _formOrder.Show(); } } } } } } } else if (_operateType == ButtonOperateType.CLEAR) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED && !string.IsNullOrEmpty(desk.DeviceNo)) { //更新桌况为非占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, string.Empty, status)) { btnDesk.BackColor = GetColorByStatus(status, string.Empty); } } } else if (_operateType == ButtonOperateType.CHANGE_DESK) { if (string.IsNullOrEmpty(_deskName1St)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { if (orderList.Count > 1) { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { _deskName1St = desk.DeskName; _orderId1St = form.SelectedOrder.OrderID; _firstDeskSingleOrder = false; } else { _currentFormActivate = true; //使线程重新活跃 return; } } else { _deskName1St = desk.DeskName; _orderId1St = orderList[0].OrderID; _firstDeskSingleOrder = true; } } else { _currentFormActivate = true; //使线程重新活跃 return; //空桌 } } else { if (!string.IsNullOrEmpty(_deskName1St)) { if (desk.DeskName == _deskName1St) { _currentFormActivate = true; //使线程重新活跃 return; //点击相同的第一张桌子 } //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList, deskChange); form.ShowDialog(); if (form.SelectedOrder != null) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } else { _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } else { //直接转台 DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; if (OrderService.GetInstance().OrderDeskOperate(deskChange)) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } } } } else if (_operateType == ButtonOperateType.CHECKOUT) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } } } } } } _currentFormActivate = true; }
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 BindDataGridView1(IList <Order> orderList) { this.dataGridView1.SelectionChanged -= new System.EventHandler(this.dataGridView1_SelectionChanged); this.dataGridView1.Rows.Clear(); if (orderList != null && orderList.Count > 0) { foreach (Order order in orderList) { string billType = string.Empty; if (order.Status == 0) { billType = "未结账"; } else if (order.Status == 1) { billType = "已结账"; } else if (order.Status == 2) { billType = "已删除"; } else if (order.Status == 3) { billType = "已预结"; } else if (order.Status == 4) { billType = "已并桌"; } int index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells["TranSequence"].Value = order.TranSequence.ToString(); dataGridView1.Rows[index].Cells["BillType"].Value = billType; dataGridView1.Rows[index].Cells["TotalSellPrice"].Value = order.TotalSellPrice.ToString("f2"); dataGridView1.Rows[index].Cells["ActualSellPrice"].Value = order.ActualSellPrice.ToString("f2"); dataGridView1.Rows[index].Cells["DiscountPrice"].Value = order.DiscountPrice.ToString("f2"); dataGridView1.Rows[index].Cells["CutOffPrice"].Value = (-order.CutOffPrice).ToString("f2"); dataGridView1.Rows[index].Cells["ServiceFee"].Value = order.ServiceFee.ToString("f2"); dataGridView1.Rows[index].Cells["PaymentMoney"].Value = order.PaymentMoney.ToString("f2"); dataGridView1.Rows[index].Cells["NeedChangePay"].Value = order.NeedChangePay.ToString("f2"); dataGridView1.Rows[index].Cells["MoreOrLess"].Value = (order.ActualSellPrice + order.ServiceFee - (order.PaymentMoney - order.NeedChangePay)).ToString("f2"); dataGridView1.Rows[index].Cells["OrderID"].Value = order.OrderID; } //设置第一行选中 int selectedIndex = 0; if (dataGridView1.RowCount > 0) { dataGridView1.Rows[selectedIndex].Selected = true; } this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged); //默认加载第一行数据 Guid orderID = new Guid(dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value.ToString()); SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrderByBillSearch(orderID); _salesOrder = salesOrder; //更新账单信息 this.lbOrderNo.Text = salesOrder.order.OrderNo; this.lbDeskName.Text = salesOrder.order.DeskName; this.lbBillType.Text = dataGridView1.Rows[selectedIndex].Cells["BillType"].Value.ToString(); string eatType = string.Empty; if (salesOrder.order.EatType == (int)EatWayType.DineIn) { eatType = "堂食"; } else if (salesOrder.order.EatType == (int)EatWayType.Takeout) { eatType = "外卖"; } else if (salesOrder.order.EatType == (int)EatWayType.OutsideOrder) { eatType = "外送"; } this.lbEatType.Text = eatType; this.lbEmployeeNo.Text = salesOrder.order.EmployeeNo; this.lbCashier.Text = salesOrder.order.PayEmployeeNo; this.lbDeviceNo.Text = salesOrder.order.DeviceNo; BindDataGridView2(salesOrder); BindDataGridView3(salesOrder); } }
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(); } } }