📄 login.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using rsgl.baseClass1;
using System.Data.SqlClient;
namespace rsgl
{
public partial class Login : Form
{
private baseClass1.adoClass adoObject;
private SqlDataReader sqlDR;
private SqlConnection con;
public Login()
{
InitializeComponent();
adoObject = new adoClass("localhost", "rsgl");
con = adoObject.GetConn();
}
private void button2_Click(object sender, EventArgs e)
{
string userName1 = this.userIDText.Text.Trim();
string psw = this.passwordText.Text.Trim();
try
{
if (userName1.IndexOf("'") != -1 || psw.IndexOf("'") != -1)
{
MessageBox.Show("你输入的用户名名或密码错误");
return;
}
con.Open();
sqlDR = new SqlCommand("select * from userTable where userName='" + userName1 + "' and userPassword='" + psw + "'", con).ExecuteReader();
if (sqlDR.Read())
{
new MainForm(this.userTypeComboBox.Text).Show();
this.Hide();
}
else
{
MessageBox.Show("你输入的用户名名或密码错误");
this.userIDText.Focus();
this.userIDText.Text = "";
this.passwordText.Text = "";
}
}
catch (Exception e2)
{
MessageBox.Show(e2.Message);
}
finally
{
con.Close();
}
}
private void button1_Click_1(object sender, EventArgs e)
{
this.userIDText.Focus();
this.userIDText.Text = "";
this.passwordText.Text = "";
new MainForm(this.userTypeComboBox.Text).Show();//调试
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -