/// <summary> /// 得到一个对象实体 /// </summary> public JSOA.Model.Employee DataRowToModel(DataRow row) { JSOA.Model.Employee model = new JSOA.Model.Employee(); if (row != null) { if (row["No"] != null) { model.No = row["No"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Pass"] != null) { model.Pass = row["Pass"].ToString(); } if (row["FK_Dept"] != null) { model.FK_Dept = row["FK_Dept"].ToString(); } if (row["FK_Unit"] != null) { model.FK_Unit = row["FK_Unit"].ToString(); } if (row["SID"] != null) { model.SID = row["SID"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public JSOA.Model.Employee GetModel(string No) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 No,Name,Pass,FK_Dept,FK_Unit,SID from Employee "); strSql.Append(" where No=@No "); SqlParameter[] parameters = { new SqlParameter("@No", SqlDbType.VarChar,20) }; parameters[0].Value = No; JSOA.Model.Employee model = new JSOA.Model.Employee(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }