private void btnPeopleNum_Click(object sender, EventArgs e) { FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入用餐人数"; form.ShowDialog(); GotoInputNum: if (string.IsNullOrEmpty(form.KeypadValue)) { this.Close(); } else { if (form.KeypadValue.IndexOf('.') >= 0) { MessageBox.Show("请输入整数!"); form.ShowDialog(); goto GotoInputNum; } else { if (int.Parse(form.KeypadValue) >= m_SalesOrder.order.PeopleNum) { if (DialogResult.Yes == MessageBox.Show("输入的人数超过原单的人数,是否继续?", "分单人数", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { this.btnPeopleNum.Text = "人数:" + form.KeypadValue; } } else { this.btnPeopleNum.Text = "人数:" + form.KeypadValue; } } } }
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 btnTranSequence_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(false); keyForm.DisplayText = "请输入流水号"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { _seachType = 2; this.txtSearchValue.Text = keyForm.KeypadValue; } }
private void btnTranSequence_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(false); keyForm.DisplayText = "请输入流水号"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { _seachType = 2; this.txtSearchValue.Text = keyForm.KeypadValue; } }
private void btnNumber_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(); keyForm.DisplayText = "请输入删除数量"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { if (decimal.Parse(keyForm.KeypadValue) <= m_ItemNum && decimal.Parse(keyForm.KeypadValue) > 0) { m_DelItemNum = decimal.Parse(keyForm.KeypadValue); this.txtItemNun.Text = m_ItemName + "*" + m_DelItemNum.ToString("f1"); } } }
private void btnNumber_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(); keyForm.DisplayText = "请输入删除数量"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { if (decimal.Parse(keyForm.KeypadValue) <= m_ItemNum && decimal.Parse(keyForm.KeypadValue) > 0) { m_DelItemNum = decimal.Parse(keyForm.KeypadValue); this.txtItemNun.Text = m_ItemName + "*" + m_DelItemNum.ToString("f1"); } else { MessageBox.Show("删除品项的数量不能超过原始数量!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void FormSplitBill_Shown(object sender, EventArgs e) { //输入分单人数 FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入用餐人数"; form.ShowDialog(); GotoInputNum: if (string.IsNullOrEmpty(form.KeypadValue)) { this.Close(); } else { if (form.KeypadValue.IndexOf('.') >= 0) { MessageBox.Show("请输入整数!"); form.ShowDialog(); goto GotoInputNum; } else { if (int.Parse(form.KeypadValue) >= m_SalesOrder.order.PeopleNum) { if (DialogResult.Yes == MessageBox.Show("输入的人数超过原单的人数,是否继续?", "分单人数", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { this.btnPeopleNum.Text = "人数:" + form.KeypadValue; } else { this.Close(); } } else { this.btnPeopleNum.Text = "人数:" + form.KeypadValue; } } } }
private void btnNumber_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(); keyForm.DisplayText = "请输入删除数量"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { if (decimal.Parse(keyForm.KeypadValue) <= m_ItemNum && decimal.Parse(keyForm.KeypadValue) > 0) { m_DelItemNum = decimal.Parse(keyForm.KeypadValue); this.txtItemNun.Text = m_ItemName + "*" + m_DelItemNum.ToString("f1"); } else { MessageBox.Show("删除品项的数量不能超过原始数量!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void txtEmployeeNo_MouseDown(object sender, MouseEventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(false); keyForm.DisplayText = "请输入用户名"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { string employeeNo = keyForm.KeypadValue; this.txtEmployeeNo.Text = employeeNo; Employee employee = null; int result = EmployeeService.GetInstance().GetEmployeeByNo(employeeNo, ref employee); if (result == 1) { this.txtEmployeeNo.Text = employee.EmployeeNo; this.txtEmployeeName.Text = employee.Name; } else if (result == 2) { MessageBox.Show("用户名不存在,请检查输入是否正确!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("获取客户信息失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
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; } } }
/// <summary> /// 将新单回滚到原来单子上 /// </summary> private bool RollbackNewOrderToSrc(DataGridView gridView1, DataGridView gridView2) { if (gridView1.CurrentRow != null && gridView1.CurrentRow.Index >= 0) { int selectedIndex = gridView1.CurrentRow.Index; int goodsType = Convert.ToInt32(gridView1.Rows[selectedIndex].Cells[5].Value); if (goodsType != (int)OrderItemType.Goods) { return false; } decimal goodsNum = Convert.ToDecimal(gridView1.Rows[selectedIndex].Cells[0].Value); string goodsName = gridView1.Rows[selectedIndex].Cells[1].Value.ToString(); decimal goodsPrice = Convert.ToDecimal(gridView1.Rows[selectedIndex].Cells[2].Value); string orderDetailsID = gridView1.Rows[selectedIndex].Cells[4].Value.ToString(); decimal splitOrderQty = 0; //更新gridView1中的数据 if (goodsNum > 1) { FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入分单份数"; form.ShowDialog(); if (!string.IsNullOrEmpty(form.KeypadValue)) { splitOrderQty = decimal.Parse(form.KeypadValue); } while (splitOrderQty > goodsNum) { MessageBox.Show("选择分单数量有误!"); splitOrderQty = 0; form.ShowDialog(); if (!string.IsNullOrEmpty(form.KeypadValue)) { splitOrderQty = decimal.Parse(form.KeypadValue); } } if (splitOrderQty > 0) { if (splitOrderQty == goodsNum) { gridView1.Rows.RemoveAt(selectedIndex); } else { gridView1.Rows[selectedIndex].Cells[0].Value = goodsNum - splitOrderQty; gridView1.Rows[selectedIndex].Cells[2].Value = goodsPrice - goodsPrice / goodsNum * splitOrderQty; } } else { return false; } } else { gridView1.Rows.RemoveAt(selectedIndex); } //更新gridView2中的数据 int containIndex = -1; for (int index = 0; index < gridView2.Rows.Count; index++) { if (gridView2.Rows[index].Cells[4].Value.ToString() == orderDetailsID) { containIndex = index; break; } } if (containIndex != -1) { decimal goodsNum2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[0].Value); decimal goodsPrice2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[2].Value); decimal goodsDiscount2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[3].Value); if (goodsNum > 1) { gridView2.Rows[containIndex].Cells[0].Value = goodsNum2 + splitOrderQty; gridView2.Rows[containIndex].Cells[2].Value = goodsPrice2 + goodsPrice / goodsNum * splitOrderQty; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[containIndex].Cells[3].Value = goodsDiscount2 + totalDiscount / goodsNum * splitOrderQty; SubtractDiscountToDic(orderDetailsID, totalDiscount / goodsNum * splitOrderQty); } else { gridView2.Rows[containIndex].Cells[0].Value = goodsNum2 + goodsNum; gridView2.Rows[containIndex].Cells[2].Value = goodsPrice2 + goodsPrice; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[containIndex].Cells[3].Value = goodsDiscount2 + totalDiscount; SubtractDiscountToDic(orderDetailsID, totalDiscount); } } else { int rowIndex = gridView2.Rows.Add(new DataGridViewRow()); if (goodsNum > 1) { gridView2.Rows[rowIndex].Cells[0].Value = splitOrderQty; gridView2.Rows[rowIndex].Cells[1].Value = goodsName; gridView2.Rows[rowIndex].Cells[2].Value = goodsPrice / goodsNum * splitOrderQty; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[rowIndex].Cells[3].Value = totalDiscount / goodsNum * splitOrderQty; gridView2.Rows[rowIndex].Cells[4].Value = orderDetailsID; gridView2.Rows[rowIndex].Cells[5].Value = goodsType; SubtractDiscountToDic(orderDetailsID, totalDiscount / goodsNum * splitOrderQty); } else { gridView2.Rows[rowIndex].Cells[0].Value = goodsNum; gridView2.Rows[rowIndex].Cells[1].Value = goodsName; gridView2.Rows[rowIndex].Cells[2].Value = goodsPrice; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[rowIndex].Cells[3].Value = totalDiscount; gridView2.Rows[rowIndex].Cells[4].Value = orderDetailsID; gridView2.Rows[rowIndex].Cells[5].Value = goodsType; SubtractDiscountToDic(orderDetailsID, totalDiscount); } } //同时移动细项 if (goodsNum > 1) { if (goodsNum > splitOrderQty) { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex, splitOrderQty); } else { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex); } } else { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex); } //设置最后一行选中 if (gridView1.Rows.Count > 0) { gridView1.Rows[gridView1.Rows.Count - 1].Selected = true; gridView1.CurrentCell = gridView1[0, gridView1.Rows.Count - 1]; } if (gridView2.Rows.Count > 0) { gridView2.Rows[gridView2.Rows.Count - 1].Selected = true; gridView2.CurrentCell = gridView2[0, gridView2.Rows.Count - 1]; } return true; } else { return false; } }
private void btnNumber_Click(object sender, EventArgs e) { FormNumericKeypad keyForm = new FormNumericKeypad(); keyForm.DisplayText = "请输入删除数量"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue)) { if (decimal.Parse(keyForm.KeypadValue) <= m_ItemNum && decimal.Parse(keyForm.KeypadValue) > 0) { m_DelItemNum = decimal.Parse(keyForm.KeypadValue); this.txtItemNun.Text = m_ItemName + "*" + m_DelItemNum.ToString("f1"); } } }
private void btnDesk_Click(object sender, EventArgs e) { if (_operateType == ButtonOperateType.NONE) { return; } CrystalButton btnDesk = sender as CrystalButton; if (btnDesk == null) { return; } BizDesk tempDesk = btnDesk.Tag as BizDesk; if (tempDesk == null) { return; } _currentFormActivate = false; //重新获取Desk信息 BizDesk desk = DeskService.GetInstance().GetBizDeskByName(tempDesk.DeskName); if (_operateType == ButtonOperateType.ORDER) { if (desk.Status == (int)DeskButtonStatus.IDLE_MODE) { //人数 Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _formOrder.PersonNum = int.Parse(keyForm.KeypadValue); } else { return; } //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { desk.Status = status; btnDesk.BackColor = GetColorByStatus(status, ConstantValuePool.BizSettingConfig.DeviceNo); _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = null; _formOrder.VisibleShow = true; _formOrder.Show(); } } else if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { if (salesOrder.order.Status == 3) //已预结 { //open check out form FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } else { //open order form _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = salesOrder; _formOrder.VisibleShow = true; _formOrder.Show(); } } } } } } } else if (_operateType == ButtonOperateType.CLEAR) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED && !string.IsNullOrEmpty(desk.DeviceNo)) { //更新桌况为非占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, string.Empty, status)) { btnDesk.BackColor = GetColorByStatus(status, string.Empty); } } } else if (_operateType == ButtonOperateType.CHANGE_DESK) { if (string.IsNullOrEmpty(_deskName1St)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { if (orderList.Count > 1) { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { _deskName1St = desk.DeskName; _orderId1St = form.SelectedOrder.OrderID; _firstDeskSingleOrder = false; } else { _currentFormActivate = true; //使线程重新活跃 return; } } else { _deskName1St = desk.DeskName; _orderId1St = orderList[0].OrderID; _firstDeskSingleOrder = true; } } else { _currentFormActivate = true; //使线程重新活跃 return; //空桌 } } else { if (!string.IsNullOrEmpty(_deskName1St)) { if (desk.DeskName == _deskName1St) { _currentFormActivate = true; //使线程重新活跃 return; //点击相同的第一张桌子 } //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList, deskChange); form.ShowDialog(); if (form.SelectedOrder != null) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } else { _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } else { //直接转台 DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; if (OrderService.GetInstance().OrderDeskOperate(deskChange)) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } } } } else if (_operateType == ButtonOperateType.CHECKOUT) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList <Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } } } } } } _currentFormActivate = true; }
private void 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(); } } } } }
private void btnTakeOut_Click(object sender, EventArgs e) { if (dgvGoodsOrder.Rows.Count <= 0) { MessageBox.Show("请先选择菜品!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!_haveDailyClose) { MessageBox.Show("上次未日结,不能新增菜单,请先进行日结操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_salesOrder == null || _salesOrder.order.EatType == (int)EatWayType.Takeout) { 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 == 1) { 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(); } } } else if (result == 0) { MessageBox.Show("外带提交失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { MessageBox.Show("没有数据可以提交!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (_salesOrder.order.EatType == (int)EatWayType.OutsideOrder) { MessageBox.Show("当前账单状态为[外送],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (_salesOrder.order.EatType == (int)EatWayType.DineIn) { MessageBox.Show("当前账单状态为[堂食],请更改类型后再进行操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// 将新单回滚到原来单子上 /// </summary> private bool RollbackNewOrderToSrc(DataGridView gridView1, DataGridView gridView2) { if (gridView1.CurrentRow != null && gridView1.CurrentRow.Index >= 0) { int selectedIndex = gridView1.CurrentRow.Index; int goodsType = Convert.ToInt32(gridView1.Rows[selectedIndex].Cells[5].Value); if (goodsType != (int)OrderItemType.Goods) { return(false); } decimal goodsNum = Convert.ToDecimal(gridView1.Rows[selectedIndex].Cells[0].Value); string goodsName = gridView1.Rows[selectedIndex].Cells[1].Value.ToString(); decimal goodsPrice = Convert.ToDecimal(gridView1.Rows[selectedIndex].Cells[2].Value); string orderDetailsID = gridView1.Rows[selectedIndex].Cells[4].Value.ToString(); decimal splitOrderQty = 0; //更新gridView1中的数据 if (goodsNum > 1) { FormNumericKeypad form = new FormNumericKeypad(); form.DisplayText = "请输入分单份数"; form.ShowDialog(); if (!string.IsNullOrEmpty(form.KeypadValue)) { splitOrderQty = decimal.Parse(form.KeypadValue); } while (splitOrderQty > goodsNum) { MessageBox.Show("选择分单数量有误!"); splitOrderQty = 0; form.ShowDialog(); if (!string.IsNullOrEmpty(form.KeypadValue)) { splitOrderQty = decimal.Parse(form.KeypadValue); } } if (splitOrderQty > 0) { if (splitOrderQty == goodsNum) { gridView1.Rows.RemoveAt(selectedIndex); } else { gridView1.Rows[selectedIndex].Cells[0].Value = goodsNum - splitOrderQty; gridView1.Rows[selectedIndex].Cells[2].Value = goodsPrice - goodsPrice / goodsNum * splitOrderQty; } } else { return(false); } } else { gridView1.Rows.RemoveAt(selectedIndex); } //更新gridView2中的数据 int containIndex = -1; for (int index = 0; index < gridView2.Rows.Count; index++) { if (gridView2.Rows[index].Cells[4].Value.ToString() == orderDetailsID) { containIndex = index; break; } } if (containIndex != -1) { decimal goodsNum2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[0].Value); decimal goodsPrice2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[2].Value); decimal goodsDiscount2 = Convert.ToDecimal(gridView2.Rows[containIndex].Cells[3].Value); if (goodsNum > 1) { gridView2.Rows[containIndex].Cells[0].Value = goodsNum2 + splitOrderQty; gridView2.Rows[containIndex].Cells[2].Value = goodsPrice2 + goodsPrice / goodsNum * splitOrderQty; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[containIndex].Cells[3].Value = goodsDiscount2 + totalDiscount / goodsNum * splitOrderQty; SubtractDiscountToDic(orderDetailsID, totalDiscount / goodsNum * splitOrderQty); } else { gridView2.Rows[containIndex].Cells[0].Value = goodsNum2 + goodsNum; gridView2.Rows[containIndex].Cells[2].Value = goodsPrice2 + goodsPrice; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[containIndex].Cells[3].Value = goodsDiscount2 + totalDiscount; SubtractDiscountToDic(orderDetailsID, totalDiscount); } } else { int rowIndex = gridView2.Rows.Add(new DataGridViewRow()); if (goodsNum > 1) { gridView2.Rows[rowIndex].Cells[0].Value = splitOrderQty; gridView2.Rows[rowIndex].Cells[1].Value = goodsName; gridView2.Rows[rowIndex].Cells[2].Value = goodsPrice / goodsNum * splitOrderQty; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[rowIndex].Cells[3].Value = totalDiscount / goodsNum * splitOrderQty; gridView2.Rows[rowIndex].Cells[4].Value = orderDetailsID; gridView2.Rows[rowIndex].Cells[5].Value = goodsType; SubtractDiscountToDic(orderDetailsID, totalDiscount / goodsNum * splitOrderQty); } else { gridView2.Rows[rowIndex].Cells[0].Value = goodsNum; gridView2.Rows[rowIndex].Cells[1].Value = goodsName; gridView2.Rows[rowIndex].Cells[2].Value = goodsPrice; decimal totalDiscount = GetDiscountFromDic(orderDetailsID); gridView2.Rows[rowIndex].Cells[3].Value = totalDiscount; gridView2.Rows[rowIndex].Cells[4].Value = orderDetailsID; gridView2.Rows[rowIndex].Cells[5].Value = goodsType; SubtractDiscountToDic(orderDetailsID, totalDiscount); } } //同时移动细项 if (goodsNum > 1) { if (goodsNum > splitOrderQty) { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex, splitOrderQty); } else { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex); } } else { RemoveDetailItem(gridView1, gridView2, selectedIndex, containIndex); } //设置最后一行选中 if (gridView1.Rows.Count > 0) { gridView1.Rows[gridView1.Rows.Count - 1].Selected = true; gridView1.CurrentCell = gridView1[0, gridView1.Rows.Count - 1]; } if (gridView2.Rows.Count > 0) { gridView2.Rows[gridView2.Rows.Count - 1].Selected = true; gridView2.CurrentCell = gridView2[0, gridView2.Rows.Count - 1]; } return(true); } else { return(false); } }
private void btnPersonNum_Click(object sender, EventArgs e) { Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _personNum = int.Parse(keyForm.KeypadValue); this.btnPersonNum.Text = "人数:" + _personNum; } }
private void btnManual_Click(object sender, EventArgs e) { if (dgvGoodsOrder.CurrentRow != null) { int selectIndex = dgvGoodsOrder.CurrentRow.Index; if (dgvGoodsOrder.Rows[selectIndex].Cells["OrderDetailsID"].Value == null) { FormNumericKeypad keyForm = new FormNumericKeypad(); keyForm.DisplayText = "请输入品项数量"; keyForm.ShowDialog(); decimal quantity; if (!string.IsNullOrEmpty(keyForm.KeypadValue) && decimal.TryParse(keyForm.KeypadValue, out quantity)) { 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; decimal sellPrice = goods == null ? 0 : goods.SellPrice; decimal originalGoodsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value); decimal originalGoodsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value); dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value = quantity; dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value = sellPrice * quantity; if (Math.Abs(originalGoodsDiscount) > 0 && originalGoodsNum > 0) { dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = originalGoodsDiscount / originalGoodsNum * quantity; } //更新细项 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; } decimal originalDetailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value); decimal originalDetailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value); decimal currentQty = originalDetailsNum / originalGoodsNum * quantity; dgvGoodsOrder.Rows[index].Cells["GoodsNum"].Value = currentQty; if (Math.Abs(originalDetailsDiscount) > 0 && originalDetailsNum > 0) { dgvGoodsOrder.Rows[index].Cells["GoodsDiscount"].Value = originalDetailsDiscount / originalDetailsNum * currentQty; } object item = dgvGoodsOrder.Rows[index].Cells["ItemID"].Tag; if (item is Goods) { Goods subGoods = item as Goods; dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value = subGoods.SellPrice * currentQty; } if (item is Details) { Details details = item as Details; dgvGoodsOrder.Rows[index].Cells["GoodsPrice"].Value = details.SellPrice * currentQty; } } } } if (itemType == (int)OrderItemType.Details) { Details details = dgvGoodsOrder.Rows[selectIndex].Cells["ItemID"].Tag as Details; decimal sellPrice = details == null ? 0 : details.SellPrice; decimal originalDetailsNum = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value); decimal originalDetailsDiscount = Convert.ToDecimal(dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value); dgvGoodsOrder.Rows[selectIndex].Cells["GoodsNum"].Value = quantity; dgvGoodsOrder.Rows[selectIndex].Cells["GoodsPrice"].Value = sellPrice * quantity; if (Math.Abs(originalDetailsDiscount) > 0 && originalDetailsNum > 0) { dgvGoodsOrder.Rows[selectIndex].Cells["GoodsDiscount"].Value = originalDetailsDiscount / originalDetailsNum * quantity; } } //统计 BindOrderInfoSum(); } } } }
private void btnDesk_Click(object sender, EventArgs e) { if (_operateType == ButtonOperateType.NONE) { return; } CrystalButton btnDesk = sender as CrystalButton; if (btnDesk == null) return; BizDesk tempDesk = btnDesk.Tag as BizDesk; if (tempDesk == null) return; _currentFormActivate = false; //重新获取Desk信息 BizDesk desk = DeskService.GetInstance().GetBizDeskByName(tempDesk.DeskName); if (_operateType == ButtonOperateType.ORDER) { if (desk.Status == (int)DeskButtonStatus.IDLE_MODE) { //人数 Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(); keyForm.DisplayText = "请输入就餐人数"; keyForm.ShowDialog(); if (!string.IsNullOrEmpty(keyForm.KeypadValue) && keyForm.KeypadValue != "0" && keyForm.KeypadValue.IndexOf('.') == -1) { _formOrder.PersonNum = int.Parse(keyForm.KeypadValue); } else { return; } //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { desk.Status = status; btnDesk.BackColor = GetColorByStatus(status, ConstantValuePool.BizSettingConfig.DeviceNo); _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = null; _formOrder.VisibleShow = true; _formOrder.Show(); } } else if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { if (salesOrder.order.Status == 3) //已预结 { //open check out form FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } else { //open order form _formOrder.CurrentDeskName = desk.DeskName; _formOrder.PlaceSalesOrder = salesOrder; _formOrder.VisibleShow = true; _formOrder.Show(); } } } } } } } else if (_operateType == ButtonOperateType.CLEAR) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED && !string.IsNullOrEmpty(desk.DeviceNo)) { //更新桌况为非占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, string.Empty, status)) { btnDesk.BackColor = GetColorByStatus(status, string.Empty); } } } else if (_operateType == ButtonOperateType.CHANGE_DESK) { if (string.IsNullOrEmpty(_deskName1St)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { if (orderList.Count > 1) { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { _deskName1St = desk.DeskName; _orderId1St = form.SelectedOrder.OrderID; _firstDeskSingleOrder = false; } else { _currentFormActivate = true; //使线程重新活跃 return; } } else { _deskName1St = desk.DeskName; _orderId1St = orderList[0].OrderID; _firstDeskSingleOrder = true; } } else { _currentFormActivate = true; //使线程重新活跃 return; //空桌 } } else { if (!string.IsNullOrEmpty(_deskName1St)) { if (desk.DeskName == _deskName1St) { _currentFormActivate = true; //使线程重新活跃 return; //点击相同的第一张桌子 } //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList, deskChange); form.ShowDialog(); if (form.SelectedOrder != null) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } else { _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } else { //直接转台 DeskChange deskChange = new DeskChange(); deskChange.DeskName = desk.DeskName; deskChange.OrderID1st = _orderId1St; deskChange.OrderID2nd = Guid.Empty; if (OrderService.GetInstance().OrderDeskOperate(deskChange)) { int status = 0; if (_firstDeskSingleOrder) { //更新桌况为空闲状态 status = (int)DeskButtonStatus.IDLE_MODE; if (!DeskService.GetInstance().UpdateDeskStatus(_deskName1St, string.Empty, status)) { MessageBox.Show("更新桌况失败!"); } } status = (int)DeskButtonStatus.OCCUPIED; if (!DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { MessageBox.Show("更新桌况失败!"); } _deskName1St = string.Empty; _orderId1St = Guid.Empty; _firstDeskSingleOrder = false; } } } } } else if (_operateType == ButtonOperateType.CHECKOUT) { if (desk.Status == (int)DeskButtonStatus.OCCUPIED) { if (string.IsNullOrEmpty(desk.DeviceNo) || desk.DeviceNo == ConstantValuePool.BizSettingConfig.DeviceNo) { //更新桌况为占用状态 const int status = (int)DeskButtonStatus.OCCUPIED; if (DeskService.GetInstance().UpdateDeskStatus(desk.DeskName, ConstantValuePool.BizSettingConfig.DeviceNo, status)) { //获取桌子的订单列表 IList<Order> orderList = OrderService.GetInstance().GetOrderList(desk.DeskName); if (orderList != null && orderList.Count > 0) { Guid orderId = Guid.Empty; if (orderList.Count == 1) { orderId = orderList[0].OrderID; } else { Feature.FormChoseMultiOrder form = new Feature.FormChoseMultiOrder(orderList); form.ShowDialog(); if (form.SelectedOrder != null) { orderId = form.SelectedOrder.OrderID; } } SalesOrder salesOrder = SalesOrderService.GetInstance().GetSalesOrder(orderId); if (salesOrder != null) { FormCheckOut checkForm = new FormCheckOut(salesOrder, desk.DeskName); checkForm.ShowDialog(); } } } } } } _currentFormActivate = true; }