Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            string time = timetest.Text;

            string[] values   = time.Split(':');
            TimeSpan timeSpan = new TimeSpan(Convert.ToInt32(values[0]), Convert.ToInt32(values[1]), 0);

            informsysEntities     context = new informsysEntities();
            JsonSerializerOptions jso     = new JsonSerializerOptions();

            jso.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping;

            json = JsonSerializer.Serialize <Test>(test, jso);

            AllForTests allForTests = new AllForTests();

            allForTests.QuestAnswerTrueAnswer = json;
            allForTests.TestTopic             = testtopic.Text;


            allForTests.TestTime   = timeSpan;
            allForTests.TestScores = Convert.ToInt32(scorestest.Text);

            context.AllForTests.Add(allForTests);
            context.SaveChanges();

            MessageBox.Show(json);

            ClearPanel(tabPage1);
        }
Beispiel #2
0
        private void add_Click(object sender, EventArgs e)
        {
            warrring.Visible = false;
            if (!(String.IsNullOrEmpty(user.Text)) && !(String.IsNullOrEmpty(pass.Text)))
            {
                informsysEntities context = new informsysEntities();
                Admins            admins  = context.Admins.Where(p => p.username == user.Text).FirstOrDefault();
                if (admins == null)
                {
                    Admins newadmins = new Admins();
                    newadmins.username  = user.Text;
                    newadmins.passwords = pass.Text;

                    context.Admins.Add(newadmins);
                    context.SaveChanges();
                    this.adminsTableAdapter.Fill(this.informsysDataSet.Admins);
                }
                else
                {
                    warrring.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("sdadasa");
            }

            user.Text = null;
            pass.Text = null;
        }
Beispiel #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 6)
            {
                informsysEntities context     = new informsysEntities();
                AllForTests       allForTests = context.AllForTests.Find(dateGridViewAllfortests.Rows[e.RowIndex].Cells[0].Value);
                context.AllForTests.Remove(allForTests);
                context.SaveChanges();

                this.allForTestsTableAdapter.Fill(this.informsysDataSet1.AllForTests);
            }
        }
Beispiel #4
0
        private void usersDataGridview_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 5)
            {
                var   context = new informsysEntities();
                Users users   = context.Users.Find(Convert.ToInt32(usersDataGridview.Rows[e.RowIndex].Cells[0].Value));

                context.Users.Remove(users);
                context.SaveChanges();

                UpdateDataGridView();
            }

            if (e.ColumnIndex == 4)
            {
                using (var context = new informsysEntities())
                {
                    Users users = context.Users.Find(Convert.ToInt32(usersDataGridview.Rows[e.RowIndex].Cells[0].Value));
                    if (users != null)
                    {
                        if (!(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[1].Value.ToString())) && !(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[2].Value.ToString())) &&
                            !(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[3].Value.ToString())))
                        {
                            warning.Visible = false;
                            users.username  = usersDataGridview.Rows[e.RowIndex].Cells[1].Value.ToString();
                            users.Email     = usersDataGridview.Rows[e.RowIndex].Cells[2].Value.ToString();
                            users.passwordd = usersDataGridview.Rows[e.RowIndex].Cells[3].Value.ToString();

                            context.Entry(users).State = EntityState.Modified;
                            context.SaveChanges();

                            UpdateDataGridView();
                        }
                        else
                        {
                            warning.Visible = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пользователь не найден");
                    }
                }
            }
        }
Beispiel #5
0
        private void adminDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                informsysEntities context = new informsysEntities();
                Admins            admins  = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value);

                if (admins != null)
                {
                    if (!(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) && !(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString())))
                    {
                        warning1.Visible            = false;
                        admins.username             = adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
                        admins.passwords            = adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
                        context.Entry(admins).State = EntityState.Modified;
                        context.SaveChanges();

                        this.adminsTableAdapter.Fill(this.informsysDataSet.Admins);
                    }
                    else
                    {
                        warning1.Visible = true;
                    }
                }
                else
                {
                    MessageBox.Show("Такого пользователя не сущетвует");
                }
            }

            if (e.ColumnIndex == 4)
            {
                informsysEntities context     = new informsysEntities();
                Admins            deliteadmin = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value);

                context.Admins.Remove(deliteadmin);
                context.SaveChanges();

                this.adminsTableAdapter.Fill(this.informsysDataSet.Admins);
            }
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            informsysEntities context = new informsysEntities();
            Users             users   = context.Users.Where(p => p.username == login.Text).FirstOrDefault();
            Users             emaill  = context.Users.Where(p => p.Email == email.Text).FirstOrDefault();

            if (users == null)
            {
                if (emaill == null)
                {
                    Users newusers = new Users();
                    newusers.username  = login.Text;
                    newusers.Email     = email.Text;
                    newusers.passwordd = password.Text;
                    if (password.Text == confirmpass.Text)
                    {
                        context.Users.Add(newusers);
                        context.SaveChanges();
                        this.Close();
                        Form1.Show();
                    }
                    else
                    {
                        attention.Visible = true;
                    }
                }
                else
                {
                    busy2.Visible = true;
                }
            }
            else
            {
                busy.Visible = true;
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            Test test1 = JsonSerializer.Deserialize <Test>(datejson);

            if (CheckRadiobuttons(groupBox1) == test1.setQuestions[qust.Length - 1].trueAnswer)
            {
                ballsfortest += ballfortrueanswer;
                trueAnswer++;
            }

            update();

            if (qust.Length < count)
            {
                Array.Resize(ref qust, qust.Length + 1);
                quest.Items.Add(test1.setQuestions[qust.Length - 1].question);

                otvet1.Text = test1.setQuestions[qust.Length - 1].answer[0];
                otvet2.Text = test1.setQuestions[qust.Length - 1].answer[1];
                if (test1.setQuestions[qust.Length - 1].answer[2] != null && test1.setQuestions[qust.Length - 1].answer[3] != null)
                {
                    otvet3.Text = test1.setQuestions[qust.Length - 1].answer[2];
                    otvet4.Text = test1.setQuestions[qust.Length - 1].answer[3];
                }
                else if (test1.setQuestions[qust.Length - 1].answer[2] != null)
                {
                    otvet3.Text = test1.setQuestions[qust.Length - 1].answer[2];
                }
                else
                {
                    otvet3.Visible = false;
                    otvet4.Visible = false;
                }
                resetRadioButton();
            }
            else
            {
                timer1.Stop();

                TimeSpan passage = new TimeSpan();
                passage = alltime - timeSpan;

                string allpassage = String.Format("{0} / {1} ", passage, alltime);

                float way = (ballsfortest * 100) / balls;
                if (way >= 90)
                {
                    ocenka = 5;
                }
                else if (way >= 75)
                {
                    ocenka = 4;
                }
                else if (way >= 50)
                {
                    ocenka = 3;
                }
                else
                {
                    ocenka = 2;
                }


                string name = nameuser;


                informsysEntities context = new informsysEntities();

                UserStatistics userStatistics = new UserStatistics();

                userStatistics.UserName   = name;
                userStatistics.TestName   = testtopic;
                userStatistics.TrueAnswer = String.Format("{0} / {1}", trueAnswer, count);
                userStatistics.SetBalls   = String.Format("{0} / {1}", ballsfortest, balls);
                userStatistics.Way        = String.Format("{0}%", way);
                userStatistics.Assessment = ocenka;
                userStatistics.traveltime = allpassage;

                context.UserStatistics.Add(userStatistics);
                context.SaveChanges();



                Statistics statistics = new Statistics();
                statistics.name = nameuser;
                this.Hide();
                statistics.Show();
            }
        }