/// <summary> /// 得到一个对象实体 /// </summary> public DataService.Model.v_UserRole GetModel(int UserID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UserID,RoleID,UserGuid,UserName,Pwd,RealName,Sex,IDCard,Tel,Status,IntoTime,AddTime,RoleName,MenuList,IsAllowCheck,IsAllowDel from v_UserRole "); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4) }; parameters[0].Value = UserID; DataService.Model.v_UserRole model = new DataService.Model.v_UserRole(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DataService.Model.v_UserRole DataRowToModel(DataRow row) { DataService.Model.v_UserRole model = new DataService.Model.v_UserRole(); if (row != null) { if (row["UserID"] != null && row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } if (row["RoleID"] != null && row["RoleID"].ToString() != "") { model.RoleID = int.Parse(row["RoleID"].ToString()); } if (row["UserGuid"] != null) { model.UserGuid = row["UserGuid"].ToString(); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["Pwd"] != null) { model.Pwd = row["Pwd"].ToString(); } if (row["RealName"] != null) { model.RealName = row["RealName"].ToString(); } if (row["Sex"] != null) { model.Sex = row["Sex"].ToString(); } if (row["IDCard"] != null) { model.IDCard = row["IDCard"].ToString(); } if (row["Tel"] != null) { model.Tel = row["Tel"].ToString(); } if (row["Status"] != null) { model.Status = row["Status"].ToString(); } if (row["IntoTime"] != null && row["IntoTime"].ToString() != "") { model.IntoTime = DateTime.Parse(row["IntoTime"].ToString()); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["RoleName"] != null) { model.RoleName = row["RoleName"].ToString(); } if (row["MenuList"] != null) { model.MenuList = row["MenuList"].ToString(); } if (row["IsAllowCheck"] != null && row["IsAllowCheck"].ToString() != "") { if ((row["IsAllowCheck"].ToString() == "1") || (row["IsAllowCheck"].ToString().ToLower() == "true")) { model.IsAllowCheck = true; } else { model.IsAllowCheck = false; } } if (row["IsAllowDel"] != null && row["IsAllowDel"].ToString() != "") { if ((row["IsAllowDel"].ToString() == "1") || (row["IsAllowDel"].ToString().ToLower() == "true")) { model.IsAllowDel = true; } else { model.IsAllowDel = false; } } } return(model); }