1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.3 KiB
C#

using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Winform.Business;
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;
namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
public partial class RoleAddForm : Form
{
/// <summary>
/// Sql业务类
/// </summary>
SysUserRoleService _sysUserRoleService;
/// <summary>
/// XML读取类
/// </summary>
XmlUtil xmlUtil = new XmlUtil();
/// <summary>
/// 规则字符数组
/// </summary>
char[] RoleChars = new char[80];
/// <summary>
/// 页面规则偏移量配置
/// </summary>
List<RoleConfig> ConfigList;
/// <summary>
/// 前端展示DataTable
/// </summary>
DataTable dt = new DataTable();
public RoleAddForm(SysUserRoleService sysUserRoleService)
{
InitializeComponent();
this._sysUserRoleService = sysUserRoleService;
Init();
}
private void Init()
{
RolesDataGridView.AutoGenerateColumns = false;
for (int i = 0; i < 80; i++)
{
RoleChars[i] = '0';
}
ConfigList = xmlUtil.ConfigReader();
dt.Columns.Add("TableName", typeof(string));
dt.Columns.Add("IsUseable", typeof(bool));
foreach (var config in ConfigList)
{
dt.Rows.Add(config.PageName, true);
}
RolesDataGridView.DataSource = null;
RolesDataGridView.DataSource = dt;
}
/// <summary>
/// 确认添加按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfrimAddButton_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}
/// <summary>
/// 全选按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < 80; i++)
{
RoleChars[i] = '1';
}
GridViewRefresh();
}
/// <summary>
/// 取消全选按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectNone_Click(object sender, EventArgs e)
{
for (int i = 0; i < 80; i++)
{
RoleChars[i] = '0';
}
GridViewRefresh();
}
/// <summary>
/// 前端页面刷新
/// </summary>
private void GridViewRefresh()
{
dt.Rows.Clear();
foreach (var config in ConfigList)
{
var dr = dt.NewRow();
dr[0] = config.PageName;
dr[1] = RoleChars[config.RoleIndex] == '1';
dt.Rows.Add(dr);
}
RolesDataGridView.DataSource = null;
RolesDataGridView.DataSource = dt;
}
}
}