forked from wenjy/HighWayIot
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.
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using HighWayIot.Repository.domain;
|
|
using HighWayIot.Repository.service;
|
|
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 UserAddForm : Form
|
|
{
|
|
/// <summary>
|
|
/// 角色数据库业务实例
|
|
/// </summary>
|
|
SysUserInfoService SysUserInfoService;
|
|
|
|
public UserAddForm(SysUserInfoService sysUserInfoService, string[] roleList)
|
|
{
|
|
InitializeComponent();
|
|
this.SysUserInfoService = sysUserInfoService;
|
|
UserRoleComboBox.DataSource = roleList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 确认添加按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ConfrimAddButton_Click(object sender, EventArgs e)
|
|
{
|
|
SysUserEntity userEntity = new SysUserEntity()
|
|
{
|
|
UserName = UserNameTextBox.Text,
|
|
Password = PasswordTextBox.Text,
|
|
UserRole = UserRoleComboBox.SelectedText
|
|
};
|
|
var list = SysUserInfoService.GetUserInfoByUserName(UserNameTextBox.Text);
|
|
if (list.Count() != 0)
|
|
{
|
|
MessageBox.Show("不能有相同用户名!", "结果", MessageBoxButtons.OK);
|
|
return;
|
|
}
|
|
if (SysUserInfoService.InsertUserInfo(userEntity))
|
|
{
|
|
MessageBox.Show("数据添加成功!", "结果", MessageBoxButtons.OK);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("数据添加失败!请看日志查询失败原因", "结果", MessageBoxButtons.OK);
|
|
}
|
|
this.Close();
|
|
this.Dispose();
|
|
}
|
|
}
|
|
}
|