📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace 学生宿舍管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
skinEngine1.SkinFile = "SteelBlue.ssk";
}
private void btnCancel_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
private void btnLogin_Click(object sender, EventArgs e)
{
FrmMain Fm = new FrmMain();
MyData mydata = new MyData();
string s = "select*from 登录信息表 where 用户名='" + this.txtusername.Text + "' and 密码 ='" + this.txtstuPSW.Text + "'and 身份='" + comboBox1.Text + "'";
OleDbDataReader dr = mydata.getDataReader(s);
if (txtusername.Text == "")
{
MessageBox.Show("请输入您的用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (txtstuPSW.Text == "")
{
MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (comboBox1.Text == "")
{
MessageBox.Show("请选择您的身份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (dr.HasRows)
{
while (dr.Read())
{
string strusername = dr["用户名"].ToString().Trim();
string username = this.txtusername.Text;
string beizhu = dr["身份"].ToString().Trim();
if (username == strusername)
{
string stuPSW = dr["密码"].ToString().Trim();
string psw = this.txtstuPSW.Text;
if (stuPSW == psw)
{
if (beizhu == this.comboBox1.Text)
{
Fm.UserName = strusername;
Fm.PassWord = stuPSW;
Fm.ShengFeng = beizhu;
Fm.Show();
txtusername.Text = "";
txtstuPSW.Text = "";
comboBox1.Text = "";
this.Hide();
}
}
}
}
}
else
{
MessageBox.Show("对不起,你的密码、用户名或身份错误!\n 请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtusername.Text = "";
txtstuPSW.Text = "";
comboBox1.Text = "";
txtusername.Focus();
}
mydata.closeConnection();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -