Пример #1
0
        private void _replace <T>(GDbTab tab, Database.Tuple tuple)
        {
            var aDb = tab.DbComponent.To <T>();

            aDb.Table.Commands.Begin();

            try {
                List <DbAttribute> attributes = _boxes.Where(p => p.IsChecked == true).Select(p => (DbAttribute)p.Tag).ToList();
                //List<ITableCommand<T, ReadableTuple<T>>> commands = new List<ITableCommand<T, ReadableTuple<T>>>();

                foreach (ReadableTuple <T> item in tab._listView.SelectedItems)
                {
                    for (int index = 0; index < attributes.Count; index++)
                    {
                        aDb.Table.Commands.Set(item, attributes[index], tuple.GetValue(attributes[index]));
                    }
                }

                //aDb.Table.Commands.StoreAndExecute(new GroupCommand<T, ReadableTuple<T>>(commands));
            }
            catch {
                aDb.Table.Commands.CancelEdit();
            }
            finally {
                aDb.Table.Commands.End();
                tab.Update();
            }
        }
Пример #2
0
 public void Select2(ServerDbs tabName, Database.Tuple tuple)
 {
     if (tuple.Attributes.PrimaryAttribute.DataType == typeof(int))
     {
         SelectInternal(tabName, new List <int> {
             tuple.GetKey <int>()
         });
     }
     else if (tuple.Attributes.PrimaryAttribute.DataType == typeof(string))
     {
         SelectInternal(tabName, new List <string> {
             tuple.GetKey <string>()
         });
     }
 }
Пример #3
0
        public AddRangeDialog(SdeEditor editor)
            : base("Add range...", "add.png", SizeToContent.WidthAndHeight, ResizeMode.NoResize)
        {
            InitializeComponent();

            _tab = editor.FindTopmostTab();

            if (_tab == null)
            {
                throw new Exception("No table selected.");
            }

            if (!(_tab is GDbTabWrapper <int, ReadableTuple <int> >))
            {
                throw new Exception("This table doesn't support this operation.");
            }

            List <ServerDbs> dbSources = new List <ServerDbs>();

            dbSources.Add(_tab.DbComponent.DbSource);

            if (_tab.DbComponent.DbSource.AdditionalTable != null)
            {
                dbSources.Add(_tab.DbComponent.DbSource.AdditionalTable);
            }

            _destTable.ItemsSource   = dbSources;
            _destTable.SelectedIndex = 0;

            WpfUtils.AddMouseInOutEffects(_imReset);

            this.Loaded += delegate {
                _tbRange.Text = "1";
                _tbFrom.Text  = "0";

                if (_tab._listView.SelectedItem != null)
                {
                    _based              = (Tuple)_tab._listView.SelectedItem;
                    _tbBasedOn.Text     = _based.GetKey <int>().ToString(CultureInfo.InvariantCulture);
                    _imReset.Visibility = System.Windows.Visibility.Visible;

                    _tbFrom.Text = (_based.GetKey <int>() + 1).ToString(CultureInfo.InvariantCulture);
                }
            };

            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;
        }
Пример #4
0
        private void _buttonSearch_Click(object sender, RoutedEventArgs e)
        {
            try {
                SelectFromDialog dialog = new SelectFromDialog(_tab.To <int>().Table, _tab.DbComponent.DbSource, _tab._listView.SelectedItem == null ? "" : (_tab._listView.SelectedItem as ReadableTuple <int>).Key.ToString());
                if (dialog.ShowDialog() == true)
                {
                    var id = Int32.Parse(dialog.Id);

                    _based = _tab.To <int>().GetMetaTable <int>(_tab.DbComponent.DbSource).TryGetTuple(id);

                    if (_based != null)
                    {
                        _tbBasedOn.Text     = id.ToString(CultureInfo.InvariantCulture);
                        _imReset.Visibility = Visibility.Visible;
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Пример #5
0
 private void _imReset_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     _tbBasedOn.Text     = "None";
     _imReset.Visibility = Visibility.Collapsed;
     _based = null;
 }
Пример #6
0
 public static void Select(ServerDbs db, Database.Tuple tuple)
 {
     Instance.Select2(db, tuple);
 }