1
0
Fork 0

add - 角色管理完毕 权限控制待加入

nodyang
SoulStar 2 months ago
parent 5b1787bc4a
commit 4a76141831

@ -36,7 +36,7 @@ namespace HighWayIot.Repository.service
if (!string.IsNullOrEmpty(userRole))
{
deviceInfo = deviceInfo.Where(x => x.UserName == userRole).ToList();
deviceInfo = deviceInfo.Where(x => x.UserRole == userRole).ToList();
}
if (isSelectByTime)

@ -34,6 +34,25 @@ namespace HighWayIot.Repository.service
}
}
/// <summary>
/// 查询所有角色列表
/// </summary>
/// <returns></returns>
public List<SysRoleEntity> GetRoleInfos(string roleName)
{
try
{
List<SysRoleEntity> deviceInfo = _repository.GetList(x => x.RoleName == roleName);
return deviceInfo;
}
catch (Exception ex)
{
log.Error("用户信息获取异常", ex);
return null;
}
}
/// <summary>
/// 添加角色信息
/// </summary>

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Winform.Business
{
public class RoleBusiness
{
/// <summary>
/// 当前登录人的姓名
/// </summary>
public static string LoginUserName = string.Empty;
}
}

@ -49,6 +49,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Business\RoleBusiness.cs" />
<Compile Include="Business\XmlUtil.cs" />
<Compile Include="MainForm\BaseForm.cs">
<SubType>Form</SubType>
@ -82,6 +83,12 @@
<Compile Include="UserControlPages\MonitorMainPage.Designer.cs">
<DependentUpon>MonitorMainPage.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleUpdateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleUpdateForm.Designer.cs">
<DependentUpon>RoleUpdateForm.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleConfigPage.cs">
<SubType>UserControl</SubType>
</Compile>
@ -94,12 +101,6 @@
<Compile Include="UserControlPages\SysConfigPages\TestPage.Designer.cs">
<DependentUpon>TestPage.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleUpdateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleUpdateForm.Designer.cs">
<DependentUpon>RoleUpdateForm.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\SysConfigPages\RoleAddForm.cs">
<SubType>Form</SubType>
</Compile>
@ -149,15 +150,15 @@
<EmbeddedResource Include="UserControlPages\MonitorMainPage.resx">
<DependentUpon>MonitorMainPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\SysConfigPages\RoleUpdateForm.resx">
<DependentUpon>RoleUpdateForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\SysConfigPages\RoleConfigPage.resx">
<DependentUpon>RoleConfigPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\SysConfigPages\TestPage.resx">
<DependentUpon>TestPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\SysConfigPages\RoleUpdateForm.resx">
<DependentUpon>RoleUpdateForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\SysConfigPages\RoleAddForm.resx">
<DependentUpon>RoleAddForm.cs</DependentUpon>
</EmbeddedResource>

@ -51,7 +51,7 @@ namespace HighWayIot.Winform.MainForm
this.HighWayLogo = new System.Windows.Forms.ToolStripStatusLabel();
this.SplitLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.StripLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.UserToolStripLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.NowLoginUserName = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.StripLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.TimeStripLabel = new System.Windows.Forms.ToolStripStatusLabel();
@ -183,7 +183,7 @@ namespace HighWayIot.Winform.MainForm
this.HighWayLogo,
this.SplitLabel1,
this.StripLabel1,
this.UserToolStripLabel,
this.NowLoginUserName,
this.toolStripStatusLabel1,
this.StripLabel2,
this.TimeStripLabel});
@ -211,17 +211,17 @@ namespace HighWayIot.Winform.MainForm
this.StripLabel1.Size = new System.Drawing.Size(80, 17);
this.StripLabel1.Text = "当前登录人:";
//
// UserToolStripLabel
// NowLoginUserName
//
this.UserToolStripLabel.Name = "UserToolStripLabel";
this.UserToolStripLabel.Size = new System.Drawing.Size(44, 17);
this.UserToolStripLabel.Text = "admin";
this.NowLoginUserName.Name = "NowLoginUserName";
this.NowLoginUserName.Size = new System.Drawing.Size(31, 17);
this.NowLoginUserName.Text = "N/A";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(1144, 17);
this.toolStripStatusLabel1.Size = new System.Drawing.Size(1157, 17);
this.toolStripStatusLabel1.Spring = true;
//
// StripLabel2
@ -282,7 +282,7 @@ namespace HighWayIot.Winform.MainForm
private ToolStripStatusLabel HighWayLogo;
private ToolStripStatusLabel StripLabel1;
private ToolStripStatusLabel SplitLabel1;
private ToolStripStatusLabel UserToolStripLabel;
private ToolStripStatusLabel NowLoginUserName;
private ToolStripStatusLabel toolStripStatusLabel1;
private ToolStripStatusLabel StripLabel2;
private ToolStripStatusLabel TimeStripLabel;

@ -1,4 +1,5 @@
using HighWayIot.Log4net;
using HighWayIot.Winform.Business;
using HighWayIot.Winform.UserControlPages;
using HighWayIot.Winform.UserControlPages.SysConfigPages;
using System;
@ -32,8 +33,9 @@ namespace HighWayIot.Winform.MainForm
public void Init()
{
logger.Info("主页面已启动");
UserPanelSwitch(typeof(MonitorMainPage), "监控主页面");
TimeDisplayTimer.Start();
NowLoginUserName.Text = RoleBusiness.LoginUserName;
UserPanelSwitch(typeof(MonitorMainPage), "监控主页面");
}
/// <summary>
@ -105,9 +107,9 @@ namespace HighWayIot.Winform.MainForm
private void UserPanelSwitch(Type userControlType, string tag)
{
bool flag = false;
foreach(UserControl us in UserControls)
foreach (UserControl us in UserControls)
{
if(us.GetType() == userControlType)
if (us.GetType() == userControlType)
{
flag = true;
//如果在标签页里,切换选项卡
@ -115,22 +117,22 @@ namespace HighWayIot.Winform.MainForm
{
try
{
foreach(Control control in this.UserControlTabs.Controls)
foreach (Control control in this.UserControlTabs.Controls)
{
if(control is TabPage page)
if (control is TabPage page)
{
if(page.Text == tag)
if (page.Text == tag)
{
UserControlTabs.SelectedTab = page;
}
}
}
}
catch(ArgumentNullException ex)
catch (ArgumentNullException ex)
{
logger.Error("找不到相关标签页!请重启程序!", ex);
}
catch(Exception ex)
catch (Exception ex)
{
logger.Error("标签页未知错误!", ex);
}
@ -156,7 +158,7 @@ namespace HighWayIot.Winform.MainForm
newControl.Tag = tag;
UserControls.Add(newControl); // 将新实例添加到列表
TabPage tabPage = new TabPage(tag);
newControl.Parent = tabPage;
newControl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
newControl.Dock = DockStyle.Fill;

@ -1,5 +1,6 @@
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Winform.Business;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -34,6 +35,7 @@ namespace HighWayIot.Winform.MainForm
if (lists.Count == 1 && lists.First().Password == PassText.Text)
{
lists.First().LastLoginTime = DateTime.Now;
RoleBusiness.LoginUserName = UserText.Text;
sysUserInfoService.UpdateUserInfo(lists.First());
DialogResult = DialogResult.OK;
this.Close();

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.UserNameTextBox = new System.Windows.Forms.TextBox();
this.RoleNameTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.ConfrimAddButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
@ -55,12 +55,12 @@
this.label1.Size = new System.Drawing.Size(0, 12);
this.label1.TabIndex = 0;
//
// UserNameTextBox
// RoleNameTextBox
//
this.UserNameTextBox.Location = new System.Drawing.Point(216, 23);
this.UserNameTextBox.Name = "UserNameTextBox";
this.UserNameTextBox.Size = new System.Drawing.Size(136, 21);
this.UserNameTextBox.TabIndex = 1;
this.RoleNameTextBox.Location = new System.Drawing.Point(216, 23);
this.RoleNameTextBox.Name = "RoleNameTextBox";
this.RoleNameTextBox.Size = new System.Drawing.Size(136, 21);
this.RoleNameTextBox.TabIndex = 1;
//
// label2
//
@ -87,7 +87,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.ConfrimAddButton);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.UserNameTextBox);
this.panel1.Controls.Add(this.RoleNameTextBox);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
@ -150,8 +150,8 @@
this.IsUseable});
this.RolesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.RolesDataGridView.Location = new System.Drawing.Point(0, 0);
this.RolesDataGridView.MultiSelect = false;
this.RolesDataGridView.Name = "RolesDataGridView";
this.RolesDataGridView.ReadOnly = true;
this.RolesDataGridView.RowHeadersVisible = false;
this.RolesDataGridView.RowTemplate.Height = 23;
this.RolesDataGridView.Size = new System.Drawing.Size(392, 541);
@ -170,6 +170,7 @@
this.IsUseable.DataPropertyName = "IsUseable";
this.IsUseable.HeaderText = "是否有权限";
this.IsUseable.Name = "IsUseable";
this.IsUseable.ReadOnly = false;
this.IsUseable.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.IsUseable.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.IsUseable.Width = 90;
@ -196,7 +197,7 @@
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox UserNameTextBox;
private System.Windows.Forms.TextBox RoleNameTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button ConfrimAddButton;
private System.Windows.Forms.Panel panel1;

@ -60,13 +60,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
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;
GridViewRefresh();
}
/// <summary>
@ -77,6 +71,44 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
private void ConfrimAddButton_Click(object sender, EventArgs e)
{
foreach (RoleConfig config in ConfigList)
{
for (int i = 0; i < ConfigList.Count; i++)
{
if (config.PageName == RolesDataGridView.Rows[i].Cells[0].Value.ToString().Trim())
{
RoleChars[config.RoleIndex] = Convert.ToBoolean(RolesDataGridView.Rows[i].Cells[1].Value) ? '1' : '0';
}
}
}
if (string.IsNullOrEmpty(RoleNameTextBox.Text))
{
MessageBox.Show("角色名不能为空!", "提示", MessageBoxButtons.OK);
return;
}
if (_sysUserRoleService.GetRoleInfos(RoleNameTextBox.Text).Count >= 1)
{
MessageBox.Show("角色名重复!", "提示", MessageBoxButtons.OK);
return;
}
SysRoleEntity role = new SysRoleEntity()
{
RoleName = RoleNameTextBox.Text,
RoleSet = new string(RoleChars),
};
if (_sysUserRoleService.InsertRoleInfo(role))
{
MessageBox.Show("角色添加成功", "提示", MessageBoxButtons.OK);
}
else
{
MessageBox.Show("角色添加失败", "提示", MessageBoxButtons.OK);
}
this.Close();
this.Dispose();
}

@ -42,6 +42,8 @@ namespace HighWayIot.Winform.UserControlPages
//
// RoleDataGridView
//
this.RoleDataGridView.AllowUserToAddRows = false;
this.RoleDataGridView.AllowUserToDeleteRows = false;
this.RoleDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
@ -49,6 +51,8 @@ namespace HighWayIot.Winform.UserControlPages
this.RoleDataGridView.Location = new System.Drawing.Point(0, 65);
this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.RoleDataGridView.Name = "RoleDataGridView";
this.RoleDataGridView.ReadOnly = true;
this.RoleDataGridView.RowHeadersVisible = false;
this.RoleDataGridView.RowTemplate.Height = 25;
this.RoleDataGridView.Size = new System.Drawing.Size(1204, 770);
this.RoleDataGridView.TabIndex = 0;

@ -1,5 +1,7 @@
using HighWayIot.Repository.domain;
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Winform.Business;
using HighWayIot.Winform.UserControlPages.SysConfigPages;
using System;
using System.Collections.Generic;
@ -17,8 +19,24 @@ namespace HighWayIot.Winform.UserControlPages
{
SysUserRoleService roleService = new SysUserRoleService();
private static LogHelper logger = LogHelper.Instance;
/// <summary>
/// 数据库实体类列表
/// </summary>
private List<SysRoleEntity> List = new List<SysRoleEntity>();
/// <summary>
/// XML读取类
/// </summary>
XmlUtil xmlUtil = new XmlUtil();
/// <summary>
/// 页面规则偏移量配置
/// </summary>
List<RoleConfig> ConfigList;
public RoleConfigPage()
{
@ -30,17 +48,41 @@ namespace HighWayIot.Winform.UserControlPages
{
RoleDataGridView.AutoGenerateColumns = false;
List = roleService.GetRoleInfos();
RoleDataGridView.DataSource = null;
RoleDataGridView.DataSource = List;
ConfigList = xmlUtil.ConfigReader();
//设置列数量
RoleDataGridView.ColumnCount = ConfigList.Count + 1;
//设置列头名称
RoleDataGridView.Columns[0].Name = "RoleName";
RoleDataGridView.Columns[0].DataPropertyName = "RoleName";
RoleDataGridView.Columns[0].HeaderText = "角色名";
RoleDataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
RoleDataGridView.Columns[0].Width = 100;
for (int i = 0; i < ConfigList.Count; i++)
{
RoleDataGridView.Columns[i + 1].Name = ConfigList[i].PageName;
RoleDataGridView.Columns[i + 1].DataPropertyName = ConfigList[i].PageName;
RoleDataGridView.Columns[i + 1].HeaderText = ConfigList[i].PageName;
RoleDataGridView.Columns[i + 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
GridViewRefresh();
}
private void UpdateRole_Click(object sender, EventArgs e)
{
RoleUpdateForm form = new RoleUpdateForm(roleService);
//写的很烂
int index = RoleDataGridView.CurrentRow.Index;
//前端数据顺序绑定的时候就是数据库的顺序,所以可以这么写。
RoleUpdateForm form = new RoleUpdateForm(roleService, List[index]);
form.ShowDialog();
List = roleService.GetRoleInfos();
RoleDataGridView.DataSource = null;
RoleDataGridView.DataSource = List;
GridViewRefresh();
}
private void AddRole_Click(object sender, EventArgs e)
@ -48,13 +90,59 @@ namespace HighWayIot.Winform.UserControlPages
RoleAddForm form = new RoleAddForm(roleService);
form.ShowDialog();
List = roleService.GetRoleInfos();
RoleDataGridView.DataSource = null;
RoleDataGridView.DataSource = List;
GridViewRefresh();
}
private void DeleteRole_Click(object sender, EventArgs e)
{
//写的很烂
int index = RoleDataGridView.CurrentRow.Index;
if (MessageBox.Show($"确认要删除{List[index].RoleName}该角色信息?", "确定?", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
//前端数据顺序绑定的时候就是数据库的顺序,所以可以这么写。
roleService.DeleteRoleInfoById(List[index].Id);
List = roleService.GetRoleInfos();
GridViewRefresh();
}
}
/// <summary>
/// 刷新列
/// </summary>
private void GridViewRefresh()
{
RoleDataGridView.Rows.Clear();
//用户名部分初始化赋值
for (int i = 0; i < List.Count; i++)
{
RoleDataGridView.Rows.Add();
RoleDataGridView.Rows[i].Cells[0].Value = List[i].RoleName;
}
//权限部分初始化赋值
for (int rowIndex = 0; rowIndex < List.Count; rowIndex++)
{
char[] roleChars = List[rowIndex].RoleSet.ToCharArray();
for (int columnIndex = 1; columnIndex < RoleDataGridView.Columns.Count; columnIndex++)
{
// 获取当前单元格
DataGridViewCell cell = RoleDataGridView.Rows[rowIndex].Cells[columnIndex];
// 获取列名
string columnName = RoleDataGridView.Columns[columnIndex].Name;
try
{
RoleDataGridView.Rows[rowIndex].Cells[columnIndex].Value =
roleChars[ConfigList.Where(x => x.PageName == columnName).First().RoleIndex] == '1' ? "√" : "";
}
catch (Exception ex)
{
logger.Error("用户角色初始化发生错误请检查Configuration.xml", ex);
}
}
}
}
}
}

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.UserNameTextBox = new System.Windows.Forms.TextBox();
this.RoleNameTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.ConfrimAddButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
@ -37,13 +37,13 @@
this.SelectNone = new System.Windows.Forms.Button();
this.SelectAll = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.RolesDataGridView = new System.Windows.Forms.DataGridView();
this.TableName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsUseable = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.RolesDataGridView)).BeginInit();
this.SuspendLayout();
//
// label1
@ -55,12 +55,12 @@
this.label1.Size = new System.Drawing.Size(0, 12);
this.label1.TabIndex = 0;
//
// UserNameTextBox
// RoleNameTextBox
//
this.UserNameTextBox.Location = new System.Drawing.Point(216, 23);
this.UserNameTextBox.Name = "UserNameTextBox";
this.UserNameTextBox.Size = new System.Drawing.Size(136, 21);
this.UserNameTextBox.TabIndex = 1;
this.RoleNameTextBox.Location = new System.Drawing.Point(216, 23);
this.RoleNameTextBox.Name = "RoleNameTextBox";
this.RoleNameTextBox.Size = new System.Drawing.Size(136, 21);
this.RoleNameTextBox.TabIndex = 1;
//
// label2
//
@ -83,11 +83,12 @@
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.ConfrimAddButton);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.UserNameTextBox);
this.panel1.Controls.Add(this.RoleNameTextBox);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(398, 66);
@ -95,10 +96,12 @@
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.SelectNone);
this.groupBox1.Controls.Add(this.SelectAll);
this.groupBox1.Controls.Add(this.panel2);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.groupBox1.Location = new System.Drawing.Point(0, 72);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(398, 593);
@ -114,6 +117,7 @@
this.SelectNone.TabIndex = 2;
this.SelectNone.Text = "全不选";
this.SelectNone.UseVisualStyleBackColor = true;
this.SelectNone.Click += new System.EventHandler(this.SelectNone_Click);
//
// SelectAll
//
@ -123,59 +127,68 @@
this.SelectAll.TabIndex = 1;
this.SelectAll.Text = "全选";
this.SelectAll.UseVisualStyleBackColor = true;
this.SelectAll.Click += new System.EventHandler(this.SelectAll_Click);
//
// panel2
//
this.panel2.Controls.Add(this.dataGridView1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel2.Controls.Add(this.RolesDataGridView);
this.panel2.Location = new System.Drawing.Point(3, 49);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(392, 541);
this.panel2.TabIndex = 0;
//
// dataGridView1
// RolesDataGridView
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.RolesDataGridView.AllowUserToAddRows = false;
this.RolesDataGridView.AllowUserToDeleteRows = false;
this.RolesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.RolesDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.TableName,
this.IsUseable});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(392, 541);
this.dataGridView1.TabIndex = 0;
this.RolesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.RolesDataGridView.Location = new System.Drawing.Point(0, 0);
this.RolesDataGridView.MultiSelect = false;
this.RolesDataGridView.Name = "RolesDataGridView";
this.RolesDataGridView.RowHeadersVisible = false;
this.RolesDataGridView.RowTemplate.Height = 23;
this.RolesDataGridView.Size = new System.Drawing.Size(392, 541);
this.RolesDataGridView.TabIndex = 0;
//
// TableName
//
this.TableName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TableName.DataPropertyName = "TableName";
this.TableName.HeaderText = "页面名称";
this.TableName.Name = "TableName";
this.TableName.ReadOnly = true;
//
// IsUseable
//
this.IsUseable.DataPropertyName = "IsUseable";
this.IsUseable.HeaderText = "是否有权限";
this.IsUseable.Name = "IsUseable";
this.IsUseable.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.IsUseable.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.IsUseable.Width = 90;
//
// UserRoleUpdateForm
// RoleUpdateForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(398, 665);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.panel1);
this.Name = "UserRoleUpdateForm";
this.Name = "RoleUpdateForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "修改角色设置";
this.Text = "修改角色信息";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.RolesDataGridView)).EndInit();
this.ResumeLayout(false);
}
@ -183,7 +196,7 @@
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox UserNameTextBox;
private System.Windows.Forms.TextBox RoleNameTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button ConfrimAddButton;
private System.Windows.Forms.Panel panel1;
@ -191,7 +204,7 @@
private System.Windows.Forms.Button SelectNone;
private System.Windows.Forms.Button SelectAll;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridView RolesDataGridView;
private System.Windows.Forms.DataGridViewTextBoxColumn TableName;
private System.Windows.Forms.DataGridViewCheckBoxColumn IsUseable;
}

@ -1,5 +1,6 @@
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Winform.Business;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -14,27 +15,149 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
public partial class RoleUpdateForm : Form
{
/// <summary>
/// Sql业务类
/// </summary>
SysUserRoleService _sysUserRoleService;
public RoleUpdateForm(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();
/// <summary>
/// 要更改的数据
/// </summary>
SysRoleEntity _roleEntity;
public RoleUpdateForm(SysUserRoleService sysUserRoleService, SysRoleEntity sysRoleEntity)
{
InitializeComponent();
this._sysUserRoleService = sysUserRoleService;
this._roleEntity = sysRoleEntity;
Init();
}
private void Init()
{
RolesDataGridView.AutoGenerateColumns = false;
RoleNameTextBox.Text = _roleEntity.RoleName;
RoleChars = _roleEntity.RoleSet.ToCharArray();
ConfigList = xmlUtil.ConfigReader();
dt.Columns.Add("TableName", typeof(string));
dt.Columns.Add("IsUseable", typeof(bool));
GridViewRefresh();
}
/// <summary>
/// 确认添加按钮
/// 确认修改按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfrimAddButton_Click(object sender, EventArgs e)
{
foreach (RoleConfig config in ConfigList)
{
for (int i = 0; i < ConfigList.Count; i++)
{
if (config.PageName == RolesDataGridView.Rows[i].Cells[0].Value.ToString().Trim())
{
RoleChars[config.RoleIndex] = Convert.ToBoolean(RolesDataGridView.Rows[i].Cells[1].Value) ? '1' : '0';
}
}
}
if (string.IsNullOrEmpty(RoleNameTextBox.Text))
{
MessageBox.Show("角色名不能为空!", "提示", MessageBoxButtons.OK);
return;
}
if (_sysUserRoleService.GetRoleInfos(RoleNameTextBox.Text).Where(x => x.Id != _roleEntity.Id).Count() > 0)
{
MessageBox.Show("角色名重复!", "提示", MessageBoxButtons.OK);
return;
}
_roleEntity.RoleName = RoleNameTextBox.Text;
_roleEntity.RoleSet = new string(RoleChars);
if (_sysUserRoleService.UpdateRoleInfo(_roleEntity))
{
MessageBox.Show("角色修改成功", "提示", MessageBoxButtons.OK);
}
else
{
MessageBox.Show("角色修改失败", "提示", MessageBoxButtons.OK);
}
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;
}
}
}

@ -15,14 +15,15 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
public partial class UserAddForm : Form
{
/// <summary>
/// 数据库服务类
/// 角色数据库业务实例
/// </summary>
SysUserInfoService SysUserInfoService;
public UserAddForm(SysUserInfoService sysUserInfoService)
public UserAddForm(SysUserInfoService sysUserInfoService, string[] roleList)
{
InitializeComponent();
this.SysUserInfoService = sysUserInfoService;
UserRoleComboBox.DataSource = roleList;
}
/// <summary>

@ -32,26 +32,26 @@ namespace HighWayIot.Winform.UserControlPages
private void InitializeComponent()
{
this.UserInfoDataGridView = new System.Windows.Forms.DataGridView();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.UserName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Password = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.UserRole = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LastLoginTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.AddUser = new System.Windows.Forms.Button();
this.UpdateUser = new System.Windows.Forms.Button();
this.DeleteUser = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.SelectUser = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SelectUserName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SelectUserRole = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.IsCheckByLoginTime = new System.Windows.Forms.CheckBox();
this.SelectUserLoginBeginTime = new System.Windows.Forms.DateTimePicker();
this.SelectUserLoginEndTime = new System.Windows.Forms.DateTimePicker();
this.label4 = new System.Windows.Forms.Label();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.UserName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Password = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.UserRole = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LastLoginTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SelectUserLoginEndTime = new System.Windows.Forms.DateTimePicker();
this.SelectUserLoginBeginTime = new System.Windows.Forms.DateTimePicker();
this.IsCheckByLoginTime = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label();
this.SelectUserRole = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.SelectUserName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SelectUser = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.UserInfoDataGridView)).BeginInit();
this.ButtonPanel.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -78,6 +78,46 @@ namespace HighWayIot.Winform.UserControlPages
this.UserInfoDataGridView.Size = new System.Drawing.Size(1188, 869);
this.UserInfoDataGridView.TabIndex = 0;
//
// Id
//
this.Id.DataPropertyName = "Id";
this.Id.HeaderText = "ID";
this.Id.Name = "Id";
this.Id.ReadOnly = true;
this.Id.Width = 50;
//
// UserName
//
this.UserName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.UserName.DataPropertyName = "UserName";
this.UserName.HeaderText = "用户名";
this.UserName.Name = "UserName";
this.UserName.ReadOnly = true;
//
// Password
//
this.Password.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Password.DataPropertyName = "Password";
this.Password.HeaderText = "用户密码";
this.Password.Name = "Password";
this.Password.ReadOnly = true;
//
// UserRole
//
this.UserRole.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.UserRole.DataPropertyName = "UserRole";
this.UserRole.HeaderText = "用户角色";
this.UserRole.Name = "UserRole";
this.UserRole.ReadOnly = true;
//
// LastLoginTime
//
this.LastLoginTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.LastLoginTime.DataPropertyName = "LastLoginTime";
this.LastLoginTime.HeaderText = "上次登录时间";
this.LastLoginTime.Name = "LastLoginTime";
this.LastLoginTime.ReadOnly = true;
//
// AddUser
//
this.AddUser.Location = new System.Drawing.Point(11, 11);
@ -146,58 +186,33 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox1.TabStop = false;
this.groupBox1.Text = "条件查询,某项为空则不判断该项";
//
// SelectUser
//
this.SelectUser.Location = new System.Drawing.Point(6, 19);
this.SelectUser.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.SelectUser.Name = "SelectUser";
this.SelectUser.Size = new System.Drawing.Size(67, 28);
this.SelectUser.TabIndex = 4;
this.SelectUser.Text = "查询";
this.SelectUser.UseVisualStyleBackColor = true;
this.SelectUser.Click += new System.EventHandler(this.SelectUser_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(79, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 5;
this.label1.Text = "用户名:";
//
// SelectUserName
//
this.SelectUserName.Location = new System.Drawing.Point(81, 28);
this.SelectUserName.Name = "SelectUserName";
this.SelectUserName.Size = new System.Drawing.Size(100, 21);
this.SelectUserName.TabIndex = 6;
//
// label2
// label4
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(185, 12);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 7;
this.label2.Text = "角色:";
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(484, 31);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(17, 12);
this.label4.TabIndex = 13;
this.label4.Text = "到";
//
// SelectUserRole
// SelectUserLoginEndTime
//
this.SelectUserRole.FormattingEnabled = true;
this.SelectUserRole.Location = new System.Drawing.Point(187, 28);
this.SelectUserRole.Name = "SelectUserRole";
this.SelectUserRole.Size = new System.Drawing.Size(100, 20);
this.SelectUserRole.TabIndex = 8;
this.SelectUserLoginEndTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss";
this.SelectUserLoginEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.SelectUserLoginEndTime.Location = new System.Drawing.Point(507, 28);
this.SelectUserLoginEndTime.Name = "SelectUserLoginEndTime";
this.SelectUserLoginEndTime.Size = new System.Drawing.Size(185, 21);
this.SelectUserLoginEndTime.TabIndex = 12;
//
// label3
// SelectUserLoginBeginTime
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(291, 12);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 9;
this.label3.Text = "登陆时间:";
this.SelectUserLoginBeginTime.CustomFormat = "yyyy年MM月dd日 HH:mm:ss";
this.SelectUserLoginBeginTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.SelectUserLoginBeginTime.Location = new System.Drawing.Point(293, 28);
this.SelectUserLoginBeginTime.Name = "SelectUserLoginBeginTime";
this.SelectUserLoginBeginTime.Size = new System.Drawing.Size(185, 21);
this.SelectUserLoginBeginTime.TabIndex = 11;
this.SelectUserLoginBeginTime.Value = new System.DateTime(2024, 11, 26, 13, 36, 9, 0);
//
// IsCheckByLoginTime
//
@ -209,68 +224,58 @@ namespace HighWayIot.Winform.UserControlPages
this.IsCheckByLoginTime.Text = "是否根据时间判断";
this.IsCheckByLoginTime.UseVisualStyleBackColor = true;
//
// SelectUserLoginBeginTime
//
this.SelectUserLoginBeginTime.Location = new System.Drawing.Point(293, 28);
this.SelectUserLoginBeginTime.Name = "SelectUserLoginBeginTime";
this.SelectUserLoginBeginTime.Size = new System.Drawing.Size(102, 21);
this.SelectUserLoginBeginTime.TabIndex = 11;
//
// SelectUserLoginEndTime
//
this.SelectUserLoginEndTime.Location = new System.Drawing.Point(424, 28);
this.SelectUserLoginEndTime.Name = "SelectUserLoginEndTime";
this.SelectUserLoginEndTime.Size = new System.Drawing.Size(102, 21);
this.SelectUserLoginEndTime.TabIndex = 12;
//
// label4
// label3
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(401, 31);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(17, 12);
this.label4.TabIndex = 13;
this.label4.Text = "到";
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(291, 12);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 9;
this.label3.Text = "登陆时间:";
//
// Id
// SelectUserRole
//
this.Id.DataPropertyName = "Id";
this.Id.HeaderText = "ID";
this.Id.Name = "Id";
this.Id.ReadOnly = true;
this.Id.Width = 50;
this.SelectUserRole.FormattingEnabled = true;
this.SelectUserRole.Location = new System.Drawing.Point(187, 28);
this.SelectUserRole.Name = "SelectUserRole";
this.SelectUserRole.Size = new System.Drawing.Size(100, 20);
this.SelectUserRole.TabIndex = 8;
//
// UserName
// label2
//
this.UserName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.UserName.DataPropertyName = "UserName";
this.UserName.HeaderText = "用户名";
this.UserName.Name = "UserName";
this.UserName.ReadOnly = true;
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(185, 12);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 7;
this.label2.Text = "角色:";
//
// Password
// SelectUserName
//
this.Password.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Password.DataPropertyName = "Password";
this.Password.HeaderText = "用户密码";
this.Password.Name = "Password";
this.Password.ReadOnly = true;
this.SelectUserName.Location = new System.Drawing.Point(81, 28);
this.SelectUserName.Name = "SelectUserName";
this.SelectUserName.Size = new System.Drawing.Size(100, 21);
this.SelectUserName.TabIndex = 6;
//
// UserRole
// label1
//
this.UserRole.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.UserRole.DataPropertyName = "UserRole";
this.UserRole.HeaderText = "用户角色";
this.UserRole.Name = "UserRole";
this.UserRole.ReadOnly = true;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(79, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 5;
this.label1.Text = "用户名:";
//
// LastLoginTime
// SelectUser
//
this.LastLoginTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.LastLoginTime.DataPropertyName = "LastLoginTime";
this.LastLoginTime.HeaderText = "上次登录时间";
this.LastLoginTime.Name = "LastLoginTime";
this.LastLoginTime.ReadOnly = true;
this.SelectUser.Location = new System.Drawing.Point(6, 19);
this.SelectUser.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.SelectUser.Name = "SelectUser";
this.SelectUser.Size = new System.Drawing.Size(67, 28);
this.SelectUser.TabIndex = 4;
this.SelectUser.Text = "查询";
this.SelectUser.UseVisualStyleBackColor = true;
this.SelectUser.Click += new System.EventHandler(this.SelectUser_Click);
//
// UserConfigPage
//

@ -15,10 +15,26 @@ namespace HighWayIot.Winform.UserControlPages
{
public partial class UserConfigPage : UserControl
{
/// <summary>
/// 用户数据库业务实例
/// </summary>
private SysUserInfoService sysUserInfoService = new SysUserInfoService();
/// <summary>
/// 角色数据库业务实例
/// </summary>
private SysUserRoleService sysUserRoleService = new SysUserRoleService();
/// <summary>
/// 用户信息列表
/// </summary>
private List<SysUserEntity> List = new List<SysUserEntity>();
/// <summary>
/// 角色名称列表
/// </summary>
private string[] RoleNames;
public UserConfigPage()
{
InitializeComponent();
@ -29,6 +45,15 @@ namespace HighWayIot.Winform.UserControlPages
{
UserInfoDataGridView.AutoGenerateColumns = false;
List = sysUserInfoService.GetUserInfos();
RoleNames = sysUserRoleService.GetRoleInfos().Select(x => x.RoleName).ToArray();
Array.Resize(ref RoleNames, RoleNames.Length + 1);
Array.Copy(RoleNames, 0, RoleNames, 1, RoleNames.Length - 1);
RoleNames[0] = string.Empty;
SelectUserLoginBeginTime.Value = DateTime.Now - TimeSpan.FromDays(3);
this.SelectUserRole.DataSource = RoleNames;
UserInfoDataGridView.DataSource = null;
UserInfoDataGridView.DataSource = List;
}
@ -42,7 +67,7 @@ namespace HighWayIot.Winform.UserControlPages
entity.UserName = UserInfoDataGridView.Rows[a].Cells["UserName"].Value.ToString();
entity.UserRole = UserInfoDataGridView.Rows[a].Cells["UserRole"].Value.ToString();
entity.Password = UserInfoDataGridView.Rows[a].Cells["Password"].Value.ToString();
UserUpDateForm form = new UserUpDateForm(sysUserInfoService, entity);
UserUpDateForm form = new UserUpDateForm(sysUserInfoService, entity, RoleNames);
form.ShowDialog();
List = sysUserInfoService.GetUserInfos();
UserInfoDataGridView.DataSource = null;
@ -51,7 +76,7 @@ namespace HighWayIot.Winform.UserControlPages
private void AddUser_Click(object sender, EventArgs e)
{
UserAddForm form = new UserAddForm(sysUserInfoService);
UserAddForm form = new UserAddForm(sysUserInfoService, RoleNames);
form.ShowDialog();
List = sysUserInfoService.GetUserInfos();
UserInfoDataGridView.DataSource = null;
@ -60,11 +85,11 @@ namespace HighWayIot.Winform.UserControlPages
private void DeleteUser_Click(object sender, EventArgs e)
{
if(MessageBox.Show("确定要删除所选行的数据?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
int a = UserInfoDataGridView.CurrentRow.Index;
if (MessageBox.Show($"确定要删除所选{List[a].UserName}行的数据?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
return;
}
int a = UserInfoDataGridView.CurrentRow.Index;
int.TryParse(UserInfoDataGridView.Rows[a].Cells["Id"].Value.ToString(), out a);
sysUserInfoService.DeleteUserInfoById(a);
List = sysUserInfoService.GetUserInfos();

@ -132,4 +132,19 @@
<metadata name="LastLoginTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="UserName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Password.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="UserRole.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LastLoginTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

@ -14,14 +14,22 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
public partial class UserUpDateForm : Form
{
/// <summary>
/// 角色数据库业务实例
/// </summary>
SysUserInfoService _userInfoService;
/// <summary>
/// 要修改的实体
/// </summary>
SysUserEntity _userEntity;
public UserUpDateForm(SysUserInfoService sysUserInfoService, SysUserEntity userEntity)
public UserUpDateForm(SysUserInfoService sysUserInfoService, SysUserEntity userEntity, string[] roleList)
{
InitializeComponent();
this._userInfoService = sysUserInfoService;
this._userEntity = userEntity;
UserRoleComboBox.DataSource = roleList;
PasswordTextBox.Text = _userEntity.Password;
UserNameTextBox.Text = _userEntity.UserName;
for(int i = 0; i < UserRoleComboBox.Items.Count; i++)

Loading…
Cancel
Save