public void AddStudentGuardian(StudentGardians studentGuardian)
 {
     using (CosmosContext ctx = new CosmosContext())
     {
         ctx.StudentsGuardians.Add(studentGuardian);
         ctx.SaveChanges();
     }
 }
        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 newStdGuardUpdateBtn_Click(object sender, EventArgs e)
        {
            Guardian guardian = new GuardianDAC().SelectGuardianByCNIC(newStdGuarSeachCNIC.Text);

            //guardian.Name = newStdGuarName.Text;
            //guardian.Relation = newStdGuarRel.Text;
            //guardian.Gender = newStdGuardianGen.SelectedText;
            //guardian.GuardianNo = newStdGurNo.Text;
            //guardian.Email = newStdGuardEmailTxt.Text;
            //guardian.Address = newStdGuardAddressTxt.Text;

            StudentGardians studentGuardian = new StudentGardians() { GuardianId = guardian.Id, StudentId = addStudentForm.student.Id };
            new StudentGuardianDAC().AddStudentGuardian(studentGuardian);
            addStudentForm.guardians.Add(guardian);
            MessageBox.Show("Guardian is added");
            this.Close();
        }