Example #1
0
        public override bool Accept()
        {
            try {
                fTask.Priority = (GDMResearchPriority)fView.Priority.SelectedIndex;
                fTask.StartDate.Assign(GDMDate.CreateByFormattedStr(fView.StartDate.Text, true));
                fTask.StopDate.Assign(GDMDate.CreateByFormattedStr(fView.StopDate.Text, true));

                GDMGoalType gt = (GDMGoalType)fView.GoalType.SelectedIndex;
                switch (gt)
                {
                case GDMGoalType.gtIndividual:
                case GDMGoalType.gtFamily:
                case GDMGoalType.gtSource:
                    fTask.Goal = GEDCOMUtils.EncloseXRef(fTempRec.XRef);
                    break;

                case GDMGoalType.gtOther:
                    fTask.Goal = fView.Goal.Text;
                    break;
                }

                fLocalUndoman.Commit();

                fBase.NotifyRecord(fTask, RecordAction.raEdit);

                return(true);
            } catch (Exception ex) {
                Logger.LogWrite("TaskEditDlgController.Accept(): " + ex.Message);
                return(false);
            }
        }
Example #2
0
        public override bool Accept()
        {
            try {
                fCommunication.CommName          = fView.Name.Text;
                fCommunication.CommunicationType = (GDMCommunicationType)fView.CorrType.SelectedIndex;
                fCommunication.Date.Assign(GDMDate.CreateByFormattedStr(fView.Date.Text, true));
                fCommunication.SetCorresponder((GDMCommunicationDir)fView.Dir.SelectedIndex, fTempInd);

                fBase.NotifyRecord(fCommunication, RecordAction.raEdit);

                CommitChanges();

                return(true);
            } catch (Exception ex) {
                Logger.LogWrite("CommunicationEditDlgController.Accept(): " + ex.Message);
                return(false);
            }
        }
Example #3
0
        public override bool Accept()
        {
            try {
                fResearch.ResearchName = fView.Name.Text;
                fResearch.Priority     = (GDMResearchPriority)fView.Priority.SelectedIndex;
                fResearch.Status       = (GDMResearchStatus)fView.Status.SelectedIndex;
                fResearch.StartDate.Assign(GDMDate.CreateByFormattedStr(fView.StartDate.NormalizeDate, true));
                fResearch.StopDate.Assign(GDMDate.CreateByFormattedStr(fView.StopDate.NormalizeDate, true));
                fResearch.Percent = int.Parse(fView.Percent.Text);

                fLocalUndoman.Commit();

                fBase.NotifyRecord(fResearch, RecordAction.raEdit);

                return(true);
            } catch (Exception ex) {
                Logger.WriteError("ResearchEditDlgController.Accept()", ex);
                return(false);
            }
        }
Example #4
0
        private void ParseSimple()
        {
            string tmp = EditName.Text.ToLower();

            string[] tokens = tmp.Split(' ');
            if (tokens.Length < 3)
            {
                ShowError(fLangMan.LS(FLS.LSID_NameInvalid));
                return;
            }

            string fam = ConvertHelper.UniformName(tokens[0]);
            string nam = ConvertHelper.UniformName(tokens[1]);
            string pat = ConvertHelper.UniformName(tokens[2]);

            GDMIndividualRecord iRec = fBase.Context.CreatePersonEx(nam, pat, fam, fSimpleTempSex, false);

            if (CheckBirth.Checked)
            {
                fBase.Context.CreateEventEx(iRec, GEDCOMTagName.BIRT, GDMDate.CreateByFormattedStr(EditBirthDate.Text, true), EditBirthPlace.Text);
            }

            if (CheckDeath.Checked)
            {
                fBase.Context.CreateEventEx(iRec, GEDCOMTagName.DEAT, GDMDate.CreateByFormattedStr(EditDeathDate.Text, true), EditDeathPlace.Text);
            }

            if (!string.IsNullOrEmpty(MemoNote.Text))
            {
                GDMNoteRecord noteRec = fBase.Context.Tree.CreateNote();
                noteRec.SetNoteText(MemoNote.Text);
                iRec.AddNote(noteRec);
            }

            fBase.NotifyRecord(iRec, RecordAction.raAdd);

            InitSimpleControls();
        }
Example #5
0
        // TODO: rollback changes when exception!
        private void ParseSource()
        {
            int srcYear;

            if (!int.TryParse(edSourceYear.Text, out srcYear))
            {
                ShowError(fLangMan.LS(FLS.LSID_SourceYearInvalid));
                return;
            }

            string srcName = cbSource.Text;
            string srcPage = edPage.Text;
            string place   = edPlace.Text;

            GDMSourceRecord srcRec = null;

            if (!string.IsNullOrEmpty(srcName))
            {
                srcRec = fBase.Context.FindSource(srcName);
                if (srcRec == null)
                {
                    srcRec            = fBase.Context.Tree.CreateSource();
                    srcRec.ShortTitle = srcName;
                }
            }

            GDMIndividualRecord iMain = null;

            int num = dataGridView1.Rows.Count;

            for (int r = 0; r < num; r++)
            {
                DataGridViewRow row = dataGridView1.Rows[r];

                string lnk     = CheckStr((string)row.Cells[0].Value);
                string nm      = CheckStr((string)row.Cells[1].Value);
                string pt      = CheckStr((string)row.Cells[2].Value);
                string fm      = CheckStr((string)row.Cells[3].Value);
                string age     = CheckStr((string)row.Cells[4].Value);
                string comment = CheckStr((string)row.Cells[5].Value);

                if (!string.IsNullOrEmpty(lnk))
                {
                    PersonLink link = GetLinkByName(lnk);
                    if (link == PersonLink.plNone)
                    {
                        continue;
                    }

                    GDMSex sx = fBase.Context.DefineSex(nm, pt);
                    GDMIndividualRecord iRec = fBase.Context.CreatePersonEx(nm, pt, fm, sx, false);

                    if (!string.IsNullOrEmpty(age) && ConvertHelper.IsDigits(age))
                    {
                        int birthYear = srcYear - int.Parse(age);
                        fBase.Context.CreateEventEx(iRec, GEDCOMTagName.BIRT, "ABT " + birthYear.ToString(), "");
                    }

                    if (!string.IsNullOrEmpty(place))
                    {
                        GDMCustomEvent evt = fBase.Context.CreateEventEx(iRec, GEDCOMTagName.RESI, "", "");
                        evt.Place.StringValue = place;
                    }

                    if (!string.IsNullOrEmpty(comment))
                    {
                        GDMNoteRecord noteRec = fBase.Context.Tree.CreateNote();
                        noteRec.SetNoteText(comment);
                        iRec.AddNote(noteRec);
                    }

                    if (srcRec != null)
                    {
                        iRec.AddSource(srcRec, srcPage, 0);
                    }

                    fBase.NotifyRecord(iRec, RecordAction.raAdd);

                    GDMFamilyRecord family = null;

                    if (link == PersonLink.plPerson)
                    {
                        iMain = iRec;
                        string evName = "";

                        if (rbSK_Met.Checked)
                        {
                            switch (cbEventType.SelectedIndex)
                            {
                            case  0:
                                evName = GEDCOMTagName.BIRT;
                                break;

                            case  1:
                                evName = GEDCOMTagName.DEAT;
                                break;

                            case  2:
                                evName = GEDCOMTagName.MARR;
                                break;
                            }
                        }

                        if (evName == GEDCOMTagName.BIRT || evName == GEDCOMTagName.DEAT)
                        {
                            GDMCustomEvent evt = fBase.Context.CreateEventEx(iRec, evName, GDMDate.CreateByFormattedStr(edEventDate.Text, false), "");
                            evt.Place.StringValue = place;
                        }
                        else if (evName == GEDCOMTagName.MARR)
                        {
                            family = iRec.GetMarriageFamily(true);
                            GDMCustomEvent evt = fBase.Context.CreateEventEx(family, evName, GDMDate.CreateByFormattedStr(edEventDate.Text, false), "");
                            evt.Place.StringValue = place;
                        }
                    }
                    else
                    {
                        if (iMain == null)
                        {
                            throw new PersonScanException(fLangMan.LS(FLS.LSID_BasePersonInvalid));
                        }
                        else
                        {
                            switch (link)
                            {
                            case PersonLink.plFather:
                            case PersonLink.plMother:
                                family = iMain.GetParentsFamily(true);
                                family.AddSpouse(iRec);
                                break;

                            case PersonLink.plGodparent:
                                iMain.AddAssociation(fLangMan.LS(FLS.LSID_PLGodparent), iRec);
                                break;

                            case PersonLink.plSpouse:
                                family = iMain.GetMarriageFamily(true);
                                family.AddSpouse(iRec);
                                break;

                            case PersonLink.plChild:
                                family = iMain.GetMarriageFamily(true);
                                family.AddChild(iRec);
                                break;
                            }
                        }
                    }
                }
            }

            InitSourceControls();
        }
Example #6
0
        private GDMCustomDate GetDate()
        {
            GDMCustomDate result = null;

            GDMCalendar cal1 = cmbDate1Calendar.GetSelectedTag <GDMCalendar>();
            GDMCalendar cal2 = cmbDate2Calendar.GetSelectedTag <GDMCalendar>();

            GDMDate gcd1 = GDMDate.CreateByFormattedStr(txtDate1.NormalizeDate, cal1, true);

            if (gcd1 == null)
            {
                throw new ArgumentNullException("gcd1");
            }

            GDMDate gcd2 = GDMDate.CreateByFormattedStr(txtDate2.NormalizeDate, cal2, true);

            if (gcd2 == null)
            {
                throw new ArgumentNullException("gcd2");
            }

            gcd1.YearBC = chkBC1.Checked.GetValueOrDefault();
            gcd2.YearBC = chkBC2.Checked.GetValueOrDefault();

            switch (cmbDateType.SelectedIndex)
            {
            case 0:
                result = gcd1;
                break;

            case 1:     // BEF gcd2
                result = GDMCustomDate.CreateRange(null, gcd2);
                break;

            case 2:     // AFT gcd1
                result = GDMCustomDate.CreateRange(gcd1, null);
                break;

            case 3:     // "BET " + gcd1 + " AND " + gcd2
                result = GDMCustomDate.CreateRange(gcd1, gcd2);
                break;

            case 4:     // FROM gcd1
                result = GDMCustomDate.CreatePeriod(gcd1, null);
                break;

            case 5:     // TO gcd2
                result = GDMCustomDate.CreatePeriod(null, gcd2);
                break;

            case 6:     // FROM gcd1 TO gcd2
                result = GDMCustomDate.CreatePeriod(gcd1, gcd2);
                break;

            case 7:     // ABT gcd1
                result = GDMCustomDate.CreateApproximated(gcd1, GDMApproximated.daAbout);
                break;

            case 8:     // CAL gcd1
                result = GDMCustomDate.CreateApproximated(gcd1, GDMApproximated.daCalculated);
                break;

            case 9:     // EST gcd1
                result = GDMCustomDate.CreateApproximated(gcd1, GDMApproximated.daEstimated);
                break;
            }

            return(result);
        }
Example #7
0
        private GDMCustomDate AssembleDate()
        {
            GDMCustomDate result = null;

            GDMCalendar cal1 = (GDMCalendar)fView.Date1Calendar.SelectedTag;
            GDMCalendar cal2 = (GDMCalendar)fView.Date2Calendar.SelectedTag;

            GDMDate gcd1 = GDMDate.CreateByFormattedStr(fView.Date1.NormalizeDate, cal1, true);

            if (gcd1 == null)
            {
                throw new ArgumentNullException("gcd1");
            }

            GDMDate gcd2 = GDMDate.CreateByFormattedStr(fView.Date2.NormalizeDate, cal2, true);

            if (gcd2 == null)
            {
                throw new ArgumentNullException("gcd2");
            }

            gcd1.YearBC = fView.Date1BC.Checked;
            gcd2.YearBC = fView.Date2BC.Checked;

            switch (fView.EventDateType.SelectedIndex)
            {
            case 0:
                result = gcd1;
                break;

            case 1:     // BEF gcd2
                result = GDMCustomDate.CreateRange(null, null, gcd2);
                break;

            case 2:     // AFT gcd1
                result = GDMCustomDate.CreateRange(null, gcd1, null);
                break;

            case 3:     // "BET " + gcd1 + " AND " + gcd2
                result = GDMCustomDate.CreateRange(null, gcd1, gcd2);
                break;

            case 4:     // FROM gcd1
                result = GDMCustomDate.CreatePeriod(null, gcd1, null);
                break;

            case 5:     // TO gcd2
                result = GDMCustomDate.CreatePeriod(null, null, gcd2);
                break;

            case 6:     // FROM gcd1 TO gcd2
                result = GDMCustomDate.CreatePeriod(null, gcd1, gcd2);
                break;

            case 7:     // ABT gcd1
                result = GDMCustomDate.CreateApproximated(null, gcd1, GDMApproximated.daAbout);
                break;

            case 8:     // CAL gcd1
                result = GDMCustomDate.CreateApproximated(null, gcd1, GDMApproximated.daCalculated);
                break;

            case 9:     // EST gcd1
                result = GDMCustomDate.CreateApproximated(null, gcd1, GDMApproximated.daEstimated);
                break;
            }

            return(result);
        }