private void btnAdd_Click(object sender, RoutedEventArgs e) { ManagementResource.Question s = new ManagementResource.Question(); s.QuestionStateID = loginstate; s.AnswerTypeID = 1; mr.StudioMQuestion.Add(s); }
private void btnSave_Click(object sender, RoutedEventArgs e) { Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem)); ManagementResource.Question s = (ManagementResource.Question)row.Item; bool exists = false; s.QuestionText = RemoveExtraCarriageReturn(s.QuestionText); if (s.QuestionText != null && s.QuestionText.Trim() != "") { if (s.QuestionID == 0) { if (!QuestionExists(s)) { exists = false; } else { exists = true; } } if (exists) { MessageBox.Show("This question already exists."); } else { try { mr.SaveQuestion(s); if (row.DetailsVisibility == Visibility.Visible) { row.DetailsVisibility = Visibility.Collapsed; } btnSearch_Click(null, null); } catch (Exception ex) { } } } else { MessageBox.Show("Please enter a question text."); } }
private bool QuestionExists(ManagementResource.Question s) { return(mr.QuestionExists(s.AnswerTypeID, s.QuestionText)); }