⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 成绩查询.txt

📁 我在北大青鸟学习cshop的作业(学生管理系统)!希望大家给以指导。
💻 TXT
字号:
using System;
using System.Data;
using System.Data.SqlClient;

namespace Aptech.Student.DataAccess
{
	using Aptech.Student.Common;
	/// <summary>
	/// Scores 类的摘要说明。
	/// 对成绩表相关的操作
	/// </summary>
	public class Scores
	{
		private DataBaseOperate dbObject = null;
		private bool bConn = false;

		public Scores()
		{
			dbObject = new DataBaseOperate();
			bConn = false;
		}

		public Scores(DataBaseOperate dbOperate)
		{
			dbObject = dbOperate;
			bConn = true;
		}

		/*添加成绩信息*/
		public bool InsertScore(int iCourseId,int iStudentId,float iScore)
		{
			string sqlStr = "insert Score values("+iCourseId+","+iStudentId+","+iScore+")";
			try
			{
				dbObject.Execute(sqlStr);
			}
			catch(Exception e)
			{
				throw e;
			}
			return true;
		}

		/*修改成绩信息*/
		public bool UpdateScore(int uScoreId,int uCourseId,int uStudentId,float uScore)
		{
			string sqlStr = "update Score set CourseId = "
								+uCourseId
								+"StudentId = "
								+uStudentId
								+"Score = "
								+uScore
								+"where ScoreId = "
								+uScoreId;
			try
			{
				dbObject.Execute(sqlStr);
			}
			catch(Exception e)
			{
				throw e;
			}
			return true;
		}

		/*查询成绩信息:根据学生ID、课程ID、班级ID的任意组合作为查询*/
		public DataSet SelectScore(int sCourseId,int sStudentId,int sClassId)
		{
			string sqlStr = "select Score.ScoreId,Score.StudentId,Score.CourseId,Score.Score,Student.ClassId "
							+" from Score "
							+" inner join Student "
							+" on Score.StudentId = Student.StudentId"
							+" where 1=1";
			if(sCourseId!=-1)
				{
					sqlStr+=" and CourseId = "+sCourseId+")";
				}
			
			if(sStudentId!=-1)
			{
				sqlStr+=" and StudentId = "+sStudentId+")";
			}
			
			if(sClassId!=-1)
			{
				sqlStr+=" and ClassId = "+sClassId+")";
			}
			DataSet ds = new DataSet();
			try
			{
				dbObject.Search(sqlStr,"Score");
			}
			catch(Exception e)
			{
				throw e;
			}
			return;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -