using System; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using AIMSModel; using AIMSObjectQuery; using System.Reflection; using System.Text; namespace AIMSDAL { internal partial class DUserPurview { public static void Add(UserPurview UserPurview) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [UserPurview]("); strSql.Append("MenuId,RoleId"); strSql.Append(")"); strSql.Append(" values ("); strSql.Append("" + UserPurview.MenuId + ","); strSql.Append("" + UserPurview.RoleId + ""); strSql.Append(")"); HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString()); } public static void Delete(int RoleId) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete UserPurview "); strSql.Append(" where RoleId=" + RoleId + ""); HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString()); } public static UserPurview GetModel(int Id) { UserPurview UserPurviewObj = new UserPurview(); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append("Id,MenuId,RoleId "); strSql.Append(" from UserPurview "); strSql.Append(" where Id=" + Id + ""); DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { UserPurviewObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["MenuId"].ToString() != "") { UserPurviewObj.MenuId = int.Parse(ds.Tables[0].Rows[0]["MenuId"].ToString()); } if (ds.Tables[0].Rows[0]["RoleId"].ToString() != "") { UserPurviewObj.RoleId = int.Parse(ds.Tables[0].Rows[0]["RoleId"].ToString()); } } return UserPurviewObj; } public static DataTable GetDataTable() { StringBuilder strSql = new StringBuilder(); strSql.Append("select [Id],[MenuId],[RoleId] "); strSql.Append(" FROM UserPurview "); return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString()); } public static List GetPurviewListByRoleId(int RoleId) { List PurviewTemp = new List(); string strSql = "SELECT * FROM UserPurview WHERE roleId='" + RoleId + "'"; DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { PurviewTemp.Add(dt.Rows[i]["MenuId"].ToString()); } } return PurviewTemp; } } }