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); }
public IC_CheckCardNO() { InitializeComponent(); port = Convert.ToInt32(ini.IniReadValue("ICCard", "Port")); baud = Convert.ToInt64(ini.IniReadValue("ICCard", "Baud")); strKeyA = CryptDes.DecryptDES(ini.IniReadValue("Key", "KeyA"), "EncryDes"); strKeyB = CryptDes.DecryptDES(ini.IniReadValue("Key", "KeyB"), "EncryDes"); }
private void Main_Load(object sender, EventArgs e) { //form加载页面时执行 if (AppConfig.ReadValue("Config", "IsConfigruation") == "1" && AppConfig.ReadValue("LED", "ISConfigruation") == "2") { //config配置 txtDBName.Text = AppConfig.ReadValue("Config", "DBName"); txtDBServer.Text = AppConfig.ReadValue("Config", "DBServer"); txtDBUserName.Text = AppConfig.ReadValue("Config", "DBUserName"); txtPassWd.Text = CryptDes.DecryptDES(AppConfig.ReadValue("Config", "DBPassWd"), "EncryDes"); this.Text = this.Text + AppConfig.ReadValue("Config", "Version"); //led配置 ComPort = short.Parse(AppConfig.ReadValue("LED", "ComPort")); //串口通讯: 计算机串口号 comboBox1.Text = ComPort.ToString(); Baudrate = int.Parse(AppConfig.ReadValue("LED", "Baudrate")); //波特率串口通讯: 通讯速率 txt_ComBaudRate.Text = Baudrate.ToString(); LedWidth = short.Parse(AppConfig.ReadValue("LED", "LedWidth")); //区域宽 txt_LedWidth.Text = LedWidth.ToString(); LedHeight = short.Parse(AppConfig.ReadValue("LED", "LedHeight")); //区域高 txt_ledHeght.Text = LedHeight.ToString(); CharColor = short.Parse(AppConfig.ReadValue("LED", "CharColor")); //文字颜色 txt_CharColor.Text = CharColor.ToString(); this.txtTitle.Text = AppConfig.ReadValue("LED", "Title"); //没有报警时显示的标题 this.txtX.Text = AppConfig.ReadValue("LED", "X"); //显示标题的x坐标 this.txtY.Text = AppConfig.ReadValue("LED", "Y"); //显示标题的y坐标 SqlHelp.ConnString = "Data Source=" + txtDBServer.Text + ";Initial Catalog=" + txtDBName.Text + ";User ID=" + txtDBUserName.Text + ";Password="******"数据库配置错误," + exc.Message.ToString(), "循环报警系统", MessageBoxButtons.OK, MessageBoxIcon.Error); Show(); this.Activate(); } //------------------------------------------------------------------------------------------------ } else { MessageBox.Show("请设置报警系统数据库和LED屏设置", "循环报警系统", MessageBoxButtons.OK, MessageBoxIcon.Information); Show(); WindowState = FormWindowState.Normal; txtPassWd.Text = ""; txtPassWd.Text = CryptDes.DecryptDES(AppConfig.ReadValue("Config", "DBPassWd"), "EncryDes"); } }
string strOperateType = ""; //操作方式 人工,升序,降序 public IC_Initial() { InitializeComponent(); try { strKeyA = CryptDes.DecryptDES(ini.IniReadValue("Key", "KeyA"), "EncryDes"); strKeyB = CryptDes.DecryptDES(ini.IniReadValue("Key", "KeyB"), "EncryDes"); DbHelperSQL.ComboxBind(this.cbxCoalKind, "TT_CoalKind", "CoalKindName", "CoalKindCode", "1=1", "CoalKindName"); this.lblBeginCardNO.Visible = false; this.txtBeginCardNO.Visible = false; } catch { MessageBox.Show("请确认App.config文件中数据库设置是否正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Form1_Load(object sender, EventArgs e) { if (AppConfig.ReadValue("Config", "IsConfigruation") == "1") { txtDBName.Text = AppConfig.ReadValue("Config", "DBName"); txtDBServer.Text = AppConfig.ReadValue("Config", "DBServer"); txtDBUserName.Text = AppConfig.ReadValue("Config", "DBUserName"); txtPassWd.Text = CryptDes.DecryptDES(AppConfig.ReadValue("Config", "DBPassWd"), "EncryDes"); this.Text = this.Text + AppConfig.ReadValue("Config", "Version"); CardType = short.Parse(AppConfig.ReadValue("LED", "CardType")); ComPort = short.Parse(AppConfig.ReadValue("LED", "ComPort")); ComBaudRate = int.Parse(AppConfig.ReadValue("LED", "ComBaudRate")); ComDelay = short.Parse(AppConfig.ReadValue("LED", "ComDelay")); LedNum = short.Parse(AppConfig.ReadValue("LED", "LedNum")); LedWidth = short.Parse(AppConfig.ReadValue("LED", "LedWidth")); LedHeight = short.Parse(AppConfig.ReadValue("LED", "LedHeight")); LedColor = short.Parse(AppConfig.ReadValue("LED", "LedColor")); SqlHelp.ConnString = "Data Source=" + txtDBServer.Text + ";Initial Catalog=" + txtDBName.Text + ";User ID=" + txtDBUserName.Text + ";Password="******"Data Source=" + txtDBServer.Text + ";Initial Catalog=" + txtDBName.Text + ";User ID=" + txtDBUserName.Text + ";Password="******"数据库配置错误," + exc.Message.ToString(), "循环报警系统", MessageBoxButtons.OK, MessageBoxIcon.Error); Show(); this.Activate(); } //------------------------------------------------------------------------------------------------ } else { MessageBox.Show("请设置报警系统数据库和LED屏设置", "循环报警系统", MessageBoxButtons.OK, MessageBoxIcon.Information); Show(); WindowState = FormWindowState.Normal; txtPassWd.Text = ""; txtPassWd.Text = CryptDes.DecryptDES(AppConfig.ReadValue("Config", "DBPassWd"), "EncryDes"); } }