public override void AddChildEntry() { var parIter = editFrameAdapter.ActiveParentTreeIter; if (parIter.Equals(TreeIter.Zero)) { return; } // Get User data EventTimeBox timeBox = new EventTimeBox(false); GetUserArgs[] args = { }; var diag = new GetUserDataDialog(args, timeBox, "Speichern", 0, "Abbruch", 1); if (diag.Run() == 0) { bool validated; while (!(validated = timeBox.ValidateTime())) { if (diag.Run() == 1) { validated = false; break; } } if (validated) // There is valid user data { var treeContent = CurrTreeStore; string time = timeBox.Time; int vId = int.Parse((string)treeContent.GetValue(parIter, (int)EventColumnId.ID)); int iId = treeContent.IterNChildren(parIter) + 1; if (iId != 1) // XXX: Start counting with 1 here (beta) { iId++; } // Save on UI treeContent.AppendValues(parIter, iId, "", "", "", time); // Save on Database var elem = new Table_Instanz(vId, iId, time); dbAdapter.InsertEntry(elem); } } diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
protected override bool HookOnSave() { // Assert data integrity if (!timeBox.ValidateTime()) { return(false); } // Mutable values string validTime = timeBox.Time; string currText = CurrText; int vId = int.Parse((string)currTreeStore.GetValue(currParentIter, (int)EventColumnId.ID)); // Save on Database DatabaseTable orig, elem; if (IsCurrParent) { orig = new Table_Veranstaltung(vId, availKrzl[origKrzlIndex], OrigText, availLang[origLangIndex], int.Parse(timeBox.OrigTime)); elem = new Table_Veranstaltung(vId, availKrzl[cbKrzl.Active], currText, availLang[cbLang.Active], int.Parse(validTime)); } else { int iId = int.Parse((string)currTreeStore.GetValue(currTreeIter, (int)EventColumnId.ID)); orig = new Table_Instanz(vId, iId, timeBox.OrigTime); elem = new Table_Instanz(vId, iId, validTime); } orig.Update(elem); // Save on UI if (IsCurrParent) { currTreeStore.SetValue(currTreeIter, (int)EventColumnId.Name, currText); } currTreeStore.SetValue(currTreeIter, (int)EventColumnId.Zeit, validTime); // Save on this timeBox.Time = validTime; origKrzlIndex = cbKrzl.Active; origLangIndex = cbLang.Active; return(true); }