提交rbac
提交设置右键错位的bug
This commit is contained in:
203
DH.RBAC/Views/Sys/Permission/PermissionPage.cs
Normal file
203
DH.RBAC/Views/Sys/Permission/PermissionPage.cs
Normal file
@ -0,0 +1,203 @@
|
||||
|
||||
using DH.RBAC.Common;
|
||||
using Sunny.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DH.RBAC.Logic.Sys;
|
||||
using DH.RBAC.Model.Sys;
|
||||
using DH.RBAC.Utility.Other;
|
||||
using AntdUI;
|
||||
|
||||
|
||||
namespace DH.RBAC.Page.Sys.Permission
|
||||
{
|
||||
[PageCode("sys-permission")]
|
||||
public partial class PermissionPage : MyPage
|
||||
{
|
||||
Window window;
|
||||
private SysPermissionLogic permissionLogic;
|
||||
public PermissionPage(Window _window)
|
||||
{
|
||||
window= _window;
|
||||
InitializeComponent();
|
||||
permissionLogic = new SysPermissionLogic();
|
||||
dataGridView.AutoGenerateColumns = false;
|
||||
Load += UserPage_Initialize;
|
||||
btnAdd.Click += btnAdd_Click;
|
||||
btnDelete.Click += btnDelete_Click;
|
||||
btnUpdate.Click += btnModify_Click;
|
||||
btnQuery.Click += btnQuery_Click;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 画面初始化
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void UserPage_Initialize(object sender, EventArgs e)
|
||||
{
|
||||
btnQuery_Click(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void btnQuery_Click(object sender, EventArgs e)
|
||||
{
|
||||
int totalCount = 0;
|
||||
List<SysPermission> list = permissionLogic.GetList(pagination.ActivePage, pagination.PageSize, txtKeywords.Text, ref totalCount);
|
||||
pagination.TotalCount = totalCount;
|
||||
dataGridView.DataSource = list;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 图标渲染
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||
{
|
||||
if (dataGridView.Columns[e.ColumnIndex].Name == ("Symbols"))
|
||||
{
|
||||
int symbolIndex = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells["Icons"].Value.ToString());
|
||||
e.Value = FontImageHelper.CreateImage(symbolIndex, 18, Color.Black);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关键词Enter键处理
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void txtKeywords_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
btnQuery_Click(sender, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增权限
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddPermissionForm form = new AddPermissionForm();
|
||||
form.ParentPage = this;
|
||||
form.Id = string.Empty;
|
||||
FormHelper.ShowSubForm(form);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改权限
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择一行数据进行修改!", autoClose: 3);
|
||||
|
||||
return;
|
||||
}
|
||||
int index = dataGridView.SelectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择一行数据进行修改!", autoClose: 3);
|
||||
|
||||
return;
|
||||
}
|
||||
string id = dataGridView.Rows[index].Cells["PermissionId"].Value.ToString();
|
||||
AddPermissionForm form = new AddPermissionForm();
|
||||
form.ParentPage = this;
|
||||
form.Id = id;
|
||||
FormHelper.ShowSubForm(form);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除权限
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择一行数据进行删除!", autoClose: 3);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
int index = dataGridView.SelectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择一行数据进行删除!", autoClose: 3);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
string id = dataGridView.Rows[index].Cells["PermissionId"].Value.ToString();
|
||||
|
||||
var result =AntdUI. Modal.open(window, "删除警告!", "您是否确定要删除该权限?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
long count = permissionLogic.GetChildCount(id);
|
||||
if (count > 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, $"操作失败,请先删除该项的{count}个子级权限。", autoClose: 3);
|
||||
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
int row = permissionLogic.Delete(id.SplitToList().ToArray());
|
||||
|
||||
if (row == 0)
|
||||
{
|
||||
AntdUI.Message.warn(window, $"对不起,操作失败", autoClose: 3);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
//重新查询
|
||||
btnQuery_Click(null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
AntdUI.Message.warn(window, $"网络或服务器异常,请稍后再试", autoClose: 3);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 页码变更触发
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="pagingSource"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="count"></param>
|
||||
private void pagination_PageChanged(object sender, object pagingSource, int pageIndex, int count)
|
||||
{
|
||||
btnQuery_Click(null, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user