示例#1
0
        private void toolStripMenuItem_AddAttitudeDefinitions_Click(object sender, EventArgs e)
        {
            MaterialMessageComboBox.MessageBoxResult result = MaterialMessageComboBox.MessageBoxResult.None;

            long AttitudeID = Convert.ToInt64(txt_EditAttitudeDetailsName.Tag);

            if (AttitudeID != -1)
            {
                result = MaterialMessageComboBox.Show("Select survey and question.", "Easy Survey - Add New Attitude Definition", MaterialMessageComboBox.MessageBoxButtons.OKCancel, AttitudeID);
            }

            if (result == MaterialMessageComboBox.MessageBoxResult.OK)
            {
                //long NewSurveyID = MaterialMessageComboBox.Answer1;
                long NewQuestionID = MaterialMessageComboBox.Answer2;

                using (QuestionController questionController = new QuestionController())
                    using (AttitudeDefinitionController attitudeDefinitionController = new AttitudeDefinitionController())
                    {
                        string QuestionName = questionController.Get(NewQuestionID).Question1;
                        if (attitudeDefinitionController.AddRelation(AttitudeID, NewQuestionID))
                        {
                            listView_EditAttitudeDefinition.Items.Add(new ListViewItem()
                            {
                                Text = QuestionName, Tag = NewQuestionID
                            });
                        }
                    }
            }
        }
示例#2
0
        private void toolStripMenuItem_EditAttitudeDefinitions_Click(object sender, EventArgs e)
        {
            int SelectedAttitudeDefinitionCount = listView_EditAttitudeDefinition.SelectedItems.Count;

            MaterialMessageComboBox.MessageBoxResult result = MaterialMessageComboBox.MessageBoxResult.None;

            if (SelectedAttitudeDefinitionCount == 0)
            {
                return;
            }

            int CurrentAttitudeDefinition = 0;

            using (SurveyController surveyController = new SurveyController())
                using (QuestionController questionController = new QuestionController())
                {
                    long AttitudeID = Convert.ToInt64(txt_EditAttitudeDetailsName.Tag);
                    long SurveyID   = -1;
                    long QuestionID = -1;

                    foreach (ListViewItem SelectedAttitudeDefinition in listView_EditAttitudeDefinition.SelectedItems)
                    {
                        QuestionID = Convert.ToInt64(SelectedAttitudeDefinition.Tag);
                        SurveyID   = surveyController.GetByQuestion(QuestionID).SurveyID;

                        result = MaterialMessageComboBox.MessageBoxResult.None;
                        result = MaterialMessageComboBox.Show("Editeaza definitia atitudinii:", "Easy Survey - Edit Attitude Definition (" + ++CurrentAttitudeDefinition + "/" + SelectedAttitudeDefinitionCount + ")", MaterialMessageComboBox.MessageBoxButtons.OKCancel, AttitudeID, SurveyID, QuestionID);

                        if (result == MaterialMessageComboBox.MessageBoxResult.OK)
                        {
                            AttitudeDefinitionController attitudeDefinitionController = new AttitudeDefinitionController();

                            long NewSurveyID   = MaterialMessageComboBox.Answer1;
                            long NewQuestionID = MaterialMessageComboBox.Answer2;

                            attitudeDefinitionController.Update(AttitudeID, QuestionID, NewQuestionID);

                            string NewQuestionName = questionController.Get(NewQuestionID).Question1;

                            int AttitudeDefinitionIndex = listView_EditAttitudeDefinition.Items.IndexOf(SelectedAttitudeDefinition);
                            listView_EditAttitudeDefinition.Items[AttitudeDefinitionIndex].Text = NewQuestionName;
                            listView_EditAttitudeDefinition.Items[AttitudeDefinitionIndex].Tag  = NewQuestionID;
                        }
                        else if (result == MaterialMessageComboBox.MessageBoxResult.None)
                        {
                            break;
                        }
                    }
                }
        }