图书管理系统登录代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

using System;
using System.Collections.Generic;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 图书信息管理系统1._0
{
public partial class 登录 : Form
{
public 登录()
{
InitializeComponent();
}
public bool fk()
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("用户名密码不能为空!");
if (textBox1.Text == "")
{

textBox1.Focus();
return false;
}
else
{
textBox2.Focus();
return false;
}
} return true;
}

private void button1_Click(object sender, EventArgs e)
{
if (fk())
{
try
{
dbHelper.con.Open();
string sql = string.Format("select * from 员工信息表 where 员工编号='{0}' and 密码='{1}'",textBox1.Text.Trim().ToString(),textBox2.Text.Trim().ToString());
SqlCommand cond = new SqlCommand(sql,dbHelper.con);
SqlDataReader rd = cond.ExecuteReader();
if (rd.HasRows == true)
{
MessageBox.Show("欢迎登录!今天快乐吗?", "登录信息", MessageBoxButtons.OK, rmation);
图书管信息管理 gl = new 图书管信息管理();
gl.Show();
textBox1.Clear();
textBox2.Clear();
dbHelper.id = textBox1.Text.Trim().ToString();
}
else
{
MessageBox.Show("对不起,账户密码错误!");
textBox1.Clear();
textBox2.Clear();
textBox1.Focus();
}

}
catch (Exception es)
{

MessageBox.Show(es.Message);
}
finally
{
if (dbHelper.con.State == ConnectionState.Open)
dbHelper.con.Close();
}
}
}

private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == 8))
{
e.Handled = true;
}
}

private void 登录_Load(object sender, EventArgs e)
{
te

xtBox1.Focus();

}

}
}

相关文档
最新文档