/// <summary> /// 添加IP地址功能。1、超过限定数量提示,不做任何操作。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SBOK_Click(object sender, System.EventArgs e) { DataTable DtCount = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable("select * from CLIENT_LOG", CommandType.Text); string RegNum = PublicClass.DecryptDES(ConfigurationManager.AppSettings["RegNum"], "hospname"); //超过限定数量提示,不做任何操作 if (int.Parse(RegNum) <= DtCount.Rows.Count) { MessageBox.Show("已经超过注册数量!"); return; } DataTable dt_client_ip = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(string.Format("select * from CLIENT_LOG where ip = '{0}'", this.IPInput.Text.Trim()), CommandType.Text); //该机器已经注册 if (dt_client_ip.Rows.Count > 0) { MessageBox.Show("该机器已经注册,请不要重复注册!"); return; } //没有超过数量,并且没有注册的IP地址,注册 string SqlInsert = @"insert into CLIENT_LOG (IP, IP_CODE) values ('{0}', '{1}')"; SqlInsert = string.Format(SqlInsert, this.IPInput.Text.Trim(), PublicClass.EncryptDES(this.IPInput.Text.Trim(), "ip__code")); int result = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteNonQuery(SqlInsert, CommandType.Text); this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 检查注册信息 包括医院名称与注册时间,和注册IP地址 /// </summary> /// <returns></returns> public static bool CkeckRegInfo() { bool rvalue = true; try { string hpname = string.Empty; DateTime datetime = DateTime.Now; string secretkey = string.Empty; string sql = " select * from appcfg where configkey = 'CheckVersion' or configkey ='CheckTime' "; DataTable dt = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(sql, CommandType.Text); string sql_hpinfo = "select a.*,sysdate from hospitalinfo a"; DataTable dt_hpinf = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(sql_hpinfo, CommandType.Text); DataTable dt_client_ip = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(string.Format("select * from CLIENT_LOG where ip = '{0}'", PublicClass.GetIPStr()), CommandType.Text); if (dt_hpinf.Rows.Count > 0) { hpname = dt_hpinf.Rows[0]["name"].ToString().Trim(); datetime = DateTime.Parse(dt_hpinf.Rows[0]["sysdate"].ToString().Trim()); secretkey = dt_hpinf.Rows[0]["memo"].ToString().Trim(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["configkey"].ToString().ToLower() == "checkversion") { if (dt.Rows[i]["value"].ToString().Trim() != PublicClass.EncryptDES(hpname.Trim(), secretkey)) { MessageBox.Show("注册版本信息不符合!"); rvalue = false; } } if (dt.Rows[i]["configkey"].ToString().ToLower() == "checktime") { if (datetime > DateTime.Parse(PublicClass.DecryptDES(dt.Rows[i]["value"].ToString().Trim(), secretkey))) { MessageBox.Show("软件已超过使用时间,请重新注册!"); rvalue = false; } } } if (dt_client_ip.Rows.Count <= 0 || dt_client_ip.Rows[0]["ip_code"].ToString().Trim() != PublicClass.EncryptDES(PublicClass.GetIPStr().Trim(), "ip__code")) { DataTable DtCount = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable("select * from CLIENT_LOG", CommandType.Text); string RegNum = PublicClass.DecryptDES(ConfigurationManager.AppSettings["RegNum"], "hospname"); //超过限定数量,弹出清理对话框 if (int.Parse(RegNum) <= DtCount.Rows.Count) { FormReg FormReg = new FormReg(PublicClass.GetIPStr().Trim()); if (DialogResult.OK != FormReg.ShowDialog()) { rvalue = false; } } else { //没有超过数量,并且没有注册的IP地址,注册 string SqlInsert = @"insert into CLIENT_LOG (IP, IP_CODE) values ('{0}', '{1}')"; SqlInsert = string.Format(SqlInsert, PublicClass.GetIPStr().Trim(), PublicClass.EncryptDES(PublicClass.GetIPStr().Trim(), "ip__code")); int result = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteNonQuery(SqlInsert, CommandType.Text); } } } else { rvalue = false; } } else { rvalue = false; } return(rvalue); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false);; } }