punishmentmanager.cs
来自「c#开发宝典 光盘内容。本光盘主要为书中的源程序」· CS 代码 · 共 56 行
CS
56 行
using System;
using System.Data.OleDb;
using StudentsMIS.DataAccess;
namespace StudentsMIS.Business
{
/// <summary>
/// PunishmentManager实现了对punishments表的选、增、删、改。
/// </summary>
public class PunishmentManager
{
public PunishmentManager()
{
}
public IEntity Select(string id)
{
return new PunishmentEntity();
}
public int Insert(IEntity obj)
{
PunishmentEntity entity = (PunishmentEntity)obj;
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Insert Into punishments(punishment_studentID,punishment_typeID,punishment_reason,punishment_date) Values(@PunishmentStudentID,@PunishmentTypeID,@PunishmentReason,@PunishmentDate)");
objCommand.Parameters.Add("@PunishmentStudentID",entity.PunishmentStudentID);
objCommand.Parameters.Add("@PunishmentTypeID",entity.PunishmentType);
objCommand.Parameters.Add("@PunishmentReason",entity.PunishmentReason);
objCommand.Parameters.Add("@PunishmentDate",entity.PunishmentDate);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
return 0;
}
public void Delete(string id)
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Delete From punishments Where punishment_ID=@PunishmentID");
objCommand.Parameters.Add("@PunishmentID",id);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
}
public int Update(IEntity obj)
{
PunishmentEntity entity = (PunishmentEntity)obj;
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Update punishments Set punishment_typeID=@PunishmentTypeID,punishment_reason=@PunishmentReason Where punishment_ID=@PunishmentID");
objCommand.Parameters.Add("@PunishmentTypeID",entity.PunishmentType);
objCommand.Parameters.Add("@PunishmentReason",entity.PunishmentReason);
objCommand.Parameters.Add("@PunishmentID",entity.PunishmentID);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
return 0;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?