private void GetQuizTopicNameWindow_Load(object sender, EventArgs e) { foreach (String tables in GlobalStaticVariablesAndMethods.GetTableNames()) { comboBoxSubjects.Items.Add(tables); } }
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); } }
private void buttonCreateTable_Click(object sender, EventArgs e) { try { SqlConnection connection = new SqlConnection(GlobalStaticVariablesAndMethods.currentConnectionString); connection.Open(); if (richTextBoxTableName.Text.Length > 0) { String tableName = richTextBoxTableName.Text.Replace(' ', '_'); String qury = "CREATE TABLE " + tableName + " ( Id INT NOT NULL PRIMARY KEY IDENTITY(1,1), QuizTopicName VARCHAR(MAX) NULL, Question VARCHAR(MAX) NULL, Answers VARCHAR(MAX) NULL, RightAnswer VARCHAR(MAX) NULL)"; SqlCommand sqlCommand = new SqlCommand(qury, connection); sqlCommand.ExecuteNonQuery(); MessageBox.Show("Subject added Successfully."); connection.Close(); } else { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NoTableNameGivemErrorMessage); } } catch (Exception x) { GlobalStaticVariablesAndMethods.CreateErrorMessage(x.Message); } }
private void TopicSelectorDialog_Load(object sender, EventArgs e) { foreach (String subject in GlobalStaticVariablesAndMethods.GetTableNames()) { comboBoxSubjects.Items.Add(subject); } }
private void Form1_Load(object sender, EventArgs e) { //Setting connection string // by loading from app config file. GlobalStaticVariablesAndMethods.loadingMessage = "Please wait we are setting up enviroment for you..!!"; GlobalStaticVariablesAndMethods.DisplayProgressDialog(); GlobalStaticVariablesAndMethods.currentConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; }
private void buttonShowAvailSub_Click(object sender, EventArgs e) { listBox1.Items.Clear(); foreach (String tables in GlobalStaticVariablesAndMethods.GetTableNames()) { listBox1.Items.Add(tables); } }
private void buttonOpenQuiz_Click(object sender, EventArgs e) { if (GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved) { HideChild(); TopicSelectorDialog topicSelectorDialog = new TopicSelectorDialog(this, createQuizParentWindow, openQuizParentWindow); topicSelectorDialog.ShowDialog(); } else { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnsavedQuizErrorMessage); } }
private void buttonAddSubject_Click(object sender, EventArgs e) { if (GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved) { HideChild(); AddSubjectParentWindow addSubjectParentWindow = new AddSubjectParentWindow(); addSubjectParentWindow.ShowDialog(); } else { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnsavedQuizErrorMessage); } }
public static void deleteQuestionFromDataBase(int tableId) { int taget = getTheTargetIndexWithRespectToTableIndexing(tableId); if (taget != -1) { //Now we have the index where our target row wrt actual tbale indexing GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows[taget].Delete(); } else { GlobalStaticVariablesAndMethods.CreateErrorMessage("There is error in deleting this question from dataset..!!"); } }
private void buttonPrint_Click_1(object sender, EventArgs e) { if (GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved) { HideChild(); printQuizParentWindow.MdiParent = this; printQuizParentWindow.Show(); printQuizParentWindow.BringToFront(); printQuizParentWindow.Dock = DockStyle.Top; } else { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.UnsavedQuizErrorMessage); } }
public static void upddateDataSet(String question, String answers, String rightAnswer, int index) { int target = getTheTargetIndexWithRespectToTableIndexing(index); if (target != -1) { GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows[target]["Question"] = question; GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows[target]["Answers"] = answers; GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0].Rows[target]["RightAnswer"] = rightAnswer; } else { GlobalStaticVariablesAndMethods.CreateErrorMessage("There is error in updating question in this dataset..!!"); } }
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 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 }
private void buttonCQAddoption_Click(object sender, EventArgs e) { if (richTextBoxOptiontext.Text.Length <= 0 && comboBoxCOptionsType.SelectedIndex == 0) { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.NoTextFoundInOptionTextBoxErrorMessage); return; } //Here we will add choice options if (comboBoxCOptionsType.SelectedIndex == 0 && !doesFlowLayoutContainRadioButton()) { //Mcqs CheckBox checkBox = new CheckBox(); checkBox.Text = richTextBoxOptiontext.Text; checkBox.Width = ((checkBox.Text).Length) * 50; checkBox.Height = 30; flowLayoutPanelCQOptions.Controls.Add(checkBox); } else if (flowLayoutPanelCQOptions.Controls.Count == 0 && comboBoxCOptionsType.SelectedIndex == 1) { //True/False RadioButton rbTrue = new RadioButton(); RadioButton rbFalse = new RadioButton(); rbTrue.Width = 100; rbTrue.Height = 30; rbTrue.Text = "True"; rbTrue.Checked = radioButtonTrueOption.Checked; flowLayoutPanelCQOptions.Controls.Add(rbTrue); rbFalse.Width = 100; rbFalse.Height = 30; rbFalse.Text = "False"; rbFalse.Checked = radioButtonFalseOption.Checked; flowLayoutPanelCQOptions.Controls.Add(rbFalse); } else { GlobalStaticVariablesAndMethods.CreateErrorMessage(GlobalStaticVariablesAndMethods.CantAddMultipleTrueFalseErrorMessage); } }
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); } }
public static bool saveQuizToDatabase() { try { SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(GlobalStaticVariablesAndMethods.currentSqlDataAdapter); GlobalStaticVariablesAndMethods.currentSqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand(); GlobalStaticVariablesAndMethods.currentSqlDataAdapter.Update(GlobalStaticVariablesAndMethods.currentDataSetUsedForHoldingQuestions.Tables[0]); Console.WriteLine("Saved to database"); } catch (Exception e) { GlobalStaticVariablesAndMethods.CreateErrorMessage("Error in deletion"); } return(true); }
private void buttonSaveAsPdf_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = " Pdf files | *.pdf"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { Document document = new Document(PageSize.A4.Rotate()); try { PdfWriter.GetInstance(document, new FileStream(saveFileDialog.FileName, FileMode.Create)); document.Open(); document.Add(new Paragraph(richTextBoxContentdisplayer.Text)); document.Close(); GlobalStaticVariablesAndMethods.CreateInfoMesssage(GlobalStaticVariablesAndMethods.FileavedAsPdfInfoMessage); } catch (Exception v) { MessageBox.Show(v.Message); } } }
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); } }
private void buttonSaveQuizInSystem_Click(object sender, EventArgs e) { DatasetManager.saveQuizToDatabase();//save changes to database GlobalStaticVariablesAndMethods.isCurrentQuizTopicSaved = true; GlobalStaticVariablesAndMethods.CreateInfoMesssage(GlobalStaticVariablesAndMethods.ChangesSavedInfoMessage); }
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); } }