📄 log.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 CMS
{
public partial class log : Form
{
public log()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (this.ValidataInput() && ValidataUser())
{
UserHelper.user = this.txtUser.Text;
teacher fm = new teacher();
fm.str = this.txtUser.Text;
fm.Show();
this.Hide();
}
}
private bool ValidataUser()
{
try
{
DBHelper.con.Open();
string sql = string.Format("select count(*)from sky_student where 学号='{0}' and 密码='{1}'", this.txtPwd.Text, this.txtUser.Text);
SqlCommand cmd=new SqlCommand(sql,DBHelper.con );
int result = (int)cmd.ExecuteNonQuery();
if (result<0)
{
MessageBox.Show("用户登陆成功!","提示",MessageBoxButtons.OK ,MessageBoxIcon.Information );
return true ;
}
else
{
MessageBox.Show("没有此用户!");
return false;
}
}
catch (Exception ex)
{
MessageBox.Show (ex.Message);
}
finally
{
DBHelper.con.Close();
}
return false ;
}
private bool ValidataInput()
{
if (this.txtUser.Text == "")
{
MessageBox.Show("用户名不允许为空!");
this.txtUser.Focus();
return false;
}
else if (txtPwd.Text == "")
{
MessageBox.Show("密码不允许为空");
this.txtPwd.Focus();
return false;
}
return true;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -