📄 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 System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class login : Form
{
private info owner;
public login(info owner)
{
InitializeComponent();
this.owner = owner;
}
private void button7_Click(object sender, EventArgs e)
{
try
{
SqlConnection myconnection = new SqlConnection();
myconnection.ConnectionString = "server=hxl;database=studentpoints;integrated security=true ";
myconnection.Open();
SqlCommand mycommand = new SqlCommand();
mycommand.CommandText = "select * from 用户表 where 用户名='" + textBox1.Text.Trim() +
"'and " + "密码='" + textBox2.Text.Trim() + "'";
mycommand.Connection = myconnection;
SqlDataReader dr = mycommand.ExecuteReader();//查找密码跟用户名
while (dr.Read())
{
owner.USERID = dr.GetString(2);
}
if (owner.USERID != null)//表的权限标志1,2,3
{
this.Close();
owner.Opacity = 1;//透明度
}
else
{
MessageBox.Show("密码和用户输入有错误!");
}
}
catch (SqlException se)
{
MessageBox.Show("连接数据库出现错误!" + se.Message);
}
}
private void button6_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -