/// <summary> /// 加载角色信息 /// </summary> private void LoadRole() { RoleEO roleEO = new RoleEO(); roleEO = roleManage.GetRoleByPK(Request.QueryString["Rlid"]); if (!string.IsNullOrEmpty(roleEO.RlName)) { this.txtRlName.Text = roleEO.RlName; this.hfRoleName.Value = roleEO.RlName; this.ddlPf.SelectedValue = roleEO.PfId; this.rblState.SelectedValue = roleEO.RlState; } }
/// <summary> /// 更新数据 /// </summary> /// <param name = "item">要更新的实体对象</param> /// <param name="tm">事务管理对象</param> /// <return>受影响的行数</return> public virtual int UpdateRole(RoleEO item, TransactionManager tm = null) { const string sql = @"UPDATE role SET Rl_name=@Rl_name, Rl_addUser=@Rl_addUser, Rl_addTime=@Rl_addTime, Rl_state=@Rl_state, Rl_del=@Rl_del, Rl_text1=@Rl_text1, Rl_text2=@Rl_text2,Pf_id=@Pf_id WHERE Rl_id=@Rl_id"; return(Database.CreateSqlDao(sql) .AddInParameter("@Rl_id", item.RlId, DbType.String, 50) .AddInParameter("@Rl_name", item.RlName, DbType.String, 50) .AddInParameter("@Rl_addUser", item.RlAddUser != null ? (object)item.RlAddUser : DBNull.Value, DbType.String, 50) .AddInParameter("@Rl_addTime", item.RlAddTime, DbType.DateTime, 8) .AddInParameter("@Rl_state", item.RlState != null ? (object)item.RlState : DBNull.Value, DbType.AnsiStringFixedLength, 1) .AddInParameter("@Rl_del", item.RlDel != null ? (object)item.RlDel : DBNull.Value, DbType.AnsiStringFixedLength, 1) .AddInParameter("@Rl_text1", item.RlText1 != null ? (object)item.RlText1 : DBNull.Value, DbType.String, 200) .AddInParameter("@Rl_text2", item.RlText2 != null ? (object)item.RlText2 : DBNull.Value, DbType.String, 200).AddInParameter("@Pf_id", item.PfId != null ? (object)item.PfId : DBNull.Value, DbType.String, 50) .ExecNonQuery(tm)); }
/// <summary> /// 修改用户 /// </summary> /// <param name="item"></param> /// <returns></returns> public int EditRole(RoleEO item) { return(roleMO.UpdateRole(item)); }
/// <summary> /// 创建权限 /// </summary> /// <param name="item"></param> /// <returns></returns> public int AddRole(RoleEO item) { return(roleMO.Add(item)); }
/// <summary> /// 添加、修改数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { //验证表单数据:页面中文本框 if (this.CheckForm() == false) { CloseDivImplementation(); return; } RoleEO roleEO = new RoleEO(); if (Request.QueryString["State"] == "U") { roleEO = roleManage.GetRoleByPK(Request.QueryString["Rlid"]); } roleEO.RlName = this.txtRlName.Text.Trim(); roleEO.PfId = this.ddlPf.SelectedValue; roleEO.RlState = this.rblState.SelectedValue; //创建角色信息 if (Request.QueryString["State"] == "A") { //判断角色名称是否存在 if (this.CheckRoleName() == false) { this.divAlert.Visible = true; this.lblAlert.Text = this.ddlPf.SelectedItem.Text + Resources.Resource.Middle_role_name + this.txtRlName.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } string id = GetBigGuid(); roleEO.RlId = id; roleEO.RlDel = "0"; roleEO.RlAddUser = GetUserID(); roleEO.RlAddTime = DateTime.Now; if (roleManage.AddRole(roleEO) > 0) { SetGameChannel(id); //插入操作日志 InsertLog(Resources.Resource.Create_role, string.Format("rolename:{0},id:{1}", roleEO.RlName, roleEO.RlId), 4, GetPlatformIdByValue(1)); CloseDivImplementation(); Jswork.Alert(Resources.Resource.Role_information_creation_success, "RoleList.aspx"); } else { this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.Role_information_creation_failed;//"角色信息创建失败"; } } //修改角色 if (Request.QueryString["State"] == "U") { //修改时判断角色名称是否存在 if (hfRoleName.Value != this.txtRlName.Text.Trim()) { //判断角色名称是否存在 if (this.CheckRoleName() == false) { this.divAlert.Visible = true; this.lblAlert.Text = this.ddlPf.SelectedItem.Text + Resources.Resource.Middle_role_name + this.txtRlName.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } } if (roleManage.EditRole(roleEO) > 0) { SetGameChannel(roleEO.RlId); //插入操作日志 InsertLog(Resources.Resource.Modify_role, string.Format("rolename:{0},id:{1}", roleEO.RlName, roleEO.RlId), 5, GetPlatformIdByValue(1)); CloseDivImplementation(); Jswork.Alert(Resources.Resource.Role_information_change_success, "RoleList.aspx"); } else { this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.Role_information_modification_failed;//"角色信息修改失败"; } } CloseDivImplementation(); }