Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
 private void txtWifeName_Leave(object sender, EventArgs e)
 {
     if (txtWifeName.Text.Trim().Length > 0)
     {
         string surname   = GenValidation.GetSurname(txtWifeName.Text.Trim());
         string firstname = GenValidation.GetFirstname(txtWifeName.Text.Trim());
         if (wifeId == -1)
         {
             wifeId = DBAccessStatic.InsertIndividual(surname, firstname, "", "", "", "", -1, "F");
         }
         else
         {
             DBAccessStatic.UpdateIndividualSurname(wifeId, surname);
             DBAccessStatic.UpdateIndividualFirstname(wifeId, firstname);
         }
         if ((familyId == -1) && (husbandId != -1))
         {
             familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, txtMarriedDate.Text, txtMariedPlace.Text);
         }
     }
     else
     {
         MessageBox.Show("Name field cannot be left empty.");
     }
 }