/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.tUserPower model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tUserPower set "); strSql.Append("userId=@userId,"); strSql.Append("powerId=@powerId"); strSql.Append(" where upId=@upId"); SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4), new SqlParameter("@powerId", SqlDbType.Int, 4), new SqlParameter("@upId", SqlDbType.Int, 4) }; parameters[0].Value = model.userId; parameters[1].Value = model.powerId; parameters[2].Value = model.upId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.tUserPower model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tUserPower("); strSql.Append("userId,powerId)"); strSql.Append(" values ("); strSql.Append("@userId,@powerId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4), new SqlParameter("@powerId", SqlDbType.Int, 4) }; parameters[0].Value = model.userId; parameters[1].Value = model.powerId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
protected void TreePower_NodeCheck(object sender, TreeCheckEventArgs e) { if (TreeUser.SelectedNode == null) { Alert.ShowInTop("该项操作未执行,因未选择用户!"); return; } Maticsoft.BLL.tUserPower BLLtt = new Maticsoft.BLL.tUserPower(); BLLtt.Delete(int.Parse(TreeUser.SelectedNodeID)); FineUIPro.TreeNode[] nodes = TreePower.GetCheckedNodes(); if (nodes.Length > 0) { Maticsoft.Model.tUserPower m = new Maticsoft.Model.tUserPower(); Maticsoft.BLL.tUserPower BLL = new Maticsoft.BLL.tUserPower(); foreach (FineUIPro.TreeNode node in nodes) { m.userId = int.Parse(TreeUser.SelectedNodeID); m.powerId = int.Parse(node.NodeID); BLL.Add(m); } LoadPowerData(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.tUserPower DataRowToModel(DataRow row) { Maticsoft.Model.tUserPower model = new Maticsoft.Model.tUserPower(); if (row != null) { if (row["upId"] != null && row["upId"].ToString() != "") { model.upId = int.Parse(row["upId"].ToString()); } if (row["userId"] != null && row["userId"].ToString() != "") { model.userId = int.Parse(row["userId"].ToString()); } if (row["powerId"] != null && row["powerId"].ToString() != "") { model.powerId = int.Parse(row["powerId"].ToString()); } } return(model); }
protected bool haveRight(int userId, string powerName) { Maticsoft.BLL.tPower pbll = new Maticsoft.BLL.tPower(); System.Collections.Generic.List <Maticsoft.Model.tPower> list = pbll.GetModelList(" powerName='" + powerName + "'"); Maticsoft.Model.tPower pm = list.Count == 0 ? null : list[0]; if (pm == null) { return(false); } else { Maticsoft.BLL.tUserPower userpw = new Maticsoft.BLL.tUserPower(); System.Collections.Generic.List <Maticsoft.Model.tUserPower> listpw = userpw.GetModelList(" powerId=" + pm.powerId + " and userId=" + userId + " "); Maticsoft.Model.tUserPower model = listpw.Count == 0 ? null : listpw[0]; if (model == null) { return(false); } else { return(true); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.tUserPower GetModel(int upId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 upId,userId,powerId from tUserPower "); strSql.Append(" where upId=@upId"); SqlParameter[] parameters = { new SqlParameter("@upId", SqlDbType.Int, 4) }; parameters[0].Value = upId; Maticsoft.Model.tUserPower model = new Maticsoft.Model.tUserPower(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }