コード例 #1
0
        /*
         * Button (Save) - Save Button code behind
         */
        private void btnSave_Click(object sender, EventArgs e)
        {
            AddData updateStudentRecord = new AddData();
            int     studentId           = ucUpdateRecordControl1.UpdateStudent.StudentNumber;
            string  firstName           = ucUpdateRecordControl1.UpdateStudent.FirstName;
            string  surname             = ucUpdateRecordControl1.UpdateStudent.Surname;
            string  email        = ucUpdateRecordControl1.UpdateStudent.Email;
            string  phone        = ucUpdateRecordControl1.UpdateStudent.Phone;
            string  addressLine1 = ucUpdateRecordControl1.UpdateStudent.AddressLine1;
            string  addressLine2 = ucUpdateRecordControl1.UpdateStudent.AddressLine2;
            string  city         = ucUpdateRecordControl1.UpdateStudent.City;
            string  county       = ucUpdateRecordControl1.UpdateStudent.County;
            string  studentLevel = ucUpdateRecordControl1.UpdateStudent.Level;

            //send updated record to DB
            if (updateStudentRecord.EditStudentRecord(studentId, email, phone, addressLine1, addressLine2, city, county, studentLevel))
            {
                MessageBox.Show("Record Update - Student Record Successfully Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Ref Student Record Update For: " + firstName + " " + surname + "\nRecord Update Save Failed - Please Revise and Try Again",
                                "Failed Save", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }