学生成绩管理系统代码c#+sql.doc
文本预览下载声明
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 学生成绩管理系统
{
public partial class Login : Form
{
static public string sn,sub;
public Login()
{
InitializeComponent();
}
Form2 fr2 = new Form2(); Form3 fr3 = new Form3(); Form4 fr4 = new Form4();//——————————————————————————创建新窗体
private void Login_Load(object sender, EventArgs e)
{
timer1.Start(); // ——————————————————————————Timer控件
}
private void btnlogin_Click(object sender, EventArgs e)
{//Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa
// string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa;
string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa;
SqlConnection conn = new SqlConnection(str);//———————————————————————————————————连接数据库
conn.Open();
if( txtname .Text==||txtpassword .Text==)
MessageBox.Show (请不要遗漏信息!);
if (rbtnmanager.Checked)
{
string cstr=select * from 用户登录 where 类别=管理员and 用户名=+txtname.Text.Trim ()+and 密码=+txtpassword .Text.Trim ()+;
SqlCommand comm=new SqlCommand (cstr,conn );
SqlDataReader dr=comm.ExecuteReader ();
if (dr.Read())
{ sn = txtname.Text.Trim(); fr4.Show(); this.Visible = false; }
else
{
MessageBox.Show(输入有误,请重新输入!);
txtname.Text = ; txtpassword.Text = ;
}
}
if (rbtnteacher.Checked)
{
string cstr = select * from 用户登录 where 类别=教师and 用户名= + txtname.Text.Trim() + and 密码= + txtpassword
显示全部