嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Student
{
public partial class land : Form
{
public land()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{ MessageBox.Show("用户名不能为空!", "提示"); textBox1.Focus(); }
else if (textBox2.Text == "")
{ MessageBox.Show("密码不能为空!", "提示"); textBox2.Focus(); }
else
{
try //try...catch...异常处理语句
{
string usr,pwd,pwdm;
bool flag = false;
usr = textBox1.Text.Trim();
pwd = textBox2.Text.Trim();
pwdm =DESEncrypt.Encrypt(pwd); //密码加密
SqlConnection myConn = new SqlConnection(comm.str_sql_sever);//创建数据库连接类的对象
myConn.Open(); //将连接打开
string sqlstring = "select usr,pwd from users where usr='" usr "'and pwd='" pwdm "'";
SqlCommand command = new SqlCommand(sqlstring, myConn);
SqlDataReader thisReader = command.ExecuteReader();
while (thisReader.Read()) //判断用户名及密码是否正确,对flag进行赋值
{
if ((thisReader.GetValue(0).ToString().Trim()) == (usr.ToString().Trim()))
{
if (thisReader.GetValue(1).ToString().Trim() == pwdm.ToString().Trim())
{
flag = true;
}
}
}
myConn.Close(); //关闭连接
if (flag)
{
comm.current_user = usr;
comm.login_time = DateTime.Now.ToString();
Log log = new Log(AppDomain.CurrentDomain.BaseDirectory @"/log/Log.txt");
log.log("用户" comm.current_user "登录系统");
main f = new main();
f.Show();
this.Hide();
}
else
{
MessageBox.Show("请检查你的用户名和密码!", "提示");
textBox2.Text = "";
textBox1.Focus();
}
}
catch (Exception ex2)
{
MessageBox.Show("连接SQL数据库发生错误:" ex2.ToString(), "错误!");
}
}
}
private void land_Load(object sender, EventArgs e)
{
IniFile f = new IniFile();
f.ReadIni();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
frm_sz f= new frm_sz();
f.Show();
}
private void timer1_Tick(object sender, EventArgs e)
{
//使登陆的窗口以0.05秒渐渐的清晰
if (this.Opacity < 1)
{
this.Opacity = 0.1;
}
else
{
timer1.Enabled = false;
}
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
}
}