Пример #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string id      = txtID.Text;
            string content = rtContent.Text;
            string A       = rtA.Text;
            string B       = rtA.Text;
            string C       = rtC.Text;
            string D       = rtD.Text;
            string crr     = "";

            if (rdA.Checked)
            {
                crr = "_a";
            }
            if (rdB.Checked)
            {
                crr = "_b";
            }
            if (rdC.Checked)
            {
                crr = "_c";
            }
            if (rdD.Checked)
            {
                crr = "_d";
            }
            string subject = cbSubject.Text;

            if (subject.Equals("Topnotch 1"))
            {
                subject = "TN1";
            }
            if (subject.Equals("Topnotch 2"))
            {
                subject = "TN2";
            }
            if (subject.Equals("Topnotch 3"))
            {
                subject = "TN3";
            }
            if (subject.Equals("Summit 1"))
            {
                subject = "SUM1";
            }
            AdminModel dt = new AdminModel();

            if (dt.Update(id, content, A, B, C, D, subject, crr))
            {
                dataGridView1.DataSource = dt.GetConnection();
                ResetGUI();
                MessageBox.Show("Update Success");
            }
            else
            {
                MessageBox.Show("Update Fail");
            }
        }
Пример #2
0
        private void tabControl1_Click(object sender, EventArgs e)
        {
            AdminModel model = new AdminModel();

            dataGridView1.DataSource = model.GetQuestion();
            Manage_Exam me = new Manage_Exam();

            dataGridView2.DataSource = me.GetExam();
        }
Пример #3
0
        private void btnCheckID_Click(object sender, EventArgs e)
        {
            string     id    = txtID.Text;
            AdminModel model = new AdminModel();

            if (model.CheckExist(id) == false)
            {
                MessageBox.Show("ID Question Existed");
            }
            else
            {
                MessageBox.Show("Chua co ma nay nhap di!");
                addCkeck = true;
            }
        }
Пример #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string     id    = txtID.Text;
            AdminModel model = new AdminModel();

            if (model.Delete(id) == true)
            {
                dataGridView1.DataSource = model.GetConnection();
                MessageBox.Show("Delete success");
                ResetGUI();
            }
            else
            {
                MessageBox.Show("Delete fail");
            }
            txtID.ReadOnly = false;
        }
Пример #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string     user  = txtUserName.Text;
            string     pass  = txtPassWord.Text;
            AdminModel model = new AdminModel();

            CurrentUser = model.CheckLogin(user, pass);
            if (CurrentUser == null)
            {
                MessageBox.Show("Login fail");
            }
            else
            {
                MessageBox.Show("Login success");
                this.Dispose();
            }
        }
Пример #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!addFlag)
            {
                ResetControl();

                btnAdd.Text = "Save";
            }
            else
            {
                if (addCkeck)
                {
                    string id      = txtID.Text;
                    string subject = cbSubject.SelectedItem.ToString();
                    string A       = rtA.Text;
                    string B       = rtB.Text;
                    string C       = rtC.Text;
                    string D       = rtD.Text;
                    string content = rtContent.Text;
                    string correct = "";
                    if (subject.Equals("Topnotch 1"))
                    {
                        subject = "TN1";
                    }
                    if (subject.Equals("Topnotch 2"))
                    {
                        subject = "TN2";
                    }
                    if (subject.Equals("Topnotch 3"))
                    {
                        subject = "TN3";
                    }
                    if (subject.Equals("Summit 1"))
                    {
                        subject = "SUM1";
                    }
                    if (rdA.Checked)
                    {
                        correct = "_a";
                    }
                    if (rdB.Checked)
                    {
                        correct = "_b";
                    }
                    if (rdC.Checked)
                    {
                        correct = "_c";
                    }
                    if (rdD.Checked)
                    {
                        correct = "_d";
                    }
                    AdminModel model = new AdminModel();
                    if (model.AddQuestion(id, content, A, B, C, D, subject, correct))
                    {
                        MessageBox.Show("Add Success");
                    }
                    else
                    {
                        MessageBox.Show("Failed");
                    }
                    btnAdd.Text = "Add";
                    ResetControl();
                }
            }
            addFlag = !addFlag;
        }