public FormResultsStudy(FormStudy formStudy)
        {
            InitializeComponent();

            this.MinimumSize = this.Size;
            this.MaximumSize = this.Size;

            _currentTest    = formStudy._currentTest;
            _currentVzvod   = formStudy._currentVzvod;
            _currentStudent = formStudy._currentStudent;
            _currentCourse  = formStudy._currentCourse;

            labelTestName.Text      = _currentTest;
            labelVzvodName.Text     = _currentVzvod;
            labelFIOName.Text       = _currentStudent;
            labelCurrentCourse.Text = _currentCourse;

            var json = JsonConvert.SerializeObject(new Result
            {
                Mark        = "Пройдено",
                Platoon     = labelVzvodName.Text,
                StudentName = labelFIOName.Text,
                TestName    = labelTestName.Text,
                Timestamp   = DateTime.Now,
                ResultType  = "Тренировка",
                Course      = labelCurrentCourse.Text
            });
            var connectToServer = SendMessageFromServer(json);

            if (connectToServer)
            {
                return;
            }
            var path    = "res.data";
            var results = new List <Result>();

            if (File.Exists(path))
            {
                results = JsonConvert.DeserializeObject <List <Result> >(File.ReadAllText(path));
            }

            results.Add(new Result {
                Mark        = "Пройдено",
                Platoon     = labelVzvodName.Text,
                StudentName = labelFIOName.Text,
                TestName    = labelTestName.Text,
                Timestamp   = DateTime.Now,
                ResultType  = "Тренировка",
                Course      = labelCurrentCourse.Text
            });
            File.AppendAllText(path, JsonConvert.SerializeObject(results));
        }
Example #2
0
        private void startButton_Click(object sender, EventArgs e)
        {
            this.Visible = false;

            currentTest    = testName.SelectedItem.ToString();
            currentVzvod   = vzvodName.SelectedItem.ToString();
            currentStudent = FIOName.SelectedItem.ToString();
            currentCource  = comboBoxChooseCourse.SelectedItem.ToString();


            //Test currentTestInLists = new Test();
            int index = 0;

            for (int i = 0; i < listOfFormDefaultTest.TestList.Count; i++)
            {
                if (listOfFormDefaultTest.TestList[i].Name.Equals(currentTest))
                {
                    index = i;
                }
            }

            if (radioButtonTestModeTest.Checked)
            {
                _formTest = new FormTest(currentTest, currentVzvod, currentStudent, currentCource);
                listFormTests.Add(_formTest);
                _formTest.initTest(listOfFormDefaultTest.TestList[index]);
                _formTest.Visible = true;

                _formTest.Text = "ТЕСТ. " + currentTest + ". " + currentVzvod + " взвод. " + "Студент " + currentStudent;
            }

            if (radioButtonTestModeStudy.Checked)
            {
                _formStudy = new FormStudy(currentTest, currentVzvod, currentStudent, currentCource);
                listFormStudy.Add(_formStudy);
                _formStudy.initTest(listOfFormDefaultTest.TestList[index]);
                _formStudy.Visible = true;

                _formStudy.Text = "ОБУЧЕНИЕ. " + currentTest + ". " + currentVzvod + " взвод. " + "Студент " + currentStudent;
            }
        }