예제 #1
0
        public bool DeleteSingleOrderDetails(DeletedOrderDetails deletedOrderDetails)
        {
            int result = ExecuteUpdate("DeleteSingleOrderDetails", deletedOrderDetails);

            return(result > 0);
        }
예제 #2
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;
            }
        }