Пример #1
0
        private void btnDbPackage_Click(object sender, EventArgs e)
        {
            try
            {
                var items = _conn.Apply(@"<Item type='PackageDefinition' action='get' select='id' />").Items();
                var refs  = new List <ItemReference>();

                foreach (var item in items)
                {
                    refs.Add(ItemReference.FromFullItem(item, true));
                }

                using (var dialog = new FilterSelect <ItemReference>())
                {
                    dialog.DataSource    = refs;
                    dialog.DisplayMember = "KeyedName";
                    dialog.Message       = resources.Messages.PackageSelect;
                    if (dialog.ShowDialog(this, btnDbPackage.RectangleToScreen(btnDbPackage.Bounds)) ==
                        DialogResult.OK && dialog.SelectedItem != null)
                    {
                        txtFind.Text = "";
                        _findAction  = DefaultFindAction;
                        items        = _conn.Apply(@"<Item type='PackageElement' action='get' select='element_id,element_type,name' orderBy='element_type,name,element_id'>
                                    <source_id condition='in'>(select id
                                      from innovator.PACKAGEGROUP
                                      where SOURCE_ID = @0)</source_id>
                                  </Item>", dialog.SelectedItem.Unique).Items();
                        _availableRefs.Clear();
                        ItemReference newRef;
                        foreach (var item in items)
                        {
                            newRef = new ItemReference()
                            {
                                Type      = item.Property("element_type").AsString(""),
                                Unique    = item.Property("element_id").AsString(""),
                                KeyedName = item.Property("name").AsString("")
                            };
                            if (!_selectedRefs.Contains(newRef))
                            {
                                _selectedRefs.Add(newRef);
                            }
                        }

                        _existingScript       = _existingScript ?? new InstallScript();
                        _existingScript.Title = dialog.SelectedItem.KeyedName;

                        EnsureResultsTab();
                        tbcSearch.SelectedTab = pgResults;
                        txtFind.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }
        }
Пример #2
0
        private void btnItem_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dialog = new FilterSelect <ItemReference>())
                {
                    EnsureItemTypes();
                    dialog.DataSource    = _itemTypes;
                    dialog.DisplayMember = "KeyedName";
                    dialog.Message       = resources.Messages.ItemTypeSelect;
                    if (dialog.ShowDialog(this, btnItem.RectangleToScreen(btnItem.Bounds)) ==
                        DialogResult.OK && dialog.SelectedItem != null)
                    {
                        _lastQuery   = null;
                        txtFind.Text = "";
                        _availableRefs.Clear();

                        var items = _conn.Apply("<Item type='@0' action='get' maxRecords='1000' orderBy='keyed_name' select='id,source_id,related_id' />", dialog.SelectedItem.KeyedName).Items();
                        if (items.Count() >= 1000)
                        {
                            _findAction = () => FindByItem(dialog.SelectedItem.KeyedName);
                            _availableRefs.Add(_searchMessage);
                        }
                        else
                        {
                            ItemReference newRef;
                            _findAction = DefaultFindAction;
                            foreach (var result in items)
                            {
                                newRef = ItemReference.FromFullItem(result, true);
                                if (!_selectedRefs.Contains(newRef))
                                {
                                    _availableRefs.Add(newRef);
                                }
                            }
                        }
                        EnsureResultsTab();
                        tbcSearch.SelectedTab = pgResults;
                        txtFind.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }
        }
 private void btnAddItemTypes_Click(object sender, EventArgs e)
 {
     try
     {
         using (var dialog = new FilterSelect <ItemReference>())
         {
             dialog.DataSource    = _availTypes;
             dialog.DisplayMember = "KeyedName";
             dialog.Message       = resources.Messages.ItemTypeSelect;
             if (dialog.ShowDialog(this, btnAddItemTypes.RectangleToScreen(btnAddItemTypes.Bounds)) ==
                 DialogResult.OK && dialog.SelectedItem != null)
             {
                 _selectedTypes.Add(dialog.SelectedItem);
                 _availTypes.Remove(dialog.SelectedItem);
             }
         }
     }
     catch (Exception ex)
     {
         Utils.HandleError(ex);
     }
 }