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

📄 score.cs

📁 毕业设计题目,学生成绩查询系统,包括管理员和普通用户两级管理
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;

namespace StudentScroeQuery.DAL
{
	/// <summary>
	/// score 的摘要说明。
	/// </summary>
	public class score:helper
	{
		public score()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public void add_score(int stu_id,int cou_id,int score)
		{
			comm.CommandText="insert into Score(Score_Course,Score_Student,Score_Num) values(@cou_id,@stu_id,@score)";
			comm.Parameters.Add("@cou_id",SqlDbType.Int).Value=cou_id;
			comm.Parameters.Add("@stu_id",SqlDbType.Int).Value=stu_id;
			comm.Parameters.Add("@score",SqlDbType.Int).Value=score;
			this.ExcuteCommandReturnVoid(comm);
		}
		public DataSet get_allcourse()
		{
			return this.ExcuteSqlReturnDataSet("select * from Course order by Course_Id desc");
			
		}
		public bool isExistnum(int num)
		{
			this.comm.CommandText="select count(Student_id) from Student where Student_id=@num";
			comm.Parameters.Add("@num",SqlDbType.Int).Value=num;
			return !(this.ExcuteCommandReturnNumber(comm)==0);
			
		}
		public DataSet get_allscores()
		{
			comm.CommandText="select Score_Student,Course_Name,Score_Num,Course_Id,Score_Id from Score,Course  where Score.Score_Course=Course.Course_Id";
			return this.ExcuteCommandReturnDataSet(comm);
		}
		public void update_score(int stuid,int score)
		{
			comm.CommandText="update Score set Score_Num=@score where Score_Id=@stuid";
			
			comm.Parameters.Add("@score",SqlDbType.Int).Value=score;
			comm.Parameters.Add("@stuid",SqlDbType.Int).Value=stuid;
			this.ExcuteCommandReturnVoid(comm);
		}
		public void del_score(int stuid)
		{
			comm.CommandText="delete from Score where Score_Id=@stuid";
			comm.Parameters.Add("@stuid",SqlDbType.Int).Value=stuid;
			this.ExcuteCommandReturnVoid(comm);
		}
		//
		public bool ExistedCourse(int stuid,int couid)
		{
			comm.CommandText="select count(Score_Num) from Score where Score_Student=@stuid and Score_Course=@couid ";
			comm.Parameters.Add("@stuid",SqlDbType.Int).Value=stuid;
			comm.Parameters.Add("@couid",SqlDbType.Int).Value=couid;
			/////////////////
			/////////////////
			return (this.ExcuteCommandReturnNumber(comm)==0);
		}
		//由scoreid得到该学生的学号
		public int getStuNum(int id)
		{
			comm.CommandText="Select Score_Student from Score where Score_Id=@id";
			comm.Parameters.Add("@id",SqlDbType.Int).Value=id;
			DataSet ds=this.ExcuteCommandReturnDataSet(comm);
			int returnnum=Convert.ToInt32(ds.Tables[0].Rows[0]["Score_Student"].ToString());
			return returnnum;
		}
		//按学号搜索
		public DataSet getscore(int num)
		{
			comm.CommandText=comm.CommandText="select Score_Student,Course_Name,Score_Num,Course_Id,Score_Id from Score,Course  where( Score_Student =@num and Score.Score_Course=Course.Course_Id) order by Score_Student";
			comm.Parameters.Add("@num",SqlDbType.Int).Value=num;
			return this.ExcuteCommandReturnDataSet(comm);
		}
		//按课程名称搜索
		public DataSet getscore(string course)
		{
			comm.CommandText=comm.CommandText="select Score_Student,Course_Name,Score_Num,Course_Id,Score_Id from Score,Course  where( Score.Score_Course=Course.Course_Id and  Course_Name like @course) order by Score_Student";
			comm.Parameters.Add("@course",SqlDbType.VarChar).Value='%'+course+'%';
			return this.ExcuteCommandReturnDataSet(comm);
		}

	}
}

⌨️ 快捷键说明

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