Beispiel #1
0
        private void btnWholeDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null && _salesOrder != null && _salesOrder.order != null)
            {
                if (_salesOrder.order.Status == 1)
                {
                    int selectedIndex = dataGridView1.CurrentRow.Index;
                    if (dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value != null)
                    {
                        //权限验证
                        bool hasRights = false;
                        if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL))
                        {
                            hasRights = true;
                        }
                        else
                        {
                            FormRightsCode formRightsCode = new FormRightsCode();
                            formRightsCode.ShowDialog();
                            if (formRightsCode.ReturnValue)
                            {
                                IList <string> rightsCodeList = formRightsCode.RightsCodeList;
                                if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL))
                                {
                                    hasRights = true;
                                }
                            }
                        }
                        if (!hasRights)
                        {
                            return;
                        }
                        FormCancelOrder form = new FormCancelOrder();
                        form.ShowDialog();
                        if (form.CurrentReason != null)
                        {
                            //删除订单
                            DeletedOrder deletedOrder = new DeletedOrder();
                            deletedOrder.OrderID           = _salesOrder.order.OrderID;
                            deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                            deletedOrder.CancelEmployeeNo  = ConstantValuePool.CurrentEmployee.EmployeeNo;
                            deletedOrder.CancelReasonName  = form.CurrentReason.ReasonName;

                            if (DeletedOrderService.GetInstance().DeletePaidWholeOrder(deletedOrder))
                            {
                                dataGridView1.Rows[selectedIndex].Cells["BillType"].Value = "已删除";
                                _salesOrder.order.Status = 2;
                            }
                            else
                            {
                                MessageBox.Show("删除账单失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void btnCustomDiscountTo_Click(object sender, EventArgs e)
        {
            //权限验证
            bool hasRights = false;

            if (RightsItemCode.FindRights(RightsItemCode.CUSTOMDISCOUNT))
            {
                hasRights = true;
            }
            else
            {
                FormRightsCode form = new FormRightsCode();
                form.ShowDialog();
                if (form.ReturnValue)
                {
                    IList <string> rightsCodeList = form.RightsCodeList;
                    if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CUSTOMDISCOUNT))
                    {
                        hasRights = true;
                    }
                }
            }
            if (!hasRights)
            {
                return;
            }
            FormNumericKeypad keyForm = new FormNumericKeypad();

            keyForm.DisplayText = "请输入打折之后整单的金额";
            keyForm.ShowDialog();
            if (!string.IsNullOrEmpty(keyForm.KeypadValue))
            {
                if (decimal.Parse(keyForm.KeypadValue) < 0 || decimal.Parse(keyForm.KeypadValue) > m_ActualSellPrice)
                {
                    MessageBox.Show("折扣的金额不能小于零或者超过原始金额!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    decimal discountRate = (m_ActualSellPrice - decimal.Parse(keyForm.KeypadValue)) / m_ActualSellPrice;
                    if (discountRate > ConstantValuePool.CurrentEmployee.MinDiscount)
                    {
                        MessageBox.Show("当前已超过您的最低折扣!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    this.txtDiscount.Text = string.Format("打折后整单金额({0}元)", keyForm.KeypadValue);
                    Discount discount = new Discount();
                    discount.DiscountID      = new Guid("88888888-8888-8888-8888-888888888888");
                    discount.DiscountName    = "自定义折扣";
                    discount.DiscountName2nd = "自定义折扣";
                    discount.DiscountType    = (int)DiscountItemType.OffFixPay;
                    discount.OffFixPay       = m_ActualSellPrice - decimal.Parse(keyForm.KeypadValue);
                    m_DiscountItem           = discount;
                }
            }
        }
Beispiel #3
0
        private void btnCancelOrder_Click(object sender, EventArgs e)
        {
            if (_salesOrder != null)
            {
                //权限验证
                bool hasRights = false;
                if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL))
                {
                    hasRights = true;
                }
                else
                {
                    FormRightsCode formRightsCode = new FormRightsCode();
                    formRightsCode.ShowDialog();
                    if (formRightsCode.ReturnValue)
                    {
                        IList<string> rightsCodeList = formRightsCode.RightsCodeList;
                        if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL))
                        {
                            hasRights = true;
                        }
                    }
                }
                if (!hasRights)
                {
                    return;
                }
                FormCancelOrder form = new FormCancelOrder();
                form.ShowDialog();
                if (form.CurrentReason != null)
                {
                    //删除订单
                    DeletedOrder deletedOrder = new DeletedOrder();
                    deletedOrder.OrderID = _salesOrder.order.OrderID;
                    deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                    deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                    deletedOrder.CancelReasonName = form.CurrentReason.ReasonName;

                    if (DeletedOrderService.GetInstance().DeleteWholeOrder(deletedOrder))
                    {
                        //加载外卖单列表
                        IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList();
                        if (deliveryOrderList != null)
                        {
                            _pageIndex = 0;
                            _deliveryOrderList = deliveryOrderList;
                            DisplayDeliveryOrderButton();
                        }
                    }
                    else
                    {
                        MessageBox.Show("删除账单失败!");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            this.lbTotalPrice.Text = "总金额:";
            this.lbDiscount.Text = "折扣:";
            this.lbNeedPayMoney.Text = "实际应付:";
            this.lbCutOff.Text = "去零:";
            dgvGoodsOrder.Rows.Clear();
            _salesOrder = null;
            btnDeliveryGoods.Enabled = false;
            btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor;
            btnOutsideOrder.Enabled = true;
            btnOutsideOrder.BackColor = btnOutsideOrder.DisplayColor;
            txtTelephone.Text = string.Empty;
            txtName.Text = string.Empty;
            txtAddress.Text = string.Empty;
            txtTelephone.ReadOnly = false;
            txtName.ReadOnly = false;
            //更新第二屏信息
            if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
            {
                if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                {
                    ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo();
                }
            }
        }
Beispiel #4
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (dgvGoodsOrder.CurrentRow != null)
            {
                int selectIndex = dgvGoodsOrder.CurrentRow.Index;
                if (dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Value != null)
                {
                    int itemType = Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value);
                    if (itemType == (int)OrderItemType.Details)
                    {
                        MessageBox.Show("细项不能单独删除!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (itemType == (int)OrderItemType.SetMeal)
                    {
                        MessageBox.Show("套餐项不能单独删除!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    Guid orderDetailsId = new Guid(dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Value.ToString());
                    decimal goodsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value);
                    string goodsName = dgvGoodsOrder.Rows[selectIndex].Cells["GoodsName"].Value.ToString();
                    decimal goodsPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value);
                    if (!RightsItemCode.FindRights(RightsItemCode.CANCELGOODS))
                    {
                        decimal singleItemPriceSum = goodsPrice / goodsNum;
                        if (itemType == (int)OrderItemType.Goods && selectIndex < dgvGoodsOrder.Rows.Count - 1)
                        {
                            for (int index = selectIndex + 1; index < dgvGoodsOrder.RowCount; index++)
                            {
                                if (Convert.ToInt32(dgvGoodsOrder.Rows[index].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                                {
                                    break;
                                }
                                singleItemPriceSum += Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value) / Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value);
                            }
                            if (singleItemPriceSum > ConstantValuePool.CurrentEmployee.LimitMoney)
                            {
                                if (DialogResult.Yes == MessageBox.Show("当前用户不具备该权限,并且超过最高退菜限额,是否更换用户?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                                {
                                    //权限验证
                                    bool hasRights = false;
                                    FormRightsCode formRightsCode = new FormRightsCode();
                                    formRightsCode.ShowDialog();
                                    if (formRightsCode.ReturnValue)
                                    {
                                        IList<string> rightsCodeList = formRightsCode.RightsCodeList;
                                        if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELGOODS))
                                        {
                                            hasRights = true;
                                        }
                                    }
                                    if (!hasRights)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                    }
                    FormCancelOrder form = new FormCancelOrder(goodsName, goodsNum);
                    form.ShowDialog();
                    if (form.DelItemNum > 0 && form.CurrentReason != null)
                    {
                        if (form.DelItemNum < goodsNum)
                        {
                            //Key:Index, Value:RemainNum
                            Dictionary<int, decimal> dicRemainNum = new Dictionary<int, decimal>();
                            List<DeletedOrderDetails> deletedOrderDetailsList = new List<DeletedOrderDetails>();
                            //主项
                            decimal remainNum = goodsNum - form.DelItemNum;
                            dicRemainNum.Add(selectIndex, remainNum);
                            decimal originalDetailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value);
                            decimal originalDetailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value);
                            DeletedOrderDetails orderDetails = new DeletedOrderDetails();
                            orderDetails.OrderDetailsID = orderDetailsId;
                            orderDetails.DeletedQuantity = -form.DelItemNum;
                            orderDetails.RemainQuantity = remainNum;
                            orderDetails.OffPay = Math.Round(-originalDetailsDiscount / originalDetailsNum * remainNum, 4);
                            orderDetails.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                            orderDetails.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                            orderDetails.CancelReasonName = form.CurrentReason.ReasonName;
                            deletedOrderDetailsList.Add(orderDetails);
                            //细项
                            if (selectIndex < dgvGoodsOrder.Rows.Count - 1)
                            {
                                for (int index = selectIndex + 1; index < dgvGoodsOrder.RowCount; index++)
                                {
                                    if (Convert.ToInt32(dgvGoodsOrder.Rows[index].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                                    {
                                        break;
                                    }
                                    orderDetailsId = new Guid(dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Value.ToString());
                                    originalDetailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value);
                                    originalDetailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value);
                                    decimal delItemNum = originalDetailsNum / goodsNum * form.DelItemNum;
                                    remainNum = originalDetailsNum - delItemNum;
                                    dicRemainNum.Add(index, remainNum);
                                    DeletedOrderDetails item = new DeletedOrderDetails();
                                    item.OrderDetailsID = orderDetailsId;
                                    item.DeletedQuantity = -delItemNum;
                                    item.RemainQuantity = remainNum;
                                    item.OffPay = Math.Round(-originalDetailsDiscount / originalDetailsNum * remainNum, 4);
                                    item.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                                    item.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                                    item.CancelReasonName = form.CurrentReason.ReasonName;
                                    deletedOrderDetailsList.Add(item);
                                }
                            }
                            //计算价格信息
                            decimal totalPrice = 0, totalDiscount = 0;
                            for (int i = 0; i < dgvGoodsOrder.RowCount; i++)
                            {
                                if (dgvGoodsOrder.Rows[i].Cells["OrderDetailsID"].Value != null)
                                {
                                    if (dicRemainNum.ContainsKey(i))
                                    {
                                        decimal originalDetailsPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsPrice"].Value);
                                        originalDetailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsNum"].Value);
                                        originalDetailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);
                                        totalPrice += originalDetailsPrice / originalDetailsNum * dicRemainNum[i];
                                        totalDiscount += originalDetailsDiscount / originalDetailsNum * dicRemainNum[i];
                                    }
                                    else
                                    {
                                        totalPrice += Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsPrice"].Value);
                                        totalDiscount += Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);
                                    }
                                }
                            }
                            decimal wholePayMoney = totalPrice + totalDiscount;
                            decimal actualPayMoney = CutOffDecimal.HandleCutOff(wholePayMoney, ConstantValuePool.SysConfig.IsCutTail, ConstantValuePool.SysConfig.CutTailType, ConstantValuePool.SysConfig.CutTailDigit);
                            //构造DeletedSingleOrder对象
                            DeletedSingleOrder deletedSingleOrder = new DeletedSingleOrder();
                            deletedSingleOrder.OrderID = _salesOrder.order.OrderID;
                            deletedSingleOrder.TotalSellPrice = totalPrice;
                            deletedSingleOrder.ActualSellPrice = actualPayMoney;
                            deletedSingleOrder.DiscountPrice = totalDiscount;
                            deletedSingleOrder.CutOffPrice = wholePayMoney - actualPayMoney;
                            deletedSingleOrder.deletedOrderDetailsList = deletedOrderDetailsList;

                            if (DeletedOrderService.GetInstance().DeleteSingleOrder(deletedSingleOrder))
                            {
                                foreach (KeyValuePair<int, decimal> item in dicRemainNum)
                                {
                                    int index = item.Key;
                                    decimal remainsNum = item.Value;
                                    decimal detailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value);
                                    decimal detailsPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value);
                                    decimal detailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value);
                                    dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value = remainsNum;
                                    dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value = detailsPrice / detailsNum * remainsNum;
                                    dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = detailsDiscount / detailsNum * remainsNum;
                                }
                            }
                            else
                            {
                                MessageBox.Show("删除品项失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        else
                        {
                            List<int> deletedIndexList = new List<int>();
                            List<DeletedOrderDetails> deletedOrderDetailsList = new List<DeletedOrderDetails>();
                            //主项
                            deletedIndexList.Add(selectIndex);
                            DeletedOrderDetails orderDetails = new DeletedOrderDetails();
                            orderDetails.OrderDetailsID = orderDetailsId;
                            orderDetails.DeletedQuantity = -Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value);
                            orderDetails.RemainQuantity = 0;
                            orderDetails.OffPay = 0;
                            orderDetails.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                            orderDetails.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                            orderDetails.CancelReasonName = form.CurrentReason.ReasonName;
                            deletedOrderDetailsList.Add(orderDetails);
                            //细项
                            if (selectIndex < dgvGoodsOrder.RowCount - 1)
                            {
                                for (int index = selectIndex + 1; index < dgvGoodsOrder.RowCount; index++)
                                {
                                    if (Convert.ToInt32(dgvGoodsOrder.Rows[index].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                                    {
                                        break;
                                    }
                                    deletedIndexList.Add(index);
                                    orderDetailsId = new Guid(dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Value.ToString());
                                    DeletedOrderDetails item = new DeletedOrderDetails();
                                    item.OrderDetailsID = orderDetailsId;
                                    item.DeletedQuantity = -Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value);
                                    item.RemainQuantity = 0;
                                    item.OffPay = 0;
                                    item.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                                    item.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                                    item.CancelReasonName = form.CurrentReason.ReasonName;
                                    deletedOrderDetailsList.Add(item);
                                }
                            }
                            //计算价格信息
                            decimal totalPrice = 0, totalDiscount = 0;
                            for (int i = 0; i < dgvGoodsOrder.RowCount; i++)
                            {
                                if (dgvGoodsOrder.Rows[i].Cells["OrderDetailsID"].Value != null)
                                {
                                    bool hasDeleted = false;
                                    foreach (int deletedIndex in deletedIndexList)
                                    {
                                        if (i == deletedIndex)
                                        {
                                            hasDeleted = true;
                                            break;
                                        }
                                    }
                                    if (hasDeleted) continue;
                                    totalPrice += Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsPrice"].Value);
                                    totalDiscount += Convert.ToDecimal(dgvGoodsOrder.Rows[i].Cells["GoodsDiscount"].Value);
                                }
                            }
                            decimal wholePayMoney = totalPrice + totalDiscount;
                            decimal actualPayMoney = CutOffDecimal.HandleCutOff(wholePayMoney, ConstantValuePool.SysConfig.IsCutTail, ConstantValuePool.SysConfig.CutTailType, ConstantValuePool.SysConfig.CutTailDigit);
                            //构造DeletedSingleOrder对象
                            DeletedSingleOrder deletedSingleOrder = new DeletedSingleOrder();
                            deletedSingleOrder.OrderID = _salesOrder.order.OrderID;
                            deletedSingleOrder.TotalSellPrice = totalPrice;
                            deletedSingleOrder.ActualSellPrice = actualPayMoney;
                            deletedSingleOrder.DiscountPrice = totalDiscount;
                            deletedSingleOrder.CutOffPrice = wholePayMoney - actualPayMoney;
                            deletedSingleOrder.deletedOrderDetailsList = deletedOrderDetailsList;

                            if (DeletedOrderService.GetInstance().DeleteSingleOrder(deletedSingleOrder))
                            {
                                for (int i = deletedIndexList.Count - 1; i >= 0; i--)
                                {
                                    dgvGoodsOrder.Rows.RemoveAt(deletedIndexList[i]);
                                }
                            }
                            else
                            {
                                MessageBox.Show("删除品项失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value) == (int)OrderItemType.Details)
                    {
                        dgvGoodsOrder.Rows.RemoveAt(selectIndex);
                    }
                    else if (Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value) == (int)OrderItemType.SetMeal)
                    {
                        MessageBox.Show("套餐项不能单独删除!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        dgvGoodsOrder.Rows.RemoveAt(selectIndex);
                        if (selectIndex < dgvGoodsOrder.RowCount - 1)
                        {
                            for (int i = selectIndex; i < dgvGoodsOrder.RowCount; i++)
                            {
                                if (Convert.ToInt32(dgvGoodsOrder.Rows[i].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                                {
                                    break;
                                }
                                dgvGoodsOrder.Rows.RemoveAt(i);
                                i--;
                            }
                        }
                    }
                }
                //统计
                BindOrderInfoSum();
                //更新第二屏信息
                if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
                {
                    if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                    {
                        ((FormSecondScreen)ConstantValuePool.SecondScreenForm).BindGoodsOrderInfo(dgvGoodsOrder);
                    }
                }
            }
        }
Beispiel #5
0
 private void btnWholeDiscount_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.Rows.Count > 0 && dgvGoodsOrder.CurrentRow != null)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.WHOLEDISCOUNT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.WHOLEDISCOUNT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         //计算未打折金额
         decimal noDiscountPrice = 0;
         foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
         {
             bool canDiscount = Convert.ToBoolean(dr.Cells["CanDiscount"].Value);
             if (canDiscount)
             {
                 decimal itemPrice = Convert.ToDecimal(dr.Cells["GoodsPrice"].Value);
                 noDiscountPrice += itemPrice;
             }
         }
         FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.WholeDiscount, noDiscountPrice, _actualPayMoney);
         formDiscount.ShowDialog();
         if (formDiscount.CurrentDiscount != null)
         {
             Discount discount = formDiscount.CurrentDiscount;
             int firstIndex = -1; //折价索引
             decimal offFixedPay = 0;
             for (int index = 0; index < dgvGoodsOrder.Rows.Count; index++)
             {
                 DataGridViewRow dr = dgvGoodsOrder.Rows[index];
                 bool canDiscount = Convert.ToBoolean(dr.Cells["CanDiscount"].Value);
                 if (canDiscount)
                 {
                     if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                     {
                         dr.Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dr.Cells["GoodsPrice"].Value) * discount.DiscountRate;
                     }
                     else
                     {
                         if (firstIndex < 0)
                         {
                             firstIndex = index;
                         }
                         decimal itemPrice = Convert.ToDecimal(dr.Cells["GoodsPrice"].Value);
                         decimal discountPrice = itemPrice / noDiscountPrice * discount.OffFixPay;
                         discountPrice = Math.Round(discountPrice, 2);
                         dr.Cells["GoodsDiscount"].Value = -discountPrice;
                         offFixedPay += discountPrice;
                     }
                     dr.Cells["GoodsDiscount"].Tag = discount;
                 }
             }
             if (firstIndex >= 0)
             {
                 decimal gap = discount.OffFixPay - offFixedPay;
                 gap = Math.Round(gap, 2);
                 decimal discountPrice = Math.Abs(Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value));
                 discountPrice += gap;
                 dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value = -discountPrice;
             }
             //统计
             BindOrderInfoSum();
         }
     }
 }
Beispiel #6
0
 private void btnDiscount_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.Rows.Count > 0 && dgvGoodsOrder.CurrentRow != null)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.SINGLEDISCOUNT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.SINGLEDISCOUNT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         int selectIndex = dgvGoodsOrder.CurrentRow.Index;
         int itemType = Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value);
         if (itemType == (int)OrderItemType.Goods)   //主项才能打折
         {
             bool canDiscount = Convert.ToBoolean(dgvGoodsOrder.Rows[selectIndex].Cells["CanDiscount"].Value);
             if (canDiscount)
             {
                 decimal itemPrice = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value);
                 FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.SingleDiscount, -1, itemPrice);
                 formDiscount.ShowDialog();
                 if (formDiscount.CurrentDiscount != null)
                 {
                     Discount discount = formDiscount.CurrentDiscount;
                     if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                     }
                     else
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                     }
                     dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Tag = discount;
                     //更新细项
                     if (selectIndex < dgvGoodsOrder.Rows.Count - 1)
                     {
                         for (int index = selectIndex + 1; index < dgvGoodsOrder.Rows.Count; index++)
                         {
                             if (Convert.ToInt32(dgvGoodsOrder.Rows[index].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                             {
                                 break;
                             }
                             if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                             {
                                 dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                             }
                             else
                             {
                                 dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                             }
                             dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Tag = discount;
                         }
                     }
                     //统计
                     BindOrderInfoSum();
                 }
             }
         }
     }
 }
Beispiel #7
0
        private void btnWholeDiscount_Click(object sender, EventArgs e)
        {
            //权限验证
            bool hasRights = false;

            if (RightsItemCode.FindRights(RightsItemCode.WHOLEDISCOUNT))
            {
                hasRights = true;
            }
            else
            {
                FormRightsCode form = new FormRightsCode();
                form.ShowDialog();
                if (form.ReturnValue)
                {
                    IList <string> rightsCodeList = form.RightsCodeList;
                    if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.WHOLEDISCOUNT))
                    {
                        hasRights = true;
                    }
                }
            }
            if (!hasRights)
            {
                return;
            }
            //计算能打折的总金额
            decimal canDiscountPrice = 0;

            foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
            {
                OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
                if (orderDetails != null)
                {
                    if (orderDetails.CanDiscount)
                    {
                        canDiscountPrice += Convert.ToDecimal(dr.Cells["GoodsPrice"].Value);
                    }
                }
            }
            FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.WholeDiscount, canDiscountPrice, m_ActualPayMoney);

            formDiscount.ShowDialog();
            if (formDiscount.CurrentDiscount != null)
            {
                Discount discount    = formDiscount.CurrentDiscount;
                int      firstIndex  = -1; //折价索引
                decimal  offFixedPay = 0;
                for (int index = 0; index < dgvGoodsOrder.Rows.Count; index++)
                {
                    DataGridViewRow dr           = dgvGoodsOrder.Rows[index];
                    OrderDetails    orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
                    if (orderDetails != null)
                    {
                        if (orderDetails.CanDiscount)
                        {
                            if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                            {
                                dr.Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dr.Cells["GoodsPrice"].Value) * discount.DiscountRate;
                            }
                            else
                            {
                                if (firstIndex < 0)
                                {
                                    firstIndex = index;
                                }
                                decimal discountPrice = orderDetails.TotalSellPrice / canDiscountPrice * discount.OffFixPay;
                                discountPrice = Math.Round(discountPrice, 2);
                                dr.Cells["GoodsDiscount"].Value = -discountPrice;
                                offFixedPay += discountPrice;
                            }
                            orderDetails.TotalDiscount     = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
                            dr.Cells["OrderDetailsID"].Tag = orderDetails;
                            dr.Cells["GoodsDiscount"].Tag  = discount;
                        }
                    }
                }
                if (firstIndex >= 0)
                {
                    decimal gap = discount.OffFixPay - offFixedPay;
                    gap = Math.Round(gap, 2);
                    decimal discountPrice = Math.Abs(Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value));
                    discountPrice += gap;
                    dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value = -discountPrice;
                    OrderDetails orderDetails = dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag as OrderDetails;
                    orderDetails.TotalDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value);
                    dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag = orderDetails;
                }
                //重新计算
                CalculateOrderPrice();
                txtReceAmount.Text = (m_ActualPayMoney + m_ServiceFee).ToString("f2");
            }
        }
Beispiel #8
0
 private void btnCustomDiscountTo_Click(object sender, EventArgs e)
 {
     //权限验证
     bool hasRights = false;
     if (RightsItemCode.FindRights(RightsItemCode.CUSTOMDISCOUNT))
     {
         hasRights = true;
     }
     else
     {
         FormRightsCode form = new FormRightsCode();
         form.ShowDialog();
         if (form.ReturnValue)
         {
             IList<string> rightsCodeList = form.RightsCodeList;
             if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CUSTOMDISCOUNT))
             {
                 hasRights = true;
             }
         }
     }
     if (!hasRights)
     {
         return;
     }
     FormNumericKeypad keyForm = new FormNumericKeypad();
     keyForm.DisplayText = "请输入打折之后整单的金额";
     keyForm.ShowDialog();
     if (!string.IsNullOrEmpty(keyForm.KeypadValue))
     {
         if (decimal.Parse(keyForm.KeypadValue) < 0 || decimal.Parse(keyForm.KeypadValue) > m_ActualSellPrice)
         {
             MessageBox.Show("折扣的金额不能小于零或者超过原始金额!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             decimal discountRate = (m_ActualSellPrice - decimal.Parse(keyForm.KeypadValue)) / m_ActualSellPrice;
             if (discountRate > ConstantValuePool.CurrentEmployee.MinDiscount)
             {
                 MessageBox.Show("当前已超过您的最低折扣!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             this.txtDiscount.Text = string.Format("打折后整单金额({0}元)", keyForm.KeypadValue);
             Discount discount = new Discount();
             discount.DiscountID = new Guid("88888888-8888-8888-8888-888888888888");
             discount.DiscountName = "自定义折扣";
             discount.DiscountName2nd = "自定义折扣";
             discount.DiscountType = (int)DiscountItemType.OffFixPay;
             discount.OffFixPay = m_ActualSellPrice - decimal.Parse(keyForm.KeypadValue);
             m_DiscountItem = discount;
         }
     }
 }
 private void btnWholeDiscount_Click(object sender, EventArgs e)
 {
     //权限验证
     bool hasRights = false;
     if (RightsItemCode.FindRights(RightsItemCode.WHOLEDISCOUNT))
     {
         hasRights = true;
     }
     else
     {
         FormRightsCode form = new FormRightsCode();
         form.ShowDialog();
         if (form.ReturnValue)
         {
             IList<string> rightsCodeList = form.RightsCodeList;
             if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.WHOLEDISCOUNT))
             {
                 hasRights = true;
             }
         }
     }
     if (!hasRights)
     {
         return;
     }
     //计算能打折的总金额
     decimal canDiscountPrice = 0;
     foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
     {
         OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
         if (orderDetails != null)
         {
             if (orderDetails.CanDiscount)
             {
                 canDiscountPrice += Convert.ToDecimal(dr.Cells["GoodsPrice"].Value);
             }
         }
     }
     FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.WholeDiscount, canDiscountPrice, m_ActualPayMoney);
     formDiscount.ShowDialog();
     if (formDiscount.CurrentDiscount != null)
     {
         Discount discount = formDiscount.CurrentDiscount;
         int firstIndex = -1; //折价索引
         decimal offFixedPay = 0;
         for (int index = 0; index < dgvGoodsOrder.Rows.Count; index++)
         {
             DataGridViewRow dr = dgvGoodsOrder.Rows[index];
             OrderDetails orderDetails = dr.Cells["OrderDetailsID"].Tag as OrderDetails;
             if (orderDetails != null)
             {
                 if (orderDetails.CanDiscount)
                 {
                     if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                     {
                         dr.Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dr.Cells["GoodsPrice"].Value) * discount.DiscountRate;
                     }
                     else
                     {
                         if (firstIndex < 0)
                         {
                             firstIndex = index;
                         }
                         decimal discountPrice = orderDetails.TotalSellPrice / canDiscountPrice * discount.OffFixPay;
                         discountPrice = Math.Round(discountPrice, 2);
                         dr.Cells["GoodsDiscount"].Value = -discountPrice;
                         offFixedPay += discountPrice;
                     }
                     orderDetails.TotalDiscount = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
                     dr.Cells["OrderDetailsID"].Tag = orderDetails;
                     dr.Cells["GoodsDiscount"].Tag = discount;
                 }
             }
         }
         if (firstIndex >= 0)
         {
             decimal gap = discount.OffFixPay - offFixedPay;
             gap = Math.Round(gap, 2);
             decimal discountPrice = Math.Abs(Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value));
             discountPrice += gap;
             dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value = -discountPrice;
             OrderDetails orderDetails = dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag as OrderDetails;
             orderDetails.TotalDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value);
             dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag = orderDetails;
         }
         //重新计算
         CalculateOrderPrice();
         txtReceAmount.Text = (m_ActualPayMoney + m_ServiceFee).ToString("f2");
     }
 }
 private void btnDiscount_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.CurrentRow != null)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.SINGLEDISCOUNT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.SINGLEDISCOUNT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         int selectIndex = dgvGoodsOrder.CurrentRow.Index;
         OrderDetails orderDetails = dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Tag as OrderDetails;
         if (orderDetails.ItemType == (int)OrderItemType.Goods)   //主项才能打折
         {
             if (orderDetails.CanDiscount)
             {
                 FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.SingleDiscount, -1, orderDetails.TotalSellPrice);
                 formDiscount.ShowDialog();
                 if (formDiscount.CurrentDiscount != null)
                 {
                     Discount discount = formDiscount.CurrentDiscount;
                     if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                     }
                     else
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                     }
                     dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Tag = discount;
                     //更新细项
                     if (selectIndex < dgvGoodsOrder.Rows.Count - 1)
                     {
                         for (int index = selectIndex + 1; index < dgvGoodsOrder.Rows.Count; index++)
                         {
                             orderDetails = dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Tag as OrderDetails;
                             if (orderDetails.ItemType == (int)OrderItemType.Goods)
                             {
                                 break;
                             }
                             else
                             {
                                 if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                                 {
                                     dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                                 }
                                 else
                                 {
                                     dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                                 }
                                 dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Tag = discount;
                             }
                         }
                     }
                     //重新计算
                     CalculateOrderPrice();
                     txtReceAmount.Text = (m_ActualPayMoney + m_ServiceFee).ToString("f2");
                 }
             }
         }
     }
 }
Beispiel #11
0
 private void btnDiscount_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.RowCount > 0)
     {
         if (m_SalesOrder.order.Status == 3)
         {
             MessageBox.Show("当前处于预结状态,请先解锁!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (m_SalesOrder.order.Status == 0)
         {
             //权限验证
             bool hasRights = false;
             if (RightsItemCode.FindRights(RightsItemCode.WHOLEDISCOUNT))
             {
                 hasRights = true;
             }
             else
             {
                 FormRightsCode form = new FormRightsCode();
                 form.ShowDialog();
                 if (form.ReturnValue)
                 {
                     IList<string> rightsCodeList = form.RightsCodeList;
                     if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.WHOLEDISCOUNT))
                     {
                         hasRights = true;
                     }
                 }
             }
             if (!hasRights)
             {
                 return;
             }
             //计算未打折金额
             decimal noDiscountPrice = 0;
             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 || itemDiscountPrice == 0))
                     {
                         noDiscountPrice += orderDetails.TotalSellPrice;
                     }
                 }
             }
             FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.WholeDiscount, noDiscountPrice, m_ActualPayMoney);
             formDiscount.ShowDialog();
             if (formDiscount.CurrentDiscount != null)
             {
                 m_MembershipCard = string.Empty;
                 m_MemberDiscountRate = 0M;
                 Discount discount = formDiscount.CurrentDiscount;
                 int firstIndex = -1; //折价索引
                 decimal offFixedPay = 0;
                 for (int index = 0; index < dgvGoodsOrder.Rows.Count; index++)
                 {
                     DataGridViewRow dr = dgvGoodsOrder.Rows[index];
                     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 || itemDiscountPrice == 0))
                         {
                             if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                             {
                                 dr.Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dr.Cells["GoodsPrice"].Value) * discount.DiscountRate;
                             }
                             else
                             {
                                 if (firstIndex < 0)
                                 {
                                     firstIndex = index;
                                 }
                                 decimal discountPrice = orderDetails.TotalSellPrice / noDiscountPrice * discount.OffFixPay;
                                 discountPrice = Math.Round(discountPrice, 2);
                                 dr.Cells["GoodsDiscount"].Value = -discountPrice;
                                 offFixedPay += discountPrice;
                             }
                             orderDetails.TotalDiscount = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
                             dr.Cells["OrderDetailsID"].Tag = orderDetails;
                             dr.Cells["GoodsDiscount"].Tag = discount;
                         }
                     }
                 }
                 if (firstIndex >= 0)
                 {
                     decimal gap = discount.OffFixPay - offFixedPay;
                     gap = Math.Round(gap, 2);
                     decimal discountPrice = Math.Abs(Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value));
                     discountPrice += gap;
                     dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value = -discountPrice;
                     OrderDetails orderDetails = dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag as OrderDetails;
                     orderDetails.TotalDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[firstIndex].Cells["GoodsDiscount"].Value);
                     dgvGoodsOrder.Rows[firstIndex].Cells["OrderDetailsID"].Tag = orderDetails;
                 }
                 //统计
                 BindOrderInfoSum();
                 this.lbUnpaidAmount.Text = (decimal.Parse(lbReceMoney.Text) + decimal.Parse(lbServiceFee.Text) - decimal.Parse(lbPaidInMoney.Text)).ToString("f2");
                 //更新第二屏信息
                 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
                 {
                     if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                     {
                         ((FormSecondScreen)ConstantValuePool.SecondScreenForm).BindGoodsOrderInfo(dgvGoodsOrder);
                         ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ShowOrderServiceFee(m_ActualPayMoney + m_ServiceFee, m_ServiceFee);
                     }
                 }
             }
         }
     }
 }
Beispiel #12
0
 private void btnMember_Click(object sender, EventArgs e)
 {
     if (m_SalesOrder.order.Status == 3)
     {
         MessageBox.Show("当前处于预结状态,请先解锁!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (m_SalesOrder.order.Status == 0)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.MEMBERDISCOUNT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.MEMBERDISCOUNT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         Membership.FormVIPCardDiscount formCardDiscount = new Membership.FormVIPCardDiscount();
         formCardDiscount.ShowDialog();
         if (formCardDiscount.Result == 1)
         {
             m_MembershipCard = formCardDiscount.CardNo;
             m_MemberDiscountRate = formCardDiscount.DiscountRate;
             Discount discount = new Discount();
             discount.DiscountID = new Guid("99999999-9999-9999-9999-999999999999");
             discount.DiscountName = "会员折扣";
             discount.DiscountName2nd = "会员折扣";
             discount.DiscountType = (int)DiscountItemType.DiscountRate;
             discount.DiscountRate = formCardDiscount.DiscountRate;
             for (int index = 0; index < dgvGoodsOrder.Rows.Count; index++)
             {
                 DataGridViewRow dr = dgvGoodsOrder.Rows[index];
                 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 || itemDiscountPrice == 0))
                     {
                         dr.Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dr.Cells["GoodsPrice"].Value) * discount.DiscountRate;
                         orderDetails.TotalDiscount = Convert.ToDecimal(dr.Cells["GoodsDiscount"].Value);
                         dr.Cells["OrderDetailsID"].Tag = orderDetails;
                         dr.Cells["GoodsDiscount"].Tag = discount;
                     }
                 }
             }
             //统计
             BindOrderInfoSum();
             this.lbUnpaidAmount.Text = (decimal.Parse(lbReceMoney.Text) + decimal.Parse(lbServiceFee.Text) - decimal.Parse(lbPaidInMoney.Text)).ToString("f2");
             //更新第二屏信息
             if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
             {
                 if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                 {
                     ((FormSecondScreen)ConstantValuePool.SecondScreenForm).BindGoodsOrderInfo(dgvGoodsOrder);
                     ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ShowOrderServiceFee(m_ActualPayMoney + m_ServiceFee, m_ServiceFee);
                 }
             }
         }
     }
 }
Beispiel #13
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;
         }
     }
 }
        private void btnWholeDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null && _salesOrder != null && _salesOrder.order != null)
            {
                if (_salesOrder.order.Status == 1)
                {
                    int selectedIndex = dataGridView1.CurrentRow.Index;
                    if (dataGridView1.Rows[selectedIndex].Cells["OrderID"].Value != null)
                    {
                        //权限验证
                        bool hasRights = false;
                        if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL))
                        {
                            hasRights = true;
                        }
                        else
                        {
                            FormRightsCode formRightsCode = new FormRightsCode();
                            formRightsCode.ShowDialog();
                            if (formRightsCode.ReturnValue)
                            {
                                IList<string> rightsCodeList = formRightsCode.RightsCodeList;
                                if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL))
                                {
                                    hasRights = true;
                                }
                            }
                        }
                        if (!hasRights)
                        {
                            return;
                        }
                        FormCancelOrder form = new FormCancelOrder();
                        form.ShowDialog();
                        if (form.CurrentReason != null)
                        {
                            //删除订单
                            DeletedOrder deletedOrder = new DeletedOrder();
                            deletedOrder.OrderID = _salesOrder.order.OrderID;
                            deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                            deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                            deletedOrder.CancelReasonName = form.CurrentReason.ReasonName;

                            if (DeletedOrderService.GetInstance().DeletePaidWholeOrder(deletedOrder))
                            {
                                dataGridView1.Rows[selectedIndex].Cells["BillType"].Value = "已删除";
                                _salesOrder.order.Status = 2;
                            }
                            else
                            {
                                MessageBox.Show("删除账单失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Beispiel #15
0
 private void btnTasteRemark_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.CurrentRow != null)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.CUSTOMTASTE))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CUSTOMTASTE))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         int selectIndex = dgvGoodsOrder.CurrentRow.Index;
         if (dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Value == null)
         {
             string goodsName = dgvGoodsOrder.Rows[selectIndex].Cells["GoodsName"].Value.ToString();
             FormCustomDetails form = new FormCustomDetails(goodsName);
             form.ShowDialog();
             if (!string.IsNullOrEmpty(form.CustomTasteName))
             {
                 string printSolutionName = string.Empty;
                 Guid departId = Guid.Empty;
                 int itemType = Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value);
                 if (itemType == (int)OrderItemType.Goods)
                 {
                     Goods goods = dgvGoodsOrder.Rows[selectIndex].Cells["ItemID"].Tag as Goods;
                     if (goods != null)
                     {
                         printSolutionName = goods.PrintSolutionName;
                         departId = goods.DepartID;
                     }
                 }
                 else if (itemType == (int)OrderItemType.Details)
                 {
                     Details detail = dgvGoodsOrder.Rows[selectIndex].Cells["ItemID"].Tag as Details;
                     if (detail != null)
                     {
                         printSolutionName = detail.PrintSolutionName;
                         departId = detail.DepartID;
                     }
                 }
                 Details details = new Details();
                 details.DetailsID = new Guid("77777777-7777-7777-7777-777777777777");
                 details.DetailsNo = "7777";
                 details.DetailsName = details.DetailsName2nd = form.CustomTasteName.Replace("-", "");
                 details.SellPrice = 0;
                 details.CanDiscount = false;
                 details.AutoShowDetails = false;
                 details.PrintSolutionName = printSolutionName;
                 details.DepartID = departId;
                 //数量
                 decimal itemNum = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value);
                 DataGridViewRow dgr = dgvGoodsOrder.Rows[0].Clone() as DataGridViewRow;
                 dgr.Cells[0].Value = details.DetailsID;
                 dgr.Cells[0].Tag = details;
                 dgr.Cells[1].Value = itemNum;
                 dgr.Cells[2].Value = form.CustomTasteName;
                 dgr.Cells[3].Value = details.SellPrice;
                 dgr.Cells[4].Value = 0;
                 dgr.Cells[5].Value = OrderItemType.Details;
                 dgr.Cells[6].Value = details.CanDiscount;
                 int rowIndex = selectIndex + 1;
                 if (rowIndex == dgvGoodsOrder.Rows.Count)
                 {
                     dgvGoodsOrder.Rows.Add(dgr);
                 }
                 else
                 {
                     if (Convert.ToInt32(dgvGoodsOrder.Rows[selectIndex].Cells["ItemType"].Value) == (int)OrderItemType.Goods)
                     {
                         for (int i = selectIndex + 1; i < dgvGoodsOrder.RowCount; i++)
                         {
                             itemType = Convert.ToInt32(dgvGoodsOrder.Rows[i].Cells["ItemType"].Value);
                             if (itemType == (int)OrderItemType.Goods)
                             {
                                 break;
                             }
                             rowIndex++;
                         }
                     }
                     dgvGoodsOrder.Rows.Insert(rowIndex, dgr);
                 }
                 //统计
                 BindOrderInfoSum();
             }
         }
     }
 }
Beispiel #16
0
 private void btnCheckout_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.Rows.Count <= 0)
     {
         MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (!_haveDailyClose)
     {
         bool isContainsNewItem = false;
         foreach (DataGridViewRow dr in dgvGoodsOrder.Rows)
         {
             if (dr.Cells["OrderDetailsID"].Value == null)
             {
                 isContainsNewItem = true;
                 break;
             }
         }
         if (isContainsNewItem)
         {
             MessageBox.Show("上次未日结,不能新增菜单,请先进行日结操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     //权限验证
     bool hasRights = false;
     if (RightsItemCode.FindRights(RightsItemCode.CHECKOUT))
     {
         hasRights = true;
     }
     else
     {
         FormRightsCode form = new FormRightsCode();
         form.ShowDialog();
         if (form.ReturnValue)
         {
             IList<string> rightsCodeList = form.RightsCodeList;
             if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CHECKOUT))
             {
                 hasRights = true;
             }
         }
     }
     if (!hasRights)
     {
         return;
     }
     //判断参加限时组合销售
     JoinGoodsCombinedSale(this.dgvGoodsOrder);
     BindOrderInfoSum();
     string deskName;
     if (_salesOrder == null)
     {
         if (ConstantValuePool.BizSettingConfig.CarteMode)
         {
             FormNumericKeypad form = new FormNumericKeypad();
             form.DisplayText = "请输入餐牌号";
             form.ShowDialog();
             if (string.IsNullOrEmpty(form.KeypadValue))
             {
                 MessageBox.Show("餐牌号不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             if (form.KeypadValue.Length > 3)
             {
                 MessageBox.Show("您输入的餐牌号码过大!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             deskName = "W" + form.KeypadValue.PadLeft(3, '0');
         }
         else
         {
             deskName = "W001";
         }
     }
     else
     {
         deskName = _salesOrder.order.DeskName;
     }
     int result = SubmitSalesOrder(deskName, EatWayType.Takeout);
     if (result == 0)
     {
         MessageBox.Show("提交菜单信息出现异常,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         //转入结账页面
         FormPayment checkForm = new FormPayment(_salesOrder);
         checkForm.ShowDialog();
         if (checkForm.IsPaidOrder)
         {
             this.lbTotalPrice.Text = "总金额:";
             this.lbDiscount.Text = "折扣:";
             this.lbNeedPayMoney.Text = "实际应付:";
             this.lbCutOff.Text = "去零:";
             dgvGoodsOrder.Rows.Clear();
             _salesOrder = null;
             btnDeliveryGoods.Enabled = false;
             btnDeliveryGoods.BackColor = ConstantValuePool.DisabledColor;
             txtTelephone.Text = string.Empty;
             txtName.Text = string.Empty;
             txtAddress.Text = string.Empty;
             txtTelephone.ReadOnly = false;
             txtName.ReadOnly = false;
             //加载外卖单列表
             IList<DeliveryOrder> deliveryOrderList = OrderService.GetInstance().GetDeliveryOrderList();
             if (deliveryOrderList != null)
             {
                 _pageIndex = 0;
                 _deliveryOrderList = deliveryOrderList;
                 DisplayDeliveryOrderButton();
             }
             //更新第二屏信息
             if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
             {
                 if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                 {
                     ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo();
                 }
             }
         }
     }
 }
Beispiel #17
0
 private void btnCheckOut_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.Rows.Count > 0)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.CHECKOUT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList<string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CHECKOUT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         //判断参加限时组合销售
         JoinGoodsCombinedSale(this.dgvGoodsOrder);
         BindOrderInfoSum();
         if (SubmitSalesOrder())
         {
             //转入结账页面
             SalesOrder newSalesOrder = CopyExtension.Clone<SalesOrder>(_salesOrder);
             FormCheckOut checkForm = new FormCheckOut(newSalesOrder, _currentDeskName);
             checkForm.ShowDialog();
             if (checkForm.IsPaidOrder)
             {
                 //更新第二屏信息
                 if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
                 {
                     if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                     {
                         ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo();
                     }
                 }
                 _onShow = false;
                 this.Hide();
             }
             else
             {
                 if (checkForm.IsPreCheckOut)
                 {
                     //更新第二屏信息
                     if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
                     {
                         if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                         {
                             ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo();
                         }
                     }
                     _onShow = false;
                     this.Hide();
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);;
     }
 }
Beispiel #18
0
        private void btnCancelOrder_Click(object sender, EventArgs e)
        {
            if (_salesOrder != null)
            {
                //权限验证
                bool hasRights = false;
                if (RightsItemCode.FindRights(RightsItemCode.CANCELBILL))
                {
                    hasRights = true;
                }
                else
                {
                    FormRightsCode formRightsCode = new FormRightsCode();
                    formRightsCode.ShowDialog();
                    if (formRightsCode.ReturnValue)
                    {
                        IList<string> rightsCodeList = formRightsCode.RightsCodeList;
                        if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.CANCELBILL))
                        {
                            hasRights = true;
                        }
                    }
                }
                if (!hasRights)
                {
                    return;
                }
                FormCancelOrder form = new FormCancelOrder();
                form.ShowDialog();
                if (form.CurrentReason != null)
                {
                    //删除订单
                    DeletedOrder deletedOrder = new DeletedOrder();
                    deletedOrder.OrderID = _salesOrder.order.OrderID;
                    deletedOrder.AuthorisedManager = ConstantValuePool.CurrentEmployee.EmployeeID;
                    deletedOrder.CancelEmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo;
                    deletedOrder.CancelReasonName = form.CurrentReason.ReasonName;

                    if (!DeletedOrderService.GetInstance().DeleteWholeOrder(deletedOrder))
                    {
                        MessageBox.Show("删除账单失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);;
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            //更新桌况为空闲状态
            int status = (int)DeskButtonStatus.IDLE_MODE;
            if (DeskService.GetInstance().UpdateDeskStatus(_currentDeskName, string.Empty, status))
            {
                //更新第二屏信息
                if (Screen.AllScreens.Length > 1 && ConstantValuePool.BizSettingConfig.SecondScreenEnabled)
                {
                    if (ConstantValuePool.SecondScreenForm != null && ConstantValuePool.SecondScreenForm is FormSecondScreen)
                    {
                        ((FormSecondScreen)ConstantValuePool.SecondScreenForm).ClearGoodsOrderInfo();
                    }
                }
                _onShow = false;
                this.Hide();
            }
            else
            {
                MessageBox.Show("更新桌况状态错误 !");
                return;
            }
        }
Beispiel #19
0
 private void btnDiscount_Click(object sender, EventArgs e)
 {
     if (dgvGoodsOrder.CurrentRow != null)
     {
         //权限验证
         bool hasRights = false;
         if (RightsItemCode.FindRights(RightsItemCode.SINGLEDISCOUNT))
         {
             hasRights = true;
         }
         else
         {
             FormRightsCode form = new FormRightsCode();
             form.ShowDialog();
             if (form.ReturnValue)
             {
                 IList <string> rightsCodeList = form.RightsCodeList;
                 if (RightsItemCode.FindRights(rightsCodeList, RightsItemCode.SINGLEDISCOUNT))
                 {
                     hasRights = true;
                 }
             }
         }
         if (!hasRights)
         {
             return;
         }
         int          selectIndex  = dgvGoodsOrder.CurrentRow.Index;
         OrderDetails orderDetails = dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Tag as OrderDetails;
         if (orderDetails.ItemType == (int)OrderItemType.Goods)   //主项才能打折
         {
             if (orderDetails.CanDiscount)
             {
                 FormDiscount formDiscount = new FormDiscount(DiscountDisplayModel.SingleDiscount, -1, orderDetails.TotalSellPrice);
                 formDiscount.ShowDialog();
                 if (formDiscount.CurrentDiscount != null)
                 {
                     Discount discount = formDiscount.CurrentDiscount;
                     if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                     }
                     else
                     {
                         dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                     }
                     dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Tag = discount;
                     //更新细项
                     if (selectIndex < dgvGoodsOrder.Rows.Count - 1)
                     {
                         for (int index = selectIndex + 1; index < dgvGoodsOrder.Rows.Count; index++)
                         {
                             orderDetails = dgvGoodsOrder.Rows[index].Cells["OrderDetailsID"].Tag as OrderDetails;
                             if (orderDetails.ItemType == (int)OrderItemType.Goods)
                             {
                                 break;
                             }
                             else
                             {
                                 if (discount.DiscountType == (int)DiscountItemType.DiscountRate)
                                 {
                                     dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value) * discount.DiscountRate;
                                 }
                                 else
                                 {
                                     dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = -discount.OffFixPay;
                                 }
                                 dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Tag = discount;
                             }
                         }
                     }
                     //重新计算
                     CalculateOrderPrice();
                     txtReceAmount.Text = (m_ActualPayMoney + m_ServiceFee).ToString("f2");
                 }
             }
         }
     }
 }