学生成绩管理系统
Posted chenfeifen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学生成绩管理系统相关的知识,希望对你有一定的参考价值。
一、登录界面程序
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Text; 7 using System.Windows.Forms; 8 using System.Data.SqlClient; 9 10 namespace StudentSystem 11 { 12 public partial class Form_denglu : Form 13 { 14 public Form_denglu() 15 { 16 InitializeComponent(); 17 init(); 18 } 19 public void init() 20 { 21 textBox_zhanghao.Text = "请输入邮箱或手机号"; 22 textBox_zhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ; 23 textBox_mima.Text = "请输入密码"; 24 textBox_mima.ForeColor = System.Drawing.SystemColors.WindowFrame; ; 25 } 26 private void button_queding_Click(object sender, EventArgs e) 27 { 28 //创建数据库连接类的对象 29 SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True"); 30 //将连接打开 31 con.Open(); 32 //执行con对象的函数,返回一个SqlCommand类型的对象 33 SqlCommand cmd = con.CreateCommand(); 34 //把输入的数据拼接成sql语句,并交给cmd对象 35 cmd.CommandText = "select *from users where username=‘" + textBox_zhanghao.Text + "‘and password=‘" + textBox_mima.Text + "‘"; 36 37 //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据) 38 SqlDataReader dr = cmd.ExecuteReader(); 39 if (!String.IsNullOrEmpty(textBox_zhanghao.Text) && !String.IsNullOrEmpty(textBox_mima.Text)) 40 { 41 //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合 42 if (dr.Read()) 43 { 44 DialogResult dengluresult = MessageBox.Show("登录成功!!!"); 45 if (dengluresult == DialogResult.OK) 46 { 47 con.Close(); 48 Form_login form_StudentMassage = new Form_login(); 49 this.Visible = false; 50 form_StudentMassage.ShowDialog(); 51 } 52 } 53 else 54 { 55 MessageBox.Show("账号或者密码错误!!!"); 56 textBox_mima.Text = ""; 57 } 58 //用完后关闭连接,以免影响其他程序访问 59 con.Close(); 60 } 61 else 62 { 63 MessageBox.Show("账号或者密码不能为空!!!"); 64 textBox_mima.Text = ""; 65 } 66 } 67 68 private void textBox_zhanghao_MouseClick(object sender, MouseEventArgs e) 69 { 70 if(textBox_zhanghao.Text == "请输入邮箱或手机号") 71 { 72 textBox_zhanghao.Text = ""; 73 textBox_zhanghao.ForeColor = System.Color.Black; 74 } 75 if (textBox_mima.Text=="") 76 { 77 textBox_mima.Text = "请输入密码"; 78 textBox_mima.ForeColor = System.Drawing.SystemColors.WindowFrame; 79 textBox_mima.PasswordChar = ‘