private void SetBMSAndDivisionID(Int64 bmssctid, string bms)
    {
        SYS_BMS_BLogic objBMSSCT = new SYS_BMS_BLogic();
        DataSet        BmssctDs  = new DataSet();

        if (!string.IsNullOrEmpty(Convert.ToString(bmssctid)))
        {
            BmssctDs = objBMSSCT.BAL_SYS_BMSSCT_ByGroupBMSSCTID(Convert.ToString(bmssctid));
            if (BmssctDs.Tables.Count > 0)
            {
                if (BmssctDs.Tables[0].Rows.Count > 0)
                {
                    AppSessions.BMSID = Convert.ToInt32(BmssctDs.Tables[0].Rows[0]["BMSID"]);
                    AppSessions.BMS   = bms;
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //mp1.Show();
            if (Request.QueryString["BMSSCTID"].ToString() != "")
            {
                SYS_BMS_BLogic objBMSSCT = new SYS_BMS_BLogic();
                DataSet        BmssctDs  = new DataSet();
                if (!string.IsNullOrEmpty(Request.QueryString["GroupBMSSCT"].ToString()))
                {
                    BmssctDs = objBMSSCT.BAL_SYS_BMSSCT_ByGroupBMSSCTID(Request.QueryString["GroupBMSSCT"]);
                    if (BmssctDs.Tables.Count > 0)
                    {
                        StringBuilder ToolTiplblChapterValue = new StringBuilder();
                        StringBuilder ToolTiplblTopicValue   = new StringBuilder();

                        foreach (DataRow odr in BmssctDs.Tables[0].Rows)
                        {
                            string   BMSSCTNAME = odr["BMS_SCT"].ToString();
                            string[] lines      = Regex.Split(BMSSCTNAME, ">>");
                            ToolTiplblChapterValue.Append(lines[lines.Length - 1]);
                            ToolTiplblChapterValue.Append(Environment.NewLine);

                            ToolTiplblTopicValue.Append(lines[lines.Length - 2]);
                            ToolTiplblTopicValue.Append(Environment.NewLine);
                        }
                        lblChapterValue.Text = "Multiple Chapter";
                        lblTopicValue.Text   = "Multiple Topics";

                        lblChapterValue.ToolTip = ToolTiplblChapterValue.ToString();
                        lblTopicValue.ToolTip   = ToolTiplblTopicValue.ToString();
                    }
                }
                else
                {
                    BmssctDs = objBMSSCT.BAL_SYS_BMSSCT_ByBMSSCTID(Convert.ToInt32(Request.QueryString["BMSSCTID"].ToString()));
                    if (BmssctDs.Tables.Count > 0)
                    {
                        if (BmssctDs.Tables[0].Rows.Count > 0)
                        {
                            string   BMSSCTNAME = BmssctDs.Tables[0].Rows[0]["BMS_SCT"].ToString();
                            string[] lines      = Regex.Split(BMSSCTNAME, ">>");
                            lblChapterValue.Text = lines[lines.Length - 1];
                            lblTopicValue.Text   = lines[lines.Length - 2];
                            string ForTitle = "";
                            for (int Ti = 0; Ti < lines.Length - 2; Ti++)
                            {
                                if (Ti < lines.Length - 3)
                                {
                                    ForTitle = ForTitle + lines[Ti] + " >> ";
                                }
                                else
                                {
                                    ForTitle = ForTitle + lines[Ti];
                                }
                            }
                            lblExamStartOf.Text = "Your " + Request.QueryString["TestType"].ToString() + "  for " + ForTitle;
                        }
                        else
                        {
                            lblExamStartOf.Text = "Your " + Request.QueryString["TestType"].ToString() + "  for " + "";
                        }
                    }
                    else
                    {
                        lblExamStartOf.Text = "Your " + Request.QueryString["TestType"].ToString() + "  for" + "";
                    }
                }
                ViewState["TestTypeToTable"] = Request.QueryString["TestType"].ToString();
                //int Level = 0;
                //int NoOfQuestion = 0;
                //if (Request.QueryString["Level"].ToString() != "")
                //{
                //    Level = Convert.ToInt32(Request.QueryString["Level"].ToString());
                //}
                //if (Level == 0)
                //{
                //    NoOfQuestion = Convert.ToInt32(getConfigValue("MaxQuestionForAll"));
                //}
                //else
                //{
                //    NoOfQuestion = Convert.ToInt32(getConfigValue("MaxQuestionForLevelWise"));
                //}
                DataTable dt = new DataTable();

                QuestionMaster objQuestionMaster = new QuestionMaster();
                DataSet        ds = new DataSet();


                DataSet dsExamAuto = null;

                Hashtable Question = (Hashtable)Application["Exam_TeacherSheResult"];
                if (Question == null)
                {
                    Question = new Hashtable();
                }
                else
                {
                    dsExamAuto = (DataSet)Question[Session["TrackLogID"].ToString()];
                }

                // ds = objQuestionMaster.SELECTAll_QuestionByBMSSCTID(RndmQuestion, Level, NoOfQuestion, Convert.ToInt32(Request.QueryString["BMSSCTID"].ToString()), Request.QueryString["TestType"]);
                // ds = objQuestionMaster.SELECTAll_QuestionByBMSSCTID(RndmQuestion, Level, NoOfQuestion, Convert.ToInt32(Request.QueryString["BMSSCTID"].ToString()), "MCQ");
                if (dsExamAuto != null)
                {
                    if (dsExamAuto.Tables.Count > 0)
                    {
                        if (dsExamAuto.Tables.Count > 1)
                        {
                            DataRow drStudentInfo = dsExamAuto.Tables[1].NewRow();
                            drStudentInfo["StudentID"]   = AppSessions.StudentID;
                            drStudentInfo["StudentName"] = AppSessions.UserName;
                            drStudentInfo["RightAnswer"] = 0;
                            drStudentInfo["WrongAnswer"] = 0;
                            drStudentInfo["EmailID"]     = AppSessions.EmailID;
                            dsExamAuto.Tables[1].Rows.Add(drStudentInfo);
                            dsExamAuto.Tables[1].AcceptChanges();

                            Question[Session["TrackLogID"].ToString()] = dsExamAuto;
                            Application.Lock(); //lock to prevent duplicate objects
                            Application["Exam_TeacherSheResult"] = Question;
                            Application.UnLock();
                        }
                        if (dsExamAuto.Tables[0].Rows.Count > 0)
                        {
                            DataTable dtExaAuto = dsExamAuto.Tables[0];
                            string    RndoKey   = "0";
                            RndoKey = getConfigValue("JumbleQuestion");
                            int RndmQuestion = Convert.ToInt32(RndoKey);

                            DataTable dtExaAutoRandom;
                            if (RndmQuestion == 1)
                            {
                                Random     randNum    = new Random();
                                int        randomRow  = 0;
                                List <int> numbers    = new List <int>();
                                int        num        = 0;
                                int        rowToEnter = 0;
                                num = randNum.Next(1, dtExaAuto.Rows.Count + 1);
                                while (numbers.Count < dtExaAuto.Rows.Count)
                                {
                                    if (numbers.Contains(num))
                                    {
                                        num = randNum.Next(1, dtExaAuto.Rows.Count + 1);
                                    }
                                    else
                                    {
                                        randomRow = num;
                                        numbers.Add(num);
                                        dtExaAuto.Rows[rowToEnter]["RandNum"] = num;
                                        dtExaAuto.AcceptChanges();
                                        rowToEnter = rowToEnter + 1;
                                    }
                                }

                                DataView dv = new DataView(dtExaAuto);
                                dv.Sort         = "RandNum ASC";
                                dtExaAutoRandom = dv.ToTable();
                            }
                            else
                            {
                                DataView dv = new DataView(dtExaAuto);
                                dtExaAutoRandom = dv.ToTable();
                            }
                            ViewState["QuestionAnsDT"] = dtExaAutoRandom;
                            ViewState["CurQuestion"]   = 0;
                            BindNextQuestion(dtExaAutoRandom);
                        }
                        else
                        {
                            BtnButton.Visible      = false;
                            Session["ExamStarted"] = "";
                            Session["TrackLogID"]  = "";
                            WebMsg.Show("No Question found!");
                            Response.Redirect("../Dashboard/StudentDashboard.aspx");
                        }
                    }
                    else
                    {
                        BtnButton.Visible      = false;
                        Session["ExamStarted"] = "";
                        Session["TrackLogID"]  = "";
                        WebMsg.Show("No Question found!");
                        Response.Redirect("../Dashboard/StudentDashboard.aspx");
                    }
                }
                else
                {
                    Session["ExamStarted"] = "";
                    Session["TrackLogID"]  = "";
                    Response.Redirect("../Dashboard/StudentDashboard.aspx");
                }
            }
        }
    }