classs.cs
来自「三层体系结构的应用-学员管理系统 一个学校需要一个学生管理系统。分以下功能: 」· CS 代码 · 共 170 行
CS
170 行
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 + =
减小字号Ctrl + -
显示快捷键?