/// <summary> /// 更新 /// </summary> public int Update(FoWoSoft.Data.Model.UsersRole model) { int i = dataUsersRole.Update(model); ClearCache(); return(i); }
/// <summary> /// 新增 /// </summary> public int Add(FoWoSoft.Data.Model.UsersRole model) { int i = dataUsersRole.Add(model); // ClearCache(); return(i); }
/// <summary> /// 将DataRedar转换为List /// </summary> private List <FoWoSoft.Data.Model.UsersRole> DataReaderToList(SqlDataReader dataReader) { List <FoWoSoft.Data.Model.UsersRole> List = new List <FoWoSoft.Data.Model.UsersRole>(); FoWoSoft.Data.Model.UsersRole model = null; while (dataReader.Read()) { model = new FoWoSoft.Data.Model.UsersRole(); model.MemberID = dataReader.GetGuid(0); model.RoleID = dataReader.GetGuid(1); model.IsDefault = dataReader.GetBoolean(2); List.Add(model); } return(List); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string name = Request.Form["Name"]; string note = Request.Form["Note"]; string useMember = Request.Form["UseMember"]; FoWoSoft.Data.Model.Role role = new FoWoSoft.Data.Model.Role(); using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope()) { role.ID = Guid.NewGuid(); role.Name = name.Trim(); if (!useMember.IsNullOrEmpty()) { role.UseMember = useMember; FoWoSoft.Platform.UsersRole busersRole = new FoWoSoft.Platform.UsersRole(); var users = new FoWoSoft.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { FoWoSoft.Data.Model.UsersRole ur = new FoWoSoft.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } if (!note.IsNullOrEmpty()) { role.Note = note.Trim(); } new FoWoSoft.Platform.Role().Add(role); //添加一个根应用 FoWoSoft.Data.Model.RoleApp roleApp = new FoWoSoft.Data.Model.RoleApp(); roleApp.ID = Guid.NewGuid(); roleApp.ParentID = Guid.Empty; roleApp.RoleID = role.ID; roleApp.Sort = 1; roleApp.Title = "管理目录"; new FoWoSoft.Platform.RoleApp().Add(roleApp); trans.Complete(); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } } }
/// <summary> /// 更新记录 /// </summary> /// <param name="model">FoWoSoft.Data.Model.UsersRole实体类</param> public int Update(FoWoSoft.Data.Model.UsersRole model) { string sql = @"UPDATE UsersRole SET IsDefault=@IsDefault WHERE MemberID=@MemberID and RoleID=@RoleID" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@IsDefault", SqlDbType.Bit, -1) { Value = model.IsDefault }, new SqlParameter("@MemberID", SqlDbType.UniqueIdentifier, -1) { Value = model.MemberID }, new SqlParameter("@RoleID", SqlDbType.UniqueIdentifier, -1) { Value = model.RoleID } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 添加记录 /// </summary> /// <param name="model">FoWoSoft.Data.Model.UsersRole实体类</param> /// <returns>操作所影响的行数</returns> public int Add(FoWoSoft.Data.Model.UsersRole model) { string sql = @"INSERT INTO UsersRole (MemberID,RoleID,IsDefault) VALUES(@MemberID,@RoleID,@IsDefault)" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@MemberID", SqlDbType.UniqueIdentifier, -1) { Value = model.MemberID }, new SqlParameter("@RoleID", SqlDbType.UniqueIdentifier, -1) { Value = model.RoleID }, new SqlParameter("@IsDefault", SqlDbType.Bit, -1) { Value = model.IsDefault } }; return(dbHelper.Execute(sql, parameters)); }
protected void Page_Load(object sender, EventArgs e) { FoWoSoft.Platform.Role brole = new FoWoSoft.Platform.Role(); FoWoSoft.Data.Model.Role role = null; string roleID = Request.QueryString["roleid"]; Guid roleGID; string name = string.Empty; string useMember = string.Empty; string note = string.Empty; if (roleID.IsGuid(out roleGID)) { role = brole.Get(roleGID); } if (IsPostBack) { if (!Request.Form["Copy"].IsNullOrEmpty()) { string tpl = Request.Form["ToTpl"]; if (tpl.IsGuid()) { new FoWoSoft.Platform.RoleApp().CopyRoleApp(roleGID, tpl.ToGuid()); FoWoSoft.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, FoWoSoft.Platform.Log.Types.角色应用); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('复制成功!');", true); } } if (!Request.Form["Save"].IsNullOrEmpty() && role != null) { FoWoSoft.Platform.UsersRole busersRole = new FoWoSoft.Platform.UsersRole(); using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { name = Request.Form["Name"]; useMember = Request.Form["UseMember"]; note = Request.Form["Note"]; role.Name = name.Trim(); role.Note = note.IsNullOrEmpty() ? null : note.Trim(); role.UseMember = useMember.IsNullOrEmpty() ? null : useMember; brole.Update(role); busersRole.DeleteByRoleID(role.ID); if (!useMember.IsNullOrEmpty()) { busersRole.DeleteByRoleID(role.ID); var users = new FoWoSoft.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { FoWoSoft.Data.Model.UsersRole ur = new FoWoSoft.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } scope.Complete(); } Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } if (!Request.Form["Delete"].IsNullOrEmpty()) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { brole.Delete(roleGID); new FoWoSoft.Platform.RoleApp().DeleteByRoleID(roleGID); new FoWoSoft.Platform.UsersRole().DeleteByRoleID(roleGID); scope.Complete(); } FoWoSoft.Platform.Log.Add("删除的角色其及相关数据", roleID, FoWoSoft.Platform.Log.Types.角色应用); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } } if (role != null) { this.Name.Value = role.Name; this.UseMember.Value = role.UseMember; this.Note.Value = role.Note; } this.RoleOptions.Text = brole.GetRoleOptions("", roleID); }