Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            label2.Visible = false;

            var context           = new IllusionsPerceptionContext();
            var name              = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            var experimentResult  = context.Experiment1Result.Where(x => x.Id_User == _id).ToList();
            var experimentResult1 = context.Experiment2Result.Where(x => x.Id_User == _id).ToList();

            var count  = int.Parse(context.Settings.FirstOrDefault(x => x.Name == "Предъявлений1").Value);
            var count1 = int.Parse(context.Settings.FirstOrDefault(x => x.Name == "Предварительная").Value)
                         + int.Parse(context.Settings.FirstOrDefault(x => x.Name == "Контрольная").Value);

            Experiment1Result rez = new Experiment1Result();

            if (experimentResult.Count != 0)
            {
                rez = experimentResult[experimentResult.Count - 1];
            }
            else
            {
                rez.NumberDisplay    = 0;
                rez.AllNumberDisplay = count;
            }

            Experiment2Result rez1 = new Experiment2Result();

            if (experimentResult1.Count != 0)
            {
                rez1 = experimentResult1[experimentResult1.Count - 1];
            }
            else
            {
                rez1.NumberDisplay    = 0;
                rez1.AllNumberDisplay = count1;
            }

            switch (name)
            {
            case "Опыт №1":
                if (rez.NumberDisplay == rez.AllNumberDisplay)
                {
                    label2.Visible = true;
                    break;
                }
                else
                {
                    var nForm = new Form8(rez.NumberDisplay + 1, _id);
                    nForm.FormClosed += (o, ep) => this.Close();
                    nForm.Show();
                    this.Hide();
                    break;
                }

            case "Опыт №2":
                if (rez1.NumberDisplay == rez1.AllNumberDisplay)
                {
                    label2.Visible = true;
                    break;
                }
                else
                {
                    var nForm = new Form11(rez1.NumberDisplay + 1, _id);
                    nForm.FormClosed += (o, ep) => this.Close();
                    nForm.Show();
                    this.Hide();
                    break;
                }
            }
        }