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

📄 classs.cs

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

namespace Aptech.Student.DataAccess
{
	using Aptech.Student.Common;

	/// <summary>
	/// Classs 的摘要说明。
	/// </summary>
	public class Classs
	{
		private DataBaseOperate cDbObject = null;
		private bool bConn = false;
	
		
		public Classs()
		{
			cDbObject = new DataBaseOperate();
			bConn = false;
		}
		

		public Classs(DataBaseOperate dbOperate)
		{
			cDbObject = dbOperate;
			bConn = true;
		}

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


		public DataSet SelectClassCourse(
			int iClassId)
		{
			string sSql = 

				"select a.*,"
				+ " (select top 1 courseid from course b where b.subjectid = a.subjectid and b.classId = " + iClassId.ToString() + ") courseid"
				+ " from subject a";

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

		}
		public bool UpdateClass(
			int			iClassId,
			string		sClassName,
			DateTime	dEntranceDate,
			string		sRemark)
		{
			string sSql = 
				"update Class"
				+ " set ClassName = '" + sClassName + "'"
				+ ",EntranceDate = '" + dEntranceDate.ToString() + "'"
				+ ",Remark = '" + sRemark + "'"
				+ " where ClassId = " + iClassId.ToString();

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

		public bool InsertClass(
			string		sClassName,
			DateTime	dEntranceDate,
			string		sRemark)
		{
			string sSql = 
				" insert Class("
				+ " ClassName"
				+ ",EntranceDate"
				+ ",Remark"
				+ ")"
				+ " values("
				+ " '" + sClassName + "'"
				+ ",'" + dEntranceDate.ToString() + "'"
				+ ",'" + sRemark + "'"
				+ ")";
			
			try
			{
				cDbObject.Execute(sSql);
			}
			catch(Exception e)
			{
				throw(e);
			}
			return true;
		}
	
		public DataSet SelectClass(
			int		iClassId,
			string	sClassName)
		{
			string sSql = 
				" select *"
				+ " from Class"
				+ " where 1 = 1";
			if(iClassId != -1)
			{
				sSql += " and ClassId = " + iClassId.ToString();
			}
			if(sClassName != "")
			{
				sSql += " and ClassName like '%" + sClassName + "%'";
			}

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

			return dataSet;
		}

		public bool DeleteClass(
			int		iClassId)
		{
			string sSql = "delete Class where ClassId = " + iClassId.ToString();
			try
			{
				cDbObject.Execute(sSql);
			}
			catch(Exception e)
			{
				throw(e);
			}

			return true;
		}

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

⌨️ 快捷键说明

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