private void sbtnOk_Click(object sender, System.EventArgs e) { switch (label2.Text.Trim()) { case "Again": if (txtCardID.Text.Trim() == "" || txtCardID.Text.Trim().Length != 5) { MessageBox.Show("会员卡号不可为空且为5位,请重新填写会员卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } Exception err = null; CommAccess cs = new CommAccess(SysInitial.ConString); if (!cs.ChkCardIDDup(txtCardID.Text.Trim(), out err)) { SysInitial.strTmp = txtCardID.Text.Trim(); } else { MessageBox.Show("该卡号已经被其他会员使用过,不能再使用,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null) { clog.WriteLine(err); } txtCardID.Focus(); return; } break; default: break; } this.Close(); }
private void txtCardID_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar != 13) { if (e.KeyChar == 8 || e.KeyChar == 42) { return; } if (e.KeyChar < 48 || e.KeyChar > 57) { e.Handled = true; return; } } else { switch (label2.Text.Trim()) { case "Again": if (txtCardID.Text.Trim() == "" || txtCardID.Text.Trim().Length > 10) { MessageBox.Show("会员卡号不可为空且小于10位,请重新填写会员卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } Exception err = null; CommAccess cs = new CommAccess(SysInitial.ConString); if (!cs.ChkCardIDDup(txtCardID.Text.Trim(), out err)) { SysInitial.strTmp = txtCardID.Text.Trim(); } else { MessageBox.Show("该卡已经有其他会员使用,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null) { clog.WriteLine(err); } txtCardID.Focus(); return; } break; default: break; } this.Close(); } }
// private void txtCardID_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) // { // if(e.KeyChar==8) // { // return; // } // if(e.KeyChar<48||e.KeyChar>57) // { // e.Handled=true; // } // } private void sbtnOk_Click(object sender, System.EventArgs e) { Ping ping = new Ping(); PingReply pr = ping.Send("10.10.10.203"); if (pr.Status != IPStatus.Success) { MessageBox.Show("童鞋,发卡失败!vpn掉线了或者网速太慢!,请检查vpn连接!"); return; } CMSMStruct.AssociatorStruct ass1 = new CMSMData.CMSMStruct.AssociatorStruct(); if (txtCardID.Text.Trim() == "" || txtCardID.Text.Trim().Length != int.Parse(SysInitial.Card)) { MessageBox.Show("会员卡号不可为空或者位数不对,请重新填写会员卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } else if (!cs.ChkCardIDDup(txtCardID.Text.Trim(), out err)) { ass1.strCardID = txtCardID.Text.Trim(); } else { MessageBox.Show("该卡已经有其他会员使用,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } if (txtAssName.Text.Trim() == "" || txtAssName.Text.Trim().Length > 30) { MessageBox.Show("会员姓名不可为空且小于15个字,请重新填写会员姓名!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtAssName.Focus(); return; } else { ass1.strAssName = txtAssName.Text.Trim(); } if (txtAssNbr.Text.Trim() != "" && txtAssNbr.Text.Trim().Length != 15 && txtAssNbr.Text.Trim().Length != 18) { MessageBox.Show("身份证号应为15或18位,请重新填写身份证号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtAssNbr.Focus(); return; } else { ass1.strAssNbr = txtAssNbr.Text.Trim(); } if (txtLinkPhone.Text.Trim() == "" || txtLinkPhone.Text.Trim().Length > 25) { MessageBox.Show("联系电话不可为空且小于25位,请重新填写联系电话!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtLinkPhone.Focus(); return; } else { ass1.strLinkPhone = txtLinkPhone.Text.Trim(); } // CardCommon.CardRef.CardM1 cm = new CardCommon.CardRef.CardM1(SysInitial.intCom); // cm.ReadCardSnr(""); ass1.strSpell = txtSpell.Text.Trim().ToLower(); ass1.strLinkAddress = txtLinkAddress.Text.Trim(); ass1.strEmail = txtEmail.Text.Trim(); ass1.strAssState = "0"; ass1.dCharge = 0; ass1.iIgValue = 0; ass1.strCardFlag = "1"; ass1.strComments = txtComments.Text.Trim(); DateTime dtNow = DateTime.Now; ass1.striSerial = dtNow.ToString("yyyyMMddHHmmss"); ass1.strCreateDate = dtNow.ToShortDateString() + " " + dtNow.ToLongTimeString(); //ass1.striSerial = ass1.strCreateDate.Substring(0, 4) + ass1.strCreateDate.Substring(5, 2) + ass1.strCreateDate.Substring(8, 2) + ass1.strCreateDate.Substring(11, 2) + ass1.strCreateDate.Substring(14, 2) + ass1.strCreateDate.Substring(17, 2); ass1.strOperDate = ass1.strCreateDate; ass1.strDeptID = SysInitial.CurOps.strDeptID; string strAssType = cmbAssType.Text.Trim(); ass1.strAssType = GetColEn(strAssType, "AT"); err = null; string strresult = cs.InsertAssociator(ass1, out err); if (err != null || (!strresult.Equals(CardCommon.CardDef.ConstMsg.RFOK))) { if (strresult != "") { strresult = this.GetColCh(strresult, "ERR"); } MessageBox.Show("添加新会员失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null || strresult != null) { clog.WriteLine(err + "\n" + strresult); } } else { MessageBox.Show("添加新会员成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); this.ClearText(); } }
private void sbtnOk_Click(object sender, System.EventArgs e) { CMSMStruct.MemberStruct meb1 = new CMSMStruct.MemberStruct(); if (txtCardID.Text.Trim() == "" || txtCardID.Text.Trim().Length != 5) { MessageBox.Show("会员卡号不可为空且为5位,请重新填写会员卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } else if (!cs.ChkCardIDDup(txtCardID.Text.Trim(), out err)) { meb1.strCardID = txtCardID.Text.Trim(); } else { if (err == null) { MessageBox.Show("该卡已经有其他会员使用,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } else { MessageBox.Show("检查卡号错误,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); clog.WriteLine(err); return; } } if (cmbCompName.Text.Trim() == "") { MessageBox.Show("无单位信息,请先录入单位信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { meb1.strCompanyName = cmbCompName.Text.Trim(); } CMSMStruct.CompDeptStruct compdept = this.GetComDeptByCompName(meb1.strCompanyName); meb1.strCompanyID = compdept.strCompanyID; meb1.strDeptID = compdept.strDeptID; meb1.strDeptName = compdept.strDeptName; if (meb1.strDeptName == "" || meb1.strDeptID == "") { MessageBox.Show("部门参数不正确!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } if (txtLicenseTag.Text.Trim() != "" && txtLicenseTag.Text.Trim().Length > 20) { MessageBox.Show("车牌号不可为空且小于20个字符,请重新填写车牌号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtLicenseTag.Focus(); return; } else { meb1.strLicenseTag = txtLicenseTag.Text.Trim(); } meb1.strGoodsName = cmbGoodsName.Text.Trim(); meb1.strGoodsType = cmbGoodsType.Text.Trim(); meb1.strState = "0"; meb1.strComments = txtComments.Text.Trim(); meb1.strCreateDate = System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToLongTimeString(); meb1.strOperName = SysInitial.CurOps.strOperName; meb1.strOperDate = meb1.strCreateDate; err = null; string strresult = cs.InsertMember(meb1, out err); if (err != null || (!strresult.Equals(CardCommon.CardDef.ConstMsg.RFOK))) { MessageBox.Show("添加新会员失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null && strresult != null) { clog.WriteLine(err.Message + "\n" + strresult); } else if (err != null) { clog.WriteLine(err); } else { clog.WriteLine(strresult); } } else { MessageBox.Show("添加新会员成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); this.txtCardID.Text = ""; this.txtLicenseTag.Text = ""; this.txtComments.Text = ""; } }