Exemplo n.º 1
0
        protected override bool OnSave()
        {
            // Mutable values
            string currTypString = GtkHelper.ComboBoxActiveString(cbTyp);

            origDbText = API_Contract.ConvertEditCategorieToDatabse(textEntry.Buffer);

            // Save on Database
            int           currRang = int.Parse((string)currTreeStore.GetValue(currTreeIter, (int)CategorieColumnID.Rang));
            DatabaseTable origElem, newElem;

            if (IsCurrParent)
            {
                int currTyp = API_Contract.CategorieTextParentTypCR[currTypString];
                origElem = new Table_Kategorie_Tab_Titel(tabName, origDbText, origTyp, origRang);
                newElem  = new Table_Kategorie_Tab_Titel(tabName, origDbText, currTyp, currRang);
            }
            else
            {
                int    currTyp  = API_Contract.CategorieTextChildTypCR[currTypString];
                string tmpTitel = (string)currTreeStore.GetValue(currParentIter, (int)CategorieColumnID.Text);
                origElem = new Table_Kategorie_Tab_Text(tabName, tmpTitel, this.origDbText, origTyp, origRang);
                newElem  = new Table_Kategorie_Tab_Text(tabName, tmpTitel, origDbText, currTyp, currRang);
            }
            origElem.Update(newElem);
            // Save on UI
            currTreeStore.SetValue(currTreeIter, (int)CategorieColumnID.Text, origDbText);
            currTreeStore.SetValue(currTreeIter, (int)CategorieColumnID.Typ, currTypString);
            // Save on this
            origTyp  = cbTyp.Active;
            origText = textEntry.Buffer.Text;
            return(true);
        }
Exemplo n.º 2
0
        public override void AddChildEntry()
        {
            TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter;

            if (CurrTabIndex == -1 || parentIter.Equals(TreeIter.Zero))
            {
                return;
            }

            ComboBox cbTyp = new ComboBox(API_Contract.CategorieTextTypChildVal);

            cbTyp.Active = 0;             // Text is default
            Entry textEntry = new Entry();

            GetUserArgs[] args =
            {
                new GetUserArgs(new Label("Typ"),  cbTyp),
                new GetUserArgs(new Label("Text"), textEntry),
            };
            var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abburch", 1);

            if (diag.Run() == 0 && AssertNotEmpty(diag, textEntry))
            {
                var      treeContent = CurrTreeStore;
                string   text        = textEntry.Text;
                string   typString   = GtkHelper.ComboBoxActiveString(cbTyp);
                int      typ         = API_Contract.CategorieTextChildTypCR[typString];
                int      row;
                TreeIter firstIt;                 // Get row
                if (treeContent.IterChildren(out firstIt, parentIter))
                {
                    var lastIt = GtkHelper.GetLastIter(treeContent, firstIt);
                    row  = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang));
                    row += 1;
                }
                else
                {
                    row = 0;
                }
                // Save on UI
                treeContent.AppendValues(parentIter, row, typString, text);
                // Save on Database
                var titelName = (string)treeContent.GetValue(parentIter, (int)CategorieColumnID.Text);
                var insert    = new Table_Kategorie_Tab_Text(tabNames[CurrTabIndex],
                                                             titelName, text, typ, row);
                dbAdapter.InsertEntry(insert);
            }
            // Free memory
            diag.Destroy();
            foreach (var arg in args)
            {
                arg.Dispose();
            }
        }
Exemplo n.º 3
0
        public override void AddParentEntry()         // Add a Termin
        {
            TimeBox timeBox = new TimeBox(true);

            timeBox.posEntry.Text = "0";             // Default pos
            Entry    textEntry = new Entry();
            ComboBox cbType    = new ComboBox(API_Contract.ProgrammTerminTypVal);

            cbType.Active = 1;             // Default is 'Programm'
            GetUserArgs[] args = new GetUserArgs[] {
                new GetUserArgs(new Label("Text"), textEntry),
                new GetUserArgs(new Label("Sichtbarkeit"), cbType),
            };
            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 finalTime;
                    string tmpTime   = timeBox.Time;
                    string text      = textEntry.Text;
                    string typString = GtkHelper.ComboBoxActiveString(cbType);
                    int    typ       = cbType.Active;
                    // Save on UI
                    TreeIter insertIter;
                    insertIter = treeContent.AppendValues(tmpTime, text, typString);
                    GtkHelper.SortInByColumn(treeContent, (int)ProgrammColumnID.Uhrzeit, insertIter);
                    finalTime = API_Contract.ClearTimeConflicts(treeContent, insertIter);
                    // Save on Database
                    var insert = new Table_Termin(CurrTabIndex, finalTime, text, typ);
                    dbAdapter.InsertEntry(insert);
                }
            }
            // Free Memory
            diag.Destroy();
            foreach (var arg in args)             // Free args
            {
                arg.Dispose();
            }
        }
Exemplo n.º 4
0
        public override void AddParentEntry()
        {
            if (CurrTabIndex == -1)
            {
                return;
            }

            Entry nameEntry = new Entry();
            var   cbTyp     = new ComboBox(API_Contract.CategorieTextTypParentVal);

            cbTyp.Active = 0;
            GetUserArgs[] args =
            {
                new GetUserArgs(new Label("Titel"), nameEntry),
                new GetUserArgs(new Label("Typ"),   cbTyp),
            };
            var diag = new GetUserDataDialog(args, null, "Speichern", 0, "Abbrechen", 1);

            if (diag.Run() == 0 && AssertNotEmpty(diag, nameEntry))
            {
                var      treeContent = CurrTreeStore;
                string   text        = nameEntry.Text;
                string   typString   = GtkHelper.ComboBoxActiveString(cbTyp);
                int      typ         = API_Contract.CategorieTextParentTypCR[typString];
                int      row;
                TreeIter firstIt;
                if (treeContent.GetIterFirst(out firstIt))                   // Has childs
                {
                    var lastIt = GtkHelper.GetLastIter(treeContent, firstIt);
                    row  = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang));
                    row += 1;
                }
                else                     // Is empty
                {
                    row = 0;
                }
                // Save on UI
                treeContent.AppendValues(row, typString, text);
                // Save in Database
                var insert = new Table_Kategorie_Tab_Titel(tabNames[CurrTabIndex],
                                                           text, typ, row);
                dbAdapter.InsertEntry(insert);
            }
            // Free memory
            diag.Destroy();
            foreach (var arg in args)
            {
                arg.Dispose();
            }
        }
Exemplo n.º 5
0
        public override void AddChildEntry()         // Add a Beschreibung
        {
            // Is there a active parent?
            TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter;

            if (parentIter.Equals(TreeIter.Zero))
            {
                var error = new SafeCallDialog("Kein Element ausgewählt", "Ok", 0, null, 1);
                error.Run();
                error.Destroy();
                return;
            }

            ComboBox cbTyp = new ComboBox(API_Contract.ProgrammDescrTypVal);

            cbTyp.Active = 2;             // Default is 'All'
            Entry textEntry = new Entry();
            var   args      = new GetUserArgs[] {
                new GetUserArgs(new Label("Text"), textEntry),
                new GetUserArgs(new Label("Typ"), cbTyp),
            };
            var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abbruch", 1);

            if (diag.Run() == 0)
            {
                var    treeContent = CurrTreeStore;
                string text        = textEntry.Text;
                string typString   = GtkHelper.ComboBoxActiveString(cbTyp);
                int    typ         = cbTyp.Active;
                // Save on UI
                TreeIter insertIter, firstIter;
                insertIter = treeContent.AppendValues(parentIter, "└──", "\t" + text, typString);
                treeContent.IterNthChild(out firstIter, parentIter, 0);
                GtkHelper.SortInByColumn(treeContent, (int)ProgrammColumnID.Text, insertIter);
                // XXX: Save on Database
                string time   = (string)treeContent.GetValue(parentIter, (int)ProgrammColumnID.Uhrzeit);
                var    insert = new Table_Beschreibung(CurrTabIndex, time, text, typ);
                dbAdapter.InsertEntry(insert);
            }
            // Free Memory
            diag.Destroy();
            foreach (var arg in args)
            {
                arg.Dispose();
            }
        }
Exemplo n.º 6
0
        protected override bool HookOnSave()
        {
            // Assert data integrity
            if (!timeBox.ValidateTime())
            {
                return(false);
            }

            // Mutable values
            string validTime;
            string textString = CurrText;
            string origTime   = timeBox.OrigTime;
            string typString  = GtkHelper.ComboBoxActiveString(cbTyp);
            int    typ        = cbTyp.Active;

            // Save on Database
            DatabaseTable orig, newElem;

            if (IsCurrParent)
            {
                validTime = timeBox.Time;
                orig      = new Table_Termin(day, origTime, OrigText, origTyp);
                newElem   = new Table_Termin(day, validTime, textString, typ);
            }
            else
            {
                validTime  = origTime;                // Parent time, we got on EditTreeRow()
                textString = API_Contract.ConvertEditViewToDatabase(textString);
                orig       = new Table_Beschreibung(day, origTime, OrigText, origTyp);
                newElem    = new Table_Beschreibung(day, validTime, textString, typ);
            }
            orig.Update(newElem);

            // Save on UI
            if (IsCurrParent)             // Only Parent time can change
            {
                currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Uhrzeit, validTime);
            }
            currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Typ, typString);

            // Set UI text value and sort in
            if (IsCurrParent)
            {
                // Sort by time, and clear conflicts
                currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Text, textString);
                var iter = GtkHelper.SortInByColumn(currTreeStore,
                                                    (int)ProgrammColumnID.Uhrzeit, currTreeIter);
                validTime = API_Contract.ClearTimeConflicts(currTreeStore, iter);
            }
            else
            {
                // Sort by text
                currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Text,
                                       API_Contract.ConvertDatabaseToTreeChild(textString));
                GtkHelper.SortInByColumn(currTreeStore,
                                         (int)ProgrammColumnID.Text, currTreeIter);
            }

            // Save on this
            timeBox.Time = validTime;
            origTyp      = cbTyp.Active;
            return(true);
        }