コード例 #1
0
ファイル: Test.aspx.cs プロジェクト: pikapikunova/MultTech1
        protected void Button4_Click(object sender, EventArgs e)
        {
            Label newLbl = new Label();
            int   k      = 0;

            for (int i = 0; i < index; i++)
            {
                if (test[i] != -1)
                {
                    k += test[i];
                }
            }
            newLbl.Text = "Ваш результат " + k + " баллов из " + index;
            views[MultiView1.ActiveViewIndex].Controls.Add(newLbl);
            Button3.Visible = false;
            Button2.Visible = false;
            Button1.Visible = false;

            int s = Convert.ToInt32(Request.QueryString["id"]);

            var context = new MediaTech1DBContext();

            var query = context.Student.Single(c => c.ID == s);

            query.marks = k;

            var query1 = context.Student.Single(c => c.ID == s);

            query.dateOfTest = DateTime.Today;

            context.SaveChanges();

            Button4.Visible = false;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label2.Text = Page.Session["name"].ToString();

            string s = Page.Session["id"].ToString();

            var context = new MediaTech1DBContext();

            Menu1.Items[1].NavigateUrl += "?id=" + s;

            int id = Convert.ToInt32(s);

            SqlDataSource2.FilterExpression = "[ID] = " + id.ToString();
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var context = new MediaTech1DBContext();

            string log = TextBox4.Text.ToString();
            string pas = TextBox5.Text.ToString();

            var query = from c in context.Student
                        where c.login == log || c.password == pas
                        select c.ID;

            var query1 = from c in context.Teacher
                         where c.login == log || c.password == pas
                         select c.id;

            if (query.ToList().Count == 0 && query1.ToList().Count == 0)
            {
                if (RadioButtonList1.SelectedItem.ToString() == "Студент")
                {
                    context.Student.Add(new Student {
                        name = TextBox1.Text.ToString(), surname = TextBox2.Text.ToString(), patronymic = TextBox3.Text.ToString(), login = TextBox4.Text.ToString(), password = TextBox5.Text.ToString(), dateOfTest = null, marks = null
                    });
                }
                else
                {
                    context.Teacher.Add(new Teacher {
                        name = TextBox1.Text.ToString(), surname = TextBox2.Text.ToString(), patronymic = TextBox3.Text.ToString(), login = TextBox4.Text.ToString(), password = TextBox5.Text.ToString()
                    });
                }

                Button1.Visible = false;

                Label7.Text = "Вы успешно зарегистрировались!";

                context.SaveChanges();
            }
            else
            {
                Label7.Text = "Такой логин или пароль уже существует";
            }
        }
コード例 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string log = TextBox1.Text.ToString();
            string pas = TextBox2.Text.ToString();

            var context = new MediaTech1DBContext();

            var query = from c in context.Teacher
                        where c.login == log && c.password == pas
                        select c.name;

            var query3 = from c in context.Teacher
                         where c.login == log && c.password == pas
                         select c.id;

            var query2 = from c in context.Student
                         where c.login == log && c.password == pas
                         select c.ID;

            if (query.ToList().Count != 0)
            {
                Page.Session["id"]   = query3.ToList()[0];
                Page.Session["name"] = query.ToList()[0];
                Response.Redirect("LKTeacher.aspx");
            }
            else
            {
                var query1 = from c in context.Student
                             where c.login == log && c.password == pas
                             select c.name;

                if (query1.ToList().Count != 0)
                {
                    Page.Session["id"]   = query2.ToList()[0];
                    Page.Session["name"] = query1.ToList()[0];
                    Response.Redirect("LKStudent.aspx");
                }
            }
        }
コード例 #5
0
ファイル: Test.aspx.cs プロジェクト: pikapikunova/MultTech1
        protected void Button3_Click(object sender, EventArgs e)
        {
            var context = new MediaTech1DBContext();

            Label lbl = views[MultiView1.ActiveViewIndex].FindControl(views[MultiView1.ActiveViewIndex].Controls[0].ClientID) as Label;

            var answ = from c in context.Questions
                       where c.ques == lbl.Text
                       select c.answers_id;

            var idOfTheory = from c in context.Questions
                             where c.ques == lbl.Text
                             select c.theory_id;


            int a      = answ.ToList()[0];
            int idOfTh = idOfTheory.ToList()[0];



            var trueAnsw = from c in context.Answers
                           where c.id == a
                           select c.trueAnsw;

            var radioB = from c in context.Answers
                         where c.id == a
                         select c.radioBut;

            var checkB = from c in context.Answers
                         where c.id == a
                         select c.checkBox;

            var textB = from c in context.Answers
                        where c.id == a
                        select c.texBox;

            string        idOfAnsw = views[MultiView1.ActiveViewIndex].Controls[1].ClientID;
            List <string> list     = new List <string>();

            Label label = new Label();

            if (Convert.ToBoolean(radioB.ToList()[0]))
            {
                RadioButtonList t = views[MultiView1.ActiveViewIndex].FindControl(idOfAnsw) as RadioButtonList;

                list.Add(t.SelectedValue);

                if (list[0] == trueAnsw.ToList()[0].Trim(' '))
                {
                    funForTrue(label);
                }
                else
                {
                    funForFalse(label, idOfTh);
                }
            }
            else
            {
                if (Convert.ToBoolean(checkB.ToList()[0]))
                {
                    CheckBoxList t = views[MultiView1.ActiveViewIndex].FindControl(idOfAnsw) as CheckBoxList;

                    for (int i = 0; i < t.Items.Count; i++)
                    {
                        if (t.Items[i].Selected)
                        {
                            list.Add(t.Items[i].Text);
                        }
                    }

                    string[] tAnsw = trueAnsw.ToList()[0].Split(';');

                    for (int j = 0; j < tAnsw.Length; j++)
                    {
                        tAnsw[j] = tAnsw[j].Trim(' ');
                    }

                    int k = 0;
                    for (int i = 0; i < list.Count; i++)
                    {
                        for (int j = 0; j < tAnsw.Length; j++)
                        {
                            if (list[i] == tAnsw[j])
                            {
                                k++;
                            }
                        }
                    }

                    if (k == list.Count && k == tAnsw.Length)
                    {
                        funForTrue(label);
                    }
                    else
                    {
                        funForFalse(label, idOfTh);
                    }
                }
                else
                {
                    if (Convert.ToBoolean(textB.ToList()[0]))
                    {
                        TextBox t = views[MultiView1.ActiveViewIndex].FindControl(idOfAnsw) as TextBox;

                        list.Add(t.Text);

                        if (list[0] == trueAnsw.ToList()[0].Trim())
                        {
                            funForTrue(label);
                        }
                        else
                        {
                            funForFalse(label, idOfTh);
                        }
                    }
                }
            }
        }
コード例 #6
0
ファイル: Test.aspx.cs プロジェクト: pikapikunova/MultTech1
        protected void Page_PreInit(object sender, EventArgs e)
        {
            var context = new MediaTech1DBContext();

            var ques = from c in context.Questions
                       select c.ques;

            var falseAnsw = from c in context.Answers
                            select c.falseAnsw;

            var trueAnsw = from c in context.Answers
                           select c.trueAnsw;

            var radioB = from c in context.Answers
                         select c.radioBut;

            var checkB = from c in context.Answers
                         select c.checkBox;

            var textB = from c in context.Answers
                        select c.texBox;


            index = ques.ToList().Count();

            views = new View[index];

            if (!IsPostBack)
            {
                test = new int[index];
                for (int i = 0; i < index; i++)
                {
                    test[i] = -1;
                }
            }


            for (int i = 0; i < index; i++)
            {
                string[] fAnsw = new string[0];

                if (falseAnsw.ToList()[i] != null)
                {
                    fAnsw = falseAnsw.ToList()[i].Split(';');

                    for (int j = 0; j < fAnsw.Length; j++)
                    {
                        fAnsw[j] = fAnsw[j].Trim(' ');
                    }
                }

                string[] tAnsw = trueAnsw.ToList()[i].Split(';');

                for (int j = 0; j < tAnsw.Length; j++)
                {
                    tAnsw[j] = tAnsw[j].Trim(' ');
                }

                string[] answ = fAnsw.Union(tAnsw).ToArray();



                if (!IsPostBack)
                {
                    Random rand = new Random();
                    for (int j = 0; j < answ.Length; j++)
                    {
                        int    t    = rand.Next(0, j);
                        string temp = answ[j];
                        answ[j] = answ[t];
                        answ[t] = temp;
                    }
                }

                views[i] = new View();
                Label lbl = new Label();

                lbl.Text = ques.ToList()[i].ToString();
                views[i].Controls.Add(lbl);

                if (Convert.ToBoolean(radioB.ToList()[i]))
                {
                    RadioButtonList rbList = new RadioButtonList();

                    views[i].Controls.Add(rbList);

                    for (int j = 0; j < answ.Length; j++)
                    {
                        rbList.Items.Add(answ[j]);
                    }
                }
                else
                {
                    if (Convert.ToBoolean(checkB.ToList()[i]))
                    {
                        CheckBoxList chbList = new CheckBoxList();

                        views[i].Controls.Add(chbList);

                        for (int j = 0; j < answ.Length; j++)
                        {
                            chbList.Items.Add(answ[j]);
                        }
                    }
                    else
                    {
                        if (Convert.ToBoolean(textB.ToList()[i]))
                        {
                            TextBox textb = new TextBox();
                            views[i].Controls.Add(textb);
                        }
                    }
                }

                MultiView1.Views.Add(views[i]);
            }

            MultiView1.ActiveViewIndex = 0;

            Button2.Visible = false;
        }
コード例 #7
0
ファイル: Theory.aspx.cs プロジェクト: pikapikunova/MultTech1
        protected void Page_PreInit(object sender, EventArgs e)
        {
            var context = new MediaTech1DBContext();

            var query = from c in context.Theory
                        select c.paragraph;


            var im = from c in context.Theory
                     select c.image;

            var vid = from c in context.Theory
                      select c.video;

            var aud = from c in context.Theory
                      select c.audio;

            var gif = from c in context.Theory
                      select c.gif;



            index = query.ToList().Count();

            for (int i = 0; i < index; i++)
            {
                HtmlGenericControl control      = new HtmlGenericControl();
                HtmlGenericControl controlImg   = new HtmlGenericControl();
                HtmlGenericControl controlAudio = new HtmlGenericControl();
                HtmlGenericControl controlVideo = new HtmlGenericControl();
                HtmlGenericControl controlGif   = new HtmlGenericControl();

                view1 = new View();
                view1.Controls.Add(control);
                view1.Controls.Add(controlImg);
                view1.Controls.Add(controlAudio);
                view1.Controls.Add(controlVideo);
                view1.Controls.Add(controlGif);


                MultiView1.Views.Add(view1);

                control.InnerHtml = "<div>" + query.ToList()[i].ToString() + "</div>";

                if (im.ToList()[i] != null)
                {
                    controlImg.InnerHtml = "<img src=" + im.ToList()[i].ToString() + "> ";
                }

                if (aud.ToList()[i] != null)
                {
                    controlAudio.InnerHtml = "<audio controls> <source src=" + aud.ToList()[i].ToString() + "> </audio> ";
                }

                if (vid.ToList()[i] != null)
                {
                    controlVideo.InnerHtml = "<video controls width=/'/300/'/ height=/'/200/'/ src =" + vid.ToList()[i].ToString() + "></ video >";
                }

                if (gif.ToList()[i] != null)
                {
                    controlGif.InnerHtml = "<img src=" + gif.ToList()[i].ToString() + "> ";
                }
            }

            string s = Request.ServerVariables[0].ToString();

            if (s.Contains("http://localhost:50388/Test.aspx"))
            {
                MultiView1.ActiveViewIndex = Convert.ToInt32(Request.QueryString["idOfTheory"]);
            }
            else
            {
                MultiView1.ActiveViewIndex = 0;
            }

            Button2.Visible = false;
        }