/// <summary> /// 更新一条数据 /// </summary> public bool Update(FishEntity.RoleFunEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_rolefun set "); strSql.Append("roleid=@roleid,"); strSql.Append("funid=@funid"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@roleid", MySqlDbType.Int32, 11), new MySqlParameter("@funid", MySqlDbType.Int32, 11), new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.roleid; parameters[1].Value = model.funid; parameters[2].Value = model.id; int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(FishEntity.RoleFunEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_rolefun("); strSql.Append("roleid,funid)"); strSql.Append(" values ("); strSql.Append("@roleid,@funid)"); MySqlParameter[] parameters = { new MySqlParameter("@roleid", MySqlDbType.Int32, 11), new MySqlParameter("@funid", MySqlDbType.Int32, 11) }; parameters[0].Value = model.roleid; parameters[1].Value = model.funid; int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public override void Save() { if (treeViewRoles.SelectedNode == null) { return; } FishEntity.RoleEntity role = treeViewRoles.SelectedNode.Tag as FishEntity.RoleEntity; if (role == null) { return; } List <FishEntity.FunCodeEntity> newfunc = new List <FishEntity.FunCodeEntity>(); GetFuncodes(newfunc); FishBll.Bll.RoleFunBll bll = new FishBll.Bll.RoleFunBll(); List <FishEntity.RoleFunEntity> oldFunc = bll.GetModelList("roleid=" + role.roleid); foreach (FishEntity.RoleFunEntity item in oldFunc) { bool isexist = newfunc.Exists((i) => { return(i.funid == item.funid); }); if (isexist == false) { bll.Delete(item.id); } } foreach (FishEntity.FunCodeEntity item in newfunc) { bool isexist = oldFunc.Exists(i => { return(i.funid == item.funid); }); if (isexist == false) { FishEntity.RoleFunEntity entity = new FishEntity.RoleFunEntity(); entity.funid = item.funid; entity.roleid = role.roleid; bll.Add(entity); } } MessageBox.Show("保存成功"); base.Save(); }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.RoleFunEntity DataRowToModel(DataRow row) { FishEntity.RoleFunEntity model = new FishEntity.RoleFunEntity(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["roleid"] != null && row["roleid"].ToString() != "") { model.roleid = int.Parse(row["roleid"].ToString()); } if (row["funid"] != null && row["funid"].ToString() != "") { model.funid = int.Parse(row["funid"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.RoleFunEntity GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,roleid,funid from t_rolefun "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; FishEntity.RoleFunEntity model = new FishEntity.RoleFunEntity(); DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FishEntity.RoleFunEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(FishEntity.RoleFunEntity model) { return(dal.Add(model)); }