Пример #1
0
 private void btnViewStudentProfile_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         StudentProfile StudentProfileForm = new StudentProfile();
         StudentProfileForm.StudentID = dataGridView1.SelectedRows[0].Cells["StudentID"].Value.ToString();
         StudentProfileForm.ShowDialog();
     }
 }
Пример #2
0
        private void btnViewProfile_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtStudentID.Text))
            {
                MessageBox.Show("Please enter your Student ID", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string Query = "SELECT * " +
                               "FROM StudentInformationTable " +
                               "WHERE StudentID = '" + txtStudentID.Text + "'";

                if (db.ExecuteQuery(Query).Rows.Count > 0)
                {
                    StudentProfile StudentProfileForm = new StudentProfile();
                    StudentProfileForm.StudentID = txtStudentID.Text;
                    StudentProfileForm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Student ID does not exist", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }