コード例 #1
0
        public ActionResult Index()
        {
            QuestionManagement questions = new QuestionManagement();

            questions.Questions = QuestionRepo.GetQuestions((int)Session["UserId"]).ToList();
            return(View(questions));
        }
コード例 #2
0
        public void CreateQuestionTest()
        {
            QuestionManagement _QuestionManagement = new QuestionManagement();

            _QuestionManagement.CreateQuestion(new DAO.Question()
            {
                Text = StaticQuestions.Q1
            });
            _QuestionManagement.CreateQuestion(new DAO.Question()
            {
                Text = StaticQuestions.Q2
            });
            _QuestionManagement.CreateQuestion(new DAO.Question()
            {
                Text = StaticQuestions.Q3
            });
            _QuestionManagement.CreateQuestion(new DAO.Question()
            {
                Text = StaticQuestions.Q4
            });
            _QuestionManagement.CreateQuestion(new DAO.Question()
            {
                Text = StaticQuestions.Q5
            });

            _DbContext.SaveChanges();

            var _Result = _QuestionManagement.GetQuestion(StaticQuestions.Q4);

            Assert.True(_Result != null & _Result.Id > 0);
        }
コード例 #3
0
        public void AddAswerToQuestionTest()
        {
            QuestionManagement _QuestionManagement = new QuestionManagement();
            IAnswerManagement  _AnswerManagement   = AnswerManagement.Instance();

            DAO.Question _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q1);
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A1));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A2));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A3));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q2);
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A4));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A5));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A6));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q3);
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A7));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A8));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A9));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q4);
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A10));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A11));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A12));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q5);
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A13));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A14));
            _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A15));

            _DbContext.SaveChanges();

            Assert.True(_Question.Answers.Count() == 3);
            Assert.True(_Question.Answers.Where(x => x.AnswerId == _AnswerManagement.GetAnswer(StaticAnswers.A14).Id).Count() == 1);
        }
コード例 #4
0
        private void LoadData()
        {
            PersonnelBindingSource.DataSource    = PersonnelManagement.GetA(PersonnelNo);
            EducationObjBindingSource.DataSource = StaticClass.ListEducation(PersonnelNo);
            EligibilityBindingSource.DataSource  = EligibilityManagement.GetAll(PersonnelNo);
            ExperiencyBindingSource.DataSource   = ExperienceManagement.GetAll(PersonnelNo);
            VoluntaryBindingSource.DataSource    = VoluntaryManagement.GetAll(PersonnelNo);
            TrainingBindingSource.DataSource     = TrainingManagement.GetAll(PersonnelNo);
            SpousBindingSource.DataSource        = SpouseManagement.GetA(PersonnelNo);
            SkillBindingSource.DataSource        = SkillManagement.GetAll(PersonnelNo);
            OrganizationBindingSource.DataSource = OrganizationManagement.GetAll(PersonnelNo);
            DistinctionBindingSource.DataSource  = DistinctionManagement.GetAll(PersonnelNo);
            QuestionBindingSource.DataSource     = QuestionManagement.GetAll(PersonnelNo);
            ReferenceBindingSource.DataSource    = ReferencesManagement.GetAll(PersonnelNo);
            DetailBindingSource.DataSource       = Details.GetAll(PersonnelNo);

            if (SpousBindingSource?.Current == null)
            {
                return;
            }
            ChildrenObjBindingSource.DataSource = StaticClass.ListChildren(((Spous)SpousBindingSource.Current).SpouseNo);

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;

            this.reportViewer1.RefreshReport();
        }
コード例 #5
0
 public override void Load()
 {
     Bind <IAnswerManagement>().ToMethod(x => AnswerManagement.Instance());
     Bind <IInterviweeManagement>().ToMethod(x => InterviweeManagement.Instance());
     Bind <IQuestionManagement>().ToMethod(x => QuestionManagement.Instance());
     Bind <IStatistic>().ToMethod(x => Statistic.Instance());
     Bind <ITesting>().ToMethod(x => Testing.Instance());
     Bind <ITestManagement>().ToMethod(x => TestManagement.Instance());
 }
コード例 #6
0
        public void AddQuestionToTest()
        {
            TestManagement     _TestManagement     = new TestManagement();
            QuestionManagement _QuestionManagement = new QuestionManagement();

            DAO.Test _Test = _TestManagement.GetTest(StaticTests.T1);
            _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q1));
            _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q2));
            _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q3));
            _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q4));
            _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q5));
            _DbContext.SaveChanges();

            Assert.True(_Test.Questions.Where(x => x.QuestionId == _QuestionManagement.GetQuestion(StaticQuestions.Q3).Id).Count() == 1);
        }
コード例 #7
0
ファイル: SummaryListForm.cs プロジェクト: techrepublik/PDS
        private void DeleteQuestion()
        {
            var dResult = MessageBox.Show(@"Delete Question current record?", @"Delete", MessageBoxButtons.YesNo,
                                          MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (dResult == DialogResult.Yes)
            {
                if (QuestionManagement.Delete(((Question)questionBindingSource.Current).QuestionNo))
                {
                    MessageBox.Show(@"Record was deleted successfully.", @"Delete", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    questionBindingSource.RemoveCurrent();
                }
                else
                {
                    MessageBox.Show(@"Error on delete operation.", @"Delete", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    questionDataGridView.Focus();
                }
            }
        }
コード例 #8
0
 private void questionBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     if (questionBindingSource != null)
     {
         Validate();
         ((Question)questionBindingSource.Current).PersonnelNo = PersonnelNo;
         questionBindingSource.EndEdit();
         var iResult = QuestionManagement.Save((Question)questionBindingSource.Current);
         if (iResult > 0)
         {
             MessageBox.Show(@"Record was successfully saved.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             //q36A_YesCheckBox.Focus();
         }
         else
         {
             MessageBox.Show(@"Error occurred in saving.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }
コード例 #9
0
ファイル: SummaryListForm.cs プロジェクト: techrepublik/PDS
        private void LoadInitPersonnelRelatedRecord()
        {
            Cursor.Current = Cursors.WaitCursor;
            var pNo = ((Personnel)personnelBindingSource.Current).PersonnelNo;

            if (pNo > 0)
            {
                eligibilityBindingSource.DataSource  = EligibilityManagement.GetAll(pNo);
                experiencyBindingSource.DataSource   = ExperienceManagement.GetAll(pNo);
                voluntaryBindingSource.DataSource    = VoluntaryManagement.GetAll(pNo);
                trainingBindingSource.DataSource     = TrainingManagement.GetAll(pNo);
                educationObjBindingSource.DataSource = StaticClass.ListEducation(pNo);
                spousBindingSource.DataSource        = SpouseManagement.GetAll(pNo);
                skillBindingSource.DataSource        = SkillManagement.GetAll(pNo);
                organizationBindingSource.DataSource = OrganizationManagement.GetAll(pNo);
                distinctionBindingSource.DataSource  = DistinctionManagement.GetAll(pNo);
                questionBindingSource.DataSource     = QuestionManagement.GetAll(pNo);
                referenceBindingSource.DataSource    = ReferencesManagement.GetAll(pNo);
                detailBindingSource.DataSource       = Details.GetAll(pNo);
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #10
0
        public void SetCorrectAnswerToQuestionTest()
        {
            QuestionManagement _QuestionManagement = new QuestionManagement();
            AnswerManagement   _AnswerManagement   = new AnswerManagement();

            DAO.Question _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q1);
            _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A1));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q2);
            _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A6));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q3);
            _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A7));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q4);
            _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A11));

            _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q5);
            _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A13));

            _DbContext.SaveChanges();

            Assert.True(_Question.Answers.Where(x => x.AnswerId == _AnswerManagement.GetAnswer(StaticAnswers.A13).Id & x.IsCorrect).Count() == 1);
        }
コード例 #11
0
        private void SaveToListOrMock(string FileName)
        {
            if (string.IsNullOrWhiteSpace(textBox3.Text))
            {
                MessageBox.Show("Please enter the Exam Name", "Error");
                return;
            }

            if (dateTimePicker1.Enabled == true)
            {
                if (dateTimePicker1.Value.TimeOfDay.ToString() == "00:00:00")
                {
                    MessageBox.Show("Please enter the Exam Duration", "Error");
                    return;
                }
            }

            if (comboBox4.SelectedIndex == 1 || comboBox4.SelectedIndex == 2)
            {
                if (textBox2.Enabled == true)
                {
                    if (string.IsNullOrWhiteSpace(textBox2.Text))
                    {
                        MessageBox.Show("Please enter the Exam Percentage", "Error");
                        return;
                    }
                }
            }
            if (!isPrintPreviewTaken)
            {
                GenerateQuestions();
                isPrintPreviewTaken = true;
            }

            //GenerateQuestions();
            if (!Directory.Exists(Application.StartupPath + @"\QuestionPaper\"))
            {
                Directory.CreateDirectory(Application.StartupPath + @"\QuestionPaper\");
            }


            //Create Object for the QuestionManagement
            QuestionManagementColl objQuestionManagementColl;

            if (File.Exists(FileName))
            {
                objQuestionManagementColl = ObjectXMLSerializer <QuestionManagementColl> .Load(FileName);
            }
            else
            {
                objQuestionManagementColl = new QuestionManagementColl();
                objQuestionManagementColl.objQuestionManagement = new List <QuestionManagement>();
            }


            int i = (from QuestionManagement in objQuestionManagementColl.objQuestionManagement
                     where QuestionManagement.ExamName == textBox3.Text
                     select QuestionManagement).ToList().Count();

            if (i > 0)
            {
                MessageBox.Show("Already the exam name exists!!!", "Error");
                return;
            }

            QuestionManagement objQuestionManagement = new QuestionManagement();

            //for (int ik = 0; ik < objQuestions.objQuestionDetail.Count(); ik++)
            //{
            //    objQuestions.objQuestionDetail[ik].CategoryName = GetTopicName(objQuestions.objQuestionDetail[ik].QuesNo);
            //}

            if (FileName.Contains(@"\MockTest\"))
            {
                ObjectXMLSerializer <QuestionDetailData> .Save(objQuestions, Application.StartupPath + Utility.FolderType() + @"MockTest\" + textBox3.Text + ".txt");

                objQuestionManagement.FileName = Application.StartupPath + Utility.FolderType() + @"MockTest\" + textBox3.Text + ".txt";
                objQuestionManagement.TestTime = dateTimePicker1.Text;
            }
            else
            {
                ObjectXMLSerializer <QuestionDetailData> .Save(objQuestions, Application.StartupPath + Utility.FolderType() + @"QuestionPaper\" + textBox3.Text + ".txt");

                objQuestionManagement.FileName = Application.StartupPath + Utility.FolderType() + @"QuestionPaper\" + textBox3.Text + ".txt";
            }

            objQuestionManagement.QuestionMngNo = objQuestionManagementColl.objQuestionManagement.Count + 1;
            objQuestionManagement.ExamName      = textBox3.Text;
            if (treeView1.SelectedNode.Level == 0)
            {
                objQuestionManagement.QuestionTopic = treeView1.SelectedNode.Text;
            }

            if (treeView1.SelectedNode.Level == 1)
            {
                objQuestionManagement.QuestionTopic = treeView1.SelectedNode.Parent.Text;
                objQuestionManagement.Subject       = treeView1.SelectedNode.Text;
            }
            if (treeView1.SelectedNode.Level == 2)
            {
                objQuestionManagement.QuestionTopic = treeView1.SelectedNode.Parent.Parent.Text;
                objQuestionManagement.Subject       = treeView1.SelectedNode.Text;
            }


            objQuestionManagement.ExamPasPercentageScore = textBox2.Text;
            objQuestionManagement.ExamMode           = comboBox4.Text;
            objQuestionManagement.QuestionComplexity = comboBox2.Text;
            objQuestionManagement.QuestionType       = comboBox1.Text;
            objQuestionManagement.TotalQuestions     = textBox1.Text;

            objQuestionManagementColl.objQuestionManagement.Add(objQuestionManagement);

            ObjectXMLSerializer <QuestionManagementColl> .Save(objQuestionManagementColl, FileName);

            MessageBox.Show("Data saved successfully");
            enablePaperButtons();
        }
コード例 #12
0
        void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            RowIndex = e.RowIndex;
            #region admin related
            if (e.ColumnIndex > 0 && Utility.IsAdmin())
            {
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    MessageBox.Show("Please choose Client before to proceed");
                    return;
                }
                folderBrowserDialog1.Description = @"Select the folder to Export file";
                DialogResult re = new DialogResult();
                if (Utility.isStandard())
                {
                    re = folderBrowserDialog1.ShowDialog();
                }

                //eTutor
                //   if (e.ColumnIndex == 1)
                //{
                //    string FileName = Application.StartupPath + @"\" + getParent[RowIndex].Name + ".txt";

                //}

                //Admin with Question Bank and Question Paper
                if (e.ColumnIndex == 2 || e.ColumnIndex == 3 || e.ColumnIndex == 1)
                {
                    string FileName;
                    string text;
                    if (e.ColumnIndex == 1)
                    {
                        FileName = Application.StartupPath + Utility.FolderType() + @"eTutor\" + getParent[RowIndex].Name + ".txt";
                        text     = System.IO.File.ReadAllText(FileName);
                    }
                    else
                    {
                        FileName = Application.StartupPath + Utility.FolderType() + @"QuestionBank\" + getParent[RowIndex].Name + ".txt";

                        QuestionDetailData obj1 = ObjectXMLSerializer <QuestionDetailData> .Load(FileName);

                        // ObjectXMLSerializer<QuestionDetailData>.Save(obj1, "NewDoc111.txt");
                        if (e.ColumnIndex == 2)
                        {
                            obj1.objQuestionDetail = (from QuestionDetailData in obj1.objQuestionDetail
                                                      where (QuestionDetailData.ModuleName == Utility.MOD_ALL || QuestionDetailData.ModuleName == Utility.MOD_QUEST_BANK)
                                                      select QuestionDetailData).ToList();
                            obj1.QuestionType = "QUESTION BANK";
                        }
                        else
                        {
                            obj1.QuestionType = "QUESTION PAPER";
                        }


                        ObjectXMLSerializer <QuestionDetailData> .Save(obj1, "NewDoc.txt");

                        text = System.IO.File.ReadAllText(@"NewDoc.txt");
                        System.IO.File.Delete(@"NewDoc.txt");
                    }
                    FileCryptography.entropy = null;


                    string extn = "";;
                    if (e.ColumnIndex == 2)
                    {
                        extn = @"_QB.txt";
                    }
                    else if (e.ColumnIndex == 3)
                    {
                        extn = @"_QP.txt";
                    }
                    else if (e.ColumnIndex == 1)
                    {
                        extn = @"_eTutor.txt";
                    }

                    if (!Utility.isStandard() || DialogResult.OK == re)
                    {
                        string strDestFile = null;
                        if (Utility.isStandard())
                        {
                            strDestFile = folderBrowserDialog1.SelectedPath + @"\" + getParent[RowIndex].Name + "_" + textBox1.Text + extn;
                        }
                        else
                        {
                            if (e.ColumnIndex == 2)
                            {
                                strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\QuestionBank\" + getParent[RowIndex].Name + "_" + textBox1.Text + extn;
                            }
                            else if (e.ColumnIndex == 3)
                            {
                                strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\QuestionPaper\" + getParent[RowIndex].Name + "_" + textBox1.Text + extn;
                            }
                            else if (e.ColumnIndex == 1)
                            {
                                strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\eTutor\" + getParent[RowIndex].Name + "_" + textBox1.Text + extn;
                            }
                        }

                        if (File.Exists(folderBrowserDialog1.SelectedPath + @"\" + getParent[RowIndex].Name + extn))
                        {
                            System.IO.File.Delete(folderBrowserDialog1.SelectedPath + @"\" + getParent[RowIndex].Name + extn);
                        }


                        //FileCryptography.DoEncrypt(text, strDestFile, textBox1.Text);
                        FileCryptography.DoEncrypt(text, strDestFile, textBox1.Tag.ToString());
                        if (e.ColumnIndex == 2)
                        {
                            AuditPurchase(getParent[RowIndex].Name, "Km- Knowledge Base");
                        }
                        else if (e.ColumnIndex == 3)
                        {
                            AuditPurchase(getParent[RowIndex].Name, "Km-Knowledge Assessment");
                        }
                        else if (e.ColumnIndex == 1)
                        {
                            AuditPurchase(getParent[RowIndex].Name, "Km-Knowledge eTutor");
                        }
                        MessageBox.Show("Data Exported to " + strDestFile);
                    }
                }
                else if (e.ColumnIndex == 4)
                {
                    //Mock Test
                    QuestionManagementColl         objQuestionManagementColl = null;
                    QuestionDetailData             resultQuestions;
                    QuestionManagementWithQuesColl objQuestionManagementWithQuesColl;
                    objQuestionManagementWithQuesColl = new QuestionManagementWithQuesColl();
                    if (File.Exists(Application.StartupPath + Utility.FolderType() + @"MockTest\MockTestList.txt"))
                    {
                        objQuestionManagementColl = ObjectXMLSerializer <QuestionManagementColl> .Load(Application.StartupPath + Utility.FolderType() + @"MockTest\MockTestList.txt");
                    }

                    if (objQuestionManagementColl != null)
                    {
                        for (int i = 0; i < objQuestionManagementColl.objQuestionManagement.Count; i++)
                        {
                            if (objQuestionManagementColl.objQuestionManagement[i].QuestionTopic == getParent[RowIndex].Name)
                            {
                                QuestionManagementWithQues objQuestionManagement = new QuestionManagementWithQues();
                                objQuestionManagement.ExamName = objQuestionManagementColl.objQuestionManagement[i].ExamName;
                                objQuestionManagement.ExamPasPercentageScore = objQuestionManagementColl.objQuestionManagement[i].ExamPasPercentageScore;
                                objQuestionManagement.ExamMode           = objQuestionManagementColl.objQuestionManagement[i].ExamMode;
                                objQuestionManagement.QuestionComplexity = objQuestionManagementColl.objQuestionManagement[i].QuestionComplexity;
                                objQuestionManagement.QuestionType       = objQuestionManagementColl.objQuestionManagement[i].QuestionType;
                                objQuestionManagement.TotalQuestions     = objQuestionManagementColl.objQuestionManagement[i].TotalQuestions;
                                objQuestionManagement.FileName           = objQuestionManagementColl.objQuestionManagement[i].FileName;
                                objQuestionManagement.QuestionTopic      = objQuestionManagementColl.objQuestionManagement[i].QuestionTopic;
                                objQuestionManagement.Subject            = objQuestionManagementColl.objQuestionManagement[i].Subject;
                                objQuestionManagement.TestStatus         = objQuestionManagementColl.objQuestionManagement[i].TestStatus;
                                objQuestionManagement.TestResult         = objQuestionManagementColl.objQuestionManagement[i].TestResult;
                                objQuestionManagement.TestTime           = objQuestionManagementColl.objQuestionManagement[i].TestTime;
                                if (File.Exists(objQuestionManagementColl.objQuestionManagement[i].FileName))
                                {
                                    resultQuestions = ObjectXMLSerializer <QuestionDetailData> .Load(objQuestionManagementColl.objQuestionManagement[i].FileName);

                                    objQuestionManagement.objQuestionDetail = new List <QuestionDetail>();
                                    objQuestionManagement.objQuestionDetail.AddRange(resultQuestions.objQuestionDetail);
                                }
                                objQuestionManagementWithQuesColl.objQuestionManagement.Add(objQuestionManagement);
                            }
                            //objQuestionManagementWithQuesColl.objQuestionManagement[].objQuestionDetail.Add(
                        }
                        if (!Utility.isStandard() || DialogResult.OK == re)
                        {
                            ObjectXMLSerializer <QuestionManagementWithQuesColl> .Save(objQuestionManagementWithQuesColl, "NewDoc.txt");

                            string text = System.IO.File.ReadAllText(@"NewDoc.txt");
                            System.IO.File.Delete(@"NewDoc.txt");
                            FileCryptography.entropy = null;

                            string strMockFileName = null;
                            if (Utility.isStandard())
                            {
                                strMockFileName = folderBrowserDialog1.SelectedPath + @"\" + getParent[RowIndex].Name + "_" + textBox1.Text + "_Mock.txt";
                            }
                            else
                            {
                                strMockFileName = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\" + @"MockTest\" + getParent[RowIndex].Name + "_" + textBox1.Text + "_Mock.txt";
                            }
                            if (File.Exists(strMockFileName))
                            {
                                System.IO.File.Delete(strMockFileName);
                            }

                            // FileCryptography.DoEncrypt(text, strMockFileName, textBox1.Text);
                            FileCryptography.DoEncrypt(text, strMockFileName, textBox1.Tag.ToString());
                            AuditPurchase(getParent[RowIndex].Name, "Km-Knowledge Evaluator");
                            MessageBox.Show("Data Exported to " + strMockFileName);

                            // ObjectXMLSerializer<QuestionManagementWithQuesColl>.Save(objQuestionManagementWithQuesColl, folderBrowserDialog1.SelectedPath + @"\" + getParent[RowIndex].Name + "_Mock.txt");
                        }
                    }

                    // FileName = Application.StartupPath + @"\" + FileName + ".txt";
                }
            }

            #endregion
            else if (e.ColumnIndex > 0)
            {
                // MessageBox.Show(dataGridView1.Columns[e.ColumnIndex].Name);
                if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank" || dataGridView1.Columns[e.ColumnIndex].Name == "QuestionPaper" || dataGridView1.Columns[e.ColumnIndex].Name == "eTutor")
                {
                    string strDestFile = null;



                    DataGridViewDisableButtonCell buttonCell;
                    if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank")
                    {
                        buttonCell =
                            (DataGridViewDisableButtonCell)dataGridView1.
                            Rows[e.RowIndex].Cells["QuestionBank"];
                        if (!Utility.isStandard())
                        {
                            strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\QuestionBank\" + getParent[RowIndex].Name + "_" + EntropyGenerator.GetIPForMachine() + @"_QB.txt";
                        }
                    }
                    else if (dataGridView1.Columns[e.ColumnIndex].Name == "eTutor")
                    {
                        buttonCell =
                            (DataGridViewDisableButtonCell)dataGridView1.
                            Rows[e.RowIndex].Cells["eTutor"];
                        if (!Utility.isStandard())
                        {
                            strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\eTutor\" + getParent[RowIndex].Name + "_" + EntropyGenerator.GetIPForMachine() + @"_eTutor.txt";
                        }
                    }
                    else
                    {
                        buttonCell =
                            (DataGridViewDisableButtonCell)dataGridView1.
                            Rows[e.RowIndex].Cells["QuestionPaper"];
                        if (!Utility.isStandard())
                        {
                            strDestFile = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\QuestionPaper\" + getParent[RowIndex].Name + "_" + EntropyGenerator.GetIPForMachine() + @"_QP.txt";
                        }
                    }


                    //if (dataGridView1.Rows[e.RowIndex].Cells["QuestionBank"].Value.ToString() == "Purchase")
                    if (buttonCell.Value.ToString() == "Purchase")
                    {
                        //DataGridViewDisableButtonCell buttonCell =
                        //    (DataGridViewDisableButtonCell)dataGridView1.
                        //    Rows[e.RowIndex].Cells["QuestionBank"];

                        //Check whether we can open the file
                        //OpenFileDialog objFile = new OpenFileDialog();

                        //DialogResult resultdia = objFile.ShowDialog(); // Show the dialog.
                        //if (resultdia == DialogResult.OK) // Test result.
                        //{
                        //    string file = objFile.FileName;
                        //    FileCryptography.DoDecrypt(file, null);
                        //    string decryptedData = FileCryptography.decryptedData;
                        //    if (string.IsNullOrEmpty(decryptedData))
                        //    {
                        //        MessageBox.Show("File is invalid");
                        //    }
                        //    else
                        string decryptedData = ValidateImport(strDestFile);
                        if (decryptedData != null)
                        {
                            QuestionDetailData result1   = new QuestionDetailData();
                            eTutorCollData     objetutor = new eTutorCollData();
                            try
                            {
                                string FileName = null;
                                if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank")
                                {
                                    FileName = Application.StartupPath + Utility.FolderType() + @"QuestionBank\" + getParent[e.RowIndex].Name + ".txt";
                                }
                                else if (dataGridView1.Columns[e.ColumnIndex].Name == "eTutor")
                                {
                                    FileName = Application.StartupPath + Utility.FolderType() + @"eTutor\" + getParent[e.RowIndex].Name + ".txt";
                                }
                                else
                                {
                                    FileName = Application.StartupPath + Utility.FolderType() + @"QuestionPaper\" + getParent[e.RowIndex].Name + ".txt";
                                }

                                if (File.Exists(FileName))
                                {
                                    File.Delete(FileName);
                                }

                                FileCryptography.encryptedData = decryptedData;
                                FileCryptography.FileName      = FileName;
                                FileCryptography.entropy       = UnicodeEncoding.ASCII.GetBytes(KnowledgeMatrix.Properties.Settings.Default.ProductKey);
                                FileCryptography.DoEncrypt();

                                if (dataGridView1.Columns[e.ColumnIndex].Name == "eTutor")
                                {
                                    objetutor = ObjectXMLSerializer <eTutorCollData> .Load(FileName);

                                    if (objetutor == null && objetutor.eTutorlst.Count() == 0)
                                    {
                                        MessageBox.Show("No data available to import. Please contact Sales team");
                                        return;
                                    }
                                }
                                else if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank" || dataGridView1.Columns[e.ColumnIndex].Name == "QuestionPaper")
                                {
                                    result1 = ObjectXMLSerializer <QuestionDetailData> .Load(FileName);

                                    bool isValid = true;

                                    if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank" && result1.QuestionType != "QUESTION BANK")
                                    {
                                        isValid = false;
                                    }
                                    else if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionPaper" && result1.QuestionType != "QUESTION PAPER")
                                    {
                                        isValid = false;
                                    }

                                    else if (result1 == null && result1.objQuestionDetail.Count() == 0)
                                    {
                                        isValid = false;
                                    }
                                    if (!isValid)
                                    {
                                        File.Delete(FileName);
                                        MessageBox.Show("No data available to import. Please contact Sales team");
                                        return;
                                    }
                                }

                                {
                                    //ObjectXMLSerializer<QuestionDetailData>.Save(result1, FileName);

                                    MessageBox.Show("Data imported Successfully");
                                    buttonCell.Value = "Purchased";


                                    buttonCell.Enabled = false;

                                    //Update the Product Catalog
                                    int idx = result.objQuestionMas.FindIndex(
                                        delegate(QuestionMast bk)
                                    {
                                        return(bk.QuesNo == getParent[e.RowIndex].QuesNo);
                                    }
                                        );
                                    if (dataGridView1.Columns[e.ColumnIndex].Name == "QuestionBank")
                                    {
                                        result.objQuestionMas[idx].QuesBank = "Purchased";
                                    }
                                    else if (dataGridView1.Columns[e.ColumnIndex].Name == "eTutor")
                                    {
                                        result.objQuestionMas[idx].eTutor = "Purchased";
                                    }
                                    else
                                    {
                                        result.objQuestionMas[idx].QuesBankGen = "Purchased";
                                    }
                                    result.objQuestionMas[idx].QuesBankDate = System.DateTime.Now.ToString();

                                    ObjectXMLSerializer <QuestionsData> .Save(result, KnowledgeMatrix.Framework.Utility.XML_QUESTION_NAME);

                                    //  FileCryptography.encryptedData = File.ReadAllText(XML_FILE_NAME1);
                                    // FileCryptography.FileName = KnowledgeMatrix.Framework.Utility.XML_QUESTION_NAME;
                                    //FileCryptography.DoEncrypt();
                                    //File.Delete(XML_FILE_NAME1);
                                    //Update the Product Catalog
                                }
                            }
                            catch (Exception ex)
                            {
                                LogEntry.WriteLog(ex, "Thread Exception");
                                MessageBox.Show("File incorrect. Please contact Sales team");
                            }
                        }

                        //}
                    }
                    else if (dataGridView1.Rows[e.RowIndex].Cells["QuestionBank"].Value.ToString() == "Purchased" || dataGridView1.Rows[e.RowIndex].Cells["QuestionPaper"].Value.ToString() == "Purchased")
                    {
                        LicenseDetail obj = new LicenseDetail();
                        int           idx = result.objQuestionMas.FindIndex(
                            delegate(QuestionMast bk)
                        {
                            return(bk.QuesNo == getParent[e.RowIndex].QuesNo);
                        }
                            );


                        obj.objLicenseDetail.ProductName    = result.objQuestionMas[idx].Name;
                        obj.objLicenseDetail.ProductType    = dataGridView1.Columns[e.ColumnIndex].HeaderText;
                        obj.objLicenseDetail.DateOfPurchase = result.objQuestionMas[idx].QuesBankDate;
                        obj.objLicenseDetail.DateOfExpiry   = Convert.ToDateTime(result.objQuestionMas[idx].QuesBankDate).AddDays(365).ToString();
                        obj.ShowDialog();
                    }
                }
                else if (dataGridView1.Columns[e.ColumnIndex].Name == "MockTest")
                {
                    DataGridViewDisableButtonCell buttonCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["MockTest"];
                    //NEW REQ
                    if (buttonCell.Value.ToString() != "Purchases")
                    {
                        string strMockFileName = null;
                        if (!Utility.isStandard())
                        {
                            strMockFileName = KnowledgeMatrix.Properties.Settings.Default.SharePath + @"\" + @"MockTest\" + getParent[RowIndex].Name + "_" + EntropyGenerator.GetIPForMachine() + "_Mock.txt";
                        }


                        string decryptedData = ValidateImport(strMockFileName);
                        if (decryptedData != null)
                        {
                            string FileName = Application.StartupPath + Utility.FolderType() + @"MockTest\MockList" + ".txt";
                            if (File.Exists(FileName))
                            {
                                File.Delete(FileName);
                            }

                            FileCryptography.encryptedData = decryptedData;
                            FileCryptography.FileName      = FileName;
                            FileCryptography.entropy       = UnicodeEncoding.ASCII.GetBytes(KnowledgeMatrix.Properties.Settings.Default.ProductKey);
                            FileCryptography.DoEncrypt();
                            QuestionManagementWithQuesColl result1 = ObjectXMLSerializer <QuestionManagementWithQuesColl> .Load(FileName);

                            if (result1 == null || result1.objQuestionManagement.Count() == 0)
                            {
                                File.Delete(FileName);
                                MessageBox.Show("No data available to import. Please contact Sales team");
                            }
                            else
                            {
                                FileName = Application.StartupPath + Utility.FolderType() + @"MockTest\MockTestList.txt";

                                QuestionManagementColl objQuestionManagementColl;
                                if (File.Exists(FileName))
                                {
                                    objQuestionManagementColl = ObjectXMLSerializer <QuestionManagementColl> .Load(FileName);
                                }
                                else
                                {
                                    objQuestionManagementColl = new QuestionManagementColl();
                                    objQuestionManagementColl.objQuestionManagement = new List <QuestionManagement>();
                                }
                                for (int ik = 0; ik < result1.objQuestionManagement.Count(); ik++)
                                {
                                    int i = (from QuestionManagement in objQuestionManagementColl.objQuestionManagement
                                             where QuestionManagement.ExamName == result1.objQuestionManagement[ik].ExamName
                                             select QuestionManagement).ToList().Count();

                                    if (i == 0)
                                    {
                                        QuestionManagement objQuestionManagement = new QuestionManagement();// =(QuestionManagement) result1.objQuestionManagement[ik];
                                        objQuestionManagement.ExamName = result1.objQuestionManagement[ik].ExamName;
                                        objQuestionManagement.ExamPasPercentageScore = result1.objQuestionManagement[ik].ExamPasPercentageScore;
                                        objQuestionManagement.TestTime           = result1.objQuestionManagement[ik].TestTime;
                                        objQuestionManagement.ExamMode           = result1.objQuestionManagement[ik].ExamMode;
                                        objQuestionManagement.QuestionComplexity = result1.objQuestionManagement[ik].QuestionComplexity;
                                        objQuestionManagement.QuestionType       = result1.objQuestionManagement[ik].QuestionType;
                                        objQuestionManagement.TotalQuestions     = result1.objQuestionManagement[ik].TotalQuestions;
                                        objQuestionManagement.TestTime           = result1.objQuestionManagement[ik].TestTime;

                                        QuestionDetailData objQuestions = new QuestionDetailData();
                                        objQuestions.objQuestionDetail = new List <QuestionDetail>();
                                        objQuestions.objQuestionDetail.AddRange(result1.objQuestionManagement[ik].objQuestionDetail);
                                        if (File.Exists(XML_FILE_NAME1))
                                        {
                                            File.Delete(XML_FILE_NAME1);
                                        }

                                        ObjectXMLSerializer <QuestionDetailData> .Save(objQuestions, Application.StartupPath + Utility.FolderType() + @"MockTest\" + result1.objQuestionManagement[ik].ExamName + ".txt");

                                        //FileCryptography.encryptedData = File.ReadAllText(XML_FILE_NAME1);
                                        //FileCryptography.FileName = Application.StartupPath + @"\QuestionPaper\" + result1.objQuestionManagement[ik].ExamName + ".txt";
                                        //FileCryptography.DoEncrypt();
                                        //File.Delete(XML_FILE_NAME1);

                                        //ObjectXMLSerializer<QuestionDetailData>.Save(objQuestions, Application.StartupPath + @"\QuestionPaper\" + result1.objQuestionManagement[ik].ExamName + ".txt");

                                        objQuestionManagement.FileName      = Application.StartupPath + Utility.FolderType() + @"MockTest\" + result1.objQuestionManagement[ik].ExamName + ".txt";
                                        objQuestionManagement.QuestionTopic = result1.objQuestionManagement[ik].QuestionTopic;
                                        objQuestionManagement.Subject       = result1.objQuestionManagement[ik].Subject;
                                        objQuestionManagement.TestStatus    = result1.objQuestionManagement[ik].TestStatus;
                                        objQuestionManagement.TestResult    = result1.objQuestionManagement[ik].TestResult;
                                        objQuestionManagement.MockTestDate  = System.DateTime.Now.ToString();
                                        objQuestionManagementColl.objQuestionManagement.Add(objQuestionManagement);
                                    }
                                }

                                if (File.Exists(FileName))
                                {
                                    File.Delete(FileName);
                                }

                                ObjectXMLSerializer <QuestionManagementColl> .Save(objQuestionManagementColl, FileName);

                                buttonCell.Value = "Purchased";


                                buttonCell.Enabled = false;

                                //Update the Product Catalog
                                int idx = result.objQuestionMas.FindIndex(
                                    delegate(QuestionMast bk)
                                {
                                    return(bk.QuesNo == getParent[e.RowIndex].QuesNo);
                                }
                                    );

                                result.objQuestionMas[idx].MockTest     = "Purchased";
                                result.objQuestionMas[idx].QuesBankDate = System.DateTime.Now.ToString();

                                ObjectXMLSerializer <QuestionsData> .Save(result, KnowledgeMatrix.Framework.Utility.XML_QUESTION_NAME);


                                //FileCryptography.encryptedData = File.ReadAllText(XML_FILE_NAME1);
                                //FileCryptography.FileName = FileName;
                                //FileCryptography.DoEncrypt();
                                //File.Delete(XML_FILE_NAME1);

                                //ObjectXMLSerializer<QuestionManagementColl>.Save(objQuestionManagementColl, FileName);

                                MessageBox.Show("Data imported Successfully");
                            }
                        }
                    }
                    else
                    {
                        LicenseDetail obj = new LicenseDetail();
                        int           idx = result.objQuestionMas.FindIndex(
                            delegate(QuestionMast bk)
                        {
                            return(bk.QuesNo == getParent[e.RowIndex].QuesNo);
                        }
                            );


                        obj.objLicenseDetail.ProductName    = result.objQuestionMas[idx].Name;
                        obj.objLicenseDetail.ProductType    = dataGridView1.Columns[e.ColumnIndex].HeaderText;
                        obj.objLicenseDetail.DateOfPurchase = result.objQuestionMas[idx].QuesBankDate;
                        obj.objLicenseDetail.DateOfExpiry   = Convert.ToDateTime(result.objQuestionMas[idx].QuesBankDate).AddDays(365).ToString();
                        obj.ShowDialog();
                    }
                }
            }
        }