📄 personneldao.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DLOA.DALFactory;
using System.Text;
using System.Data.SqlClient;
using DLOA.Model;
namespace DLOA.DAO
{
/// <summary>
/// PersonnelDAO 的摘要说明
/// </summary>
public class PersonnelDAO
{
public PersonnelDAO()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DLOA.Model.Personnel GetModel(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select id,name,userName,password,preview,sex,datex,operatingTime,departmentid,titleXId,postId,politics,schoolRecord,graduationSchool,studiesSpecialty,note from Personnel ");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)};
parameters[0].Value = id;
DLOA.Model.Personnel model = new DLOA.Model.Personnel();
DataTable dt = DbHelperSQL.QueryByParameter(strSql.ToString(), parameters);
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["id"].ToString() != "")
{
model.id = int.Parse(dt.Rows[0]["id"].ToString());
}
model.name = dt.Rows[0]["name"].ToString();
model.userName = dt.Rows[0]["userName"].ToString();
model.password = dt.Rows[0]["password"].ToString();
model.preview = dt.Rows[0]["preview"].ToString();
model.sex = dt.Rows[0]["sex"].ToString();
if (dt.Rows[0]["datex"].ToString() != "")
{
model.datex = DateTime.Parse(dt.Rows[0]["datex"].ToString());
}
if (dt.Rows[0]["operatingTime"].ToString() != "")
{
model.operatingTime = DateTime.Parse(dt.Rows[0]["operatingTime"].ToString());
}
if (dt.Rows[0]["departmentid"].ToString() != "")
{
model.departmentid = int.Parse(dt.Rows[0]["departmentid"].ToString());
}
model.titleXId = dt.Rows[0]["titleXId"].ToString();
if (dt.Rows[0]["postId"].ToString() != "")
{
model.postId = int.Parse(dt.Rows[0]["postId"].ToString());
}
model.politics = dt.Rows[0]["politics"].ToString();
model.schoolRecord = dt.Rows[0]["schoolRecord"].ToString();
model.graduationSchool = dt.Rows[0]["graduationSchool"].ToString();
model.studiesSpecialty = dt.Rows[0]["studiesSpecialty"].ToString();
model.note = dt.Rows[0]["note"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得人员名字和编号
/// </summary>
/// <returns>DataTable</returns>
public DataTable GetPersonnel()
{
return DbHelperSQL.QueryBySql("select name,id from Personnel");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -