📄 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.SqlClient;
namespace StudentManage.UILevel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection my = new SqlConnection();
my.ConnectionString = "server=.;uid=sa;pwd=;database=raiks";
my.Open();
string se = "select * from raiks where uid='" + this.textBox1.Text + "'and pwd='" + this.textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(se, my);
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
try
{
if (textBox1.Text.Equals(reader.GetString(0)))
{
MainForm f1 = new MainForm();
this.Hide();
f1.ShowDialog();
this.Close();
}
}
catch
{
if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
{
MessageBox.Show("请输入用户名和密码", "错误提示");
}
else
MessageBox.Show("用户密码有误", "错误提示");//异常提示
}
finally
{
my.Close();
cmd.Dispose();
my.Dispose();
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void 文件ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -