private void OnMenuItemClick(object sender, RoutedEventArgs e) { if (MainDataGrid.SelectedItem == null || MainDataGrid.Items.Count == 0) { return; } var drv = (DataRowView)MainDataGrid.SelectedItem; if (drv != null) { var result = MessageBox.Show("Вы действительно хотите удалить запись?", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { var techProblemId = Convert.ToInt32(drv.Row["TechnologyProblemID"]); var globalId = drv["GlobalID"].ToString(); var requestDate = Convert.ToDateTime(drv["RequestDate"]); var requestWorkerId = Convert.ToInt32(drv["RequestWorkerID"]); _taskClass.DeleteTaskByGlobalId(globalId); _tpr.DeleteTechnologyProblem(techProblemId); AdministrationClass.AddNewAction(21); if (MainDataGrid.Items.Count != 0) { MainDataGrid.SelectedIndex = 0; } NewsHelper.DeleteNews(requestDate, requestWorkerId); } } }
private void OnDeleteWorkerRequestButtonClick(object sender, RoutedEventArgs e) { var workerRequest = WorkerRequestsDataGrid.SelectedItem as DataRowView; if (workerRequest == null) { return; } if (MessageBox.Show("Вы действительно хотите удалить выбранную заявку?", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } var workerRequestId = Convert.ToInt64(workerRequest["WorkerRequestID"]); var workerId = Convert.ToInt64(workerRequest["WorkerID"]); var creationDate = Convert.ToDateTime(workerRequest["CreationDate"]); _workerRequestsClass.DeleteWorkerRequest(workerRequestId); AdministrationClass.AddNewAction(81); NewsHelper.DeleteNews(creationDate, (int)workerId); }