private void btDelete_Questionaire_Click(object sender, RoutedEventArgs e) { lblQuestionaire_Description_msg.Visibility = Visibility.Hidden; if (selected_Questionaire == null) { MessageBox.Show("Select Questionaire First", "Confirmation"); return; } if (selected_Questionaire.Account.Username != CurrentUserInfo.USERNAME) { MessageBox.Show("Now Alloed is Not Yours", "Confirmation"); return; } IQuestionaireDao questionaireDao = new QuestionaireDaoImpl(); questionaireDao.deleteQuestionaire(selected_Questionaire); listQuestionaire.Remove(selected_Questionaire); lvQuestionaire.ItemsSource = null; lvQuestionaire.ItemsSource = listQuestionaire; selected_Questionaire = null; MessageBox.Show("Deleted"); }
private void btnRemoveQuestionFromQuestionaire_Click(object sender, RoutedEventArgs e) { if (selected_Questionaire == null) { MessageBox.Show("Select Questionaire First", "Confirmation"); return; } if (selected_Questionaire_Question == null) { MessageBox.Show("Select Questionaire Question First", "Confirmation"); return; } if (selected_Questionaire.Account.Username != CurrentUserInfo.USERNAME) { MessageBox.Show("Now Alloed is Not Yours", "Confirmation"); return; } selected_Questionaire.QuestionList.Remove(selected_Questionaire_Question); IQuestionaireDao dao = new QuestionaireDaoImpl(); dao.removeQuestionFromQuestionaire(selected_Questionaire, selected_Questionaire_Question); lvQuestionaire_Question.ItemsSource = null; lvQuestionaire_Question.ItemsSource = selected_Questionaire.QuestionList; MessageBox.Show("Question Removed", "Confirmation"); }
private void btnQuestionairesearch_Click(object sender, RoutedEventArgs e) { cbUsernameType_Questionairesearch_msg.Visibility = Visibility.Hidden; cbDateType_Questionairesearch_msg.Visibility = Visibility.Hidden; lblUsername_Questionairesearch_msg.Visibility = Visibility.Hidden; lblDate_Questionairesearch_msg.Visibility = Visibility.Hidden; if (userNameTypeQuestionaire == UsernameType.Undefined) { MessageBox.Show("UsernameType Empty"); cbUsernameType_Questionairesearch_msg.Visibility = Visibility.Visible; cbUsernameType_Questionairesearch_msg.Foreground = Brushes.Red; cbUsernameType_Questionairesearch_msg.Content = "Empty"; return; } if (dateTypeQuestionaire == DateType.Undefined) { MessageBox.Show("DateType Empty"); cbDateType_Questionairesearch_msg.Visibility = Visibility.Visible; cbDateType_Questionairesearch_msg.Foreground = Brushes.Red; cbDateType_Questionairesearch_msg.Content = "Empty"; return; } string username=""; DateTime? date = new DateTime(); switch (userNameTypeQuestionaire) { case UsernameType.ALL: break; case UsernameType.MINE: username = CurrentUserInfo.USERNAME; break; case UsernameType.OTHER: username = tbUsername_Questionairesearch.Text; if (String.IsNullOrEmpty(username)) { MessageBox.Show("Username Field Empty"); lblUsername_Questionairesearch_msg.Visibility = Visibility.Visible; lblUsername_Questionairesearch_msg.Foreground = Brushes.Red; lblUsername_Questionairesearch_msg.Content = "Empty"; return; } //Check if Searched Username Existt if (!usernameExist(username)) { MessageBox.Show("Username Dosent Exist"); return; } break; } switch (dateTypeQuestionaire) { case DateType.ALL: break; case DateType.OTHER: date = dpDate_Questionairesearch.SelectedDate; if(date == null) { MessageBox.Show("Date Field Null"); lblDate_Questionairesearch_msg.Visibility = Visibility.Visible; lblDate_Questionairesearch_msg.Foreground = Brushes.Red; lblDate_Questionairesearch_msg.Content = "Empty"; return; } break; } DateTime dateTime = DateTime.Parse(date.ToString()); IQuestionaireDao dao = new QuestionaireDaoImpl(); List<Questionaire> listQuestionaire = dao.findQuestionare(username, dateTime, userNameTypeQuestionaire, dateTypeQuestionaire); lvQuestionaire.ItemsSource = listQuestionaire; MessageBox.Show("Questionaire Retrieved", "Confirmation"); }
private void btEdit_Questionaire_Click(object sender, RoutedEventArgs e) { lblQuestionaire_Description_msg.Visibility = Visibility.Hidden; if (selected_Questionaire == null) { MessageBox.Show("Select Questionaire First", "Confirmation"); return; } if (selected_Questionaire.Account.Username != CurrentUserInfo.USERNAME) { MessageBox.Show("Now Alloed is Not Yours", "Confirmation"); return; } string description = tbQuestionaire_Description.Text; Questionaire questionaire = new Questionaire() { Id = selected_Questionaire.Id,Date = DateTime.Now, Questionaire_descr = description, Account = CurrentUserInfo.CURENT_ACCOUNT }; IQuestionaireDao questionaireDao = new QuestionaireDaoImpl(); questionaireDao.updateQuestionaire(questionaire); listQuestionaire.Remove(selected_Questionaire); listQuestionaire.Add(questionaire); lvQuestionaire.ItemsSource = null; lvQuestionaire.ItemsSource = listQuestionaire; selected_Questionaire = null; MessageBox.Show("Edited"); }
//ToolBar private void btSave_Questionaire_Click(object sender, RoutedEventArgs e) { lblQuestionaire_Description_msg.Visibility = Visibility.Hidden; string description = tbQuestionaire_Description.Text; if (String.IsNullOrEmpty(description)) { lblQuestionaire_Description_msg.Visibility = Visibility.Visible; lblQuestionaire_Description_msg.Foreground = Brushes.Red; lblQuestionaire_Description_msg.Content = "Empty"; MessageBox.Show("Empty"); return; } Questionaire questionaire = new Questionaire() {Date = DateTime.Now , Questionaire_descr = description , HasQuestions = false , Account = CurrentUserInfo.CURENT_ACCOUNT}; IQuestionaireDao questionaireDao = new QuestionaireDaoImpl(); questionaireDao.saveQuestionaire(questionaire); listQuestionaire.Add(questionaire); lvQuestionaire.ItemsSource = null; lvQuestionaire.ItemsSource = listQuestionaire; selected_Questionaire = null; MessageBox.Show("Saved"); }