|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
using HighWayIot.Repository.service;
|
|
|
|
|
using HighWayIot.Repository.service.Impl;
|
|
|
|
|
using HighWayIot.Winform.UserControlPages.SysConfigPages;
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
public partial class UserConfigPage : UserControl
|
|
|
|
|
{
|
|
|
|
|
private ISysUserInfoService SysUserInfoService = new BaseSysUserInfoServiceImpl();
|
|
|
|
|
|
|
|
|
|
private List<SysUserEntity> List = new List<SysUserEntity>();
|
|
|
|
|
|
|
|
|
|
public UserConfigPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
UserInfoDataGridView.AutoGenerateColumns = false;
|
|
|
|
|
List = SysUserInfoService.GetUserInfos();
|
|
|
|
|
UserInfoDataGridView.DataSource = null;
|
|
|
|
|
UserInfoDataGridView.DataSource = List;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateUser_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SysUserEntity entity = new SysUserEntity();
|
|
|
|
|
int a = UserInfoDataGridView.CurrentRow.Index;
|
|
|
|
|
int.TryParse(UserInfoDataGridView.Rows[a].Cells["Id"].Value.ToString(), out int id);
|
|
|
|
|
entity.Id = id;
|
|
|
|
|
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);
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
List = SysUserInfoService.GetUserInfos();
|
|
|
|
|
UserInfoDataGridView.DataSource = null;
|
|
|
|
|
UserInfoDataGridView.DataSource = List;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddUser_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UserAddForm form = new UserAddForm(SysUserInfoService);
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
List = SysUserInfoService.GetUserInfos();
|
|
|
|
|
UserInfoDataGridView.DataSource = null;
|
|
|
|
|
UserInfoDataGridView.DataSource = List;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteUser_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(MessageBox.Show("确定要删除所选行的数据?", "确认", 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();
|
|
|
|
|
UserInfoDataGridView.DataSource = null;
|
|
|
|
|
UserInfoDataGridView.DataSource = List;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectUser_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
List = SysUserInfoService.GetUserInfos(SelectUserName.Text, SelectUserRole.Text, SelectUserLoginBeginTime.Value, SelectUserLoginEndTime.Value, IsCheckByLoginTime.Checked);
|
|
|
|
|
UserInfoDataGridView.DataSource = null;
|
|
|
|
|
UserInfoDataGridView.DataSource = List;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|