예제 #1
0
        public Security(string Email, String Password)
        {
            DataSet ds = new DataSet();

                DAL myDal = new DAL(ConfigurationManager.ConnectionStrings["Exam"].ConnectionString);
                myDal.ClearParams();
                myDal.AddParam("@Email", Email + ConfigurationManager.AppSettings["EmailDomainName"]);
                myDal.AddParam("@Password", Password);
                ds = myDal.ExecuteProcedure("UserspLogin");

                if (ds.Tables[0].Rows.Count == 0)
                {
                    SecurityLevel = 0;
                    Firstname = "Invalid Login";
                    Userid = -1;

                }
                else
                {
                    SecurityLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["SecurityLevel"].ToString());
                    Firstname = "Welcome " + ds.Tables[0].Rows[0]["FirstName"].ToString() + "!";
                    Userid = Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"].ToString());
                }
                HttpContext.Current.Session["Firstname"] = Firstname;
                HttpContext.Current.Session["SecurityLevel"] = SecurityLevel;
                HttpContext.Current.Session["Userid"] = Userid;
        }
예제 #2
0
        protected void btnfinish_Click1(object sender, EventArgs e)
        {
            Security s=new Security();
            DAL mydal = new DAL(conn);
             //  mydal.AddParam("@QuizResponseId",);
            for (int i=0;i<(int)Session["NumberofQuestion"];i++)
            {
                mydal.ClearParams();
              mydal.AddParam("@UserId",s.Userid);
              mydal.AddParam("@QuizId", (int)Session["QuizId"]);

                mydal.AddParam("@QuestionId",(i+1).ToString());
              mydal.AddParam("@Response",Responses[i]);
              mydal.ExecuteProcedure("spInsertQuestionResponse");
            }
        }
        public void updateResponses()
        {
            bool isFinish = false;
            Security s = new Security();
            DAL mydal = new DAL(conn);

            string newQuizResponseId = insertQuizInformation();

            int j = (int)Session["NumberofQuestion"];
            for (int i = 0; i < (int)Session["NumberofQuestion"]; i++)
            {
                if (Responses[i] != null)
               {
                    mydal.ClearParams();
                    mydal.AddParam("@newQuizResponseId", newQuizResponseId);
                    mydal.AddParam("@QuestionId", (i + 1).ToString());
                    mydal.AddParam("@Response", Responses[i]);
                    DataSet ds = mydal.ExecuteProcedure("spInsertQuestionResponse");
                    string Result = ds.Tables[0].Rows[0]["Result"].ToString();
                    if (Result == "success")
                    {

                        isFinish = true;
                    }
               }

            }

            if (isFinish)
            {
                Response.Redirect("FinishExam.aspx");
            }
            else
            {
                //to do
            }
        }