📄 punishmenttypemanager.cs
字号:
using System;
using System.Data.OleDb;
using StudentsMIS.DataAccess;
namespace StudentsMIS.Business
{
/// <summary>
/// PunishmentTypeManager实现了对PunishmentTypes表的增、删、改。
/// </summary>
public class PunishmentTypeManager
{
public PunishmentTypeManager()
{
}
public int Insert(string id,string type)
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select * From punishmentTypes Where punishmentType_ID=@PunishmentTypeID");
objCommand.Parameters.Add("@PunishmentTypeID",id);
if(objCommand.ExecuteReader().HasRows)
{
CommandCloser.CloseOleDbCommand(objCommand);
return 0;
}
objCommand = CommandBuilder.BuildOleDbCommand("Select * From punishmentTypes Where punishmentType_name=@PunishmentTypeName");
objCommand.Parameters.Add("@PunishmentTypeName",type);
if(objCommand.ExecuteReader().HasRows)
{
CommandCloser.CloseOleDbCommand(objCommand);
return 1;
}
objCommand = CommandBuilder.BuildOleDbCommand("Insert Into punishmentTypes(punishmentType_ID,punishmentType_name) Values(@PunishmentTypeID,@PunishmentTypeName)");
objCommand.Parameters.Add("@PunishmentTypeID",id);
objCommand.Parameters.Add("@PunishmentTypeName",type);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
return 2;
}
public void Delete(string id)
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Delete From punishmentTypes Where punishmentType_ID=@PunishmentTypeID");
objCommand.Parameters.Add("@PunishmentTypeID",id);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
}
public int Update(string id,string type)
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select * From punishmentTypes Where punishmentType_name=@PunishmentTypeName");
objCommand.Parameters.Add("@PunishmentTypeName",type);
if(objCommand.ExecuteReader().HasRows)
{
CommandCloser.CloseOleDbCommand(objCommand);
return 0;
}
objCommand = CommandBuilder.BuildOleDbCommand("Update punishmentTypes Set punishmentType_name=@PunishmentTypeName Where punishmentType_ID=@PunishmentTypeID");
objCommand.Parameters.Add("@PunishmentTypeName",type);
objCommand.Parameters.Add("@PunishmentTypeID",id);
objCommand.ExecuteNonQuery();
CommandCloser.CloseOleDbCommand(objCommand);
return 1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -