Exemple #1
0
        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            var db = DB.Database.GetDatabase();

            // Person:
            if (this.Person.id == 0)
                this.Person.id = (long)db.Insert(this.Person);
            else
                db.Update(this.Person);

            // Person's marriage:
            if (this.PersonMarriage != null)
            {
                if (!chkUnknownDateOfMarriage.Checked)
                    this.PersonMarriage.date = dtpDateOfMarriage.Value;
                this.PersonMarriage.place = txtPlaceOfMarriage.Text;

                if (this.PersonMarriage?.id == 0)
                    this.PersonMarriage.id = (long)db.Insert(this.PersonMarriage);
                else
                    db.Update(this.PersonMarriage);
            }

            // Link to parent's marriage:
            if (this.ParentsMarriage != null)
            {
                var marriageSon = new MarriageSon()
                {
                    marriage_id = this.ParentsMarriage.id,
                    son_id = this.Person.id
                };
                if (this.MarriageSon == null)
                    marriageSon.id = (long)db.Insert(marriageSon);
                else
                {
                    marriageSon.id = this.MarriageSon.id;
                    db.Update(marriageSon);
                }
            }
        }
        private void ProcessMarriage(string husbandLine, string wifeLine)
        {
            var husband = GetPersonFromLine(husbandLine);
            var wife = GetPersonFromLine(wifeLine);
            var marriage = GetMarriageFromHusbandLine(husbandLine, husband, wife);

            if(husband != null)
            {
                var husbandIndexing = _personsDict[husband];
                var sonId = (int) Math.Truncate((double)husbandIndexing.Item2 / 2);
                var son = _personsDict.Where(x => x.Value.Item2.Equals(sonId)).Select(x => x.Key).FirstOrDefault();
                if(son != null)
                {
                    var marriageSon = new MarriageSon()
                    {
                        marriage_id = marriage.id,
                        son_id = son.id
                    };
                    var id = _db.Insert(marriageSon);
                    marriageSon.id = (long) id;
                }
            }
        }