private void Window_Loaded_1(object sender, RoutedEventArgs e) { IdNameDAL idNameDAL = new IdNameDAL(); cbGender.ItemsSource = idNameDAL.GetByCategory("性别"); cbMarriage.ItemsSource = idNameDAL.GetByCategory("婚姻状况"); cbPartyStatus.ItemsSource = idNameDAL.GetByCategory("政治面貌"); cbEducation.ItemsSource = idNameDAL.GetByCategory("学历"); cbDepatment.ItemsSource = new DepartmentDAL().ListAll(); if (IsAddNew) { Employee employee = new Employee(); employee.InDate = DateTime.Today;//给默认值 employee.ContractStartDay = DateTime.Today; employee.ContractEndDay = DateTime.Today.AddYears(1); employee.Nationality = "汉族"; employee.Email = "@itcast.cn"; //employee.Number = "YG"; employee.Number = new SettingDAL().GetValue("员工工号前缀"); gridEmployee.DataContext = employee; } else { Employee employee = new EmployeeDAL().GetById(EditingId); gridEmployee.DataContext = employee; if (employee.Photo != null) { ShowImg(employee.Photo); } } }