Exemple #1
0
        private void CreateGUI()
        {
            AddButton = ControlsFactory.CreateStandardAddCircularButton(
                "Προσθήκη ραντεβού πελάτη",
                null,
                DataPresenter,
                () =>
            {
                var form = iPetrosDataModelHelpers.CreateCustomerAppointmentDataModelDataForm();

                form.ShowSearchInput <CustomerDataModel, int>(x => x.CustomerId, async search => await iPetrosDI.GetDataStorage.GetCustomersAsync(0, new DateDataStorageArgs()
                {
                    Search = search
                }), x => x.FirstName + " " + x.LastName, x => x.Id, x => null);
                form.ShowSearchInput <StaffMemberDataModel, int>(x => x.StaffMemberId, async search => await iPetrosDI.GetDataStorage.GetStaffMembersAsync(0, new DateDataStorageArgs()
                {
                    Search = search
                }), x => x.FirstName + " " + x.LastName, x => x.Id, x => null);

                return(form);
            },
                () => new CustomerAppointmentDataModel()
            {
                DateStart = DateTimeOffset.Now, DateEnd = DateTimeOffset.Now.AddHours(1)
            },
                async model => await iPetrosDI.GetDataStorage.AddCustomerAppointmentAsync(model),
                Args);

            ContentGrid.Children.Add(AddButton);
        }
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Create the form
                var form = new DataForm <DataGridPresenterMap>(new DataGridPresenterMap(QueryMap))
                {
                    Mapper = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value
                }
                .ShowInput(x => x.Name, settings => { settings.Name = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Name); settings.IsRequired = true; })
                .ShowInput(x => x.Description, settings => settings.Name      = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Description))
                .ShowStringColorInput(x => x.Color, settings => settings.Name = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Color));

                // Show an add dialog
                var dialogResult = await DialogHelpers.ShowConventionalAddDialogAsync(this, "Data grid creation", null, form);

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Return
                    return;
                }

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register it
                QueryMap.Add(form.Model);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Return
                    return;
                }

                // Add the model
                DataPresenter.Add(form.Model);
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
Exemple #3
0
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Create the form
                var form = CeidDiplomatikiDataModelHelpers.CreatePageMapDataForm();

                // Set the model
                form.Model = new PageMap();

                // Show the dialog
                var dialogResult = await DialogHelpers.ShowConventionalAddDialogAsync(this, "Page creation", null, form);

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Return
                    return;
                }

                // Update the values of the model
                form.UpdateModelValues();

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register it
                manager.Register(form.Model);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Return
                    return;
                }

                // Add it to the presenter
                DataPresenter.Add(form.Model);
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
        private void CreateGUI()
        {
            AddButton = ControlsFactory.CreateStandardAddCircularButton(
                "Προσθήκη υπαλλήλου",
                null,
                DataPresenter,
                () =>
            {
                return(iPetrosDataModelHelpers.CreateCustomerDataModelDataForm());
            },
                () => new CustomerDataModel(),
                async model => await iPetrosDI.GetDataStorage.AddCustomerAsync(model),
                Args);

            ContentGrid.Children.Add(AddButton);
        }
        private void CreateGUI()
        {
            AddButton = ControlsFactory.CreateStandardAddCircularButton(
                "Προσθήκη υπαλλήλου",
                null,
                DataPresenter,
                () =>
            {
                return(iPetrosDataModelHelpers.CreateStaffMemberDataModelDataForm()
                       .ShowSelectEnumSingleOptionInput(x => x.Type, (dataForm, propertyInfo) => new DropDownMenuEnumOptionsFormInput <StaffMemberType>(dataForm, propertyInfo, new List <StaffMemberType>()
                {
                    StaffMemberType.Moderator, StaffMemberType.StaffMember
                }, x => x.ToLocalizedString()), settings => settings.IsRequired = true));
            },
                () => new StaffMemberDataModel(),
                async model => await iPetrosDI.GetDataStorage.AddStaffMemberAsync(model),
                Args);

            AddButton.Visibility = iPetrosDI.ConnectedUser.Type == StaffMemberType.Admin ? Visibility.Visible : Visibility.Collapsed;

            ContentGrid.Children.Add(AddButton);
        }
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Disable the button
                AddButton.IsEnabled = false;

                // Get the analyzer
                var analyzer = CeidDiplomatikiDI.GetDatabaseAnalyzer(DatabaseOptions.Provider);

                // Get the connection string
                DatabaseOptions.TryGetConnectionString(out var connectionString);

                // Get all the tables
                var tables = analyzer.GetTables(Database.DatabaseName);

                // Get all the foreign key columns
                var foreignKeyColumns = analyzer.GetForeignKeyColumns(Database.DatabaseName, null);

                // Create a steps presenter
                var stepsPresenter = new StepsPresenter()
                {
                    AllowArbitraryNavigation = false
                };

                // Create a node component
                var nodeComponent = new NodeComponent <IDbProviderTable>(tables, (table) =>
                {
                    // Get the foreign keys of the table
                    var foreignKeys = foreignKeyColumns.Where(x => x.TableName == table.TableName).ToList();

                    // Get the tables whose primary key is related to one of the foreign keys
                    var foreignToPrimaryKeyTables = tables.Where(x => foreignKeys.Any(y => y.ReferencedTableName == x.TableName)).ToList();

                    // Get the foreign keys that are related to the primary key of the table
                    var relatedForeignKeys = foreignKeyColumns.Where(x => x.ReferencedTableName == table.TableName).ToList();

                    // Get the tables
                    var primaryToForeignKeyTables = tables.Where(x => relatedForeignKeys.Any(y => y.TableName == x.TableName)).ToList();

                    return(foreignToPrimaryKeyTables.Concat <IDbProviderTable, IDbProviderTable>(primaryToForeignKeyTables).Distinct());
                }, table => table.TableName);

                var nodeComponentScrollViewer = new ScrollViewer()
                {
                    Content = nodeComponent,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Visible
                };

                // Add it to the steps presenter
                stepsPresenter.Add("Query", nodeComponentScrollViewer, element => nodeComponent.NodePath.Model != null);

                // Create the form
                var form = new DataForm <QueryMap>()
                           .ShowInput(x => x.Name, settings => { settings.Name = CeidDiplomatikiDataModelHelpers.QueryMapMapper.Value.GetTitle(x => x.Name); settings.IsRequired = true; })
                           .ShowInput(x => x.Description, settings => settings.Name      = CeidDiplomatikiDataModelHelpers.QueryMapMapper.Value.GetTitle(x => x.Description))
                           .ShowStringColorInput(x => x.Color, settings => settings.Name = CeidDiplomatikiDataModelHelpers.QueryMapMapper.Value.GetTitle(x => x.Color));

                // Add it to the steps presenter
                stepsPresenter.Add("Info", form, (element) => element.Validate());

                // Show a dialog
                var dialogResult = await DialogHelpers.ShowStepsDialogAsync(this, "Query map creation", null, stepsPresenter, IconPaths.TablePath);

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Get the selected tables
                tables = nodeComponent.NodePath.DistinctModels;

                // Get the pairs
                var pairs = nodeComponent.NodePath.Pairs;

                // Get the node path
                var nodePath = nodeComponent.NodePath;

                // Get the columns of the table
                var columns = analyzer.GetColumns(DatabaseOptions.DatabaseName, null).Where(x => tables.Any(y => y.TableName == x.TableName)).ToList();

                // The joins collection
                var joins = new List <JoinMap>();

                // For every pair...
                foreach (var pair in pairs)
                {
                    JoinMap joinMap;

                    if (foreignKeyColumns.Any(x => x.TableName == pair.Value.Model.TableName && x.ReferencedTableName == pair.Key.Model.TableName))
                    {
                        // Get the foreign key column
                        var foreignKeyColumn = foreignKeyColumns.First(x => x.TableName == pair.Value.Model.TableName && x.ReferencedTableName == pair.Key.Model.TableName);

                        // Get the principle column
                        var principleColumn = columns.First(x => x.ColumnName == foreignKeyColumn.ReferencedColumnName);

                        // Get the foreign key column
                        var referencedColumn = columns.First(x => x.ColumnName == foreignKeyColumn.ColumnName);

                        // Create the join map
                        joinMap = new JoinMap(pair.Key.Model, principleColumn, pair.Value.Model, referencedColumn, pair.Key.Index, false);
                    }
                    else
                    {
                        // Get the foreign key column
                        var foreignKeyColumn = foreignKeyColumns.First(x => x.ReferencedTableName == pair.Value.Model.TableName && x.TableName == pair.Key.Model.TableName);

                        // Get the principle column
                        var principleColumn = columns.First(x => x.ColumnName == foreignKeyColumn.ColumnName);

                        // Get the foreign key column
                        var referencedColumn = columns.First(x => x.ColumnName == foreignKeyColumn.ReferencedColumnName);

                        // Create the join map
                        joinMap = new JoinMap(pair.Key.Model, principleColumn, pair.Value.Model, referencedColumn, pair.Key.Index, true);
                    }

                    // Add it to the joins
                    joins.Add(joinMap);
                }

                // Create the model
                var model = QueryMap.FromDataModel(DatabaseOptions, Database, tables, columns, joins);

                // Set it to the form
                form.Model = model;

                // Update its values
                form.UpdateModelValues();

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register the model
                await manager.RegisterAsync(model);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Add it to the presenter
                DataPresenter.Add(model);

                // Re enable the button
                AddButton.IsEnabled = true;
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Disable the button
                AddButton.IsEnabled = false;

                // Create a steps presenter
                var stepsPresenter = new StepsPresenter()
                {
                    AllowArbitraryNavigation = false
                };

                // Create a columns container
                var propertiesContainer = new UniformGridCollapsibleVerticalMenuCategorizingItemsControl <PropertyInfo, InformationalButton>()
                {
                    Columns            = 3,
                    CategoryNameGetter = (prop) => prop.DeclaringType.Name.Split("-").Last()
                };

                propertiesContainer.Linker = (prop) => new InformationalButton()
                {
                    MinWidth = 0,
                    Text     = prop.Name,
                    Command  = new RelayCommand(() =>
                    {
                        foreach (var element in propertiesContainer.Elements)
                        {
                            element.Selected = false;
                        }

                        propertiesContainer.GetElement(prop).Selected = true;
                    })
                };

                // Add the tables
                propertiesContainer.SetItemsSource(QueryMap.DataModelTypes.SelectMany(x => x.GetProperties().Where(y => !DataPresenter.Items.Any(z => z.PropertyInfo == y))).OrderBy(x => x.Name));

                // Add it to the steps presenter
                stepsPresenter.Add("Property", propertiesContainer, (element) => element.Elements.Any(x => x.Selected));

                // Create the form
                var form = new DataForm <PropertyMap>()
                {
                    Mapper = CeidDiplomatikiDataModelHelpers.PropertyMapMapper.Value
                }
                .ShowInput(x => x.Name, settings => settings.IsRequired = true)
                .ShowInput(x => x.Description)
                .ShowStringColorInput(x => x.Color)
                .ShowSelectMultipleOptionsInput(x => x.Attributes, (form, propertyInfo) => new DropDownMenuOptionsFormInput <ColumnAttribute>(form, propertyInfo, ColumnAttributes.Data.Value, x => x.Name), null, settings => settings.IsRequired = true)
                .ShowNumericInput(x => x.Order)
                .ShowInput(x => x.DefaultValue)
                .ShowInput(x => x.IsEditable)
                .ShowInput(x => x.IsRequired)
                .ShowInput(x => x.IsPreview);

                // Add it to the steps presenter
                stepsPresenter.Add("Info", form, (element) => element.Validate());

                // Show a dialog
                var dialogResult = await DialogHelpers.ShowStepsDialogAsync(this, "Property map creation", null, stepsPresenter, IconPaths.TableColumnPath);

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Get the selected property
                var property = propertiesContainer.Get(propertiesContainer.Elements.First(x => x.Selected));

                // Create the model
                var model = new PropertyMap(QueryMap, property.DeclaringType, property, QueryMap.GetColumnOrNull(property));

                // Set it to the form
                form.Model = model;

                // Update its values
                form.UpdateModelValues();

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register the model
                QueryMap.Add(model);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Add it to the presenter
                DataPresenter.Add(model);

                // Re enable the button
                AddButton.IsEnabled = true;
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
Exemple #8
0
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Create the component
                var component = new DatabaseOptionComponentsContainer();

                // Add the options
                component.Add(new SQLiteOptionsComponent(new SQLiteOptionsDataModel()));
                component.Add(new MySQLOptionsComponent(new MySQLOptionsDataModel()));
                component.Add(new SQLServerOptionsComponent(new SQLServerOptionsDataModel()));
                component.Add(new PostgreSQLOptionsComponent(new PostgreSQLOptionsDataModel()));

                // Show the dialog
                var dialogResult = await DialogHelpers.ShowValidationDialogAsync(this, "Database addition", null, component, (element) =>
                {
                    // TODO: Make sure that the database exists
                    if (!element.Validate())
                    {
                        return(false);
                    }

                    element.UpdateOptionData();

                    return(true);
                });

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Return
                    return;
                }

                // Get the options
                var options = component.SelectedOptions;

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register the options
                manager.Register(options);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Add them to the presenter
                DataPresenter.Add(options);
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }