private void btnSave_Click(object sender, EventArgs e) { if (!Regex.IsMatch(this.txtKeyA.Text.Trim(), "[A-Za-z0-9]{6}")) { MessageBox.Show("A密码必须为六位的字母和数字的组合", "天大天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!Regex.IsMatch(this.txtKeyB.Text.Trim(), "[A-Za-z0-9]{6}")) { MessageBox.Show("B密码必须为六位的字母和数字的组合", "天大天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.txtKeyA.Text.Trim() != this.txtKeyAAgain.Text.Trim()) { MessageBox.Show("A密码与确认密码不一致", "天大天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.txtKeyB.Text.Trim() != this.txtKeyBAgain.Text.Trim()) { MessageBox.Show("B密码与确认密码不一致", "天大天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strKeyA = CryptDes.ToHex(this.txtKeyA.Text.Trim(), "gb2312", false);; strKeyA = CryptDes.EncryptDES(strKeyA, "EncryDes"); string strA = CryptDes.DecryptDES(strKeyA, "EncryDes"); ini.IniWriteValue("Key", "KeyA", strKeyA); string strKeyB = CryptDes.ToHex(this.txtKeyB.Text.Trim(), "gb2312", false); strKeyB = CryptDes.EncryptDES(strKeyB, "EncryDes"); ini.IniWriteValue("Key", "KeyB", strKeyB); MessageBox.Show("密码设置成功!", "天大天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnLogin_Click(object sender, EventArgs e) { if (this.txtUserCode.Text.Trim() == "") { MessageBox.Show("请输入用户名", "提示", MessageBoxButtons.OK); return; } RWini ini=new RWini(); ini.IniWriteValue("UserInfo", "UserCode", this.txtUserCode.Text.Trim()); this.DialogResult = DialogResult.OK; }
private void btnLogin_Click(object sender, EventArgs e) { if (this.txtUserCode.Text.Trim() == "") { MessageBox.Show("请输入用户名", "提示", MessageBoxButtons.OK); return; } RWini ini = new RWini(); ini.IniWriteValue("UserInfo", "UserCode", this.txtUserCode.Text.Trim()); this.DialogResult = DialogResult.OK; }
private void btnSave_Click(object sender, EventArgs e) { try { string strMsg = ""; if (this.txtICCardlen.Text.Trim() == "") { strMsg += "请输入IC卡号长度!\r\n"; } if (!DbHelperSQL.bolIsNumber(this.txtICCardlen.Text.Trim(), 2) && !DbHelperSQL.bolIsNumber(this.txtICCardlen.Text.Trim(), 1)) { strMsg += "IC卡长度只能为数字!\r\n"; } else if (Convert.ToInt32(this.txtICCardlen.Text.Trim()) > 20) { strMsg += "IC卡长度不能大于20!\r\n"; } else { strMsg += ""; } if (this.txtRfCardLen.Text.Trim() == "") { strMsg += "请输入电子标签长度!\r\n"; } if (!DbHelperSQL.bolIsNumber(this.txtRfCardLen.Text.Trim(), 2)) { strMsg += "电子标签长度只能为数字!\r\n"; } else if (Convert.ToInt32(this.txtRfCardLen.Text.Trim()) > 20) { strMsg += "电子标签长度不能大于20!"; } if (strMsg != "") { MessageBox.Show(strMsg, "天科初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } string strBps = ""; if (this.rdbtn9600.Checked) { strBps = "9600"; } if (this.rdbtn19200.Checked) { strBps = "19200"; } int iCom = Convert.ToInt32(this.cbxIcCom.Text.Replace("COM", "")) - 1; ini.IniWriteValue("ICCard", "Port", iCom.ToString()); ini.IniWriteValue("ICCard", "Baud", strBps); ini.IniWriteValue("ICCard", "CardNoLen", this.txtICCardlen.Text.Trim()); ini.IniWriteValue("ReMote", "COM", this.cbxRFCom.Text); ini.IniWriteValue("ReMote", "Boud", this.cbxRFBound.Text.Replace("bps", "")); ini.IniWriteValue("ReMote", "CardNoLen", this.txtRfCardLen.Text.Trim()); ini.IniWriteValue("ReMote", "Interval", this.txtReadAndWrite.Text.Trim()); MessageBox.Show("读卡器串口初始化设置成功", "天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show("串口失败初始化:" + ex.Message, "天科IC卡初始化系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } }