| | |
| | | using DevExpress.CodeParser; |
| | | using DevExpress.XtraEditors.TextEditController.Win32; |
| | | using DevExpress.XtraGrid; |
| | | using HStation.Dto; |
| | | using HStation.Model; |
| | | using HStation.Vmo; |
| | | using HStation.WinFrmUI.Organize.Core._00_UserControl; |
| | | using HStation.WinFrmUI.Organize.Core._02_Employee; |
| | | using Mapster; |
| | |
| | | //ShowEmloyee(); |
| | | } |
| | | |
| | | List<EmployeeViewModel> _AllEmployee = new List<EmployeeViewModel>(); |
| | | List<HStation.Vmo.EmployeeMain> _AllEmployee = new List<HStation.Vmo.EmployeeMain>(); |
| | | |
| | | private void DateShow() |
| | | private async void DateShow() |
| | | { |
| | | HStation.Service.EmployeeMain _service = new(); |
| | | HStation.BLL.EmployeeMain _service = new(); |
| | | _AllEmployee.Clear(); |
| | | var _All = _service.GetAll(); |
| | | List<EmployeeViewModel> _AllDateSource = _All.Adapt<List<EmployeeMain>, List<EmployeeViewModel>>(); |
| | | var _All = await _service.GetAll(); |
| | | |
| | | foreach (EmployeeViewModel emp in _AllDateSource) |
| | | foreach (HStation.Vmo.EmployeeMain emp in _All) |
| | | { |
| | | emp.StaffStatusLabel = emp.StaffStatus == 0 ? "离职" : "在职"; |
| | | emp.RequirePasswordResetLabel = emp.RequirePasswordReset == 0 ? "否" : "是"; |
| | | if (String.IsNullOrEmpty(emp.LastName)) |
| | | { |
| | | emp.LastName = "暂无"; |
| | | } |
| | | //HStation.WinFrmUI.Organize.EmployeeViewModel All = new HStation.WinFrmUI.Organize.EmployeeViewModel(emp); |
| | | _AllEmployee.Add(emp); |
| | | } |
| | | employeeViewModelBindingSource.DataSource = _AllEmployee; |
| | | this.employeeViewModelBindingSource.ResetBindings(false); |
| | | employeeModelBindingSource.DataSource = _AllEmployee; |
| | | this.employeeModelBindingSource.ResetBindings(false); |
| | | } |
| | | //public void ShowEmloyee() |
| | | //{ |
| | | // List<Model.EmployeeMain> all = _service.GetAll(); |
| | | // employeeViewModelBindingSource.DataSource = all; |
| | | //} |
| | | |
| | | |
| | | |
| | | //添加 |
| | | private async void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var dlg = new AddEmployeeDlg(); |
| | | dlg.ShowDialog(); |
| | | if (dlg.GetAddSuccessfully() != true) |
| | | if (dlg.ShowDialog() != DialogResult.OK) |
| | | { |
| | | return; |
| | | } |
| | | var bll = new BLL.EmployeeMain(); |
| | | var NewAddemployeeDate = await bll.GetByID(dlg.GetNewAddEmloyeeId()); |
| | | EmployeeViewModel _NewAddemployeeDate = NewAddemployeeDate.Adapt<EmployeeMainDto, EmployeeViewModel>(); |
| | | _NewAddemployeeDate.StaffStatusLabel = _NewAddemployeeDate.StaffStatus == 0 ? "离职" : "在职"; |
| | | _NewAddemployeeDate.RequirePasswordResetLabel = _NewAddemployeeDate.RequirePasswordReset == 0 ? "否" : "是"; |
| | | _AllEmployee.Add(_NewAddemployeeDate); |
| | | this.employeeViewModelBindingSource.ResetBindings(false); |
| | | DateShow(); |
| | | } |
| | | |
| | | //编辑 |
| | |
| | | { |
| | | var dlg = new UpdateEmployeeDlg(); |
| | | var currentVm = this.gridView1.GetCurrentViewModel(_AllEmployee); |
| | | //var a =currentVm.ErpCode; |
| | | if (currentVm == null) |
| | | { |
| | | MessageBoxHelper.ShowWarning("请选择数据行"); |
| | | return; |
| | | } |
| | | dlg.SetDate(currentVm.ID); |
| | | dlg.ShowDialog(); |
| | | dlg.IncomingData(currentVm); |
| | | if (dlg.ShowDialog() != DialogResult.OK) |
| | | { |
| | | return; |
| | | } |
| | | DateShow(); |
| | | this.employeeViewModelBindingSource.ResetBindings(false); |
| | | |
| | | } |
| | | |
| | | ////删除 |
| | | //private async void BtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //{ |
| | | // var bll = new BLL.EmployeeMain(); |
| | | // var currentVm = this.gridView1.GetCurrentViewModel(_AllEmployee); |
| | | // if (currentVm == null) |
| | | // { |
| | | // MessageBox.Show("请选择数据行!"); |
| | | // } |
| | | // else |
| | | // { |
| | | private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) |
| | | { |
| | | if (e.Column == colStaffStatus) |
| | | { |
| | | var employee = e.Row as HStation.Vmo.EmployeeMain; |
| | | if (employee == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // if (MessageBox.Show("确认删除员工" + currentVm.ID + "吗?", "删除", MessageBoxButtons.OKCancel) == DialogResult.Cancel) |
| | | // { |
| | | // return; |
| | | // } |
| | | // if (await bll.DeleteByID(currentVm.ID)) |
| | | // { |
| | | // _AllEmployee.Remove(currentVm); |
| | | // this.employeeViewModelBindingSource.ResetBindings(false); |
| | | // MessageBox.Show("删除成功!"); |
| | | // } |
| | | // } |
| | | //} |
| | | e.Value = employee.StaffStatus == eJobType.exist ? "在职" : "离职"; |
| | | } |
| | | if (e.Column == colRequirePasswordReset) |
| | | { |
| | | var employee = e.Row as HStation.Vmo.EmployeeMain; |
| | | if (employee == null) |
| | | { |
| | | return; |
| | | } |
| | | e.Value = employee.RequirePasswordReset == 1 ? "是" : "否"; |
| | | } |
| | | |
| | | |
| | | } |
| | | //删除 |
| | | private async void barButtonItemDelEmployee_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var currentVm = this.gridView1.GetCurrentViewModel(_AllEmployee); |
| | | HStation.BLL.EmployeeMain _service = new(); |
| | | if (currentVm == null) |
| | | { |
| | | MessageBox.Show("请选择数据行!"); |
| | | return; |
| | | } |
| | | if (MessageBox.Show("确认删除这个员工吗?" , "删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) |
| | | { |
| | | return; |
| | | } |
| | | if (await _service.DeleteByID(currentVm.EmployeeID)) |
| | | { |
| | | _AllEmployee.Remove(currentVm); |
| | | this.employeeModelBindingSource.ResetBindings(false); |
| | | MessageBox.Show("删除成功!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |