public decimal GetLastCustomPrice(string dailyStatementNo, Guid goodsId)
 {
     decimal result = 0M;
     OrderDetails orderDetails = new OrderDetails();
     orderDetails.DailyStatementNo = dailyStatementNo;
     orderDetails.GoodsID = goodsId;
     object objValue = ExecuteQueryForObject("GetLastCustomPrice", orderDetails);
     if (objValue != null)
     {
         result = (decimal)objValue;
     }
     return result;
 }
예제 #2
0
 public void CreateOrderDetails(OrderDetails orderDetails)
 {
     try
     {
         _daoManager.OpenConnection();
         _orderDetailsDao.CreateOrderDetails(orderDetails);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[CreateOrderDetails]参数:orderDetails_{0}", JsonConvert.SerializeObject(orderDetails)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
 }
예제 #3
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();
         }
     }
 }
예제 #4
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;
        }
 public bool LadeOrderDetails(OrderDetails orderDetails)
 {
     int result = ExecuteUpdate("UpdateLadeOrderDetails", orderDetails);
     return result > 0;
 }
 public void CreateOrderDetails(OrderDetails orderDetails)
 {
     ExecuteInsert("InsertOrderDetails", orderDetails);
 }
 public bool UpdateOrderDetailsDiscount(OrderDetails orderDetails)
 {
     int result = ExecuteUpdate("UpdateOrderDetailsDiscount", orderDetails);
     return result > 0;
 }
 public bool SubtractSalesSplitOrder(OrderDetails orderDetails)
 {
     int result = ExecuteUpdate("SubtractSalesSplitOrder", orderDetails);
     return result > 0;
 }
 private bool ItemInPromotion(OrderDetails orderDetails, PromotionCondition promotionCondition)
 {
     bool result = false;
     if (promotionCondition.GroupOrItem)
     {
         //组
         if (promotionCondition.GoodsGroupID != null)
         {
             result = GoodsUtil.IsGoodsInGroup(orderDetails.GoodsID, (Guid) promotionCondition.GoodsGroupID);
         }
     }
     else
     { 
         //品项
         if (orderDetails.GoodsID == promotionCondition.GoodsID)
         {
             result = true;
         }
     }
     return result;
 }
예제 #10
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;
 }
예제 #11
0
        private void btnPromotion_Click(object sender, EventArgs e)
        {
            if (dgvGoodsOrder.Rows.Count <= 0)
            {
                MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (ConstantValuePool.PromotionList == null || ConstantValuePool.PromotionList.Count <= 0)
            {
                MessageBox.Show("未找到有效的促销条件,请检查是否在后台添加。", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IList<Promotion> promotionList;
            if (ConstantValuePool.PromotionCronTriggerList != null && ConstantValuePool.PromotionCronTriggerList.Count > 0)
            {
                promotionList = new List<Promotion>();
                foreach (Promotion promotion in ConstantValuePool.PromotionList)
                {
                    foreach (PromotionCronTrigger cronTrigger in ConstantValuePool.PromotionCronTriggerList)
                    {
                        if (promotion.ActivityNo == cronTrigger.ActivityNo)
                        {
                            PromotionCronTriggerService cronTriggerService = new PromotionCronTriggerService(cronTrigger);
                            if (cronTriggerService.IsPromotionInTime())
                            {
                                promotionList.Add(promotion);
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                promotionList = ConstantValuePool.PromotionList;
            }
            if (promotionList == null || promotionList.Count <= 0)
            {
                MessageBox.Show("未找到符合条件的促销规则", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IList<OrderDetails> orderDetailsList = new List<OrderDetails>();
            //组装OrderDetails
            foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
            {
                //填充OrderDetails
                OrderDetails orderDetails = new OrderDetails();
                orderDetails.GoodsID = new Guid(dr.Cells["ItemID"].Value.ToString());
                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.SellPrice = orderDetails.TotalSellPrice/orderDetails.ItemQty;
                orderDetailsList.Add(orderDetails);
            }
            foreach (Promotion promotion in promotionList)
            {
                IList<PromotionCondition> promotionConditionList = null;
                if (ConstantValuePool.PromotionConditionList != null && ConstantValuePool.PromotionConditionList.Count > 0)
                {
                    promotionConditionList = ConstantValuePool.PromotionConditionList.Where(promotionCondition => promotion.ActivityNo == promotionCondition.ActivityNo).ToList();
                }
                PromotionConditionService conditionService = new PromotionConditionService(promotionConditionList);
                bool result = conditionService.IsItemEligible(orderDetailsList, promotion.IsIncluded, promotion.AndOr);
                if (result)
                {
                    //totalQuantity
                    decimal totalQuantity = 0M;
                    foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
                    {
                        int itemType = Convert.ToInt32(dr.Cells["ItemType"].Value);
                        if (itemType == (int) OrderItemType.Goods)
                        {
                            totalQuantity += Convert.ToDecimal(dr.Cells["GoodsNum"].Value);
                        }
                    }
                    //PromotionPresent
                    IList<PromotionPresent> promotionPresentList = new List<PromotionPresent>();
                    foreach (PromotionPresent promotionPresent in ConstantValuePool.PromotionPresentList)
                    {
                        if (promotion.ActivityNo == promotionPresent.ActivityNo)
                        {
                            if (promotionPresent.TotalMoney <= _actualPayMoney && promotionPresent.TotalQuantity <= totalQuantity)
                            {
                                promotionPresentList.Add(promotionPresent);
                            }
                        }
                    }
                    if (promotionPresentList.Count > 0)
                    {
                        PromotionPresentService presentService;
                        if (promotion.PresentType == 1)
                        {
                            presentService = new PromotionPresentCommonService(_actualPayMoney, totalQuantity, promotionPresentList);
                            presentService.GetPromotionPresents(dgvGoodsOrder);
                        }
                        if (promotion.PresentType == 2)
                        {
                            presentService = new PromotionPresentMultipleService(_actualPayMoney, totalQuantity, promotionPresentList);
                            presentService.GetPromotionPresents(dgvGoodsOrder);
                        }
                        if (promotion.PresentType == 3 || promotion.PresentType == 4)
                        {

                        }
                        if (!promotion.WithOtherPromotion) break;
                    }
                }
            }
        }
예제 #12
0
 private void btnLadeOrder_Click(object sender, EventArgs e)
 {
     bool canLadeOrder = true;
     foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
     {
         if (dr.Cells["OrderDetailsID"].Value == null)
         {
             canLadeOrder = false;
             break;
         }
     }
     if (canLadeOrder)
     {
         List<OrderDetails> orderDetailsList = new List<OrderDetails>();
         foreach (DataGridViewRow dgr in dgvGoodsOrder.Rows)
         {
             if (dgr.Cells["Wait"].Value != null && Convert.ToInt32(dgr.Cells["Wait"].Value) == 1)
             {
                 OrderDetails orderDetails = new OrderDetails();
                 orderDetails.OrderDetailsID = new Guid(dgr.Cells["OrderDetailsID"].Value.ToString());
                 orderDetails.Wait = 0;
                 orderDetailsList.Add(orderDetails);
             }
         }
         if (orderDetailsList.Count > 0)
         {
             if (OrderDetailsService.GetInstance().LadeOrderDetails(orderDetailsList))
             {
                 //更新GridView
                 foreach (DataGridViewRow dgr in dgvGoodsOrder.Rows)
                 {
                     if (dgr.Cells["Wait"].Value != null && Convert.ToInt32(dgr.Cells["Wait"].Value) == 1)
                     {
                         string goodsName = dgr.Cells["GoodsName"].Value.ToString();
                         dgr.Cells["GoodsName"].Value = goodsName.Replace("*", "");
                         dgr.Cells["Wait"].Value = 0;
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("没有需要提单的品项!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("有新单,不能整单提单!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.exTabControl1.SelectedIndex = 0;
 }
예제 #13
0
 private void btnLadeGoods_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.CurrentRow != null)
     {
         int seletedIndex = dgvGoodsOrder.CurrentRow.Index;
         DataGridViewRow dgr = dgvGoodsOrder.Rows[seletedIndex];
         if (dgr.Cells["OrderDetailsID"].Value != null)
         {
             int itemType = Convert.ToInt32(dgr.Cells["ItemType"].Value);
             if ((dgr.Cells["Wait"].Value != null && Convert.ToInt32(dgr.Cells["Wait"].Value) == 1) && itemType == (int)OrderItemType.Goods)
             {
                 List<OrderDetails> orderDetailsList = new List<OrderDetails>();
                 OrderDetails orderDetails = new OrderDetails();
                 orderDetails.OrderDetailsID = new Guid(dgr.Cells["OrderDetailsID"].Value.ToString());
                 orderDetails.Wait = 0;
                 orderDetailsList.Add(orderDetails);
                 //细项
                 for (int index = seletedIndex + 1; index < dgvGoodsOrder.Rows.Count; index++)
                 {
                     itemType = Convert.ToInt32(dgvGoodsOrder.Rows[index].Cells["ItemType"].Value);
                     if (itemType == (int)OrderItemType.Goods)
                     {
                         break;
                     }
                     orderDetails = new OrderDetails();
                     orderDetails.OrderDetailsID = new Guid(dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Value.ToString());
                     orderDetails.Wait = 0;
                     orderDetailsList.Add(orderDetails);
                 }
                 if (OrderDetailsService.GetInstance().LadeOrderDetails(orderDetailsList))
                 {
                     //更新GridView
                     for (int i = 0; i < orderDetailsList.Count; i++)
                     {
                         string goodsName = dgvGoodsOrder.Rows[seletedIndex + i].Cells["GoodsName"].Value.ToString();
                         dgvGoodsOrder.Rows[seletedIndex + i].Cells["GoodsName"].Value = goodsName.Replace("*", "");
                         dgvGoodsOrder.Rows[seletedIndex + i].Cells["Wait"].Value = orderDetailsList[i].Wait;
                     }
                 }
             }
         }
     }
     this.exTabControl1.SelectedIndex = 0;
 }
예제 #14
0
 public bool UpdateOrderDetailsDiscount(OrderDetails orderDetails)
 {
     bool result = false;
     try
     {
         _daoManager.OpenConnection();
         result = _orderDetailsDao.UpdateOrderDetailsDiscount(orderDetails);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[UpdateOrderDetailsDiscount]参数:orderDetails_{0}", JsonConvert.SerializeObject(orderDetails)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }