C#用户登录模块的设计
public partial class Form1 : Form
{ public static string userName;
public static string User_Type;
public static Form10 frmMain;
public Form1()
{ InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{ if (textBox1.Text.Trim() == "")
{ MessageBox.Show("用户名不能为空!");
textBox1.Focus(); }
else
if (textBox2.Text.Trim() == "")
{ MessageBox.Show("请输入密码!");
textBox2.Focus(); }
else
{ SqlConnection Conn = new SqlConnection(@"server=.;integrated security=sspi; database=WMS;");
Conn.Open();
string sql = "select * from Users where UID ='" + textBox1.Text + "' and UPassword='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(sql, Conn);
SqlDataReader ds = cmd.ExecuteReader();
if (ds.Read())
{ userName = textBox1.Text.Trim();
this.Hide();
frmMain = new Form10(); frmMain.Show(); }
else
{ MessageBox.Show("对不起,你的帐号或密码错误!!!"); }
ds.Close();
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载
- 1
- 2
前往页