?? 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 + -