//修改支付金额,直接传入 payedCard 实体 public CardBox(PayedCard payedCard, decimal moneyTotal) { InitializeComponent(); panelCardShow(); panelCard.Hide(); Card alterCard = cardList.Where(c => c.id == payedCard.id).FirstOrDefault(); index = cardList.IndexOf(alterCard); lbCard.Text = payedCard.card; MoneyTotal = moneyTotal; txtCardCash.Text = MoneyTotal.ToString(); txtCardCash.SelectionStart = txtCardCash.TextLength; txtCardCash.Focus(); }
/// <summary> /// 支付小窗按键绑定 /// </summary> /// <param></param> private void Keyboard_CardInput() { TextBox focusing = (TextBox)box.Controls.Find("txtCardCash", true).FirstOrDefault(); if (focusing.Text == "0.0" && (!focusing.Focused)) { focusing.Text = ""; } //退格 if (keyInput == miniKeyboard.Backspace) { InputValidate.InputBackspace(focusing); } else if (keyInput == miniKeyboard.KeyEnter) { Panel panelCard = (Panel)box.Controls.Find("panelCard", false).FirstOrDefault(); Panel panelCardCash = (Panel)box.Controls.Find("panelCardCash", false).FirstOrDefault(); if (panelCard.Visible) { MessageBox.Show("请选择支付方式"); return; } else if (focusing.Text == "" && panelCardCash.Visible) { MessageBox.Show("请输入支付金额"); return; } PayedCard payedCard = new PayedCard(box.cardList[box.index]); payedCard.je = Convert.ToDecimal(focusing.Text); //根据标记判断是增加还是修改操作 if (isAddorAlter) { payedCardList.Add(payedCard); } else { payedCardList[cardIndex] = payedCard; } dgvCardPay_DataBind(); box.Hide(); } //按取消,关闭小窗 else if (keyInput == miniKeyboard.Cancel) { Panel panelCard = (Panel)box.Controls.Find("panelCard", false).FirstOrDefault(); Panel panelCardCash = (Panel)box.Controls.Find("panelCardCash", false).FirstOrDefault(); //根据面板判断:如果输入支付金额面板显示,就隐藏并显示选择支付方式面板 //否则说明显示的是选择支付方式面板,取消键直接关闭支付小窗 if (panelCardCash.Visible) { panelCard.Show(); box.MoneyTotal = Convert.ToDecimal(box.txtCardCash.Text == "" ? "0" : box.txtCardCash.Text); panelCardCash.Hide(); } else { dgvCardPay_DataBind(); box.Hide(); } } //其他键直接输入 //不能输入 X else if (keyInput != miniKeyboard.X) { if (focusing.SelectedText != "") { focusing.SelectedText = keyInput; } else { focusing.SelectedText += keyInput; } } //按键完毕,保持焦点 focusing.Focus(); }
/// <summary> /// 会员卡支付小窗按键绑定 /// </summary> /// <param></param> private void Keyboard_mCardPayInput() { TextBox focusing = (TextBox)mCardPay.Controls.Find("txtCardCash", true).FirstOrDefault(); if (focusing.Text == "0.0" && (!focusing.Focused)) { focusing.Text = ""; } //退格 if (keyInput == miniKeyboard.Backspace) { InputValidate.InputBackspace(focusing); } else if (keyInput == miniKeyboard.KeyEnter) { if (focusing.Text == "") { MessageBox.Show("请输入支付金额"); return; } else if (Convert.ToDecimal(focusing.Text) == 0) { MessageBox.Show("支付金额必须大于零"); return; } //增加员工卡模型,员工卡结算方式编号 "5" PayedCard payedCard = new PayedCard("5"); if (payedCardList != null) { payedCard.je = Convert.ToDecimal(focusing.Text); string mdh = ConfigHelper.GetAppConfig("MDH"); string jh = ConfigHelper.GetAppConfig("JH"); string xph = GetXPH(); //会员卡支付接口 string result = CardTran.cardTran(mdh, jh, sell.Membercard, xph, focusing.Text);//提交SVN和生产环境使用(生成Release版本) //string result = "OK";//pos上测试时使用(生成Release版本) //#if DEBUG // result = "OK"; //#endif if (result.Substring(0, 2) == "OK") { //MessageBox.Show("支付成功!"); payedCardList.Add(payedCard); if (mName != mCardPay.mName) { mIniBalance = mCardPay.Balance; } mName = mCardPay.mName; mEndBalance = mCardPay.Balance - payedCard.je; Log.WriteNormalLog(mName + " 卡付 " + payedCard.je + "元", "", ""); btnReturn.Enabled = false; btnReturn.Visible = false; } else { MessageBox.Show(result); return; } } else { return; } ////根据标记判断是增加还是修改操作 //if (isAddorAlter) // payedCardList.Add(payedCard); //else // payedCardList[cardIndex] = payedCard; dgvCardPay_DataBind(); mCardPay.Hide(); } //按取消,关闭小窗 else if (keyInput == miniKeyboard.Cancel) { mCardPay.Hide(); } //其他键直接输入 //不能输入 X else if (keyInput != miniKeyboard.X) { if (focusing.SelectedText != "") { focusing.SelectedText = keyInput; } else { focusing.SelectedText += keyInput; } } //按键完毕,保持焦点 focusing.Focus(); }
/// <summary> /// 出牌后事件 /// </summary> /// <param name="card"></param> void OnPayedCard(Card card) { EjectionTakon(card); PayedCard?.Invoke(this, new EventArgs()); }