Exemplo n.º 1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (_TableRowId == null || _TableRowId.Length == 0)
            {
                DatasetManager.deleteQuestionFromDataSet(_listIndex);
                CreateQuizParentWindow.QuestionsListFlowLoayoutPanel.Controls.RemoveAt(_listIndex);//this will update the list.
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.QuestionDeletedInfoMessage);
            }
            else
            {
                DatasetManager.deleteQuestionFromDataBase(Int32.Parse(_TableRowId));//this will delete question from dataset.

                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.QuestionDeletedInfoMessage);
                CreateQuizParentWindow.QuestionsListFlowLoayoutPanel.Controls.RemoveAt(_listIndex);//this will update the list.
            }
        }
        private void buttonCQSaveQuestion_Click(object sender, EventArgs e)
        {
            //Before saving a question we need to check few things.
            //1. is any option from options is selected.
            //2. is only one option is selected.

            //Accessing the collection of objects from flow panel.
            if (doesFlowLayoutContainRadioButton() && comboBoxCOptionsType.SelectedIndex == 0)
            {
                comboBoxCOptionsType.SelectedIndex = 1;
            }

            if (comboBoxCOptionsType.SelectedIndex == 0)
            {
                //Becuase this is only for mcqs not true false.
                bool isChec = true, isOneChecked = false;
                int  index = 0;
                if (comboBoxCOptionsType.SelectedIndex == 0)
                {
                    foreach (CheckBox controls in flowLayoutPanelCQOptions.Controls)
                    {
                        if (controls.Checked)
                        {
                            isChec = false;
                            index++;
                        }
                        if (index >= 2)
                        {
                            isOneChecked = true;
                            break;
                        }
                    }
                }

                if (flowLayoutPanelCQOptions.Controls.Count == 0)
                {
                    //this means no options are added
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NotAddedOptionsErrorMessage);
                }
                else if (isOneChecked)
                {
                    //this means more than one check box are selected.
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.MultipleOptionSelectedErrorMessage);
                }
                else if (isChec)
                {
                    //this means no option from list is selected;
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnSelectedErrorMessage);
                }

                else
                {
                    //Here we will add question in current dataset

                    //so we need to do 2 things here
                    //1. generate a string having all options seprated with ';'

                    String asnwers     = "";
                    String rightAnswer = "";
                    foreach (var controls in flowLayoutPanelCQOptions.Controls)
                    {
                        if (controls is RadioButton)
                        {
                            RadioButton radioButton = controls as RadioButton;
                            //if options are true and false.
                            asnwers += radioButton.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                            if (radioButton.Checked)
                            {
                                rightAnswer = radioButton.Text;
                            }
                        }
                        else
                        {
                            //if mcsqs
                            CheckBox checkBox = controls as CheckBox;
                            asnwers += checkBox.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                            if (checkBox.Checked)
                            {
                                rightAnswer = checkBox.Text;
                            }
                        }
                    }

                    // DatasetManager.insertRowInTable(ref questionDataTable, textBoxQuestionText.Text, asnwers, rightAnswer);

                    DatasetManager.insertRowInTable(textBoxQuestionText.Text, asnwers, rightAnswer);


                    //Here we will store in dataset.
                    CLEARALL();
                }
            }
            else if (comboBoxCOptionsType.SelectedIndex == 1)
            {
                bool isChec = true, isOneChecked = false;
                int  index = 0;

                foreach (var controls in flowLayoutPanelCQOptions.Controls)
                {
                    CheckBox checkBox;
                    if (controls is RadioButton)
                    {
                        isChec = false;
                        break;
                    }
                    else
                    {
                        checkBox = controls as CheckBox;
                    }
                    if (checkBox.Checked)
                    {
                        isChec = false;
                        index++;
                    }
                    if (index >= 2)
                    {
                        isOneChecked = true;
                        break;
                    }
                }


                if (flowLayoutPanelCQOptions.Controls.Count == 0)
                {
                    //this means no options are added
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NotAddedOptionsErrorMessage);
                }
                else if (isOneChecked)
                {
                    //this means more than one check box are selected.
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.MultipleOptionSelectedErrorMessage);
                }
                else if (isChec)
                {
                    //this means no option from list is selected;
                    GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnSelectedErrorMessage);
                }
                else
                {
                    String asnwers     = "";
                    String rightAnswer = "";
                    foreach (var controls in flowLayoutPanelCQOptions.Controls)
                    {
                        if (controls is RadioButton)
                        {
                            RadioButton radioButton = controls as RadioButton;
                            //if options are true and false.
                            asnwers += radioButton.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                            if (radioButton.Checked)
                            {
                                rightAnswer = radioButton.Text;
                            }
                        }
                        else
                        {
                            //if mcsqs
                            CheckBox checkBox = controls as CheckBox;
                            asnwers += checkBox.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                            if (checkBox.Checked)
                            {
                                rightAnswer = checkBox.Text;
                            }
                        }
                    }

                    //Here we will store in dataset.



                    DatasetManager.insertRowInTable(textBoxQuestionText.Text, asnwers, rightAnswer);

                    CLEARALL();

                    GlobalStaticVariablesAndMethods.currentQuectionNumber = GlobalStaticVariablesAndMethods.currentQuectionNumber + 1;

                    labelQuestionNumber.Text = "Question Number: " + GlobalStaticVariablesAndMethods.currentQuectionNumber;
                }
            }
            else if (comboBoxCOptionsType.SelectedIndex < 0)
            {
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NoOptionTypeSelectedErrorMessage);
            }
        }
Exemplo n.º 3
0
 private void buttonSaveQuizInSystem_Click(object sender, EventArgs e)
 {
     DatasetManager.saveQuizToDatabase();//save changes to database
     GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved = true;
     GlobalStaticVariablesAndMethods.CreateInfoMesssage(GlobalStaticVariablesAndMethods.ChangesSavedInfoMessage);
 }
Exemplo n.º 4
0
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions = DatasetManager.createDataSetForHoldingQuestions(GlobalStaticVariablesAndMethods.currentSubjectName);

                openQuizParentWindow.MdiParent = form1;
                openQuizParentWindow.Show();
                openQuizParentWindow.BringToFront();
                openQuizParentWindow.Dock = DockStyle.Top;



                this.Hide();
            }
            else
            {
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NoTopicSelectedErrorMessage);
            }
        }
Exemplo n.º 5
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count > 0)
            {
                createQuizParentWindow.MdiParent = form1;
                createQuizParentWindow.Show();
                createQuizParentWindow.BringToFront();
                createQuizParentWindow.Dock = DockStyle.Top;



                //setting the isQuizSavedflag;

                GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved = false;

                //Create a dataset to hold the questions...

                GlobalStaticVariablesAndMethods.currentQuectionNumber = 1;

                GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions = DatasetManager.createDataSetForHoldingQuestions(GlobalStaticVariablesAndMethods.currentSubjectName);
                GlobalStaticVariablesAndMethods.currentSizeOfDataSet = GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows.Count;

                //We will now use this gloabl variable to store questions.
                this.Hide();
            }
            else
            {
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NoTopicSelectedErrorMessage);
            }
        }
Exemplo n.º 6
0
        private void buttonSaved_Click(object sender, EventArgs e)
        {
            bool isChec = true, isOneChecked = false;
            int  index = 0;

            //befor saving changes .... lets checkfew things.
            foreach (CheckBox controls in _options)
            {
                if (controls.Checked)
                {
                    isChec = false;
                    index++;
                }
                if (index >= 2)
                {
                    isOneChecked = true;
                    break;
                }
            }

            if (CreateQuizParentWindow.QuestionsListFlowLoayoutPanel.Controls.Count == 0)
            {
                //this means no options are added
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NotAddedOptionsErrorMessage);
            }
            else if (isOneChecked)
            {
                //this means more than one check box are selected.
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.MultipleOptionSelectedErrorMessage);
            }
            else if (isChec)
            {
                //this means no option from list is selected;
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnSelectedErrorMessage);
            }

            else
            {
                //Here we will add question in current dataset

                //so we need to do 2 things here
                //1. generate a string having all options seprated with ';'

                String asnwers     = "";
                String rightAnswer = "";
                foreach (var controls in _options)
                {
                    if (controls is RadioButton)
                    {
                        RadioButton radioButton = controls as RadioButton;
                        //if options are true and false.
                        asnwers += radioButton.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                        if (radioButton.Checked)
                        {
                            rightAnswer = radioButton.Text;
                        }
                    }
                    else
                    {
                        //if mcsqs
                        CheckBox checkBox = controls as CheckBox;
                        asnwers += checkBox.Text + GlobalStaticVariablesAndMethods.seperatorCharactor;
                        if (checkBox.Checked)
                        {
                            rightAnswer = checkBox.Text;
                        }
                    }
                }

                //Here we will update dataset.
                DatasetManager.upddateDataSet(richTextBoxListItemQuestion.Text, asnwers, rightAnswer, Int32.Parse(TableRowId));
                GlobalStaticVariablesAndMethods.CreateInfoMesssage(GlobalStaticVariablesAndMethods.ChangesSavedInDataseInfoMessage);
            }
        }
Exemplo n.º 7
0
        private void buttonCreateNewQuiz_Click(object sender, EventArgs e)
        {
            if (GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved)
            {
                HideChild();

                GlobalStaticVariablesAndMethods.currentTopicName   = null; //this will be setted from dialog window which we are opening down
                GlobalStaticVariablesAndMethods.currentSubjectName = null; //this will be setted from dialog window which we are opening down

                GetQuizTopicNameWindow getQuizTopicNameWindow = new GetQuizTopicNameWindow();
                getQuizTopicNameWindow.ShowDialog();


                if (GlobalStaticVariablesAndMethods.currentTopicName != null)
                {
                    //this means some topic name is provided
                    createQuizParentWindow.MdiParent = this;
                    createQuizParentWindow.Show();
                    createQuizParentWindow.BringToFront();
                    createQuizParentWindow.Dock = DockStyle.Top;

                    //setting the isQuizSavedflag;

                    GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved = false;

                    //Create a dataset to hold the questions...

                    GlobalStaticVariablesAndMethods.currentQuectionNumber = 1;

                    GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions = DatasetManager.createDataSetForHoldingQuestions(GlobalStaticVariablesAndMethods.currentSubjectName);
                    GlobalStaticVariablesAndMethods.currentSizeOfDataSet = GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows.Count;

                    //We will now use this gloabl variable to store questions.
                }
                else
                {
                    GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved = true;
                }
            }
            else
            {
                GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnsavedQuizErrorMessage);
            }
            //Open dialog
        }