private void button_finish_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want to finish ?", "Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                if (File.Exists(GetFilePathAnswer()))
                {
                    using (StreamWriter file = new StreamWriter(GetFilePathAnswer()))
                    {
                        foreach (string line in Answers)
                        {
                            file.WriteLine(line);
                        }
                    }

                    LogInUi logInPage = new LogInUi();
                    logInPage.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Not found", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 2
0
        private void tabControl_teacher_panel_Selected(object sender, TabControlEventArgs e)
        {
            if (e.TabPage == tabPage_log_out)
            {
                DialogResult dr = MessageBox.Show("Are you want to exit ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (dr == DialogResult.Yes)
                {
                    LogInUi logInPage = new LogInUi();
                    logInPage.Show();
                    this.Hide();
                }
            }
            else if (e.TabPage == tabPage_teacher_exam_list)
            {
                TeacherCurrentExamInfoFillup();
            }
            else if (e.TabPage == tabPage_create_exam)
            {
                for (int i = 0; i < 13; i++)
                {
                    string strNumber = i.ToString();
                    if (strNumber.Count() == 1)
                    {
                        strNumber = "0" + strNumber;
                    }
                    comboBox_exam_time_hh.Items.Add(strNumber);
                    comboBox_duration_hh.Items.Add(strNumber);
                }

                for (int i = 0; i < 60; i++)
                {
                    string strNumber = i.ToString();
                    if (strNumber.Count() == 1)
                    {
                        strNumber = "0" + strNumber;
                    }
                    comboBox_exam_time_mm.Items.Add(strNumber);
                    comboBox_duration_mm.Items.Add(strNumber);
                }
            }
        }
        private void tabControl_admin_panel_Selected(object sender, TabControlEventArgs e)
        {
            if (e.TabPage == tabPage_log_out)
            {
                DialogResult dr = MessageBox.Show("Are you want to exit ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (dr == DialogResult.Yes)
                {
                    LogInUi logInPage = new LogInUi();
                    logInPage.Show();
                    this.Hide();
                }
            }
            else if (e.TabPage == tabPage_teacher_info)
            {
                FillUpTeachersInfo();
            }
            else if (e.TabPage == tabPage_current_exams)
            {
                CurrentExamInfoFillUp();
            }
        }
        private void loadFunction()
        {
            Second = 59;
            SetExamDateTime();
            string date = DateTime.Now.ToString("dd.MM.yyyy");
            string time = DateTime.Now.ToString("hh:mm tt");

            if ((Convert.ToDateTime(ExamDate)).Date == (Convert.ToDateTime(date)).Date && IsValidTime(time, ExamTime))
            {
                makeEnable();
                string timeDuration = (GetExamDuration().Substring(0, 5));

                DateTime crntTime = DateTime.Now;
                DateTime endTime  = GetExamLastTime();
                TimeSpan diff     = endTime - crntTime;

                Hour   = diff.Hours;
                Minute = diff.Minutes;

                ShowTimer();

                IndexQuestion  = -2;
                QuestionNumber = 1;

                if (!File.Exists(GetFilePathQuestion()))
                {
                    MessageBox.Show("Question file not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LogInUi loginPage = new LogInUi();
                    loginPage.Show();
                    this.Hide();
                }
                else
                {
                    using (StreamReader read = new StreamReader(GetFilePathQuestion()))
                    {
                        string line;
                        while ((line = read.ReadLine()) != null)
                        {
                            if (line != "★★★")
                            {
                                Questions.Add(line);
                            }
                        }
                    }
                }
                TotalQuestions = (Questions.Count) / 2;
                for (int i = 0; i < TotalQuestions * 2; i++)
                {
                    Answers.Add(" ");
                }
                Answers.Add(" ");
                IndexQuestion = IndexQuestion + 2;
                ShowQuestionAndAnswer();
                button_previous.Enabled = false;
                if (QuestionNumber == TotalQuestions)
                {
                    button_next.Enabled = false;
                }
                CreateFile();
            }
            else
            {
                MessageBox.Show("Exam is not running", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                makeDisable();
            }
        }