private void frmQuestion_Load(object sender, EventArgs e) { if (currentSubject != null && currentSubject.IdSchoolSubject != null && currentSubject.IdSchoolSubject != "") { //string dummyId = currentSubject.IdSchoolSubject; //currentSubject = db.GetSchoolSubject(dummyId); cmbSchoolSubject.SelectedValue = currentSubject.IdSchoolSubject; } switch (formType) { case QuestionFormType.CreateSeveralQuestions: { btnNewQuestion.Visible = true; btnSaveQuestion.Text = "Salva"; break; } case QuestionFormType.EditOneQuestion: { btnNewQuestion.Visible = false; btnSaveQuestion.Text = "Salva e Esci"; break; } } cmbQuestionType.SelectedValue = currentQuestion.IdQuestionType; if (currentQuestion != null) { if (currentQuestion.IdQuestion != 0) { currentQuestion = db.GetQuestionById(currentQuestion.IdQuestion); } txtIdQuestion.Text = currentQuestion.IdQuestion.ToString(); txtQuestionText.Text = currentQuestion.Text; txtQuestionImage.Text = currentQuestion.QuestionImage; txtDuration.Text = currentQuestion.Duration.ToString(); txtWeight.Text = currentQuestion.Weight.ToString(); txtDifficulty.Text = currentQuestion.Difficulty.ToString(); tagsList = db.TagsOfAQuestion(currentQuestion.IdQuestion); lstTags.DataSource = tagsList; Commons.LastTagsChosen = tagsList; // show the path of the topic of the question if (currentTopic != null) { txtTopic.Text = dbMptt.GetTopicPath(currentTopic.Id); } answersList = db.GetAnswersOfAQuestion(currentQuestion.IdQuestion); dgwAnswers.DataSource = answersList; } else { currentQuestion = new Question(); } txtImagesPath.Text = Commons.PathImages; }
internal frmQuestion(QuestionFormType Type, Question Question, SchoolSubject Subject, Class Class, Topic Topic) { InitializeComponent(); // fills the lookup tables' combos List <QuestionType> listQuestions = db.GetListQuestionTypes(true); cmbQuestionType.DisplayMember = "Name"; cmbQuestionType.ValueMember = "idQuestionType"; cmbQuestionType.DataSource = listQuestions; List <SchoolSubject> listSubjects = db.GetListSchoolSubjects(true); cmbSchoolSubject.DisplayMember = "Name"; cmbSchoolSubject.ValueMember = "idSchoolSubject"; cmbSchoolSubject.DataSource = listSubjects; currentClass = Class; currentSubject = Subject; currentQuestion = Question; formType = Type; if (formType == QuestionFormType.EditOneQuestion) { currentQuestion = db.GetQuestionById(Question.IdQuestion); } if (Topic != null) { currentTopic = db.GetTopicById(Topic.Id); if (currentTopic.Id != 0) { txtTopic.Text = dbMptt.GetTopicPath(currentTopic.Id); } } //if (Subject != null) // idSchoolSubject = Subject.IdSchoolSubject; }
private void dgwAnswers_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { dgwAnswers.Rows[e.RowIndex].Selected = true; List <Answer> ls = (List <Answer>)(dgwAnswers.DataSource); Answer a = ls[e.RowIndex]; Question q = db.GetQuestionById(a.IdQuestion); frmQuestion fq = new frmQuestion(frmQuestion.QuestionFormType.EditOneQuestion, q, null, null, null); fq.Show(); } }
private void btnChoose_Click(object sender, EventArgs e) { if (dgwQuestions.SelectedRows.Count > 0) { //int key = int.Parse(dgwQuestions.SelectedRows[0].Cells[6].Value.ToString()); int key = (int)dgwQuestions.SelectedRows[0].Cells[6].Value; if (grandparentForm != null) { // form called by student's assessment form grandparentForm.CurrentQuestion = db.GetQuestionById(key); grandparentForm.DisplayCurrentQuestion(); } } else { MessageBox.Show("Scegliere una domanda nella griglia"); return; } }