/// <summary> /// 查出登录用户的权限 /// </summary> private void UserRoleInfo() { Expression <Func <UserInfo, bool> > p = n => n.UserId == Common.GetInt(Common.USERID); UserInfo userinfo = UserInfoDAL.Single(p); if (userinfo != null) { if (userinfo.UserId > 0) { Expression <Func <RoleInfo, bool> > funroleinfo = n => n.Role_Id == userinfo.User_Role_Id; foreach (var n in RoleInfoDAL.Query(funroleinfo)) { if (n.Role_Permission != null) { Common.PERI = n.Role_Permission; } break; } } } }
/// <summary> /// 查看修改信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnUpdate_select() { try { if (lvwUserList.SelectedRows.Count > 0)//选中行 { if (lvwUserList.SelectedRows.Count > 1 || lvwUserList.SelectedRows[0].Cells[1].Value.ToString() == "") { MessageBox.Show("修改只能选中一行且修改行信息不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //清空权限 txtRoleName.ReadOnly = true; chkCheckPaper.Checked = false; chkSetBag.Checked = false; chkSetPaper.Checked = false; chkSystem.Checked = false; chb_ShuiFen.Checked = false; if (lvwUserList.SelectedRows[0].Cells["Role_Id"].Value != null) { int id = Convert.ToInt32(lvwUserList.SelectedRows[0].Cells["Role_Id"].Value.ToString()); Common.RoleID = id; lblId.Text = id.ToString(); Expression <Func <RoleInfo, bool> > funbif = n => n.Role_Id == id; foreach (var n in RoleInfoDAL.Query(funbif)) { if (n.Role_Name != null) { txtRoleName.Text = n.Role_Name; } if (n.Role_Permission != null) { txtRemark.Text = n.Role_Permission; } if (n.Role_Remark != null) { txtRemark.Text = n.Role_Remark; } if (n.Role_Permission != null) { string peri = n.Role_Permission; //系统管理0:隐藏 if (peri.Substring(0, 1) == "1") { chkSystem.Checked = true; } //异常管理 if (peri.Substring(1, 1) == "1") { chkSetBag.Checked = true; } //质检管理 if (peri.Substring(2, 1) == "1") { chkCheckPaper.Checked = true; } //数据统计 if (peri.Substring(3, 1) == "1") { chkSetPaper.Checked = true; } //车辆登记 if (peri.Substring(4, 1) == "1") { chkCheckCar.Checked = true; } //水分管理 if (peri.Substring(5, 1) == "1") { chb_ShuiFen.Checked = true; } } break; } } else { MessageBox.Show("选中行的角色ID不能为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } //显示隐藏按钮 btnAdd.Visible = false; btnCancle.Visible = true; btnUpdate.Visible = true; } } else//没有选中 { MessageBox.Show("请选择要修改的行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Common.WriteTextLog("角色管理 tsbtnUpdate_Click" + ex.Message.ToString()); } }