




免费预览已结束,剩余13页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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.Text.Trim() + ; SqlCommand comm = new SqlCommand(cstr, conn); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read() sn = txtname.Text.Trim(); sub = dr.GetValue(3).ToString (); fr3.Show(); this.Visible = false; else MessageBox.Show(输入有误,请重新输入!); txtname.Text = ; txtpassword.Text = ; if (rbtnstudent.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();fr2.Show(); this.Visible=false ; else MessageBox.Show(输入有误,请重新输入!); txtname.Text = ; txtpassword.Text = ; conn.Close(); conn.Dispose(); private void button2_Click(object sender, EventArgs e) Application.Exit(); private void timer1_Tick(object sender, EventArgs e) label1.Text = 当前时间为: +DateTime.Now .ToLongDateString() + +DateTime.Now.ToLongTimeString(); 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 Form2 : Form public Form2() InitializeComponent(); private void Form2_Load(object sender, EventArgs e) label1.Text = Login.sn + 同学,欢迎您使用本成绩管理系统!;/用窗体掉用静态变量 timer1.Start(); groupBox1.Visible = false; groupBox2.Visible = false; private void button1_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e) /string str = Password=kzl;Persist Security Info=True;User ID=kzl;Initial Catalog=学生成绩管理系统;Data Source=(local); /SqlConnection conn = new SqlConnection(str); /conn.Open(); /SqlDataAdapter da = new SqlDataAdapter(Select * from 学生成绩表 where 姓名=+textBox1 .Text , conn); /DataSet ds = new DataSet(); /da.Fill(ds, usertable); /dataGridView1.DataSource = ; private void toolStripButton1_Click(object sender, EventArgs e) string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(Select * from 学生成绩表 where 姓名= + Login.sn.Trim ()+,conn);/详细信息 DataSet ds = new DataSet(); da.Fill(ds, usertable); dataGridView1.DataSource = ds.Tablesusertable.DefaultView; conn.Close(); conn.Dispose(); private void toolStripButton2_Click(object sender, EventArgs e) private void toolStripButton4_Click(object sender, EventArgs e) groupBox1.Visible = true; private void button1_Click_1(object sender, EventArgs e) string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); if (txtnpd.Text != txtnpassword.Text) MessageBox.Show(请确认信密码的正确性!); if (txtnpd.Text =& txtnpassword.Text = ) MessageBox.Show(密码不允许为空!); if (txtnpd.Text = txtnpassword.Text & txtnpd.Text!= ) SqlCommand com = new SqlCommand(update 用户登录 set 密码= + txtnpassword.Text.Trim() + where 用户名= + Login.sn.Trim() + , conn); if (com.ExecuteNonQuery() = 1) MessageBox.Show(密码修改成功!); groupBox1.Visible = false; conn.Close(); conn.Dispose(); private void toolStripButton5_Click(object sender, EventArgs e) this.Close(); Login l = new Login(); l.Visible = true;/?、 private void toolStripButton6_Click(object sender, EventArgs e) / string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; / SqlConnection conn = new SqlConnection(str); / conn.Open(); / SqlDataAdapter da = new SqlDataAdapter(Select * from 学生成绩表 where 姓名= + Login.sn.Trim() + , conn); /DataSet ds = new DataSet(); / da.Fill(ds, usertable); / string s; / for (int i = 2; i = 6; i+) / / if (int.Parse(ds.Tablesusertable.Rows0i.ToString() 60) / s=int.Parse(ds.Tablesusertable.Rows0i.ToString(); / private void groupBox2_Enter(object sender, EventArgs e) private void toolStripButton3_Click(object sender, EventArgs e) groupBox2.Visible = true ; string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(Select * from 学生成绩表 where 姓名= + Login.sn.Trim() + , conn); DataSet ds = new DataSet(); da.Fill(ds, usertable); int max=0,min=1001; double ave=0.0; for (int i = 2; i max) max = int.Parse(ds.Tablesusertable.Rows0i.ToString (); if (int.Parse(ds.Tablesusertable.Rows0i.ToString ()min) min =int.Parse(ds.Tablesusertable.Rows0i.ToString(); txthscore.Text = max.ToString (); txtlscore.Text = min.ToString (); txtall.Text =ds.Tablesusertable.Rows0总分.ToString (); ave = int.Parse(ds.Tablesusertable.Rows0总分.ToString()/(double)5; txtave.Text = ave.ToString(); conn.Close(); conn.Dispose(); private void timer1_Tick(object sender, EventArgs e) label6.Text = 当前时间为: + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString(); 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 Form3 : Form public Form3() InitializeComponent(); private void Form3_Load(object sender, EventArgs e) lblshow.Text = Login.sn + 老师,欢迎使用本成绩管理系统!; textBox2.Text = Login.sub; groupBox3.Visible = false;/修改密码的框 timer1.Start(); /string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; /SqlConnection conn = new SqlConnection(str); /conn.Open(); /SqlDataAdapter da = new SqlDataAdapter(Select * from 学生成绩表 , conn); /DataSet ds = new DataSet(); /da.Fill(ds, chaxun); /dataGridView1.DataSource = ds.Tableschaxun.DefaultView; private void button1_Click_1(object sender, EventArgs e)/查找框 string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); if (comboBox1.Text = 学号) SqlCommand cm = new SqlCommand(Select 学号,姓名, + Login.sub + from 学生成绩表 where 学号= + textBox1.Text + , conn); if (cm.ExecuteScalar() = null) MessageBox.Show(查无此人!); else SqlDataAdapter da = new SqlDataAdapter(Select 学号,姓名, + Login.sub + from 学生成绩表 where 学号= + textBox1.Text + , conn); DataSet ds = new DataSet(); da.Fill(ds, chaxun); dataGridView1.DataSource = ds.Tableschaxun.DefaultView; if (comboBox1.Text = 姓名) SqlCommand cm = new SqlCommand(Select 学号,姓名, + Login.sub + from 学生成绩表 where 姓名= + textBox1.Text + , conn); if (cm.ExecuteScalar() = null) MessageBox.Show(查无此人!); else SqlDataAdapter da = new SqlDataAdapter(Select 学号,姓名, + Login.sub + from 学生成绩表 where 姓名= + textBox1.Text + , conn); DataSet ds = new DataSet(); da.Fill(ds, table); dataGridView1.DataSource = ds.Tablestable.DefaultView; conn.Close(); conn.Dispose(); private void textBox1_TextChanged(object sender, EventArgs e) private void 查找_Click(object sender, EventArgs e) groupBox1.Enabled = true;/查找框 private void 所有成绩_Click(object sender, EventArgs e)/菜单栏中的按钮 string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(select 学号,姓名, + Login.sub + from 学生成绩表, conn); DataSet ds = new DataSet(); da.Fill(ds, table); dataGridView1.DataSource = ds.Tablestable.DefaultView; conn.Close(); conn.Dispose(); private void button2_Click(object sender, EventArgs e)/修改 string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlCommand com = new SqlCommand(update 学生成绩表 set + Login.sub + = + textBox3.Text + where 姓名= + textBox4.Text + , conn); if (com.ExecuteNonQuery() = 1) MessageBox.Show(修改成功!); else MessageBox.Show(修改失败,请重新输入!); conn.Close(); conn.Dispose(); private void 修改_Click(object sender, EventArgs e) groupBox2.Enabled = true; private void groupBox2_Enter(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)/修改密码 string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); if (txtnpd.Text != txtnpassword.Text) MessageBox.Show(请确认信密码的正确性!); if (txtnpd.Text = & txtnpassword.Text = ) MessageBox.Show(密码不允许为空!); if (txtnpd.Text = txtnpassword.Text & txtnpd.Text != ) SqlCommand com = new SqlCommand(update 用户登录 set 密码= + txtnpassword.Text.Trim() + where 用户名= + Login.sn.Trim() + , conn); if (com.ExecuteNonQuery() = 1) MessageBox.Show(密码修改成功!); groupBox3.Visible = false; conn.Close(); conn.Dispose(); private void 修改密码_Click(object sender, EventArgs e) groupBox3.Visible = true; private void 成绩统计_Click(object sender, EventArgs e) string str = Data Source=LEE-PC;Initial Catalog=学生成绩管理系统;User ID=sa;Password=sa; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(select 学号,姓名, + Login.sub + from 学生成绩表 order by + Login.sub + desc, conn); DataSet ds = new DataSet(); da.Fill(ds, table); dataGridView1.DataSource = ds.Tablestable.DefaultView; conn.Close(); conn.Dispose(); private void 退出_Click(object sender, EventArgs e) this.Close(); Login l = new Login(); l.Visible = true; private void timer1_Tick(object sender, EventArgs e) label8.Text = 当前时间为:n + DateTime.Now.ToLongDateString() + n + DateTime.Now.ToLongTimeString(); private void lblshow_Click(object sender, EventArgs e) private void ToolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) 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 Form4 : Form public Form4() InitializeComponent(); private void groupBox2_Enter(object sender, EventArgs e) private void Form4_Load(object sender, EventArgs e) timer1.Start(); label1.Text = Login.sn + 管理员,欢迎使用本成绩管理系统!; groupBox2.Enabled = false; private void radioButton1_CheckedChanged(object sender, EventArgs e) if (radioButton1.Checked) groupBox2.Enabled = true; txtkm.Enabled = true ; private void radioButton2_CheckedChanged(object sender, EventArgs e) if (radioButton2.Checked) groupBox2.Enabled = true; txtkm.Enabled = false; private void button2_Click(object sender, EventArgs e) txtkm.Text = txtmm.Text = txtyhm.Text = ; private void button3_Click(object sender, EventArgs e) this.Close(); Login l = new Login(); l.Visible = true; private void label2_Click(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e) label2.Text = 当前时间为: + DateTime.Now.ToLongDateString() + + DateTime.Now.ToLongTimeString(); private vo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025租赁合同格式范本
- 2025动物全面护理服务合同
- 生态移民面试实战模拟题分享
- 技术研发面试题及答案分享
- 舍入精度实时监控-洞察及研究
- 环境教育传播创新-洞察及研究
- 小说的要素英文
- 2025云南辅警笔试题目及答案
- 肱骨近端解剖特点
- 公司环保知识培训简报课件
- 校园智能化工程项目投标文件
- LY/T 1788-2008木材性质术语
- 齿廓啮合基本定律
- GB/T 19722-2005洗净绵羊毛
- GB 27742-2011可免于辐射防护监管的物料中放射性核素活度浓度
- 第三单元名著导读《朝花夕拾-二十四孝图》课件(15张PPT) 部编版语文七年级上册
- 新版《工会基础知识》试题库及答案汇总-上(单选、多选题)
- 2022年液化气站项目可行性研究报告
- 中控室人员进出登记表
- 细胞重组和细胞融合PPT
- STOP安全观察卡
评论
0/150
提交评论