using System; using System.Windows.Forms; using DevComponents.DotNetBar; using IOM_cs.irisDb; using IOM_cs.irisDb.model; using IOM_cs.irisDb.service; namespace IOM_cs.insertForm.sysSetting { public partial class CtrlUserAdd : Office2007Form { IUserService iUserService = (IUserService)DbService.getEntity("IUserService"); public CtrlUserAdd() { InitializeComponent(); } private void roundButton1_Click(object sender, EventArgs e) { User user = new User(); user.UserId = textBoxUserId.Text; user.Name = textBoxUserName.Text; user.PoliceId = textBoxPoliceId.Text; user.UserNumber = textBoxUseNumber.Text; user.Password = textBoxPassword.Text; user.UserType = 1; user.CreatTime = DateTime.Now; user.IsAdmin = 1; user.IsSynch = "1"; user.SynchMessage = "未同步"; user.Active = 1; if (textBoxUserId.Text.Trim() == "") { MessageBox.Show(this, "账号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (iUserService.GetUserCountByUserId(textBoxUserId.Text.Trim()) > 0) { MessageBox.Show("已存在该账号"); return; } if (textBoxUserName.Text.Trim() == "") { MessageBox.Show(this, "姓名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { if (!Validation.CheckName(textBoxUserName.Text.Trim())) { MessageBox.Show(this, "请输入真实姓名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (textBoxPoliceId.Text.Trim() == "") { MessageBox.Show(this, "警务编号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (textBoxPassword.Text.Trim() == "") { MessageBox.Show(this, "密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (textBoxUseNumber.Text.Trim() == "") { MessageBox.Show(this, "身份证不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { if (!Validation.CheckIDCard(textBoxUseNumber.Text.Trim())) { MessageBox.Show(this, "请输入正确的身份证号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } try { if (iUserService.AddUser(user) == 0) { MessageBox.Show("添加成功", "提示"); DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show("添加失败", "提示"); } } private void roundButton2_Click(object sender, EventArgs e) { this.Close(); } } }