partial void DeleteStudent(Student instance);
 partial void InsertStudent(Student instance);
 partial void UpdateStudent(Student instance);
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            // creates a reference to the SQL Database
            StudentDataContext db = new StudentDataContext();

            Student newStudent = new Student();

            // check if the form type is Details, Edit or Delete
            if(this.FormType > 3)
            {
                newStudent = (from student in db.Students
                              where student.StudentID == this.StudentID
                              select student).FirstOrDefault();
            }

            // copy data into Student Object from form Text Boxes
            newStudent.FirstName = FirstNameTextBox.Text;
            newStudent.LastName = LastNameTextBox.Text;
            newStudent.Number = StudentNumberTextBox.Text;

            // Check if Form Type is "Add Student"
            if(this.FormType < 4) {
                // Insert the new Student Object into the SQL Database
                db.GetTable<Student>().InsertOnSubmit(newStudent);
            }

            // Delete Record
            if(this.FormType == (int)ColumnButton.Delete)
            {
                //Confirm if the user wants to delete the record
                DialogResult result = MessageBox.Show("Are You Sure?", "Confirm Deletion", MessageBoxButtons.OKCancel);
                if(result == DialogResult.OK)
                {
                    db.GetTable<Student>().DeleteOnSubmit(newStudent);
                }
            }

            // Save changes / update record
            db.SubmitChanges();

            // show the Student List Form
            this.studentListForm.Show();

            // close this form
            this.Close();
        }