Exemple #1
0
        private void button4_Click(object sender, System.EventArgs e)
        {
            var context = new IllusionsPerceptionContext();

            var count = context.User.Count();
            var user  = context.User.ToList();

            _id = user[count - 1].Id;

            if (_number > _number1)
            {
                button4.Enabled = false;
                button6.Visible = true;
            }
            else
            {
                var length        = 590;
                var center        = length / 2;
                var value         = center - button3.Location.X + 49;
                var absoluteValue = 0;
                var sign          = "";
                if (value < 0)
                {
                    absoluteValue = Math.Abs(value);
                    sign          = "-";
                }
                else
                {
                    absoluteValue = value;
                    sign          = "+";
                }

                context.Experiment1Result.Add(new Experiment1Result
                {
                    Id_User          = _id,
                    AbsoluteValue    = absoluteValue,
                    Sign             = sign,
                    NumberDisplay    = _number,
                    AllNumberDisplay = _number1
                });
                context.SaveChanges();
                _number++;
                if (_number == _number1 + 1)
                {
                    button4.Enabled = false;
                    button6.Visible = true;
                }
                else
                {
                    label3.Text = _number.ToString();
                }
                button3.Location = new Point(new Random().Next(103, 636), 280);
            }
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var number  = comboBox1.SelectedItem.ToString();
            var context = new IllusionsPerceptionContext();
            var model   = new Settings()
            {
                Id = 6, Name = "Коэфициент", Value = number
            };

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

            OutputOfImage(double.Parse(number));
        }
        private void button6_Click(object sender, EventArgs e)
        {
            var number  = comboBox3.SelectedItem.ToString();
            var context = new IllusionsPerceptionContext();
            var model   = new Settings()
            {
                Id = 3, Name = "Контрольная", Value = number
            };

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

            WriteInformation();
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var context = new IllusionsPerceptionContext();

            label7.Visible = false;
            label4.Visible = false;
            label5.Visible = false;
            var name        = textBox1.Text;
            var groupNumber = int.Parse(textBox2.Text);
            var user        = context.User.ToList();
            var number1     = int.Parse(context.Settings.First(x => x.Name == "Предъявлений1").Value);
            var _count1     = int.Parse(context.Settings.First(x => x.Name == "Предварительная").Value);
            var _count2     = int.Parse(context.Settings.First(x => x.Name == "Контрольная").Value);
            var number2     = _count1 + _count2;

            if (user.Any(x => x.Name == name &&
                         user.Any(m => m.Group == groupNumber)))
            {
                var id = user.First(x => x.Name == name).Id;

                if (context.Experiment1Result.Count(x => x.Id_User == id) == number1 &&
                    context.Experiment2Result.Count(x => x.Id_User == id) == number2)
                {
                    label6.Visible = true;
                }
                else
                {
                    var result = MessageBox.Show("У Вас есть незавершенные опыты, хотите продолжить?", "Незавершенные опыты", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        var nForm = new Form17(id);
                        nForm.FormClosed += (o, ep) => this.Close();
                        nForm.Show();
                        this.Hide();
                    }
                }
            }
            else
            {
                context.User.Add(new User {
                    Name = name, Group = groupNumber, Date = DateTime.Now
                });
                context.SaveChanges();

                label4.Visible  = true;
                button3.Visible = true;
            }
        }
        private void WriteToDb()
        {
            var context = new IllusionsPerceptionContext();

            var count = context.User.Count();
            var user  = context.User.ToList();

            _id = user[count - 1].Id;

            context.Experiment2Result.Add(new Experiment2Result
            {
                Id_User          = _id,
                TesteeResponse   = _testeeAnswer,
                CorrectAnswer    = _rightAnswer,
                Confidence       = _confidence,
                NumberDisplay    = _number,
                AllNumberDisplay = _number1
            });
            context.SaveChanges();
        }
Exemple #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            var id = int.Parse(dataGridView1.CurrentRow.Cells[3].Value.ToString());

            var context = new IllusionsPerceptionContext();
            var model   = new User {
                Id = id
            };

            var result = MessageBox.Show("Вы уверены, что хотите удалить данного студента?", "Удаление студента", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                context.User.Attach(model);
                context.User.Remove(model);
                context.SaveChanges();

                WriteToDataGridView();
            }
        }
        static void Main()
        {
            using (var context = new IllusionsPerceptionContext())
            {
                if (!context.Database.Exists())
                {
                    context.User.Add(new User {
                        Name = "admin", Group = 0, Password = "******"
                    });

                    context.Settings.Add(new Settings {
                        Name = "Предъявлений1", Value = "30"
                    });
                    context.Settings.Add(new Settings {
                        Name = "Предварительная", Value = "6"
                    });
                    context.Settings.Add(new Settings {
                        Name = "Контрольная", Value = "4"
                    });
                    context.Settings.Add(new Settings {
                        Name = "Экспозиция", Value = "200"
                    });
                    context.Settings.Add(new Settings {
                        Name = "Задержка", Value = "500"
                    });
                    context.Settings.Add(new Settings {
                        Name = "Коэфициент", Value = "1,2"
                    });

                    context.SaveChanges();
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }