public override bool IsUserInRole(string username, string roleName) { Server.DbDataSet.平台用户Row 平台用户Row1 = Program.db.平台用户.Get平台用户(username); 角色 角色1 = (角色)平台用户Row1.角色; return(角色1.ToString() == roleName); }
private void comboBox角色_SelectedIndexChanged(object sender, EventArgs e) { 角色 角色1 = (角色)Enum.Parse(typeof(角色), this.comboBox角色.SelectedItem.ToString(), false); this.groupBox1.Enabled = 角色1 == 角色.交易员; this.groupBox2.Enabled = 角色1 == 角色.普通风控员; if (角色1 == 角色.超级管理员) { this.comboBox分组.DataSource = System.Enum.GetNames(typeof(分组)); this.comboBox分组.Text = 分组.ALL.ToString(); this.comboBox分组.Enabled = false; } else if (角色1 == 角色.交易员) { if (this.comboBox分组.Enabled == false) { this.comboBox分组.Enabled = true; } this.comboBox分组.DataSource = System.Enum.GetNames(typeof(分组)).Skip(1).ToList(); } else { if (this.comboBox分组.Enabled == false) { this.comboBox分组.Enabled = true; } this.comboBox分组.DataSource = System.Enum.GetNames(typeof(分组)); } }
public override string[] GetRolesForUser(string username) { Server.DbDataSet.平台用户Row 平台用户Row1 = Program.db.平台用户.Get平台用户(username); 角色 角色1 = (角色)平台用户Row1.角色; return(new string[] { 角色1.ToString() }); }
private void 导入用户ToolStripMenuItem_Click(object sender, EventArgs e) { try { DialogResult DialogResult1 = this.openFileDialog1.ShowDialog(); if (DialogResult1 != System.Windows.Forms.DialogResult.OK) { return; } string[] FileContent = File.ReadAllLines(this.openFileDialog1.FileName, Encoding.Default); for (int i = 1; i < FileContent.Length; i++) { string[] Data = FileContent[i].Split(','); 角色 角色1 = (角色)Enum.Parse(typeof(角色), Data[2], false); 分组 分组1 = (分组)Enum.Parse(typeof(分组), Data[7], false); Program.AASServiceClient.AddUser(Data[0], Data[1], 角色1, decimal.Parse(Data[3]), decimal.Parse(Data[4]), decimal.Parse(Data[5]), Data[6] == "是" ? true : false, 分组1); } } catch (Exception ex) { Exception ex1 = ex.InnerException == null ? ex : ex.InnerException; MessageBox.Show(ex1.Message + ex1.StackTrace); } this.bindingSource用户.DataSource = Program.AASServiceClient.QueryUser(); }
private void dataGridView用户_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if ((sender as DataGridView).Columns[e.ColumnIndex].HeaderText == "角色") { int int1 = (int)e.Value; 角色 角色1 = (角色)Enum.Parse(typeof(角色), int1.ToString(), false); e.Value = 角色1.ToString(); } else if ((sender as DataGridView).Columns[e.ColumnIndex].HeaderText == "分组") { 分组 分组1 = (分组)Enum.Parse(typeof(分组), e.Value.ToString(), false); e.Value = 分组1.ToString(); } }
private void button确定_Click(object sender, EventArgs e) { if (this.textBox密码.Text != this.textBox确认密码.Text) { MessageBox.Show("确认密码与密码不同"); return; } 角色 角色1 = (角色)Enum.Parse(typeof(角色), this.comboBox角色.SelectedItem.ToString(), false); 分组 region = (分组)Enum.Parse(typeof(分组), this.comboBox分组.SelectedItem.ToString(), false); Program.AASServiceClient.AddUser(this.textBox用户名.Text, this.textBox密码.Text, 角色1, this.numericUpDown仓位限制.Value, this.numericUpDown亏损限制.Value, this.numericUpDown手续费率.Value, this.checkBox允许删除碎股订单.Checked, region); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public ActionResult Role_Modify() { try { var id = int.Parse(Request.Params["id"]); if (string.IsNullOrEmpty(Request.Params["name"])) { return Content("角色名不能为空!"); } else if (Request.Params["name"] != 角色管理.查找角色((long)id).角色名 && 权限管理.角色已存在(Request.Params["name"])) { return Content("该角色名已经存在,请重新填写!"); } 角色 model = new 角色(); var selectlist = Request.Params["permissionstr"]; model.Id = id; List<string> 包含用户组 = new List<string>(); if (!string.IsNullOrEmpty(selectlist)) { 包含用户组 = selectlist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } model.角色名 = Request.Params["name"]; model.包含用户组 = 包含用户组; 角色管理.更新角色(model); return Content("success"); } catch { return Content("输入有误,请重新填写!"); } }
public void RolesAdd() { 角色 model = new 角色(); var selectlist = Request.Params["per"]; var name = Request.Params["name"]; // var selectlist = Request.Form["permissionstr"]; model.包含用户组 = new List<string>(); if (!string.IsNullOrEmpty(selectlist)) { model.包含用户组 = selectlist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } model.角色名 = name; 角色管理.添加角色(model); }
public static bool 添加角色(角色 content) { return Mongo.添加(content); }
public static bool 更新角色(角色 content) { return Mongo.更新(content); }