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 { /// /// 角色数据库业务实例 /// SysUserInfoService SysUserInfoService; public UserAddForm(SysUserInfoService sysUserInfoService, string[] roleList) { InitializeComponent(); this.SysUserInfoService = sysUserInfoService; UserRoleComboBox.DataSource = roleList; } /// /// 确认添加按钮 /// /// /// 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(); } } }