private void button_question_finish_Click(object sender, EventArgs e)
        {
            int i = 0;

            if (File.Exists(GetFilePath()))
            {
                using (StreamWriter file = new StreamWriter(GetFilePath()))
                {
                    foreach (string line in QuestionList)
                    {
                        file.WriteLine(line);
                        file.WriteLine("★★★");
                        file.WriteLine(QuestionMarks[i]);
                        file.WriteLine("★★★");
                        i++;
                    }
                }

                TeacherPanelUi teacherPanel = new TeacherPanelUi();
                teacherPanel.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Not found", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void button_back_Click(object sender, EventArgs e)
        {
            TeacherPanelUi back = new TeacherPanelUi();

            back.Show();
            this.Hide();
        }
Ejemplo n.º 3
0
        private void AnswerSheetUi_Load(object sender, EventArgs e)
        {
            TotalMarks     = 0;
            IndexQuestion  = 0;
            QuestionNumber = QuestionNumber + 1;

            if (!File.Exists(GetFilePathAnswer()))
            {
                MessageBox.Show("Answer file not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ParticipantInfo participantPage = new ParticipantInfo();
                participantPage.Show();
                this.Hide();
            }
            else
            {
                using (StreamReader read = new StreamReader(GetFilePathAnswer()))
                {
                    string line;
                    while ((line = read.ReadLine()) != null)
                    {
                        Answers.Add(line);
                    }
                }
            }

            if (!File.Exists(GetFilePathQuestion()))
            {
                MessageBox.Show("Question file not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TeacherPanelUi teacherPanel = new TeacherPanelUi();
                teacherPanel.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;
            ShowQuestionAndAnswer();
        }
Ejemplo n.º 4
0
        private void button_logIn_Click(object sender, EventArgs e)
        {
            DBAccess  sqlcon = new DBAccess();
            DataTable table  = new DataTable();

            string username    = textBox_username.Text;
            string password    = textBox_password.Text;
            string designation = comboBox_designation.Text;

            if (username.Equals("") || password.Equals(""))
            {
                MessageBox.Show("Invalid id or password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                RefreshPage();
            }
            else if (designation.Equals("ADMIN") || designation.Equals("TEACHER"))
            {
                string query = "Select * from User_Master Where User_Id= '" + username + "' AND Password= '******' AND Designation= '" + designation + "'";

                sqlcon.readDatathroughAdapter(query, table);
                if (table.Rows.Count == 1)
                {
                    MessageBox.Show("Logged In Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    FillExamTeacherInfo(username, "abcd", "abcd");

                    sqlcon.closeConn();

                    if (designation == "ADMIN")
                    {
                        AdminPanelUi nextPage = new AdminPanelUi();
                        nextPage.Show();
                        this.Hide();
                    }
                    else
                    {
                        TeacherPanelUi nextPage = new TeacherPanelUi();
                        nextPage.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Invalid id or password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    RefreshPage();
                }
            }
            else if (designation.Equals("STUDENT"))
            {
                string     query       = "Select * from Student_Master Where Student_Id= '" + username + "' AND Password= '******'";
                SqlCommand selectQuery = new SqlCommand(query);

                sqlcon.readDatathroughAdapter(query, table);

                if (table.Rows.Count == 1)
                {
                    table.Clear();
                    query = "Select Teacher_Id,Course_Code from Student_Master Where Student_Id= '" + username + "' AND Password= '******'";
                    sqlcon.readDatathroughAdapter(query, table);

                    string teacherId  = table.Rows[0]["Teacher_Id"].ToString();
                    string courseCode = table.Rows[0]["Course_Code"].ToString();
                    FillExamTeacherInfo(teacherId, courseCode, username);
                    if (isAvailableStudent())
                    {
                        sqlcon.closeConn();
                        StudentPanelUi studentPanel = new StudentPanelUi();
                        studentPanel.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Your already submit your answer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        RefreshPage();
                    }
                }
                else
                {
                    MessageBox.Show("Incorect id or password", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                RefreshPage();
            }
            else
            {
                MessageBox.Show("Please select a designation", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            sqlcon.closeConn();
        }