示例#1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     _activeStudent.FirstName = txtFName.Text;
     _activeStudent.LastName  = txtLName.Text;
     StudentDAO.Update(_activeStudent);
     txtStuID.Clear();
     txtLName.Clear();
     txtFName.Clear();
 }
示例#2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            txtStuID.Enabled = false;
            txtStuID.Clear(); //incase user trys to enter ID while adding
            _activeStudent           = new Student();
            _activeStudent.FirstName = txtFName.Text;
            _activeStudent.LastName  = txtLName.Text;

            StudentDAO.Create(_activeStudent);
            MessageBox.Show("Student has been added", "Students", MessageBoxButtons.OK, MessageBoxIcon.Information);

            txtFName.Clear();
            txtLName.Clear();
        }
示例#3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var student = int.Parse(txtStuID.Text);

            var result = MessageBox.Show("Are you sure you want to delete the student?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                StudentDAO.Delete(_activeStudent);
                txtStuID.Clear();
                txtLName.Clear();
                txtFName.Clear();
            }
        }
示例#4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var studentID = int.Parse(txtStuID.Text);

            _activeStudent = StudentDAO.GetStudent(studentID);
            if (_activeStudent == null)
            {
                MessageBox.Show("Student Does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            txtFName.Text = _activeStudent.FirstName;

            txtLName.Text     = _activeStudent.LastName;
            btnDelete.Enabled = true;
            btnUpdate.Enabled = true;
        }