private void modStdSaveBtn_Click(object sender, EventArgs e) { //Guardian gur = new Guardian(); guardian.Name = newStdGuarName.Text; guardian.CNIC = newStdGuarCnic.Text; guardian.Relation = newStdGuarRel.Text; guardian.Gender = newStdGuardianGen.SelectedText; guardian.GuardianNo = newStdGurNo.Text; guardian.Email = newStdGuardEmailTxt.Text; guardian.Address = newStdGuardAddressTxt.Text; this.type = "Guardian"; EnrollmentForm enrollForm = new EnrollmentForm(this); enrollForm.ShowDialog(); Guardian addedGuardian = new GuardianDAC().AddGuardian(guardian); if (addedGuardian.Id != 0) { StudentGardians studentGuardian = new StudentGardians() { GuardianId = addedGuardian.Id, StudentId = addStudentForm.student.Id }; new StudentGuardianDAC().AddStudentGuardian(studentGuardian); addedGuardian.FingerCode = new byte[0]; addStudentForm.guardians.Add(addedGuardian); MessageBox.Show("Guardian is added"); } else { MessageBox.Show("Please Enter Correct Information"); } this.Close(); }
private void newStdSaveBtn_Click(object sender, EventArgs e) { try { //Student std = new Student(); student.Gender = genderComboBox.Text; student.RegNo = newStdRegNo.Text; student.Name = newStdNameTxt.Text; student.FatherName = newStdFatherNameTxt.Text; student.FatherCNIC = newStdFatherNicTxt.Text; student.SectionId = Convert.ToInt32(sectionsComboBox.SelectedValue); student.RollNo = newStdRollNo.Text; student.Religion = religionComboBox.Text; student.Dob = Convert.ToDateTime(newStdDob.Text); student.HomeNumber = newStdHomeNo.Text; student.FatherNo = newStdFatherNo.Text; student.Email = newStdEmailTxt.Text; student.Address = newStdAddressTxt.Text; //int newStdId = new StudentDAC().AddStudent(std); this.type = "Student"; EnrollmentForm enrollForm = new EnrollmentForm(this); enrollForm.ShowDialog(); ////Student newlyAddedStudent = new StudentDAC().GetStudentById(newStdId); int newStdId = new StudentDAC().AddStudent(student); student.Id = newStdId; if (newStdId != 0) { MessageBox.Show("Student is Added"); addNewGuardianBtn.Visible = true; addExistingGuardianBtn.Visible = true; BindingSource bs = new BindingSource(); guardiansGridView.DataSource = bs; guardians = new List<Guardian>(); } else { new StudentDAC().DeleteStudentById(newStdId); } } catch (Exception) { MessageBox.Show("Please Enter Valid Information"); } }