Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                int j    = 0;
                int rint = 0;
                ////得到添加的数据
                string name   = txtRoleName.Text;
                string permi  = SetRoles();
                string remark = txtRemark.Text;
                if (!btnCheck())
                {
                    return;
                }
                var rf = new RoleInfo
                {
                    Role_Name       = name,
                    Role_Permission = permi,
                    Role_Remark     = remark
                };
                if (!RoleInfoDAL.InsertOneRoleInfo(rf, out rint))
                {
                    j++;
                }

                if (j == 0)
                {
                    MessageBox.Show("成功增加", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("成功失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                string Log_Content = String.Format("角色名称:{0}", name);
                Common.WriteLogData("新增", Log_Content, Common.NAME);//添加日志
            }
            catch (Exception ex)
            {
                Common.WriteTextLog("角色管理 btnAdd_Click()" + ex.Message.ToString());
            }
            finally
            {
                page = new PageControl();
                page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
                LoadData();//更新数据
            }
        }
Exemple #2
0
        /// <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;
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 确认修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                //得到修改的数据
                string            name   = txtRoleName.Text;
                string            permi  = SetRoles();
                string            remark = txtRemark.Text;
                string            id     = lblId.Text;
                int               j      = 0;
                Action <RoleInfo> action = n =>
                {
                    n.Role_Name       = name;
                    n.Role_Permission = permi;
                    n.Role_Remark     = remark;
                };
                Expression <Func <RoleInfo, bool> > funroleinfo = n => n.Role_Id.ToString() == id;
                if (!RoleInfoDAL.UpdateOneRoleInfo(funroleinfo, action))//角色是否修改失败
                {
                    j++;
                }

                ////删除角色的所有权限
                //Expression<Func<PermissionsInfo, bool>> funmenuinfo = n => n.Permissions_Role_Id.ToString()== id;
                //if (!PermissionsInfoDAL.DeleteToMany(funmenuinfo))//角色权限菜单是否删除失败
                //{
                //    j++;
                //}
                //for (int i = 0; i < Common.arraylist.Count; i++)
                //{

                //    var permissionsInfo = new PermissionsInfo
                //    {
                //        Permissions_Menu_ID = Common.GetInt(Common.arraylist[i].ToString()),
                //        Permissions_Dictionary_ID = DictionaryDAL.GetDictionaryID("启动"),
                //        Permissions_Visible = true,
                //        Permissions_Enabled = true,
                //        Permissions_Role_Id = Common.RoleID

                //    };
                //    if (!PermissionsInfoDAL.InsertOneQCRecord(permissionsInfo))//是否添加失败
                //    {
                //        j++;
                //    }
                //}
                 

                if (j == 0)
                {
                    MessageBox.Show("修改成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(" 修改失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                string Log_Content = String.Format("角色名称:{0}", name);
                Common.WriteLogData("修改", Log_Content, Common.NAME);//添加日志
            }
            catch (Exception ex)
            {
                Common.WriteTextLog("角色管理 btnUpdate_Click" + ex.Message.ToString());
            }
            finally
            {
                page = new PageControl();
                page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
                LoadData();
            }
        }
Exemple #4
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsbtnDel_delete()
 {
     try
     {
         int    j           = 0;
         string Log_Content = "";
         if (lvwUserList.SelectedRows.Count > 0)//选中删除
         {
             if (MessageBox.Show("确定要删除吗?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 //选中数量
                 int count = lvwUserList.SelectedRows.Count;
                 //string id = "";
                 //遍历
                 for (int i = 0; i < count; i++)
                 {
                     Expression <Func <View_UserInfo_D_R_d, bool> > funviewuserinfo = n => n.Role_Name == lvwUserList.SelectedRows[i].Cells["Role_Name"].Value.ToString();
                     if (UserInfoDAL.Query(funviewuserinfo).Count() > 0)
                     {
                         MessageBox.Show("删除的用户角色中有角色正在使用,不能删除!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return;
                     }
                     Expression <Func <RoleInfo, bool> > funuserinfo = n => n.Role_Id.ToString() == lvwUserList.SelectedRows[i].Cells["Role_Id"].Value.ToString();
                     if (!RoleInfoDAL.DeleteToMany(funuserinfo))
                     {
                         j++;
                     }
                     else
                     {
                         Log_Content += lvwUserList.SelectedRows[i].Cells["Role_Id"].Value.ToString() + " ";
                     }
                     if (lvwUserList.SelectedRows[i].Cells["Role_Id"].Value != null)
                     {
                         //删除角色的所有权限
                         Expression <Func <PermissionsInfo, bool> > funmenuinfo = n => n.Permissions_Role_Id == Common.GetInt(lvwUserList.SelectedRows[i].Cells["Role_Id"].Value.ToString());
                         if (!PermissionsInfoDAL.DeleteToMany(funmenuinfo))//用户权限菜单是否删除失败
                         {
                             j++;
                         }
                     }
                 }
                 if (j == 0)
                 {
                     MessageBox.Show("成功删除", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("删除失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 Common.WriteLogData("删除", "删除角色" + Log_Content, Common.NAME);//操作日志
             }
         }
         else//没有选中
         {
             MessageBox.Show("请选择要删除的行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         Common.WriteTextLog("角色管理  tsbtnDel_delete()" + ex.Message.ToString());
     }
     finally
     {
         page = new PageControl();
         page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
         LoadData();
     }
 }
Exemple #5
0
 /// <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());
     }
 }