예제 #1
0
    protected void SubmitBtn3_Click(object sender, EventArgs e)
    {
        TestingSystemEntities2 ts = new TestingSystemEntities2();
        Sub   s = new Sub();
        Topic t = new Topic();

        if (SubTxt2.Text != "")
        {
            if (ts.Subs.Any(a => a.name == SubTxt2.Text))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "key", "alert('Subject Name already exist')", true);
            }
            else
            {
                if (SubTxt2.Text != null && TopicTxt2.Text != null)
                {
                    s.name = SubTxt2.Text;
                    ts.Subs.Add(s);
                    ts.SaveChanges();
                    t.Tname = TopicTxt2.Text;
                    t.subId = s.id;
                    ts.Topics.Add(t);
                    ts.SaveChanges();
                    Response.Redirect("MCQPage.aspx");
                }
            }
        }
    }
예제 #2
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        TestingSystemEntities2 db = new TestingSystemEntities2();
        MainData maindata         = Session["Maindata"] as MainData;

        Question q = new Question();

        q.point    = maindata.Points;
        q.Tid      = maindata.Topicid;
        q.Qstate   = txtBoxQuestion.Text;
        q.hardness = maindata.Hardness;
        db.Questions.Add(q);

        Program p = new Program();

        p.Qid  = q.id;
        p.code = txtBoxCode.Text;
        db.Programs.Add(p);
        db.SaveChanges();

        txtBoxCode.Text     = "";
        txtBoxQuestion.Text = "";

        Response.Redirect("Default.aspx");
    }
예제 #3
0
    protected void AddMoreTopicBtn_Click(object sender, EventArgs e)
    {
        int data = 1;
        TestingSystemEntities2 ts = new TestingSystemEntities2();
        Topic t = new Topic();
        Sub   s = new Sub();

        if (data == 1)
        {
            if (ts.Subs.Any(a => a.name == SubTxt1.Text))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "key", "alert('Subject Name already exist')", true);
            }
            else
            {
                s.name = SubTxt1.Text;
                ts.Subs.Add(s);
                ts.SaveChanges();

                ViewState["subjectid"] = s.id;
                if (TopicTxt1.Text != null)
                {
                    t.Tname = TopicTxt1.Text;
                    t.subId = s.id;
                    ts.Topics.Add(t);
                    ts.SaveChanges();
                }
                TopicTxt1.Text = "";
            }
            data = 5;
        }
        else
        {
            int id = Convert.ToInt32(ViewState["subjectid"]);
            if (TopicTxt1.Text != null)
            {
                t.Tname = TopicTxt1.Text;
                t.subId = id;
                ts.Topics.Add(t);
                ts.SaveChanges();
            }
            TopicTxt1.Text = "";
        }
    }
예제 #4
0
    protected void SubmitBtn2_Click(object sender, EventArgs e)
    {
        TestingSystemEntities2 ts = new TestingSystemEntities2();
        Topic t  = new Topic();
        int   id = Convert.ToInt32(ViewState["subjectid"]);

        if (TopicTxt1.Text != null)
        {
            t.Tname = TopicTxt1.Text;
            t.subId = id;
            ts.Topics.Add(t);
            ts.SaveChanges();
        }
        TopicTxt1.Text = "";
        Response.Redirect("MCQPage.aspx");
    }
예제 #5
0
    protected void SubmitQues_Click(object sender, EventArgs e)
    {
        MainData               maindata = Session["Maindata"] as MainData;
        List <TempData>        data     = ViewState["datalist"] as List <TempData>;
        TestingSystemEntities2 db       = new TestingSystemEntities2();

        Question q = new Question();

        q.Qstate   = txtofQstat.Text;
        q.point    = maindata.Points;
        q.Tid      = maindata.Topicid;
        q.hardness = maindata.Hardness;
        db.Questions.Add(q);

        int       lindex = data.Count();
        MCQOption mq;

        for (int i = 0; i < lindex; i++)
        {
            mq     = new MCQOption();
            mq.Qid = q.id;

            mq.MOption = data[i].Option;
            if (data[i].Status == true)
            {
                mq.correct = true;
            }
            else
            {
                mq.correct = false;
            }
            db.MCQOptions.Add(mq);
        }
        db.SaveChanges();

        Response.Redirect("Default.aspx");
    }