/// <summary> /// 得到一个对象实体 /// </summary> public AndroidMvcServer.Model.Tb_Dept DataRowToModel(DataRow row) { AndroidMvcServer.Model.Tb_Dept model = new AndroidMvcServer.Model.Tb_Dept(); if (row != null) { if (row["DepId"] != null) { model.DepId = row["DepId"].ToString(); } if (row["DepName"] != null) { model.DepName = row["DepName"].ToString(); } if (row["ParDepId"] != null) { model.ParDepId = row["ParDepId"].ToString(); } if (row["DisplayIndex"] != null && row["DisplayIndex"].ToString() != "") { model.DisplayIndex = int.Parse(row["DisplayIndex"].ToString()); } if (row["DirectorId"] != null) { model.DirectorId = row["DirectorId"].ToString(); } if (row["DepEmail"] != null) { model.DepEmail = row["DepEmail"].ToString(); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["IsLeaf"] != null && row["IsLeaf"].ToString() != "") { model.IsLeaf = int.Parse(row["IsLeaf"].ToString()); } if (row["Comment"] != null) { model.Comment = row["Comment"].ToString(); } } return model; }
public Model.Tb_Dept GetModelById(string DepId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select DepId,DepName,ParDepId,DisplayIndex,DirectorId,DepEmail,Status,IsLeaf,Comment from tb_dept "); strSql.Append(" where DepId=@DepId "); MySqlParameter[] parameters = { new MySqlParameter("@DepId", MySqlDbType.VarChar,50) }; parameters[0].Value = DepId; AndroidMvcServer.Model.Tb_Dept model = new AndroidMvcServer.Model.Tb_Dept(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }