private void btnAccept_Click(object sender, EventArgs e) { try { fCommunication.CommName = txtName.Text; fCommunication.CommunicationType = (GKCommunicationType)cmbCorrType.SelectedIndex; fCommunication.Date.Assign(GEDCOMDate.CreateByFormattedStr(txtDate.Text, true)); fCommunication.SetCorresponder((GKCommunicationDir)txtDir.SelectedIndex, fTempInd); CommitChanges(); fBase.NotifyRecord(fCommunication, RecordAction.raEdit); DialogResult = DialogResult.Ok; } catch (Exception ex) { Logger.LogWrite("CommunicationEditDlg.btnAccept_Click(): " + ex.Message); DialogResult = DialogResult.None; } }
public override bool Accept() { try { fCommunication.CommName = fView.Name.Text; fCommunication.CommunicationType = (GKCommunicationType)fView.CorrType.SelectedIndex; fCommunication.Date.Assign(GEDCOMDate.CreateByFormattedStr(fView.Date.Text, true)); fCommunication.SetCorresponder((GKCommunicationDir)fView.Dir.SelectedIndex, fTempInd); fBase.NotifyRecord(fCommunication, RecordAction.raEdit); CommitChanges(); return(true); } catch (Exception ex) { Logger.LogWrite("CommunicationEditDlgController.Accept(): " + ex.Message); return(false); } }
public override bool Accept() { try { fResearch.ResearchName = fView.Name.Text; fResearch.Priority = (GKResearchPriority)fView.Priority.SelectedIndex; fResearch.Status = (GKResearchStatus)fView.Status.SelectedIndex; fResearch.StartDate.Assign(GEDCOMDate.CreateByFormattedStr(fView.StartDate.Text, true)); fResearch.StopDate.Assign(GEDCOMDate.CreateByFormattedStr(fView.StopDate.Text, true)); fResearch.Percent = int.Parse(fView.Percent.Text); fLocalUndoman.Commit(); fBase.NotifyRecord(fResearch, RecordAction.raEdit); return(true); } catch (Exception ex) { Logger.LogWrite("ResearchEditDlgController.Accept(): " + ex.Message); return(false); } }
private static object ConvertColumnStr(string val, DataType type) { switch (type) { case DataType.dtString: return(val); case DataType.dtInteger: return(SysUtils.ParseInt(val, 0)); case DataType.dtFloat: return(SysUtils.ParseFloat(val, 0.0)); case DataType.dtDateTime: return(DateTime.Parse(val)); case DataType.dtGEDCOMDate: return(GEDCOMDate.GetUDNByFormattedStr(val, GEDCOMCalendar.dcGregorian)); } return(val); }
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 = SysUtils.NormalizeName(tokens[0]); string nam = SysUtils.NormalizeName(tokens[1]); string pat = SysUtils.NormalizeName(tokens[2]); GEDCOMIndividualRecord iRec = fBase.Context.CreatePersonEx(nam, pat, fam, fSimpleTempSex, false); if (CheckBirth.Checked) { fBase.Context.CreateEventEx(iRec, "BIRT", GEDCOMDate.CreateByFormattedStr(EditBirthDate.Text, true), EditBirthPlace.Text); } if (CheckDeath.Checked) { fBase.Context.CreateEventEx(iRec, "DEAT", GEDCOMDate.CreateByFormattedStr(EditDeathDate.Text, true), EditDeathPlace.Text); } if (!string.IsNullOrEmpty(MemoNote.Text)) { GEDCOMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(MemoNote.Text); iRec.AddNote(noteRec); } fBase.NotifyRecord(iRec, RecordAction.raAdd); InitSimpleControls(); }
public override void PrepareFilter() { IndividualListFilter iFilter = (IndividualListFilter)fFilter; filter_abd = GEDCOMDate.GetUDNByFormattedStr(iFilter.AliveBeforeDate, GEDCOMCalendar.dcGregorian); if (iFilter.GroupRef == "") { filter_grp = null; } else { filter_grp = fBaseContext.Tree.XRefIndex_Find(iFilter.GroupRef) as GEDCOMGroupRecord; } if (iFilter.SourceRef == "") { filter_source = null; } else { filter_source = fBaseContext.Tree.XRefIndex_Find(iFilter.SourceRef) as GEDCOMSourceRecord; } }
private GEDCOMCustomDate AssembleDate() { GEDCOMCustomDate result = null; GEDCOMCalendar cal1 = GetComboCalendar(cmbDate1Calendar); GEDCOMCalendar cal2 = GetComboCalendar(cmbDate2Calendar); GEDCOMDate gcd1 = GEDCOMDate.CreateByFormattedStr(txtEventDate1.Text, cal1, true); if (gcd1 == null) { throw new ArgumentNullException("gcd1"); } GEDCOMDate gcd2 = GEDCOMDate.CreateByFormattedStr(txtEventDate2.Text, cal2, true); if (gcd2 == null) { throw new ArgumentNullException("gcd2"); } gcd1.YearBC = btnBC1.Checked; gcd2.YearBC = btnBC2.Checked; switch (cmbEventDateType.SelectedIndex) { case 0: result = gcd1; break; case 1: // BEF gcd2 result = GEDCOMCustomDate.CreateRange(null, null, null, gcd2); break; case 2: // AFT gcd1 result = GEDCOMCustomDate.CreateRange(null, null, gcd1, null); break; case 3: // "BET " + gcd1 + " AND " + gcd2 result = GEDCOMCustomDate.CreateRange(null, null, gcd1, gcd2); break; case 4: // FROM gcd1 result = GEDCOMCustomDate.CreatePeriod(null, null, gcd1, null); break; case 5: // TO gcd2 result = GEDCOMCustomDate.CreatePeriod(null, null, null, gcd2); break; case 6: // FROM gcd1 TO gcd2 result = GEDCOMCustomDate.CreatePeriod(null, null, gcd1, gcd2); break; case 7: // ABT gcd1 result = GEDCOMCustomDate.CreateApproximated(null, null, gcd1, GEDCOMApproximated.daAbout); break; case 8: // CAL gcd1 result = GEDCOMCustomDate.CreateApproximated(null, null, gcd1, GEDCOMApproximated.daCalculated); break; case 9: // EST gcd1 result = GEDCOMCustomDate.CreateApproximated(null, null, gcd1, GEDCOMApproximated.daEstimated); break; } return(result); }
// 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; GEDCOMSourceRecord srcRec = null; if (!string.IsNullOrEmpty(srcName)) { srcRec = fBase.Context.FindSource(srcName); if (srcRec == null) { srcRec = fBase.Context.Tree.CreateSource(); srcRec.FiledByEntry = srcName; } } GEDCOMIndividualRecord iMain = null; int num = dataGridView1.Rows.Count; for (int r = 0; r < num; r++) { DataGridViewRow row = dataGridView1.Rows[r]; string lnk = (string)row.Cells[0].Value; string nm = (string)row.Cells[1].Value; string pt = (string)row.Cells[2].Value; string fm = (string)row.Cells[3].Value; string age = (string)row.Cells[4].Value; string comment = (string)row.Cells[5].Value; if (!string.IsNullOrEmpty(lnk)) { PersonLink link = GetLinkByName(lnk); GEDCOMSex sx = fBase.Context.DefineSex(nm, pt); GEDCOMIndividualRecord iRec = fBase.Context.CreatePersonEx(nm, pt, fm, sx, false); if (!string.IsNullOrEmpty(age) && SysUtils.IsDigits(age)) { int birthYear = srcYear - int.Parse(age); fBase.Context.CreateEventEx(iRec, "BIRT", "ABT " + birthYear.ToString(), ""); } if (!string.IsNullOrEmpty(place)) { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, "RESI", "", ""); evt.Place.StringValue = place; } if (!string.IsNullOrEmpty(comment)) { GEDCOMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(comment); iRec.AddNote(noteRec); } if (srcRec != null) { iRec.AddSource(srcRec, srcPage, 0); } fBase.NotifyRecord(iRec, RecordAction.raAdd); GEDCOMFamilyRecord family = null; if (link == PersonLink.plPerson) { iMain = iRec; string evName = ""; if (rbSK_Met.Checked) { switch (cbEventType.SelectedIndex) { case 0: evName = "BIRT"; break; case 1: evName = "DEAT"; break; case 2: evName = "MARR"; break; } } if (evName == "BIRT" || evName == "DEAT") { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } else if (evName == "MARR") { family = iRec.GetMarriageFamily(true); GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(family, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } } else if (link > PersonLink.plPerson) { 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(); }