using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; using CCWin; using Leadshine.SMC.IDE.Motion; using System.Threading; using System.Drawing.Drawing2D; using MathNet.Numerics.LinearAlgebra; using System.IO; using System.Runtime.InteropServices;
private void button3_Click_1(object sender, EventArgs e) { 注册界面 mylogin = new 注册界面(); mylogin.Show(); }
private void skinButton1_Click_3(object sender, EventArgs e) { System.Diagnostics.Process.Start("osk.exe"); }
bool random0 =true;//验证码判断标志 //更换验证码
private void txtpwd_TextChanged(object sender, EventArgs e) { if (random0) { Random random = new Random(); int minV = 1234, maxV = 9876; checkcode.Text = random.Next(minV, maxV).ToString(); random0 = !random0; } }
//验证码更换验证值
private void checkcode_Click(object sender, EventArgs e) { Random random = new Random(); int minV = 1234, maxV = 9876; checkcode.Text = random.Next(minV, maxV).ToString();
}
//登陆系统,连接SQL数据库中存储的账号和密码进行确认
private void skinButton1_Click_1(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtname.Text) && !String.IsNullOrEmpty(txtpwd.Text)) //判断账号和密码是否为空 { errorTime = errorTime - 1; string username = txtname.Text.Trim(); //取出账号
string pwd = txtpwd.Text.Trim(); //取出密码
string constr = @"Data Source=LENOVO-PC\SQLEXPRESS02;Initial Catalog=CCClink;Integrated Security=True"; //连接数据库字符串
SqlConnection mysqlcon = new SqlConnection(constr); mysqlcon.Open(); SqlCommand mycom = new SqlCommand(constr, mysqlcon); string sql = "select * from 用户 where 账号='" + username + "'and 密码='" + pwd + "'";//编写SQL命令
mycom.CommandText = sql; //执行SQL命令
if (null != mycom.ExecuteScalar()) { if (checkcode.Text == txtvalid.Text) { this.Hide(); 系统界面 myform = new 系统界面(); myform.Show(); } else { MessageBox.Show("验证码填写错误"); txtvalid.Text = ""; } } else { if (errorTime < 100) { MessageBox.Show("用户名或密码有错。请重新输入!还有" + errorTime.ToString() + "次机会"); txtname.Text = ""; //清空账号
txtpwd.Text = ""; //清空密码?
txtvalid.Text = ""; //清空验证码
txtname.Focus(); //光标设置在账号上
} else { MessageBox.Show("你输入的用户名或密码已达十次? 将退出程序"); this.Close(); } } } }
private void skinButton1_Click(object sender, EventArgs e) { string userID = userId.Text.Trim(); //取出账号 //连接数据库
string constr = @"Data Source=LENOVO-PC\SQLEXPRESS02;Initial Catalog=CCClink;Integrated Security=True"; //连接数据库字符串
SqlConnection mysqlcon = new SqlConnection(constr); mysqlcon.Open(); string s1 = "select * from 用户 where 账号='" + userID + "'";//编写SQL命令
SqlCommand mycom = new SqlCommand(s1, mysqlcon); mycom.CommandText = s1; if (null != mycom.ExecuteScalar()) { MessageBox.Show("用户名存在"); userId.Text = ""; userPw.Text = ""; //确认密码
if (ensurePw.Text != userPw.Text) { ensurePw.Text = ""; } //验证码
if (textCheck.Text != checkcode.Text) { textCheck.Text = ""; } } //插入数据SQL
string s = "insert into 用户(账号,密码) values ('" + userId.Text + "','" + userPw.Text + "')"; SqlCommand cmd = new SqlCommand(s, mysqlcon); //创建执行
cmd.ExecuteNonQuery();//执行SQL
if (userId.Text == "" || ensurePw.Text == "" || textCheck.Text == "") { MessageBox.Show("请将信息填完整"); } else { MessageBox.Show("注册成功"); this.Close(); } }
//退出系统
private void skinButton1_Click_2(object sender, EventArgs e) { Application.Exit(); }