Esempio n. 1
0
        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;
        }
Esempio n. 2
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 = "Такой логин или пароль уже существует";
            }
        }