private void grdChildren_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (familyId == -1) { familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, txtMarriedDate.Text, txtMariedPlace.Text); } if (grdChildren[0, e.RowIndex].Value == null) { int childID = DBAccessStatic.InsertIndividual("", "", "", "", "", "", familyId, ""); grdChildren[0, e.RowIndex].Value = childID; DBAccessStatic.InsertFamilyChild(familyId, childID); } if (e.ColumnIndex == 1) { string surname = GenValidation.GetSurname(grdChildren["ChildName", e.RowIndex].Value.ToString()); string firstname = GenValidation.GetFirstname(grdChildren["ChildName", e.RowIndex].Value.ToString()); DBAccessStatic.UpdateIndividualFirstname((int)grdChildren[0, e.RowIndex].Value, firstname); DBAccessStatic.UpdateIndividualSurname((int)grdChildren[0, e.RowIndex].Value, surname); } else if (e.ColumnIndex == 2) { DBAccessStatic.UpdateIndividualGender((int)grdChildren[0, e.RowIndex].Value, grdChildren[2, e.RowIndex].Value.ToString()); } else if (e.ColumnIndex == 3) { DBAccessStatic.UpdateIndividualBornDate((int)grdChildren[0, e.RowIndex].Value, grdChildren[3, e.RowIndex].Value.ToString()); } else if (e.ColumnIndex == 4) { DBAccessStatic.UpdateIndividualDiedDate((int)grdChildren[0, e.RowIndex].Value, grdChildren[4, e.RowIndex].Value.ToString()); } }
private void AttachChild(int childId) { if (familyId == -1) { familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, "", ""); } DBAccessStatic.InsertFamilyChild(familyId, childId); LoadFamilyByFamily(familyId); }