📄 sectioninfo.cs
字号:
using System;
using System.Data ;
using HRAdmin.COMMON ;
using HRAdmin.DAL ;
namespace HRAdmin.BLL
{
/// <summary>
/// SectionInfo 的摘要说明。
/// </summary>
public class SectionInfo
{
public SectionInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region 私有变量
private int _sectionID ;
private string _sectionName ;
private string _sectionDescription ;
private int _governorID ;
private int _personnelNum ;
#endregion
#region 公共属性
/// <summary>
/// 事业部编号
/// </summary>
public int SectionID
{
get { return _sectionID ; }
set { _sectionID = value ; }
}
/// <summary>
/// 事业部名称
/// </summary>
public string SectionName
{
get { return _sectionName ; }
set { _sectionName = value ; }
}
/// <summary>
/// 事业部描述
/// </summary>
public string SectionDescription
{
get { return _sectionDescription ;}
set { _sectionDescription = value ;}
}
/// <summary>
/// 事业部总监
/// </summary>
public int GovernorID
{
get { return _governorID ; }
set { _governorID = value ; }
}
/// <summary>
/// 事业部员工总数
/// </summary>
public int PersonnelNum
{
get { return _personnelNum ; }
set { _personnelNum = value ; }
}
#endregion
#region 公用方法
/// <summary>
/// 查询所有事业部信息
/// </summary>
/// <returns>DataSet所有事业部信息</returns>
public static DataSet GetAllSection()
{
//存储过程名
string spName = "HR_Section_GetAll" ;
//执行存储过程,并返回DataSet
return DataAccess.ExecuteDataset(spName) ;
}
/// <summary>
/// 查询指定ID的事业部信息
/// </summary>
/// <param name="id">ID</param>
/// <returns>DataSet特定事业部信息</returns>
public bool GetSection(string id)
{
bool ret = false ;
//存储过程名
DataSet ds = new DataSet() ;
string spName = "HR_Section_Get" ;
//参数
object[] para = new object[] {id} ;
//执行存储过程,并返回ds
ds = DataAccess.ExecuteDataset(spName,para) ;
if(ds != null)
{
DataTable dt = ds.Tables[0] ;
if(dt != null && dt.Rows.Count > 0 )
{
//查询成功
DataRow dr = dt.Rows[0] ;
//指定属性
AssignAttribute(dr) ;
ret = true ;
}
}
return ret ;
}
/// <summary>
/// 指定事业部属性
/// </summary>
/// <param name="dr">dr</param>
public void AssignAttribute(DataRow dr)
{
this._sectionID = CommHandler.StringToInt(dr["sectionID"].ToString()) ;
this._sectionName = dr["sectionName"].ToString() ;
this._governorID = CommHandler.StringToInt(dr["governorID"].ToString()) ;
this._personnelNum = CommHandler.StringToInt(dr["personnelNum"].ToString()) ;
this._sectionDescription = dr["sectionDescription"].ToString() ;
}
/// <summary>
/// 添加事业部信息
/// </summary>
/// <returns>新产生的事业部ID</returns>
public int AddSection()
{
//存储过程名
string spName = "HR_Section_Add" ;
//存储过程参数
object[] para = new object[] {"",_sectionName,_sectionDescription,_governorID,_personnelNum} ;
//调用数据访问层的方法访问存储过程
_sectionID = DataAccess.ExecuteNonQuery(spName,true,para) ;
//返回新事业部ID
return _sectionID ;
}
/// <summary>
/// 修改事业部信息
/// </summary>
/// <returns>修改的命令所影响的行数</returns>
public int ModifySection()
{
int ret = -1 ;
//存储过程名
string spName = "HR_Section_Modify" ;
//存储过程参数
object[] para = new object[] {"",_sectionID,_sectionName,_sectionDescription,_governorID,_personnelNum} ;
//调用数据访问层的方法执行存储过程,并返回受影响的行数
ret = DataAccess.ExecuteNonQuery(spName,true,para) ;
return ret ;
}
public static int DeleteSection(string id)
{
int ret = -1 ;
//删除事业部信息的存储过程
string spName = "HR_Section_Delete" ;
//存储过程参数
object[] para = new object[] {id} ;
//调用数据访问方法执行存储过程,并返回受影响的行数
ret = DataAccess.ExecuteNonQuery(spName,false,para) ;
return ret ;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -