📄 classs.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 + -