Esempio n. 1
0
        public DetailTableEditor(Table SourceTable, TableDetailDesignator SourceDesignator, TableAppearance SourceCustomLook, bool ForceSingleRecord = false)
            : this()
        {
            this.SourceTable      = SourceTable;
            this.SourceDesignator = SourceDesignator;
            this.SourceCustomLook = SourceCustomLook;

            // Operations: Append-Record and Reset-Records...
            Tuple <Action <TableRecord>, Action> RecordOperations = null;

            if (this.SourceCustomLook.IsMultiRecord && !ForceSingleRecord)
            {
                RecordOperations = SetMultiRecordEditor();
            }
            else
            {
                RecordOperations = SetSingleRecordEditor();
            }

            var ImportWidget = DomainServices.CreateTransferWidget(SourceDesignator, SourceTable.OwnerIdea, false, false,
                                                                   (compatdef, datarecords, append) =>
            {
                if (compatdef == null)
                {
                    Display.DialogMessage("Attention", "Cannot load data with incomptaible table-structure.",
                                          EMessageType.Warning);
                    return;
                }

                if (!append)
                {
                    RecordOperations.Item2();           // Reset-Records
                }
                foreach (var datarecord in datarecords)
                {
                    RecordOperations.Item1(new TableRecord(SourceTable, datarecord));           // Append-Record
                }
            },
                                                                   this.SourceTable);

            ImportWidget.MaxWidth            = 300;
            ImportWidget.HorizontalAlignment = HorizontalAlignment.Left;
            DockPanel.SetDock(ImportWidget, Dock.Left);
            this.BottomPanel.Children.Add(ImportWidget);
        }