Exemple #1
0
        private IEnumerator <object> AddTypeTask()
        {
            using (new ControlWaitCursor(this))
                using (var dialog = new AddTypeDialog(Program.Scheduler)) {
                    long categoryID = 0;
                    yield return(Program.Database.ExecuteScalar <long>(
                                     "SELECT categoryID FROM evedata.categories WHERE name = ?",
                                     "Entity"
                                     ).Bind(() => categoryID));

                    int groupID = (from se in SelectedEntries
                                   where se.GroupID.HasValue
                                   select se.GroupID.Value).FirstOrDefault();

                    yield return(dialog.PopulateGroups(categoryID, groupID));

                    yield return(dialog.RefreshList());

                    if (dialog.ShowDialog() != DialogResult.OK)
                    {
                        yield break;
                    }

                    var newType = dialog.Types.SelectedItem as TypeEntry;

                    int priority = 0;
                    if (SelectedEntries.Count() > 0)
                    {
                        priority = SelectedEntries.Max((pe) => pe.Priority);
                    }

                    yield return(Program.Database.ExecuteSQL(
                                     "REPLACE INTO enemyPriorities (groupID, typeID, priority) VALUES (?, ?, ?)",
                                     newType.GroupID, newType.TypeID, priority
                                     ));

                    Script.Preferences.Flush();

                    yield return(RefreshList(new PriorityEntry {
                        GroupID = newType.GroupID, TypeID = newType.TypeID
                    }));
                }
        }
        private IEnumerator<object> AddTypeTask()
        {
            using (new ControlWaitCursor(this))
            using (var dialog = new AddTypeDialog(Program.Scheduler)) {
                long categoryID = 0;
                yield return Program.Database.ExecuteScalar<long>(
                    "SELECT categoryID FROM evedata.categories WHERE name = ?",
                    "Entity"
                ).Bind(() => categoryID);

                int groupID = (from se in SelectedEntries
                               where se.GroupID.HasValue
                               select se.GroupID.Value).FirstOrDefault();

                yield return dialog.PopulateGroups(categoryID, groupID);

                yield return dialog.RefreshList();

                if (dialog.ShowDialog() != DialogResult.OK)
                    yield break;

                var newType = dialog.Types.SelectedItem as TypeEntry;

                int priority = 0;
                if (SelectedEntries.Count() > 0)
                    priority = SelectedEntries.Max((pe) => pe.Priority);

                yield return Program.Database.ExecuteSQL(
                    "REPLACE INTO enemyPriorities (groupID, typeID, priority) VALUES (?, ?, ?)",
                    newType.GroupID, newType.TypeID, priority
                );

                Script.Preferences.Flush();

                yield return RefreshList(new PriorityEntry { GroupID = newType.GroupID, TypeID = newType.TypeID });
            }
        }