验证中...
Languages: C#
Categories: 数据库相关
Latest update 2019-06-12 21:19
用户登录(更新).txt
Raw Copy
using System;
using System.Data.SqlClient;
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.Windows;
namespace Nurse_Station
{
public partial class 用户登录 : System.Windows.Forms.Form
{
public 用户登录()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
}
private void btn_LogIn_Click(object sender, EventArgs e)
{
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = @"Data Source=22WRRS7FHHMPW08\SQLEXPRESS;Initial Catalog=nurse;Integrated Security=True";
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText =
"SELECT COUNT(1) FROM tb_User"
+ " WHERE No='" + this.txb_UserNo.Text.Trim() + "'"
+ " AND Password=HASHBYTES('MD5','" + this.txb_Password.Text.Trim() + "');";
sqlConnection.Open();
int rowCount = (int)sqlCommand.ExecuteScalar();
sqlConnection.Close();
if (rowCount == 1)
{
MessageBox.Show("登录成功。");
}
else
{
MessageBox.Show("用户号/密码有误,请重新输入!");
this.txb_Password.Focus();
this.txb_Password.SelectAll();
}
}
private void btn_login_Click_1(object sender, EventArgs e)
{
办公大厅 Form = new 办公大厅();
Form.Show();
this.Hide();
}
private void button1_Click(object sender, EventArgs e)
{
首页 Form = new 首页();
Form.Show();
this.Hide();
}
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_you_jiang_zheng_wen Zheng_wen_close