using DevComponents.DotNetBar.Controls; using DevComponents.DotNetBar.SuperGrid; using POS.Language.Language; using POSV.Bean; using POSV.Card; using POSV.Component; using POSV.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Windows.Forms; namespace POSV.Member { public partial class CardEditPwdForm : BusinessForm { public string cardNo = null; public CardEditPwdForm() { InitializeComponent(); this.controlBox.Text =LangProxy.ToLang( "修改密码"); this.controlBox.ShowApplicationVersion = false; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) return; DefaultGridStyle.setDefaultGridStyle(this.cardListTable); this.Focus(); this.txtInput.Focus(); this.txtInput.SelectAll(); this.ActiveControl = this.txtInput; } private void OnCloseTouchClick(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } private void OnControlBoxKeyboardClick(object sender, EventArgs e) { try { KeyboardType keyboardType = KeyboardType.英文; Type type = this.ActiveControl.GetType(); PropertyInfo pinfo = type.GetProperty("Keyboard"); if (pinfo != null) { keyboardType = (KeyboardType)pinfo.GetValue(this.ActiveControl, null); } var keyboard = Application.OpenForms["VirtualKeyboard"]; if (keyboard == null) { keyboard = new VirtualKeyboard(keyboardType); } ((VirtualKeyboard)keyboard).ShowVirtualKeyboard(this, keyboardType); } catch (Exception ex) { LOGGER.Error(ex, "打开屏幕键盘异常"); } } private void OnFinishedClick(object sender, EventArgs e) { var isVerify = InputVerify(); if (isVerify) { var voucherNo = this.txtInput.Text; //智能识别刷卡方式 var way = CardUtils.JudgeCardWay(Global.Instance.Worker.TenantId, voucherNo); if (way == MemberCardNoType.未知) { this.ShowMessage(this.lblInfo, LangProxy.ToLang("无法识别的卡号,请确认"), true); return; } switch (way) { case MemberCardNoType.手机号: { CardInfoMessage("mobile"); } break; case MemberCardNoType.电子卡号: { CardInfoMessage("scanCode"); } break; case MemberCardNoType.真实卡号: { CardInfoMessage("cardNo"); } break; case MemberCardNoType.卡面号: { CardInfoMessage("surfaceNo"); } break; } this.numericTextBox1.Focus(); this.numericTextBox1.SelectAll(); } } /// /// 输入是否验证通过 /// private bool InputVerify() { if (string.IsNullOrEmpty(this.txtInput.Text.Trim())) { ShowMessage(this.lblInfo, LangProxy.ToLang("请输入卡号信息"), false); return false; } return true; } /// /// 会员卡信息 /// private bool CardInfoMessage(string property) { bool result = false; try { var request = new MemberInfoQueryRequest(); request.Property = property; request.Keyword = this.txtInput.Text.Trim(); request.ShopNo = Global.Instance.Authc.StoreNo; request.PosNo = Global.Instance.Authc.PosNo; request.WorkerNo = Global.Instance.Worker.No; var response = CardUtils.MemberInfoQuery(request); //成功 if (response.Item1) { result = true; ShowMessage(this.lblInfo, response.Item2, false); MemberInfoQueryResponse memberInfoQueryResponse = response.Item3; List list = memberInfoQueryResponse.CardList; foreach (MemberCard memberCard in list) { switch (memberCard.Status) { case 1: memberCard.CardStatus = LangProxy.ToLang("正常"); break; case 2: memberCard.CardStatus = LangProxy.ToLang("预售"); break; case 3: memberCard.CardStatus = LangProxy.ToLang("挂失"); break; case 4: memberCard.CardStatus = LangProxy.ToLang("冻结"); break; case 5: memberCard.CardStatus = LangProxy.ToLang("销户"); break; default: memberCard.CardStatus = LangProxy.ToLang("未知"); break; } } cardListTable.PrimaryGrid.DataSource = list; } else { result = false; List list = new List(); cardListTable.PrimaryGrid.DataSource = list; ShowMessage(this.lblInfo, response.Item2, true); } } catch (Exception ex) { result = false; ShowMessage(this.lblInfo, LangProxy.ToLang("会员卡信息查询异常"), true); LOGGER.Error(ex, "会员卡信息查询异常"); } return result; } private void btn_exit_Click(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } private void btn_ok_Click(object sender, EventArgs e) { CardPwdEdit(); } /// /// 输入是否验证通过 /// private bool InputOkVerify() { if (cardNo == null || "".Equals(cardNo)) { ShowMessage(this.lblInfo, LangProxy.ToLang("请选择要修改密码的卡"), true); return false; } if (this.numericTextBox2.Text == null || "".Equals(this.numericTextBox2.Text)) { ShowMessage(this.lblInfo, LangProxy.ToLang("请输入新密码"), true); return false; } if (this.numericTextBox3.Text == null || "".Equals(this.numericTextBox3.Text)) { ShowMessage(this.lblInfo, LangProxy.ToLang("请再次输入新密码"), true); return false; } if (!this.numericTextBox3.Text.Equals(this.numericTextBox2.Text)) { ShowMessage(this.lblInfo, LangProxy.ToLang("两次输入的密码不一致"), true); return false; } return true; } private void in_oldPwd_Enter(object sender, Component.EnterEventArg e) { this.numericTextBox2.Focus(); this.numericTextBox2.SelectAll(); } private void in_newPwd_Enter(object sender, Component.EnterEventArg e) { this.numericTextBox3.Focus(); this.numericTextBox3.SelectAll(); } private void in_rNewPwd_Enter(object sender, Component.EnterEventArg e) { CardPwdEdit(); } public void CardPwdEdit() { var isVerify = InputOkVerify(); if (isVerify) { try { var request = new CardPwdChangeRequest(); request.CardNo = cardNo; request.Passwd = string.IsNullOrEmpty(this.numericTextBox1.Text) ? "" : DesUtils.Encrypt(this.numericTextBox1.Text); request.NewPasswd = string.IsNullOrEmpty(this.numericTextBox2.Text) ? "" : DesUtils.Encrypt(this.numericTextBox2.Text); request.ShopNo = Global.Instance.Authc.StoreNo; request.PosNo = Global.Instance.Authc.PosNo; request.WorkerNo = Global.Instance.Worker.No; var response = CardUtils.CardPwdChange(request); //成功 if (response.Item1) { this.numericTextBox1.Text = ""; this.numericTextBox2.Text = ""; this.numericTextBox3.Text = ""; this.txtInput.Focus(); this.txtInput.SelectAll(); ShowMessage(this.lblInfo, response.Item2, false); } else { ShowMessage(this.lblInfo, response.Item2, true); } } catch (Exception ex) { ShowMessage(this.lblInfo, LangProxy.ToLang("卡密码修改异常"), true); LOGGER.Error(ex, "卡密码修改异常"); } } } private void OnTicketRowActivated(object sender, DevComponents.DotNetBar.SuperGrid.GridRowActivatedEventArgs e) { GridPanel grid = e.GridPanel; if (e.NewActiveRow != null) { //先清除其他表数据 GridRow row = e.NewActiveRow as GridRow; grid.SetSelected(e.NewActiveRow, false); grid.SetActiveRow(e.NewActiveRow); cardNo = row.Cells["cardNo"].Value.ToString(); } } private void OnReadCardClick(object sender, EventArgs e) { var result = CardOperateUtils.Instance.ReadCardNo(); if (result.Item1) { this.txtInput.Text = result.Item2; //读卡成功,模拟回车事件 InputSimulatorUtils.SendKey(KeyCodes.Map["return"]); } else { result = CardOperateUtilsOther.Instance.ReadCardNo(); if (result.Item1) { this.txtInput.Text = result.Item2; //读卡成功,模拟回车事件 InputSimulatorUtils.SendKey(KeyCodes.Map["return"]); } else { this.ShowMessage(lblInfo, result.Item2); } } } } }