C#编写简易的学生成绩查询

什么是学生成绩查询系统?

使用C#语言编写的一个可安装的简单CS系统,实现了用户登录,学生信息添加,成绩修改,删除,查询等功能

开发环境

开发环境

visual studio2010(新版本2015,2017也可)

visual studio2010(sql2008数据库)

 

安装步骤

 

 

功能展示

笔者在这里详情下一下制作步骤

 

1. 首先是登录界面及代码

2.

3. 先是创建一个windows窗体应用程序把名称改成学生成绩管理系统

4. 然后添加一个groupBox控件并且把名称改为登陆,然后添加两个lable控件分别为账户密码  两个txtbox控件 一个button控件

5.   using System;

6.   using System.Collections.Generic;

7.   using System.ComponentModel;

8.   using System.Data;

9.   using System.Drawing;

10. using System.Linq;

11. using System.Text;

12. using System.Windows.Forms;

13.

14. namespace 测a试º?

15. {

16.     public partial class login : Form

17.     {

18.         public login()

19.         {

20.             InitializeComponent();

21.         }

22.

23.         private void textBox1_TextChanged(object sender, EventArgs e)

24.         {

25.

26.         }

27.

28.         private void button1_Click(object sender, EventArgs e)

29.         {

30.             if (textBox1.Text == string.Empty)//如果文本为空

31.             {

32.                 MessageBox.Show( "账?户¡ì不?能¨¹为a空?","错䨪误¨®提¬¨¢示º?",MessageBoxButtons.OK,MessageBoxIcon.Error);//弹出消息框

33.             }

34.             if (textBox1.Text == "一°?班㨤三¨y组Á¨¦" && textBox2.Text == "1403")//如果账户密码正确

35.             {

36.          studentmange frm=new studentmange();//实例学生成绩化窗体

37.                 frm.Show();//显示窗体

38.                 this.Visible=false;//隐藏登陆窗体

39.

40.             }

41.

42.         }

43.

44.         private void login_Load(object sender, EventArgs e)

45.         {

46.

47.         }

48.     }

49. }

添加成绩查询窗体

与第一个窗体一样添加控件  多了一个dataGridView控件

代码如下:

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 测a试º?

{

public partial class studentmange : Form

{

public void shuju()//创建方法

{

String strcon = "server=(bds288146407.my3w.com);database=bds288146407_db;uid= bds288146407;pwd=chen419216";//连接数据库

SqlConnection conn = new SqlConnection(strcon);

conn.Open();//打开数据库

String sql = "select * from 成¨¦绩¡§表À¨ª where 学¡ì号?='" + this.textBox3.Text.Trim() + "'and 课?程¨¬名?称?='" + this.textBox4.Text.Trim() + "'";//输入sql查询语句

SqlDataAdapter reae = new SqlDataAdapter(sql, conn);

DataSet ds = new DataSet();//填充数据

reae.Fill(ds);

dataGridView2.DataSource = ds.Tables[0];//显示数据

}

public studentmange()

{

InitializeComponent();

}

private void button2_Click(object sender, EventArgs e)

{

if (textBox1.Text == string.Empty)//如果文本框为空

{

MessageBox.Show("不?能¨¹为a空?", "错䨪误¨®提¬¨¢示º?", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (textBox2.Text == string.Empty)

{

MessageBox.Show("不?能¨¹为a空?", "错䨪误¨®提¬¨¢示º?", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;//结束查询

}

String strcon = "server=(bds288146407.my3w.com);database=bds288146407_db;uid=bds288146407;pwd=chen419216";

SqlConnection conn = new SqlConnection(strcon);

conn.Open();

String sql = "select * from 成¨¦绩¡§表À¨ª where 姓?名?='"+ this.textBox1.Text.Trim()+ "'and 学¡ì号?='"+this.textBox2.Text.Trim()+"'";

SqlCommand cmd = new SqlCommand(sql, conn);

/this.dataGridView1.DataSource = DataBindings;

SqlDataAdapter reae = new SqlDataAdapter(sql, conn);

DataSet ds = new DataSet();

reae.Fill(ds);

dataGridView1.DataSource = ds.Tables[0];

}

private void button1_Click(object sender, EventArgs e)

{

textBox1.Text = "";

textBox2.Text = "";

}

private void Form1_Load(object sender, EventArgs e)

{

}

private void textBox4_TextChanged(object sender, EventArgs e)

{

}

private void button4_Click(object sender, EventArgs e)

{

if (textBox3.Text == string.Empty)

{

MessageBox.Show("不?能¨¹为a空?", "错䨪误¨®提¬¨¢示º?", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (textBox4.Text == string.Empty)

{

MessageBox.Show("不?能¨¹为a空?", "错䨪误¨®提¬¨¢示º?", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (textBox5.Text == string.Empty)

{

MessageBox.Show("不?能¨¹为a空?", "错䨪误¨®提¬¨¢示º?", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

String strcon = "server=(bds288146407.my3w.com);database=bds288146407_db;uid= bds288146407;pwd=chen419216";

SqlConnection conn = new SqlConnection(strcon);

conn.Open();

string sql = "update 成¨¦绩¡§表À¨ª set 课?程¨¬名?称?='"+this.textBox4.Text.Trim()+"',成¨¦绩¡§='"+this.textBox5.Text.Trim()+"'where 学¡ì号?='"+this.textBox3.Text.Trim()+"'";

SqlCommand cmd = new SqlCommand(sql, conn);

cmd.ExecuteNonQuery();

shuju();//方法调用

conn.Close();

}

private void button3_Click(object sender, EventArgs e)

{

String strcon = "server=(bds288146407.my3w.com);database=bds288146407_db;uid= bds288146407;pwd=chen419216";

SqlConnection conn = new SqlConnection(strcon);

conn.Open();

string sql = "delete  成¨¦绩¡§表À¨ª where 学¡ì号?='" + this.textBox3.Text.Trim() + "'";

SqlCommand cmd = new SqlCommand(sql, conn);//数据采集

cmd.ExecuteNonQuery();//执行查询

MessageBox.Show("删¦?除y成¨¦功|");

String sql2 = "select * from 成¨¦绩¡§表À¨ª";

SqlDataAdapter reae = new SqlDataAdapter(sql2, conn);

DataSet ds = new DataSet();

reae.Fill(ds);

dataGridView2.DataSource = ds.Tables[0];

conn.Close();

}

private void button5_Click(object sender, EventArgs e)

{

String strcon = "server=(bds288146407.my3w.com);database=bds288146407_db;uid= bds288146407;pwd=chen419216";

SqlConnection conn = new SqlConnection(strcon);

conn.Open();

string sql = "insert into  成¨¦绩¡§表À¨ª(姓?名?,学¡ì号?,课?程¨¬名?称?,成¨¦绩¡§,年¨º龄¢?) values ('" + this.textBox6.Text.Trim() + "','" + this.textBox7.Text.Trim() + "','" + this.textBox8.Text.Trim() + "','" +Convert.ToInt32( this.textBox9.Text.Trim()) + "','" + this.textBox10.Text.Trim() + "') ";

SqlCommand cmd = new SqlCommand(sql, conn);

cmd.ExecuteNonQuery();

MessageBox.Show("添¬¨ª加¨®成¨¦功|");

String sql2 = "select * from 成¨¦绩¡§表À¨ª";

SqlDataAdapter reae = new SqlDataAdapter(sql2, conn);

DataSet ds = new DataSet();

reae.Fill(ds);

dataGridView3.DataSource = ds.Tables[0];

conn.Close();

}

private void button6_Click(object sender, EventArgs e)

{

Application.Exit();

}

private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)

{

}

private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)

{

}

private void toolStrip1_ItemClicked_1(object sender, ToolStripItemClickedEventArgs e)

{

}

}

}

数据库ER图

转载于:https://www.cnblogs.com/qufeiba/p/7056840.html

C#编写简易的学生成绩查询相关推荐

  1. C++编写高校学生成绩查询系统

    编写一个高校学生成绩查询系统,具备课程.学生信息管理与查询功能,可以修改,增加,删除某一门课程的成绩,或修改,增加,删除某一学生的成绩. 学生类别包括研究生和本科生2类,要求用继承的方法构造两个类,学 ...

  2. python成绩管理系统界面-python实现简易版学生成绩管理系统

    300来行python代码实现简易版学生成绩管理系统,供大家参考,具体内容如下 使用链表来实现 class Node(object): def __init__(self, data, pointer ...

  3. 学生成绩管理系统设计报告python_python实现简易版学生成绩管理系统

    300来行python代码实现简易版学生成绩管理系统,供大家参考,具体内容如下 使用链表来实现 class Node(object): def __init__(self, data, pointer ...

  4. asp毕业设计——基于asp+access的学生成绩查询系统设计与实现(毕业论文+程序源码)——成绩查询系统

    基于asp+access的学生成绩查询系统设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于asp+access的学生成绩查询系统设计与实现,文章末尾附有本毕业设计的论文和源码下载地址哦. ...

  5. 基于PHP学生成绩查询系统设计与实现 开题报告

      本科生毕业论文 基于PHP学生成绩查询系统 开题报告 学    院: 专    业: 计算机科学与技术 年    级: 学生姓名: 指导教师:   XXXX大学本科生毕业论文(设计)开题报告书 姓 ...

  6. Java综合实践——学生成绩查询系统

    数组是最常用的一种数据结构,利用它可以解决很多较复杂的问题.通过一个"学生成绩查询系统"的设计,提高运用数组和编写较大规模代码的综合能力. "学生成绩查询系统" ...

  7. 学生成绩查询系统(Java实现),你第一个Java小项目

    一.学生成绩查询系统(Java实现) 项目要求(我们可以做的更面向对象一点,灵活处理): 具体思路如下: 1.引入程序需要调用的包 2.创建总程序包 "stuScoreInquirySyst ...

  8. 简单的学生成绩查询web系统

    实验内容:基于 JSP+Mysql 做一个简单的学生成绩查询web系统. 文章目录 一.Java Web 1. B/S系统 2.主要框架 3.servlet 4.Web服务器 Tomcat 5.JSP ...

  9. 期末课程设计—学生成绩查询系统

    /* *Copyright(c)2017,烟台大学计算机学院 *All right reserved. *文件名:main.cpp sqqueue.h sqqueue.cpp *作者:黄士胜 *完成日 ...

最新文章

  1. sql必知必会样例表导入失败_记录WordPress搬家遇到的数据库导入错误问题
  2. jsp springmvc 视图解析器_SpringMVC学习笔记
  3. strip 命令的使用方法
  4. 解密SVM系列(二):SVM的理论基础(转载)
  5. macOS 10.11.* 安装scrapy
  6. 不断变化的MONGODB结果集
  7. 技术实践丨手把手教你使用MQTT方式对接华为IoT平台
  8. 艾为数字ic面试题_秋招 应聘FPGA/数字IC笔试面试经验分享(简单列举FPGA/数字IC公司)...
  9. Android 获取地理位置信息 封装好了 直接用
  10. 部署Nginx+Keepalived
  11. Unity移动平台相关(一)
  12. Linux电脑怎么接投影,linux如何连接投影机
  13. python中import 模块的路径问题
  14. mysql删除一行_MySql删除表中一行的实操方法
  15. SHELL的文本处理工具
  16. C++ 程序设计 week5 魔兽世界二: 装备
  17. python中main.py是什么意思_Python的__main__.py用法
  18. 我的北漂在路上--------时不时的停下脚步思考
  19. 专项审计有哪些?专项审计报告包含哪些内容?
  20. JS复制文本到粘贴板,前端H5移动端点击按钮复制文本到粘贴板。

热门文章

  1. elementui设置时间_element-ui 表格数据时间格式化的方法
  2. lssvm回归 matlab,lssvm回归预测的程序运行不了 求高手修改指点
  3. 1909升级卡64_苹果最新系统 macOS Catalina 10.15正式版更新,有哪些升级注意事项
  4. tensorflow中同时两个损失函数_深度度量学习中的损失函数
  5. linux grep命令例子,详解linux grep命令
  6. MySQL从安装改密码到navicate远程连接,以及修改存储路径
  7. mysql硬解析与软解析_SQL 软解析和硬解析详解
  8. pytorch torch.nn.Module
  9. py2neo database
  10. mysql的orm框架_Mysql-Sqlalchemy-ORM框架