📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Security.Cryptography;
using System.Data.OleDb;
using System.Web;
namespace 六合彩
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private static string strconnection = "provider=microsoft.jet.oledb.4.0;Data Source="+Application.StartupPath+@"\ld1\ld1.mdb" ;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(144, 40);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 11F);
this.label1.Location = new System.Drawing.Point(80, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 23);
this.label1.TabIndex = 1;
this.label1.Text = "机器码:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(144, 136);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "注册";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(144, 96);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 11F);
this.label2.Location = new System.Drawing.Point(80, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 23);
this.label2.TabIndex = 4;
this.label2.Text = "验证码:";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(408, 266);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "六合彩";
this.Load += new System.EventHandler(this.Form1_Load);
this.Closed += new System.EventHandler(this.Form1_Closed);
this.ResumeLayout(false);
}
#endregion
// /// <summary>
// /// 应用程序的主入口点。
// /// </summary>
// [STAThread]
// static void Main()
// {
// Application.Run(new Form1());
// }
private void tCheck()
{
string sMd5="";
string sHD=textBox2.Text;
try
{
OleDbConnection cusconnection = new OleDbConnection(strconnection);
cusconnection.Open();
string strcmd="select md5 from md5table where id=1 ";
OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection);
OleDbDataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
sMd5=reader["md5"].ToString ();
}
cusconnection.Close();
}
catch(Exception ex)
{
MessageBox.Show (ex.Message );
}
string sHDmd5=GetMd5Str(HardwareInfo.GetCpuID()).ToLower();
if(sMd5.ToLower()==sHDmd5)
{
FrmIN frm1 = new FrmIN();
frm1.ShowDialog(this);
this.Hide();
}
// else if(sMd5==sHD)
// {
// md5Update();
//// MessageBox.Show("验证码正确!");
// FrmIN frm1 = new FrmIN();
// frm1.ShowDialog(this);
// this.Hide();
// }
else
{
MessageBox.Show("验证失败!");
}
}
private void md5Update()
{
string sMd5=textBox2.Text;
try
{
OleDbConnection cusconnection = new OleDbConnection(strconnection);
cusconnection.Open();
string strcmd = "update md5table set md5='"+sMd5+"' where id= 1";
OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection);
cmd.ExecuteNonQuery();
cusconnection.Close();
//以下这段代码和上面实现的功能是一样,只是实现的方式不同。
/*
string SqlCmd = "insert into mshoe(shoe,mm,inserttime) VALUES (@shoe, @mm, @inserttime)";
OleDbCommand cmd = new OleDbCommand(SqlCmd,cusconnection);
cmd.Parameters.Add("@shoe", OleDbType.VarChar,8).Value =sNum;
cmd.Parameters.Add("@mm", OleDbType.Integer).Value =22;
cmd.Parameters.Add("@inserttime",OleDbType.Date).Value = sDateTime;
cmd.ExecuteNonQuery();
*/
}
catch(Exception ex)
{
MessageBox.Show (ex.Message );
}
}
private void HDUpdate()
{
string sHD=HardwareInfo.GetCpuID();
try
{
OleDbConnection cusconnection = new OleDbConnection(strconnection);
cusconnection.Open();
string strcmd = "update md5table set HardDiskID='"+sHD+"' where id= 1";
OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection);
cmd.ExecuteNonQuery();
cusconnection.Close();
//以下这段代码和上面实现的功能是一样,只是实现的方式不同。
/*
string SqlCmd = "insert into mshoe(shoe,mm,inserttime) VALUES (@shoe, @mm, @inserttime)";
OleDbCommand cmd = new OleDbCommand(SqlCmd,cusconnection);
cmd.Parameters.Add("@shoe", OleDbType.VarChar,8).Value =sNum;
cmd.Parameters.Add("@mm", OleDbType.Integer).Value =22;
cmd.Parameters.Add("@inserttime",OleDbType.Date).Value = sDateTime;
cmd.ExecuteNonQuery();
*/
}
catch(Exception ex)
{
MessageBox.Show (ex.Message );
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
textBox1.Text=HardwareInfo.GetCpuID().ToString() ;
HDUpdate();
tCheck();
// textBox3.Text=GetMd5Str(HardwareInfo.GetHardDiskID());
}
private void button1_Click(object sender, System.EventArgs e)
{
md5Update();
tCheck();
// textBox2.Text=GetMd5Str(HardwareInfo.GetHardDiskID());
}
public static string GetMd5Str(string ConvertString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);
t2 = t2.Replace("-", "");
return t2;
}
private void Form1_Closed(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -