Example #1
0
 private void PopulateFields(DataforStudent Students)
 {
     LBid.Text            = Students.id.ToString();
     tbstudentfname.Text  = Students.StudentFName;
     tbstudentlname.Text  = Students.StudentLName;
     tbnationality.Text   = Students.Nationality;
     tbparentfname.Text   = Students.ParentFirstName;
     tbparentlname.Text   = Students.ParentLastName;
     tbaddress.Text       = Students.Address;
     tbcontactnumber.Text = Students.ContactNumber;
 }
Example #2
0
 public EditStudentData(DataforStudent editStudent, ManageStudentData manageStudentData = null)
 {
     InitializeComponent();
     lAddEdit.Text     = "Edit Student";
     this.Text         = "Edit Student";
     managestudentdata = manageStudentData;
     if (editStudent == null)
     {
         MessageBox.Show("Select a valid record to edit");
         Close();
     }
     else
     {
         ManageData = new Norman_Manley_Institution_fo_the_ImpairedEntities1();
         PopulateFields(editStudent);
     }
 }
Example #3
0
        private void bSave_Click(object sender, EventArgs e)
        {
            try
            {
                var studentsfname = tbStudentsFName.Text;
                var studentslname = tbStudentsLName.Text;
                var Nationality   = tbNationality.Text;
                var DateofBirth   = dtpDateOfBirth.Value;
                var disability    = cbDisability.Text;
                var Gender        = cbGender.Text;
                var Class         = cbClass.Text;
                var parentsfname  = tbParentsFName.Text;
                var parentslname  = tbParentsLName.Text;
                var contactnumber = tbContactNumber.Text;
                var address       = tbAddress.Text;
                var EmailAddress  = tbEmailAddress.Text;
                var status        = tbStatus.Text;

                var isValid = true;

                if (string.IsNullOrWhiteSpace(studentsfname) || string.IsNullOrWhiteSpace(studentslname))
                {
                    isValid = false;
                    MessageBox.Show("All fields are required");
                }

                if (isValid == true)
                {
                    var StudentData = new DataforStudent();
                    StudentData.StudentFName    = studentsfname;
                    StudentData.StudentLName    = studentslname;
                    StudentData.Nationality     = Nationality;
                    StudentData.DateofBirth     = DateofBirth;
                    StudentData.ParentFirstName = parentsfname;
                    StudentData.ParentLastName  = parentslname;
                    StudentData.ContactNumber   = contactnumber;
                    StudentData.Address         = address;
                    StudentData.Status          = status;
                    StudentData.Disabilityid    = (int)cbDisability.SelectedValue;
                    StudentData.StudentGenderid = (int)cbGender.SelectedValue;
                    StudentData.Classid         = (int)cbClass.SelectedValue;

                    norman_Manley_Institution_Fo_the_ImpairedEntities1.DataforStudents.Add(StudentData);
                    norman_Manley_Institution_Fo_the_ImpairedEntities1.SaveChanges();



                    MessageBox.Show($"Students First Name: {studentsfname}\n\r" +
                                    $"Students Last Name: {studentslname}\n\r" +
                                    $"Childs Nationality: {Nationality}\n\r" +
                                    $"Date of Birth: {DateofBirth}\n\r" +
                                    $"Childs Disability: {disability}\n\r" +
                                    $"Childs Gender: {Gender}\n\r" +
                                    $"Childs Class: {Class}\n\r" +
                                    $"Parents First Name: {parentsfname}\n\r" +
                                    $"Parents Last Name: {parentslname}\n\r" +
                                    $"Contact Number: {contactnumber}\n\r" +
                                    $"Parents Address: {address}\n\r" +
                                    $"Parents Email Address: {EmailAddress}\n\r" +
                                    $"Childs Status: {status}\n\r" +
                                    $"FILE WAS SAVED SUCCESSFULLY");

                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }