Ejemplo n.º 1
0
 public Export_to_Pdf()
 {
     InitializeComponent();
     //Create object for pdf.
     document = new PdfDocument();
     page = document.AddPage();
     gfx = XGraphics.FromPdfPage(page);
     //Set by default values.
     font = new XFont("Arial", 12, XFontStyle.Regular);
     header_font = new XFont("Arial", 12, XFontStyle.Regular);
     page.Size = PageSize.A4;
     page.Orientation = PageOrientation.Portrait;
     //////////////////////////////////////////////////////////////////////
     //Create a fake questionanire to test the print process to pdf.
     if (questionaire != null)
     {
         List<Question> question_list = new List<Question>();
         List<Answer> answer_list = new List<Answer>();
         Answer ans = new Answer();
         ans.Answer_descr = "einai to dsfgdsfgsd";
         answer_list.Add(ans);
         answer_list.Add(ans);
         answer_list.Add(ans);
         Question quest = new Question() { AnswerList = answer_list };
         quest.Question_descr = "H ekfoonisi tis erotisis aytis einai blablbalbablbalblab";
         for (int i = 0; i < 10; i++)
         {
             question_list.Add(quest);
         }
     questionaire = new Quastionnaire.Model.Questionaire() { Questionaire_descr = "sdfsakdfjdflshsadflkjashflasdfkh", QuestionList = question_list };
     }
     //////////////////////////////////////////////////////////////////////
 }
Ejemplo n.º 2
0
        private void initialize_question(Quastionnaire.Model.Questionaire questionaire)
        {
            int number_of_erotiseis = 20;
            int number_of_answer = 4;
            //Dimiourgoume tin lista ton apantiseon.
            List<Answer> answs = new List<Answer>();
            Question quest = new Question() { AnswerList = answs};
            quest.Question_descr = "H ekfoonisi tis erotisis aytis einai blablbalbablbalblab";
            for (int i = 0; i < number_of_erotiseis; i++)
            {
                questionaire.QuestionList.Add(quest);
            }
            //MessageBox.Show(lst.Count().ToString());
            //Put the question in questionaire
            //questionaire.QuestionList.AddRange(lst);
            //List<int> deepCopy = new List<int>(originalList);
            MessageBox.Show(questionaire.QuestionList.Count.ToString());
            //List<Answer> answs = new List<Answer>();

            Answer ans = new Answer();
            ans.Answer_descr = "einai to dsfgdsfgsd";

            for (int i=0;i< questionaire.QuestionList.Count;i++)
            {
                for (int j = 0; j < number_of_answer; j++)
                {
                    questionaire.QuestionList.ElementAt(i).AnswerList.Add(ans);
                }
            }
        }
Ejemplo n.º 3
0
        private void lvQuestionaire_Question_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Question question = (Question)lvQuestionaire_Question.SelectedItem;

            if (question == null)
                return;

            selected_Questionaire_Question = question;
        }
Ejemplo n.º 4
0
        //Table
        private void lvQuestion_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lblLevel_Question_msg.Visibility = Visibility.Hidden;
            lblQuestion_Description_msg.Visibility = Visibility.Hidden;
            lblSubject_Question_msg.Visibility = Visibility.Hidden;
            lblDepartment_Question_msg.Visibility = Visibility.Hidden;

            Question question = (Question)lvQuestion.SelectedItem;

            if (question == null)
                return;

            selected_Question = question;

            Debug.WriteLine("Sos " + selected_Question.Question_descr);

            tbLevel_Question.Text = question.Level.ToString();
            tbOwner_Question.Text = question.Account.Username.ToString();
            tbDate_Question.Text = question.Date.ToString();
            tbQuestion_Description.Text = question.Question_descr.ToString();
            cbSubject_Question.Text = question.Subject.Subject_descr.ToString();
            cbDepartment_Question.Text = question.Department.Department_descr.ToString();

            //Load Answer Table
            lvAnswer.ItemsSource = question.AnswerList;
        }
Ejemplo n.º 5
0
        private void btClear_Question_Click(object sender, RoutedEventArgs e)
        {
            lblLevel_Question_msg.Visibility = Visibility.Hidden;
            lblQuestion_Description_msg.Visibility = Visibility.Hidden;
            lblSubject_Question_msg.Visibility = Visibility.Hidden;
            lblDepartment_Question_msg.Visibility = Visibility.Hidden;

            selected_Question = null;
            clearQuestionWidgets();
        }
Ejemplo n.º 6
0
        private void clearQuestionWidgets()
        {
            tbLevel_Question.Clear();
            tbOwner_Question.Clear();
            tbDate_Question.Clear();
            tbQuestion_Description.Clear();

            selected_Question = null;
        }
Ejemplo n.º 7
0
        //Question ToolBAr
        private void btSave_Question_Click(object sender, RoutedEventArgs e)
        {
            lblLevel_Question_msg.Visibility = Visibility.Hidden;
            lblQuestion_Description_msg.Visibility = Visibility.Hidden;
            lblSubject_Question_msg.Visibility = Visibility.Hidden;
            lblDepartment_Question_msg.Visibility = Visibility.Hidden;

            string level = tbLevel_Question.Text;
            DateTime date = DateTime.Now;
            string question_descr = tbQuestion_Description.Text;

            string subject = cbSubject_Question.Text;
            string department = cbDepartment_Question.Text;
            int subjectID = cbSubject_Question.SelectedIndex;
            int departmentID = cbDepartment_Question.SelectedIndex;

            if (checkQuestionForNullInput(level, question_descr, subject, department))
            {
                MessageBox.Show("Empty", "Confirmation");
                return;
            }
            if (checkQuestionForNullInput(level, question_descr, subject, department))
                return;

            int num = 0;
            if (!Int32.TryParse(level,out num))
            {
                lblLevel_Question_msg.Visibility = Visibility.Visible;
                lblLevel_Question_msg.Foreground = Brushes.Red;
                lblLevel_Question_msg.Content = "Integer Only";
                return;

            }

            Question question = new Question() { Subject = subjectList[subjectID], Department = subjectList[subjectID].DepList[departmentID], Question_descr = question_descr, Date = date, Level = num , AnswerList = new List<Answer>() };
            question.Account = CurrentUserInfo.CURENT_ACCOUNT;

            IQuestionDao questionDao = new QuestionDaoImpl();
            questionDao.saveQuestion(question);

            if (departmentID == cbDepartment_search.SelectedIndex && subjectID == cbSubject_search.SelectedIndex)
            {
                questionData.Add(question);
                lvQuestion.ItemsSource = null;
                lvQuestion.ItemsSource = questionData;
            }

            selected_Question = null;
            MessageBox.Show("Question Saved", "Confirmation");
        }
Ejemplo n.º 8
0
        private void btEdit_Question_Click(object sender, RoutedEventArgs e)
        {
            lblLevel_Question_msg.Visibility = Visibility.Hidden;
            lblQuestion_Description_msg.Visibility = Visibility.Hidden;
            lblSubject_Question_msg.Visibility = Visibility.Hidden;
            lblDepartment_Question_msg.Visibility = Visibility.Hidden;

            if (selected_Question == null)
            {
                MessageBox.Show("Select Question First", "Confirmation");
                return;
            }
            if(selected_Question.Account.Username != CurrentUserInfo.USERNAME)
            {
                MessageBox.Show("Now Alloed is Not Yours", "Confirmation");
                return;
            }

            string level = tbLevel_Question.Text;
            DateTime date = DateTime.Now;
            string question_descr = tbQuestion_Description.Text;

            string subject = cbSubject_Question.Text;
            string department = cbDepartment_Question.Text;
            int subjectID = cbSubject_Question.SelectedIndex;
            int departmentID = cbDepartment_Question.SelectedIndex;

            if (checkQuestionForNullInput(level, question_descr, subject, department))
                return;
            if (checkQuestionForNullInput(level, question_descr, subject, department))
                return;

            int num = 0;
            if (!Int32.TryParse(level, out num))
            {
                lblLevel_Question_msg.Visibility = Visibility.Visible;
                lblLevel_Question_msg.Foreground = Brushes.Red;
                lblLevel_Question_msg.Content = "Integer Only";
                return;

            }

            Question question = new Question() { Subject = subjectList[subjectID], Department = subjectList[subjectID].DepList[departmentID], Question_descr = question_descr, Date = date, Level = num };

            question.Id = selected_Question.Id;
            question.Account = CurrentUserInfo.CURENT_ACCOUNT;

            IQuestionDao questionDao = new QuestionDaoImpl();
            questionDao.updateQuestion(question);

            //Refresh
            questionData.Remove(selected_Question);
            questionData.Add(question);
            lvQuestion.ItemsSource = null;
            lvQuestion.ItemsSource = questionData;

            selected_Question = null;
            MessageBox.Show("Question Updated", "Confirmation");
        }
Ejemplo n.º 9
0
        private void btDelete_Question_Click(object sender, RoutedEventArgs e)
        {
            lblLevel_Question_msg.Visibility = Visibility.Hidden;
            lblQuestion_Description_msg.Visibility = Visibility.Hidden;
            lblSubject_Question_msg.Visibility = Visibility.Hidden;
            lblDepartment_Question_msg.Visibility = Visibility.Hidden;

            if (selected_Question == null)
            {
                MessageBox.Show("Select Question First", "Confirmation");
                return;
            }
            if (selected_Question.Account.Username != CurrentUserInfo.USERNAME)
            {
                MessageBox.Show("Now Alloed is Not Yours", "Confirmation");
                return;
            }

            IQuestionDao questionDao = new QuestionDaoImpl();
            questionDao.deleteQuestion(selected_Question);

            //Refresh
            questionData.Remove(selected_Question);
            lvQuestion.ItemsSource = null;
            lvQuestion.ItemsSource = questionData;

            lvAnswer.ItemsSource = null;

            clearQuestionWidgets();
            clearAnswerWidgets();

            selected_Question = null;
            MessageBox.Show("Question Deleted", "Confirmation");
        }