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.

60 lines
1.8 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)
{
InitializeComponent();
this.SysUserInfoService = sysUserInfoService;
}
/// <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();
}
}
}