/// <summary>
        /// Create Entry form instance
        /// </summary>
        /// <param name="EtityBLO"></param>
        /// <param name="entity"></param>
        /// <param name="critereRechercheFiltre"></param>
        /// <param name="AutoGenerateField"></param>
        public BaseEntryForm(
            IGwinBaseBLO EtityBLO,
            BaseEntity entity,
            Dictionary <string, object> critereRechercheFiltre,
            bool AutoGenerateField)
        {
            InitializeComponent();
            errorProvider.RightToLeft = GwinApp.isRightToLeft;

            if (System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Designtime)
            {
                CheckPramIsNull.CheckParam_is_NotNull(EtityBLO, this, nameof(EtityBLO));

                // Init Variables
                this.EntityBLO         = EtityBLO;
                this.Entity            = entity;
                this.FilterValues      = critereRechercheFiltre;
                this.AutoGenerateField = AutoGenerateField;
                this.ConfigEntity      = ConfigEntity.CreateConfigEntity(this.EntityBLO.TypeEntity);

                // Default values
                this.ConteneurFormulaire      = FlowLayoutContainer;
                this.isStepInitializingValues = false;
                this.MessageValidation        = new MessageValidation(errorProvider);
                this.Fields      = new Dictionary <string, BaseField>();
                this.GroupsBoxes = new Dictionary <string, GroupBox>();

                // Create PLO Instance if PLO exist
                if (this.EntityPLO == null && this.ConfigEntity.PresentationLogic != null)
                {
                    this.EntityPLO = (IGwinPLO)Activator.CreateInstance(this.ConfigEntity.PresentationLogic.TypePLO);
                }


                // Create or Config Entity Instance
                if (this.EntityBLO != null && this.Entity == null)
                {
                    this.Entity = (BaseEntity)EtityBLO.CreateEntityInstance();
                }
                if ((this.Entity == null || this.Entity.Id == 0) && this.FilterValues != null)
                {
                    this.InitialisationEntityParCritereRechercheFiltre();
                }

                // Create Field in Form
                this.CreateFieldIfNotGenerated();
            }
        }
예제 #2
0
        /// <summary>
        /// Create EntityDataGrid Instance
        /// </summary>
        /// <param name="EtityBLO">Business object instance</param>
        /// <param name="FilterValues">Filter values</param>
        public GwinDataGridComponent(IGwinBaseBLO EtityBLO, Dictionary <string, object> FilterValues)
        {
            CheckPramIsNull.CheckParam_is_NotNull(EtityBLO, this, nameof(EtityBLO));

            InitializeComponent();

            // Init Params values
            this.EntityBLO    = EtityBLO;
            this.FilterValues = FilterValues;

            // Init ShownEntityProperties
            var requete = from i in EntityBLO.TypeEntity.GetProperties()
                          where i.GetCustomAttribute(typeof(DataGridAttribute)) != null
                          orderby((DataGridAttribute)i.GetCustomAttribute(typeof(DataGridAttribute))).Ordre
                          select i;

            this.ShownEntityProperties = requete.ToList <PropertyInfo>();

            _Insert_Column_In_DataGrid();
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AppMenu">Main Form application,
        /// it contrain the menu of application
        /// it is Mdi Form
        /// </param>
        /// <param name="user">Connected user,
        /// it can be null if the user is not yet connected
        /// </param>
        /// <param name="TypeDbContext">
        /// Type of EntityFramework DbContext
        /// id used to create instance of GwinApp EntityBAO object
        /// </param>
        public static void Start(Type TypeDbContext, Type TypeBaseBLO, FormApplication AppMenu, User user)
        {
            // User must not be null
            CheckPramIsNull.CheckParam_is_NotNull(user, nameof(GwinApp), nameof(user));

            // Lunch Loading Interface
            GwinApp.Loading_Start();
            GwinApp.Loading_Status("Start Gwin Applicaton ...");

            // Create GwinInstance to Authenticate
            GwinApp.Instance = new GwinApp(TypeDbContext, TypeBaseBLO, AppMenu, user);

            //Layer configuration : Initialize the dependency resolver
            DependencyResolver.Initialize();



            //
            // Update Menu
            //
            // Change User Culture and Tread to do Update with User Language
            GwinApp.instance.CultureInfo          = new CultureInfo(user.Language.ToString());
            Thread.CurrentThread.CurrentCulture   = GwinApp.instance.CultureInfo;
            Thread.CurrentThread.CurrentUICulture = GwinApp.instance.CultureInfo;
            // Update GwinApplicatio, after  ModelConfiguration changes
            //[Update]
            // Must be befor Language Change, because SetLanguge Use MenuTable
            InstallApplicationGwinBLO installApplication = new InstallApplicationGwinBLO(TypeDbContext);

            installApplication.Update();



            // Change Gwin Language
            if (AppMenu != null && user != null)
            {
                GwinApp.SetLanguage(GwinApp.Instance.CultureInfo);
            }



            // Load ApplicationName Instance
            IGwinBaseBLO  ApplicationNameBLO = new GwinBaseBLO <ApplicationName>((DbContext)Activator.CreateInstance(instance.TypeDBContext));
            List <object> ls_apps            = ApplicationNameBLO.GetAll();

            if (ls_apps != null && ls_apps.Count > 0)
            {
                GwinApp.instance.ApplicationName = (ApplicationName)ls_apps.First();
            }
            else
            {
                ApplicationName applicationName = new ApplicationName();
                applicationName.Name             = new Entities.MultiLanguage.LocalizedString();
                applicationName.Name.Current     = "Gwin Application";
                GwinApp.instance.ApplicationName = applicationName;
            }

            // Set Name Applicatoin in ApplicationMenu
            if (AppMenu != null)
            {
                AppMenu.Text = instance.ApplicationName.Name.Current;
            }

            // Close Loading Interface
            GwinApp.Loading_Close();

            // Authentification
            Login();
        }