private void datagrid_show(SelectStage selectstage) { this.dg_abnormal_event.ItemsSource = null; string category = this.cbb_category.Text; string application_unit = this.cbb_application_unit.Text; DateTime startdate = ((dp_startdate.SelectedDate == null) ? DateTime.MinValue : (DateTime)dp_startdate.SelectedDate); DateTime enddate = ((dp_enddate.SelectedDate == null) ? DateTime.MinValue : (DateTime)dp_enddate.SelectedDate); List <Abnormal_event_ViewModel> abnormal_events = new List <Abnormal_event_ViewModel>(); Abnormal_event_ViewModel abnormal_Event_ViewModel = new Abnormal_event_ViewModel(); ObservableCollection <abnormal_event_list> abnormal_event_itemlist = new ObservableCollection <abnormal_event_list>(); switch (selectstage) { case SelectStage.nostage: abnormal_events = abnormal_Event_ViewModel.SelectAbnormal_Event_byStage("", category, application_unit, startdate, enddate); break; case SelectStage.newevent: abnormal_events = abnormal_Event_ViewModel.SelectAbnormal_Event_byStage("新事件", category, application_unit, startdate, enddate); break; case SelectStage.review: abnormal_events = abnormal_Event_ViewModel.SelectAbnormal_Event_byStage("成案審核", category, application_unit, startdate, enddate); break; case SelectStage.processing: abnormal_events = abnormal_Event_ViewModel.SelectAbnormal_Event_byStage("處理中", category, application_unit, startdate, enddate); break; case SelectStage.endprocessing: abnormal_events = abnormal_Event_ViewModel.SelectAbnormal_Event_byStage("事件完成", category, application_unit, startdate, enddate); break; } foreach (var row in abnormal_events) { abnormal_event_itemlist.Add(new abnormal_event_list() { 事件案號 = row.Abnormal_event_ID, 事件名稱 = row.Abnormal_event, 異常事件類別 = row.event_category, 志工 = row.Volunteer_name, 運用單位 = row.Application_unit, 處理階段 = row.Stage, 通報時間 = row.Notification_date, 結案時間 = row.Closing_date }); } this.dg_abnormal_event.ItemsSource = abnormal_event_itemlist; if (selectstage == SelectStage.nostage) { this.dg_abnormal_event.Columns[0].Visibility = Visibility.Collapsed; } else { this.dg_abnormal_event.Columns[0].Visibility = Visibility.Visible; } }