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

📄 courses.cs

📁 三层体系结构的应用-学员管理系统 一个学校需要一个学生管理系统。分以下功能: 管理班档案 管理学生档案 学校开了多门课程
💻 CS
字号:
using System;
using System.Data;

namespace Aptech.Student.DataAccess
{
	using Aptech.Student.Common;
	
	public class Courses
	{
		private DataBaseOperate cDbObject = null;
		private bool bConn = false;
	
		
		public Courses()
		{
			cDbObject = new DataBaseOperate();
			bConn = false;
		}
	
		public Courses(DataBaseOperate dbOperate)
		{
			cDbObject = dbOperate;
			bConn = true;
		}

		public bool UpdateCourse(
			int			iCourseId,
			DateTime	dBeginDate,
			DateTime	dFinishDate,
			string		sRemark)
		{
			string sSql = 
				"update Course set"
				+ " BeginDate = '" + dBeginDate.ToString() + "'"
				+ ",FinishDate = '" + dFinishDate.ToString() + "'"
				+ ",Remark = '" + sRemark + "'"
				+ " where CourseId = " + iCourseId.ToString();

			try
			{
				cDbObject.Execute(sSql);
			}
			catch(Exception e)
			{
				throw(e);
			}
			return true;


		}
		
		public DataSet SelectCourse(
			int		iCourseId,
			int		iClassId,
			int		iSubjectId)
		{
			string sSql = 
				"select a.*"
				+ ",b.ClassName"
				+ ",c.SubjectName"
				+ " from Course a"
				+ ",Class b"
				+ ",Subject c"
				+ " where a.ClassId = b.ClassId"
				+ " and a.SubjectId = c.SubjectId";

			if(iCourseId != -1)
			{
				sSql += " and a.CourseId = " + iCourseId.ToString();
			}
			if(iClassId != -1)
			{
				sSql += " and a.ClassId = " + iClassId.ToString();
			}
			if(iSubjectId != -1)
			{
				sSql += " and a.SubjectId = " + iSubjectId.ToString();
			}

			DataSet dataSet = new DataSet();
			try
			{
				dataSet = cDbObject.Search(sSql, "Course");
			}
			catch(Exception e)
			{
				throw(e);
			}
			return dataSet;
		}		

		/// <summary>
		/// 为一个班级建立一门新的课程
		/// </summary>
		/// <param name="iClassId">班级ID</param>
		/// <param name="iSubjectId">科目ID</param>
		/// <param name="dBeginDate">开课日期</param>
		/// <param name="dFinishDate">结课日期</param>
		/// <param name="sRemark">备注</param>
		/// <returns>成功建立</returns>
		public bool InsertCourse(
			int			iClassId,
			int			iSubjectId,
			DateTime	dBeginDate,
			DateTime	dFinishDate,
			string		sRemark)
		{
			string sSql = 
				"insert Course("
				+ "ClassId"
				+ ",SubjectId"
				+ ",BeginDate"
				+ ",FinishDate"
				+ ",Remark"
				+ ")"
				+ "values("
				+ iClassId.ToString()
				+ ","  + iSubjectId.ToString()
				+ ",'" + dBeginDate.ToString() + "'"
				+ ",'" + dFinishDate.ToString() + "'"
				+ ",'" + sRemark + "'"
				+ ")";

			try
			{
				cDbObject.Execute(sSql);
			}
			catch(Exception e)
			{
				throw(e);
			}
			return true;
		}

		public bool DeleteCourse(
			int		iCourseId,
			int		iSubjectId,
			int		iClassId)
		{
			string sSql = 
				"delete Course"
				+ " where 1 = 1";
			if(iCourseId != -1)
			{
				sSql += " and CourseId = " + iCourseId.ToString();
			}
			if(iSubjectId != -1)
			{
				sSql += " and SubjectId = " + iSubjectId.ToString();
			}
			if(iClassId != -1)
			{
				sSql += " and ClassId = " + iClassId.ToString();
			}
			try
			{
				cDbObject.Execute(sSql);
			}
			catch(Exception e)
			{
				throw(e);
			}
			return true;
		}

		public void Dispose()
		{
			Dispose(true);
			GC.SuppressFinalize(true); 
		}

		public virtual void Dispose(bool disposing)
		{
			if(!disposing)
			{
				return;
			}
			
			if(!bConn)
			{
				cDbObject.CloseDataBase();
			}
		}
	}
}

⌨️ 快捷键说明

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