Esempio n. 1
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.");
     }
 }
Esempio n. 2
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());
            }
        }
Esempio n. 3
0
 private void AttachChild(int childId)
 {
     if (familyId == -1)
     {
         familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, "", "");
     }
     DBAccessStatic.InsertFamilyChild(familyId, childId);
     LoadFamilyByFamily(familyId);
 }
Esempio n. 4
0
 private void txtHusbandDiedDate_Leave(object sender, EventArgs e)
 {
     if (husbandId == -1)
     {
         MessageBox.Show("Please enter name first");
     }
     else
     {
         DBAccessStatic.UpdateIndividualDiedDate(husbandId, txtHusbandDiedDate.Text);
     }
 }
Esempio n. 5
0
 private void txtWifeDiedPlace_Leave(object sender, EventArgs e)
 {
     if (wifeId == -1)
     {
         MessageBox.Show("Please enter name first");
     }
     else
     {
         DBAccessStatic.UpdateIndividualDiedPlace(wifeId, txtWifeDiedPlace.Text);
     }
 }
Esempio n. 6
0
 private void txtMariedPlace_Leave(object sender, EventArgs e)
 {
     if (familyId == -1)
     {
         familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, txtMarriedDate.Text, txtMariedPlace.Text);
     }
     else
     {
         DBAccessStatic.UpdateFamilyMarriagePlace(familyId, txtMariedPlace.Text);
     }
 }
Esempio n. 7
0
        private void LoadFamilyByFamily(int familyId)
        {
            ClearHusbandData();
            ClearWifeData();
            ClearMarriageData();
            ClearChildrenData();

            DataSet family = DBAccessStatic.GetFamily(familyId);

            if (family.Tables[0].Rows.Count > 0)
            {
                familyId  = (int)(family.Tables[0].Rows[0]["ID"]);
                wifeId    = (int)(family.Tables[0].Rows[0]["WifeId"]);
                husbandId = (int)(family.Tables[0].Rows[0]["HusbandId"]);
                if (husbandId != -1)
                {
                    DataSet husband = DBAccessStatic.GetIndividual(husbandId);
                    LoadHusbandData(husband);
                }
                if (wifeId != -1)
                {
                    DataSet wife = DBAccessStatic.GetIndividual(wifeId);
                    LoadWifeData(wife);
                }
                if (husbandId != -1)
                {
                    history.Add(husbandId);
                }
                else
                {
                    if (wifeId != -1)
                    {
                        history.Add(wifeId);
                    }
                }
                if (!history.IsEmpty())
                {
                    tbrBack.Enabled = true;
                }
                LoadMarriageData(family, 0);

                DataSet children = DBAccessStatic.GetFamilyChildren(familyId);
                if (children.Tables[0].Rows.Count > 0)
                {
                    LoadChildrenData(children);
                }
            }
            else
            {
                familyId  = -1;
                wifeId    = -1;
                husbandId = -1;
            }
        }
Esempio n. 8
0
 private void AttachSpouse(int spouseId)
 {
     if (activePerson == husbandId)
     {
         familyId = DBAccessStatic.InsertFamily(husbandId, spouseId, "", "");
     }
     else
     {
         familyId = DBAccessStatic.InsertFamily(spouseId, wifeId, "", "");
     }
     LoadFamilyByFamily(familyId);
 }
Esempio n. 9
0
        private void LoadIndividuals()
        {
            lstIndividuals.Items.Clear();

            DataSet individuals = DBAccessStatic.GetAllIndividuals();

            for (int i = 0; i < individuals.Tables[0].Rows.Count; i++)
            {
                lstIndividuals.Items.Add(GenValidation.GetNameWithDates(individuals.Tables[0].Rows[i]["Surname"].ToString(), individuals.Tables[0].Rows[i]["Firstname"].ToString(), individuals.Tables[0].Rows[i]["BornDate"].ToString(), individuals.Tables[0].Rows[i]["DiedDate"].ToString()));
                individualIds.Add((int)(individuals.Tables[0].Rows[i]["ID"]));
            }
        }
Esempio n. 10
0
 private void DetachSpouse()
 {
     if (activePerson == husbandId)
     {
         wifeId = -1;
         DBAccessStatic.UpdateFamilyWifeId(familyId, wifeId);
     }
     else
     {
         husbandId = -1;
         DBAccessStatic.UpdateFamilyHusbandId(familyId, husbandId);
     }
     LoadFamilyByFamily(familyId);
 }
Esempio n. 11
0
 private void grdChildren_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (grdChildren[0, e.RowIndex].Value == null)
     {
         MessageBox.Show("Please enter some information for the child before moving to their record");
     }
     else
     {
         if (grdChildren[2, e.RowIndex].Value == null)
         {
             DBAccessStatic.UpdateIndividualGender((int)grdChildren[0, e.RowIndex].Value, "M");
         }
         LoadFamily((int)grdChildren[0, e.RowIndex].Value);
     }
 }
Esempio n. 12
0
 public static int UpdateIndividualSurname(int individualId, string surname)
 {
     return(DBAccessStatic.UpdateTable("Individual", "Surname", surname, individualId));
 }
Esempio n. 13
0
 private void DeleteIndividual(int individualId)
 {
     DBAccessStatic.DeleteIndividual(individualId);
 }
Esempio n. 14
0
 private void DetachChild(int childId)
 {
     DBAccessStatic.DeleteFamilyChild(childId);
     LoadFamilyByFamily(familyId);
 }
Esempio n. 15
0
 public static int UpdateIndividualBornPlace(int individualId, string bornPlace)
 {
     return(DBAccessStatic.UpdateTable("Individual", "BornPlace", bornPlace, individualId));
 }
Esempio n. 16
0
 public static int UpdateIndividualDiedPlace(int individualId, string diedPlace)
 {
     return(DBAccessStatic.UpdateTable("Individual", "DiedPlace", diedPlace, individualId));
 }
Esempio n. 17
0
 public static int UpdateIndividualGender(int individualId, string gender)
 {
     return(DBAccessStatic.UpdateTable("Individual", "Gender", gender, individualId));
 }
Esempio n. 18
0
 public static int UpdateIndividualPArentFamilyId(int individualId, int parentFamilyId)
 {
     return(DBAccessStatic.UpdateTable("Individual", "ParentFamilyId", parentFamilyId.ToString(), individualId));
 }
Esempio n. 19
0
 public static int UpdateFamilyHusbandId(int familyId, int husbandId)
 {
     return(DBAccessStatic.UpdateTable("Family", "HusbandId", husbandId.ToString(), familyId));
 }
Esempio n. 20
0
 public static int UpdateFamilyWifeId(int familyId, int wifeId)
 {
     return(DBAccessStatic.UpdateTable("Family", "WifeId", wifeId.ToString(), familyId));
 }
Esempio n. 21
0
 public static int UpdateIndividualFirstname(int individualId, string firstname)
 {
     return(DBAccessStatic.UpdateTable("Individual", "Firstname", firstname, individualId));
 }
Esempio n. 22
0
 public static int UpdateFamilyMarriagePlace(int familyId, string marriagePlace)
 {
     return(DBAccessStatic.UpdateTable("Family", "MarriagePlace", marriagePlace, familyId));
 }
Esempio n. 23
0
        private void LoadFamily(int individualId, int familyIndex)
        {
            ClearHusbandData();
            ClearWifeData();
            ClearMarriageData();
            ClearChildrenData();
            wifeParentId    = -1;
            husbandParentId = -1;

            DataSet individual = DBAccessStatic.GetIndividual(individualId);

            if (individual.Tables[0].Rows[0]["Gender"].ToString() == "M")
            {
                husbandId       = individualId;
                husbandParentId = (int)(individual.Tables[0].Rows[0]["ParentFamilyId"]);
                LoadHusbandData(individual);
                SetHusbandActive();
                DataSet family = DBAccessStatic.GetFamilyForHusband(husbandId);
                if (family.Tables[0].Rows.Count > 0)
                {
                    familyId = (int)(family.Tables[0].Rows[familyIndex]["ID"]);
                    wifeId   = (int)(family.Tables[0].Rows[familyIndex]["WifeId"]);
                    if (wifeId != -1)
                    {
                        DataSet wife = DBAccessStatic.GetIndividual(wifeId);
                        wifeParentId = (int)(wife.Tables[0].Rows[0]["ParentFamilyId"]);
                        LoadWifeData(wife);
                    }
                    LoadMarriageData(family, familyIndex);
                }
                else
                {
                    familyId = -1;
                    wifeId   = -1;
                }
            }
            else
            {
                wifeId       = individualId;
                wifeParentId = (int)(individual.Tables[0].Rows[0]["ParentFamilyId"]);
                LoadWifeData(individual);
                SetWifeActive();
                DataSet family = DBAccessStatic.GetFamilyForWife(wifeId);
                if (family.Tables[0].Rows.Count > 0)
                {
                    familyId  = (int)(family.Tables[0].Rows[familyIndex]["ID"]);
                    husbandId = (int)(family.Tables[0].Rows[familyIndex]["HusbandId"]);
                    if (husbandId != -1)
                    {
                        DataSet husband = DBAccessStatic.GetIndividual(husbandId);
                        husbandParentId = (int)(husband.Tables[0].Rows[0]["ParentFamilyId"]);

                        LoadHusbandData(husband);
                    }
                    LoadMarriageData(family, familyIndex);
                }
                else
                {
                    familyId = -1;
                    wifeId   = -1;
                }
            }

            if (familyId != -1)
            {
                DataSet children = DBAccessStatic.GetFamilyChildren(familyId);
                LoadChildrenData(children);
            }
            history.Add(individualId);
            if (!history.IsEmpty())
            {
                tbrBack.Enabled = true;
            }
        }