Пример #1
0
        PageTableContainer <T> InitContainer <T>(IQueryable <T> entity, string entityInstanceName)
        {
            PageTableContainer <T> container = new PageTableContainer <T> {
                entity             = entity,
                entityInstanceName = entityInstanceName,
                DataGridChanged    = DataGridChanged,
                DbChanged          = DbChanged
            };

            if (this.constraint.items != null)
            {
                foreach (MenuItem item in this.constraint.items)
                {
                    if (item.Parent != null)
                    {
                        /* Detach the items from the old logical parent, to attach
                         * it to an other data grid's context menu. */
                        (this.FrameMain.Content as pageTable).dataGrid.ContextMenu.Items.Clear();

                        break;
                    }
                }
            }

            container.constraint = this.constraint = this.constraints[entityInstanceName];

            return(container);
        }
Пример #2
0
        void InitEntity <T>(PageTableContainer <T> container) where T : class, new()
        {
            this.lstEntities        = container.entity.ToList <object>();
            this.entityInstanceName = container.entityInstanceName;
            DataGridChanged         = container.DataGridChanged;
            DbChanged = container.DbChanged;

            /* Setup the context menu. */
            this.events = new List <RoutedEventHandler> {
                InfoMenuItem_Click,
                CopyMenuItem_Click,
                ModifyMenuItem_Click,
                RemoveMenuItem_Click
            };

            this.dataGrid.ContextMenu = new ContextMenu();
            ConstraintAccess(container.constraint);
            this.constraint = container.constraint;

            GetColumnNames(new T());
            Context.ctx.Set <T>().Local.CollectionChanged += OnCollectionChanged;

            if (this.entityInstanceName == EntityInstanceNames.Campaign)
            {
                /* It's not good. */
                this.btnAdd.Visibility = Visibility.Collapsed;
            }

            this.dataGrid.ItemsSource        = this.lstEntities;
            this.dataGrid.IsReadOnly         = true;
            this.cmbAttributes.SelectedIndex = 0;

            DataGridMergeVirtual += OnDataGridMergeVirtual;
            Unloaded             += pageTable_Unloaded;
        }
Пример #3
0
        void btnStock_Click(object sender, RoutedEventArgs e)
        {
            PageTableContainer <Stock> container = new PageTableContainer <Stock>();

            if (PrepareNavigation(Context.ctx.Stock, EntityInstanceNames.Stock,
                                  (string)this.btnStock.Content, ref container) == -1)
            {
                return;
            }

            this.FrameMain.Navigate(new pageTable(container));
        }
Пример #4
0
        void btnContractorsProduction_Click(object sender, RoutedEventArgs e)
        {
            PageTableContainer <ContractorsProduction> container =
                new PageTableContainer <ContractorsProduction>();

            if (PrepareNavigation(Context.ctx.ContractorsProduction,
                                  EntityInstanceNames.ContractorProduction,
                                  (string)this.btnContractorsProduction.Content, ref container) == -1)
            {
                return;
            }

            this.FrameMain.Navigate(new pageTable(container));
        }
Пример #5
0
        int PrepareNavigation <T>(IQueryable <T> entity, string entityInstanceName,
                                  string title, ref PageTableContainer <T> container)
        {
            if (this.isDataGridChanged && ConfirmSaveChanges() == Changes.Leaved)
            {
                return(-1);
            }

            if (this.conDep != null)
            {
                IQueryable <Employees> e = entity as IQueryable <Employees>;

                container = InitContainer((IQueryable <T>)e.Where(
                                              empl => empl.Positions.department == this.conDep), entityInstanceName);
            }
            else
            {
                container = InitContainer(entity, entityInstanceName);
            }

            this.Title = this.title + " -> " + title;

            return(0);
        }
Пример #6
0
        public pageTable(PageTableContainer <OrdReqs> container)
        {
            InitializeComponent();

            InitEntity(container);
        }
Пример #7
0
        public pageTable(PageTableContainer <Campaigns> container)
        {
            InitializeComponent();

            InitEntity(container);
        }
Пример #8
0
        public pageTable(PageTableContainer <Employees> container)
        {
            InitializeComponent();

            InitEntity(container);
        }
Пример #9
0
        public pageTable(PageTableContainer <ContractorsProduction> container)
        {
            InitializeComponent();

            InitEntity(container);
        }
Пример #10
0
        public pageTable(PageTableContainer <ContractorsMedia> container)
        {
            InitializeComponent();

            InitEntity(container);
        }