private void TxtProductId_GotFocus(object sender, EventArgs e) { SuperText text = sender as SuperText; text.BackColor = Color.Cyan; text.SelectAll(); }
//当获取焦点时 private void TxtVip_GotFocus(object sender, EventArgs e) { SuperText txt = sender as SuperText; txt.BackColor = Color.Cyan; txt.SelectAll();//选中所有文本 }
private void Other_KeyDown(object sender, KeyEventArgs e) { SuperText text = sender as SuperText; if (e.KeyCode == Keys.Enter) { //如果是数量文本框 if (text.Tag.ToString() == "quantity") { if (text.CheckData(@"^[1-9]\d*$", "数量为整数") != 0) { BindProduct(); } else { MessageBox.Show("数量为整数", "提示"); } text.Text = "1"; } //如果是单价文本框 else if (text.Tag.ToString() == "unitPrice") { if (text.CheckData(@"^(([1-9]\d*)|([1-9]\d*.\d{0,2}))$", "价钱输入有误") != 0) { if (text.Text.Contains(".") && text.Text.IndexOf('.') == text.Text.Length - 1) { //输入的是整数 text.Text += "0"; } decimal money = Convert.ToDecimal(text.Text.Trim()); text.Text = money.ToString("F2"); BindProduct(); } else { MessageBox.Show("单价为数字", "提示"); } text.Text = "0.00"; } //如果文本框是折扣 else { if (text.CheckData(@"^((\d)|(\d.\d))$", "折扣输入有误") != 0) { BindProduct(); } else { MessageBox.Show("折扣输入有误", "提示"); } text.Text = "0"; } txtProductId.Focus(); } }
private void TxtVip_LostFocus(object sender, EventArgs e) { SuperText txt = sender as SuperText; txt.BackColor = Color.White; if (txtAmount.Text.Contains(".") && txtAmount.Text.IndexOf(".") == txtAmount.Text.Length) { txtAmount.Text += "00"; } else if (!txtAmount.Text.Contains(".")) { txtAmount.Text += ".00"; } txtAmount.Text = Convert.ToDecimal(txtAmount.Text).ToString("F2"); }
private void TxtProductId_LostFocus(object sender, EventArgs e) { SuperText text = sender as SuperText; text.BackColor = Color.White; }
private void TxtAdmName_GotFocus(object sender, EventArgs e) { SuperText text = sender as SuperText; text.SelectAll(); }
private void TxtProductId_GotFocus(object sender, EventArgs e) { SuperText text = sender as SuperText; text.SelectAll();//选中所有文本 }
private void TxtName_GotFocus(object sender, EventArgs e) { SuperText text = sender as SuperText; }
//键盘事件 private void txtVip_KeyDown(object sender, KeyEventArgs e) { txtAmount.Text = txtAmount.Text.Replace("\r\n", ""); txtVip.Text = txtVip.Text.Replace("\r\n", ""); if (e.KeyCode == Keys.F1) { radMoney.Checked = true;//确定选中 } else if (e.KeyCode == Keys.F2) { radCard.Checked = true; } else if (e.KeyCode == Keys.F3) { radQRCode.Checked = true; } else if (e.KeyCode == Keys.Enter) { if (txtAmount.CheckData(@"^(([1-9]\d*)|(\d*.\d{0,2}))$", "输入金额有误!") != 0) { if (txtAmount.Text.Contains(".") && txtAmount.Text.IndexOf(".") == txtAmount.Text.Length) { txtAmount.Text += "00"; } else if (!txtAmount.Text.Contains(".")) { txtAmount.Text += ".00"; } txtAmount.Text = Convert.ToDecimal(txtAmount.Text).ToString("F2"); if (txtVip.Text.Length == 0)//如果不是会员 { this.Tag = txtAmount.Text.Trim(); } else//有会员 { if (txtVip.CheckData(@"^[1-9]\d*$", "会员卡号有误!或手机号有误!") != 0) { //进一步判断会员卡号是否正常 SMMembers members = memberManager.GetMembersById(txtVip.Text.Trim()); if (members == null) { this.Tag = $"{txtAmount.Text.Trim()}${txtVip.Text.Trim()}"; } else { this.Tag = txtAmount.Text.Trim(); } } //卡号无误则 else { this.Tag = txtAmount.Text.Trim(); } } if (Convert.ToDecimal(txtPay.Text) <= Convert.ToDecimal(txtAmount.Text)) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("客户所付金额不足!", "注意!"); } } } else if (e.KeyCode == Keys.Escape) { this.Tag = "Esc"; this.Close(); } else if (e.KeyCode == Keys.Tab) { SuperText txt = sender as SuperText; if (txt.Tag.ToString() == "Vip") { txtAmount.Focus(); } else if (txt.Tag.ToString() == "pay") { txtVip.Focus(); } } }
private void txtVip_KeyDown(object sender, KeyEventArgs e) { txtAmount.Text = txtAmount.Text.Replace("\r\n", ""); txtVip.Text = txtVip.Text.Replace("\r\n", ""); if (e.KeyCode == Keys.A) { radMoney.Checked = true; } else if (e.KeyCode == Keys.B) { radCard.Checked = true; } else if (e.KeyCode == Keys.C) { radQRCode.Checked = true; } else if (e.KeyCode == Keys.Enter)//回车键:表示正常结算 { if (txtAmount.CheckData(@"^(([1-9]\d*)|(\d*.\d{0,2}))$", "输入金额有误") != 0) { if (txtAmount.Text.Contains(".") && txtAmount.Text.IndexOf(".") == txtAmount.Text.Length) { txtAmount.Text += "00"; } else if (!txtAmount.Text.Contains(".")) { txtAmount.Text += ".00"; } txtAmount.Text = Convert.ToDecimal(txtAmount.Text).ToString("F2"); if (txtVip.Text.Length == 0)//判断不是会员 { this.Tag = txtAmount.Text.Trim(); } else//有会员卡号 { if (txtVip.CheckData(@"^[1-9]\d*$", "会员卡号有误") != 0) { //进一步判断会员是否正常、、自己完成 SMMembers members = memberManager.GetMembersById(int.Parse(txtVip.Text.Trim())); if (members != null) { this.Tag = $"{txtAmount.Text.Trim()}&{txtVip.Text.Trim()}"; } else { this.Tag = txtAmount.Text.Trim(); } } else { this.Tag = txtAmount.Text.Trim(); } } //证明客户付钱够了 if (Convert.ToDecimal(txtPay.Text) <= Convert.ToDecimal(txtAmount.Text)) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("客户实际付款金额不足!", "注意"); } } } else if (e.KeyCode == Keys.Escape) { this.Tag = "Esc"; this.Close(); } else if (e.KeyCode == Keys.Tab) { SuperText txt = sender as SuperText; if (txt.Tag.ToString() == "vip") { txtAmount.Focus(); } else if (txt.Tag.ToString() == "pay") { txtVip.Focus(); } } }