C#学生管理系统
C#实现的学生管理系统
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 学生管理系统
{
public partial class 登陆 : Form
{
int MyField;
public 登陆()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//string source = "server= LLTS-20110105UW"+" integrated security=SSPI "+"database=library";
string source = "Data Source=;Initial Catalog=library;Integrated Security=True";
SqlConnection conn = new SqlConnection(source);
try
{
conn = new SqlConnection(source);
string selectStr = "select LoginName,Password from denglu where LoginName=" + "'" + textBox1.Text.Trim() + "'" + " and Password=" + "'" + textBox2.Text.Trim() + "'"+"and identity="+"'"+"and identity="+"'";//+ +"'";
SqlCommand Command = new SqlCommand(selectStr, conn);
conn.Open();
SqlDataReader sqlread = Command.ExecuteReader(CommandBehavior.CloseConnection);
sqlread.Read();
if (sqlread.HasRows)
{
if (MyField == 1)
{ //this.Hide();
Form a = new 学生界面();
a.Show();
}
else if (MyField ==2)
{
Form Form = new 教师界面();
Form.Show();
this.Hide();
}
}
else
{
MessageBox.Show("用户名或者密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = "";
textBox2.Text = "";
textBox1.Focus();
}
sqlread.Close();
}
catch (Exception sqlException)
{
MessageBox.Show("连接错误" + sqlException.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
MyField = 2;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
MyField = 1;
}
}
}