| | |
| | | namespace HStation.WinFrmUI.Organize |
| | | using DevExpress.Mvvm.Native; |
| | | using DevExpress.Office.Utils; |
| | | using DevExpress.XtraEditors; |
| | | using Dm.filter.log; |
| | | using HStation.Dto; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using Yw.DAL.Basic; |
| | | |
| | | namespace HStation.WinFrmUI.Organize.Core._02_Employee |
| | | { |
| | | public partial class AddEmployeeDlg : DevExpress.XtraEditors.XtraForm |
| | | { |
| | | public AddEmployeeDlg() |
| | | { |
| | | InitializeComponent(); |
| | | loginUserForm.SetNoInput(); |
| | | } |
| | | |
| | | //完成 |
| | | private async void BtnOk_Click(object sender, EventArgs e) |
| | | private readonly HStation.Service.LoginUserMain _service = new(); |
| | | long _emloyeeId; |
| | | bool AddSuccessfully; |
| | | private async void AddEmloyeeUse() |
| | | { |
| | | var bll = new BLL.EmployeeMain(); |
| | | await bll.InsertLoginUserEx(new Dto.AddEmployeeMainDto |
| | | |
| | | _emloyeeId = await bll.InsertLoginUserEx(new Dto.UpdateEmployeeMainDto |
| | | { |
| | | AddTime = DateTime.Now, |
| | | ErpCode = emloyeeInfoCtrl.GetErpCode(), |
| | | PositonName = emloyeeInfoCtrl.GetPositonName(), |
| | | FirstName = emloyeeInfoCtrl.GetName(), |
| | | LastName = emloyeeInfoCtrl.GetEnglishNametextEdit(), |
| | | Telephone = emloyeeInfoCtrl.GetTelephone(), |
| | | DrawSignal = emloyeeInfoCtrl.GetDrawSignal(), |
| | | Email = emloyeeInfoCtrl.GetEmail(), |
| | | StaffStatus = emloyeeInfoCtrl.GetZhuangTai(), |
| | | RequirePasswordReset = emloyeeInfoCtrl.GetChongZhi(), |
| | | LastModifyTime = DateTime.Now, |
| | | |
| | | }, new Dto.AddUserLoginMapDto |
| | | { |
| | | ObjectType = Service.Organize.eObjectType.Employee, |
| | | ObjectID = 1123 |
| | | }, new Dto.AddLoginUserMainDto { LoginName = "duheng", PassWord = "123" }); |
| | | }, new Dto.AddLoginUserMainDto { LoginName = loginUserForm.GetLoginName(), PassWord = loginUserForm.GetPassWord(), CreateTime = DateTime.Now }); |
| | | AddSuccessfully = false; |
| | | } |
| | | private async void AddEmloyee() |
| | | { |
| | | //List<Model.LoginUserMain> all = _service.GetAll(); |
| | | var bll = new BLL.EmployeeMain(); |
| | | _emloyeeId = await bll.InsertEx(new Dto.UpdateEmployeeMainDto |
| | | { |
| | | AddTime = DateTime.Now, |
| | | ErpCode = emloyeeInfoCtrl.GetErpCode(), |
| | | PositonName = emloyeeInfoCtrl.GetPositonName(), |
| | | FirstName = emloyeeInfoCtrl.GetName(), |
| | | LastName = emloyeeInfoCtrl.GetEnglishNametextEdit(), |
| | | Telephone = emloyeeInfoCtrl.GetTelephone(), |
| | | DrawSignal = emloyeeInfoCtrl.GetDrawSignal(), |
| | | Email = emloyeeInfoCtrl.GetEmail(), |
| | | StaffStatus = emloyeeInfoCtrl.GetZhuangTai(), |
| | | RequirePasswordReset = emloyeeInfoCtrl.GetChongZhi(), |
| | | LastModifyTime = DateTime.Now, |
| | | }, new Dto.AddUserLoginMapDto |
| | | { |
| | | |
| | | LoginID = 11, |
| | | ObjectType = Service.Organize.eObjectType.Employee, |
| | | |
| | | }); |
| | | AddSuccessfully = false; |
| | | } |
| | | public long GetNewAddEmloyeeId() |
| | | { |
| | | return _emloyeeId; |
| | | } |
| | | public bool GetAddSuccessfully() |
| | | { |
| | | return AddSuccessfully; |
| | | } |
| | | // @"^[^@\s]+@[^@\s]+\.[^@\s]+$" |
| | | private bool IsValidEmail(string email) |
| | | { |
| | | return Regex.IsMatch(email, @"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$"); |
| | | } |
| | | |
| | | private async void QueDingsimpleButton_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | emloyeeInfoCtrl.IsValid(); |
| | | |
| | | if (!IsValidEmail(emloyeeInfoCtrl.GetEmail())&& !String.IsNullOrEmpty(emloyeeInfoCtrl.GetEmail())) |
| | | { |
| | | MessageBox.Show("邮箱格式错误!"); |
| | | return; |
| | | } |
| | | if (loginUserForm.GetPassWord() != loginUserForm.GetQueRenPassWord()) |
| | | { |
| | | MessageBox.Show("两次输入密码不一致、请重新输入!"); |
| | | AddSuccessfully = false; |
| | | return; |
| | | } |
| | | var bll = new BLL.EmployeeMain(); |
| | | EmployeeMainDto employeeDate = await bll.GetByErpCode(emloyeeInfoCtrl.GetErpCode()); |
| | | if (employeeDate != null && String.IsNullOrEmpty(emloyeeInfoCtrl.GetErpCode())) |
| | | { |
| | | MessageBox.Show("编号重复,请重新输入!"); |
| | | return; |
| | | } |
| | | if (String.IsNullOrEmpty(emloyeeInfoCtrl.GetEnglishNametextEdit())) |
| | | { |
| | | emloyeeInfoCtrl.SetEnglishNametextEdit("暂无"); |
| | | } |
| | | if (employeeDate != null) |
| | | { |
| | | MessageBox.Show("编号重复,请重新输入!"); |
| | | return; |
| | | } |
| | | if (CreateLogincheckEdit.Checked == true) |
| | | { |
| | | loginUserForm.IsValid(); |
| | | } |
| | | |
| | | //String.IsNullOrEmpty(emloyeeFrom.GetChongZhiText()) || String.IsNullOrEmpty(emloyeeFrom.GetZhuangTaiText()) || |
| | | if (String.IsNullOrEmpty(emloyeeInfoCtrl.GetDrawSignal())||String.IsNullOrEmpty(emloyeeInfoCtrl.GetErpCode()) || String.IsNullOrEmpty(emloyeeInfoCtrl.GetPositonName()) || String.IsNullOrEmpty(emloyeeInfoCtrl.GetName()) || String.IsNullOrEmpty(emloyeeInfoCtrl.GetTelephone()) || String.IsNullOrEmpty(emloyeeInfoCtrl.GetDrawSignal())) |
| | | { |
| | | MessageBox.Show("基本信息不能部分为空!"); |
| | | AddSuccessfully = false; |
| | | return; |
| | | } |
| | | |
| | | if (emloyeeInfoCtrl.GetTelephone().Length != 11) |
| | | { |
| | | MessageBox.Show("请输入正确格式的电话号!"); |
| | | AddSuccessfully = false; |
| | | return; |
| | | } |
| | | //if (emloyeeInfoCtrl.GetZhuangTai() != 0 && emloyeeInfoCtrl.GetZhuangTai() != 1) |
| | | //{ |
| | | // MessageBox.Show("在职状态请选择'离职'或'在职'!"); |
| | | // AddSuccessfully = false; |
| | | // return; |
| | | //} |
| | | //if (emloyeeInfoCtrl.GetChongZhi() != 0 && emloyeeInfoCtrl.GetChongZhi() != 1) |
| | | //{ |
| | | // MessageBox.Show("是否登录重置请选择'是'或'否'!"); |
| | | // AddSuccessfully = false; |
| | | // return; |
| | | //} |
| | | if (CreateLogincheckEdit.Checked == true) |
| | | { |
| | | if (String.IsNullOrEmpty(loginUserForm.GetLoginName()) || String.IsNullOrEmpty(loginUserForm.GetPassWord())) |
| | | { |
| | | MessageBox.Show("登录用户名或密码不能为空!"); |
| | | AddSuccessfully = false; |
| | | return; |
| | | } |
| | | AddEmloyeeUse(); |
| | | } |
| | | else |
| | | { |
| | | AddEmloyee(); |
| | | } |
| | | MessageBox.Show("添加成功!"); |
| | | AddSuccessfully = true; |
| | | this.Close(); |
| | | } |
| | | |
| | | private void QuXiaosimpleButton_Click(object sender, EventArgs e) |
| | | { |
| | | if (e == null) |
| | | { |
| | | return; |
| | | } |
| | | this.Close(); |
| | | } |
| | | |
| | | |
| | | |
| | | private void CreateLogincheckEdit_CheckedChanged(object sender, EventArgs e) |
| | | { |
| | | if (CreateLogincheckEdit.Checked == true) |
| | | { |
| | | loginUserForm.SetOffInput(); |
| | | } |
| | | else |
| | | { |
| | | loginUserForm.SetNoInput(); |
| | | } |
| | | } |
| | | } |
| | | } |