Shuxia Ning
2024-10-29 a434b83043a5646d5dd99c3e934cc8a30ac6165f
WinFrmUI/HStation.WinFrmUI.Organize.Core/02-Employee/EmployeeMgrMainPanel.cs
@@ -35,7 +35,7 @@
            employeeModelBindingSource.DataSource = _AllEmployee;
            this.employeeModelBindingSource.ResetBindings(false);
        }
        //添加
        private void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -46,7 +46,6 @@
                return;
            }
            DateShow();
            this.employeeModelBindingSource.ResetBindings(false);
        }
        //编辑
@@ -61,11 +60,11 @@
                return;
            }
            dlg.IncomingData(currentVm);
            if (dlg.ShowDialog() == DialogResult.OK)
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                DateShow();
                this.employeeModelBindingSource.ResetBindings(false);
                return;
            }
            DateShow();
        }
@@ -81,7 +80,7 @@
                e.Value = employee.StaffStatus == eJobType.exist ? "在职" : "离职";
            }
            if(e.Column == colRequirePasswordReset)
            if (e.Column == colRequirePasswordReset)
            {
                var employee = e.Row as HStation.Vmo.EmployeeMain;
                if (employee == null)
@@ -93,30 +92,28 @@
        }
        //删除
        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("删除成功!");
            }
        }
        ////删除
        //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
        //    {
        //        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("删除成功!");
        //        }
        //    }
        //}
    }
}