Exemplo n.º 1
0
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            // Set ErrorProvider Instance
            this.errorProvider = param.errorProvider;

            StringField stringField = new StringField();

            stringField.StopAutoSizeConfig();
            stringField.Name             = param.PropertyInfo.Name;
            stringField.Location         = param.Location;
            stringField.OrientationField = param.OrientationField;
            stringField.SizeLabel        = param.SizeLabel;
            stringField.SizeControl      = param.SizeControl;
            stringField.IsMultiline      = param.ConfigProperty.EntryForm.MultiLine;
            stringField.NombreLigne      = param.ConfigProperty.EntryForm.NumberLine;
            if (param.ConfigProperty.EntryForm.WidthControl != 0)
            {
                stringField.Width = param.ConfigProperty.EntryForm.WidthControl;
            }

            stringField.TabIndex   = param.TabIndex;
            stringField.Text_Label = param.ConfigProperty.DisplayProperty.Title;
            stringField.ConfigSizeField();

            if (param.ConfigProperty.EntryForm.isRequired)
            {
                stringField.Validating += StringField_Validating;
            }
            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(stringField);
            return(stringField);
        }
Exemplo n.º 2
0
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            this.errorProvider = param.errorProvider;

            DateTimeField dateTimeField = new DateTimeField();

            dateTimeField.StopAutoSizeConfig();
            dateTimeField.Name             = param.PropertyInfo.Name;
            dateTimeField.Location         = param.Location;
            dateTimeField.OrientationField = param.OrientationField;
            dateTimeField.SizeLabel        = param.SizeLabel;
            dateTimeField.SizeControl      = param.SizeControl;

            dateTimeField.TabIndex   = param.TabIndex;
            dateTimeField.Text_Label = param.ConfigProperty.DisplayProperty.Title;
            dateTimeField.ConfigSizeField();

            // Validation
            // We can not check validation of DateTime Control because we can not knew the default value
            //dateTimeField.Validating += DateTimeField_Validating;

            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(dateTimeField);
            return(dateTimeField);
        }
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            ComboBoxField comboBoxField = new ComboBoxField();

            comboBoxField.StopAutoSizeConfig();
            comboBoxField.Name             = param.PropertyInfo.Name;
            comboBoxField.Location         = param.Location;
            comboBoxField.OrientationField = param.OrientationField;
            comboBoxField.SizeLabel        = param.SizeLabel;
            comboBoxField.SizeControl      = param.SizeControl;

            comboBoxField.TabIndex   = param.TabIndex;
            comboBoxField.Text_Label = param.ConfigProperty.DisplayProperty.Title;
            comboBoxField.ConfigSizeField();

            // DataSource
            //var DataObject = Activator.CreateInstance(param.ConfigProperty.DataSource.TypeObject);
            //IList ls_data = (IList)DataObject.GetType().GetMethod(param.ConfigProperty.DataSource.MethodeName).Invoke(DataObject, null);
            IList ls_data = param.ConfigProperty.DataSource.GetData();

            List <object> ls_data_object = ls_data.Cast <string>().ToList <object>();


            comboBoxField.DataSource = ls_data_object;

            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(comboBoxField);
            return(comboBoxField);
        }
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            if (param.ConfigProperty.EntryForm?.TabPage == true)
            {
                TabPage tabPage = new TabPage();
                tabPage.Name = "tabPage" + param.PropertyInfo.Name;
                tabPage.Text = param.ConfigProperty.DisplayProperty.Title;
                param.TabControlForm.TabPages.Add(tabPage);
                param.ConteneurFormulaire = tabPage;
            }


            //Default Value
            List <BaseEntity> ls_default_value = null;

            if (param.Entity != null)
            {
                IList ls_obj = param.PropertyInfo.GetValue(param.Entity) as IList;

                if (ls_obj != null)
                {
                    ls_default_value = ls_obj.Cast <BaseEntity>().ToList();
                }
            }

            if (param.SizeControl.Height < 80)
            {
                param.SizeControl = new System.Drawing.Size(param.SizeControl.Width, 100);
            }

            ManyToManyField manyToManyField = new ManyToManyField(param.PropertyInfo,
                                                                  param.OrientationField,
                                                                  param.SizeLabel,
                                                                  param.SizeControl,
                                                                  param.ConfigProperty.ConfigEntity,
                                                                  param.ConteneurFormulaire,
                                                                  param.EntityBLO);

            manyToManyField.Name = param.PropertyInfo.Name;



            if (param.ConfigProperty.EntryForm?.TabPage == true)
            {
                manyToManyField.Dock = DockStyle.Fill;
            }

            // Inert in to Interface
            param.ConteneurFormulaire.Controls.Add(manyToManyField);
            return(manyToManyField);
        }
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            Int32Filed int32Filed = new Int32Filed();

            int32Filed.StopAutoSizeConfig();
            int32Filed.Name             = param.PropertyInfo.Name;
            int32Filed.Location         = param.Location;
            int32Filed.OrientationField = param.OrientationField;
            int32Filed.SizeLabel        = param.SizeLabel;
            int32Filed.SizeControl      = param.SizeControl;

            int32Filed.TabIndex   = param.TabIndex;
            int32Filed.Text_Label = param.ConfigProperty.DisplayProperty.Titre;
            int32Filed.ConfigSizeField();

            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(int32Filed);
            return(int32Filed);
        }
Exemplo n.º 6
0
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            Int64 InitValue = 0;

            ManyToOneField manyToOneField = new ManyToOneField(param.EntityBLO, param.PropertyInfo,
                                                               param.ConteneurFormulaire, param.OrientationField,
                                                               param.SizeLabel,
                                                               param.SizeControl, InitValue, param.ConfigProperty.ConfigEntity, param.Entity
                                                               );

            manyToOneField.Location   = param.Location;
            manyToOneField.Name       = param.PropertyInfo.Name;
            manyToOneField.TabIndex   = param.TabIndex;
            manyToOneField.Text_Label = param.ConfigProperty.DisplayProperty.Title;


            // Inert in to Interface
            param.ConteneurFormulaire.Controls.Add(manyToOneField);
            return(manyToOneField);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Step1 : CreateField in EntryForm
        /// </summary>
        /// <param name="param">
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            // Set ErrorProvider Instance
            this.errorProvider = param.errorProvider;

            DefaultField defaultField = new DefaultField();

            defaultField.StopAutoSizeConfig();
            defaultField.Name             = param.PropertyInfo.Name;
            defaultField.Location         = param.Location;
            defaultField.OrientationField = param.OrientationField;
            defaultField.SizeLabel        = param.SizeLabel;
            defaultField.SizeControl      = param.SizeControl;
            defaultField.TabIndex         = param.TabIndex;
            defaultField.Text_Label       = param.ConfigProperty.DisplayProperty.Title;
            defaultField.ConfigSizeField();

            //Validating
            if (param.ConfigProperty.EntryForm.isRequired)
            {
                defaultField.Validating += DefaultField_Validating;
            }

            // Type of Property
            defaultField.PropertyInfo = param.ConfigProperty.PropertyInfo;

            // Can not Update Not supported Type , you can Just read it value
            // NB : String is not a primitve type
            if (
                !param.ConfigProperty.PropertyInfo.PropertyType.IsPrimitive &&
                !(param.ConfigProperty.PropertyInfo.PropertyType == typeof(string))
                )
            {
                defaultField.Enabled = false;
            }


            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(defaultField);
            return(defaultField);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Step1 : CreateField in EntryForm
        /// </summary>
        /// <param name="param">
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            BooleanField booleanField = new BooleanField();

            booleanField.StopAutoSizeConfig();
            booleanField.Name             = param.PropertyInfo.Name;
            booleanField.Location         = param.Location;
            booleanField.OrientationField = param.OrientationField;
            booleanField.SizeLabel        = param.SizeLabel;
            booleanField.SizeControl      = param.SizeControl;
            booleanField.TabIndex         = param.TabIndex;
            booleanField.Text_Label       = param.ConfigProperty.DisplayProperty.Title;
            booleanField.ConfigSizeField();

            // Type of Property
            booleanField.PropertyInfo = param.ConfigProperty.PropertyInfo;

            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(booleanField);
            return(booleanField);
        }
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            // Create Field
            ComboBoxField comboBoxField = new ComboBoxField();

            comboBoxField.StopAutoSizeConfig();
            comboBoxField.Name             = param.PropertyInfo.Name;
            comboBoxField.Location         = param.Location;
            comboBoxField.OrientationField = param.OrientationField;
            comboBoxField.SizeLabel        = param.SizeLabel;
            comboBoxField.SizeControl      = param.SizeControl;
            comboBoxField.TabIndex         = param.TabIndex;
            comboBoxField.Text_Label       = param.ConfigProperty.DisplayProperty.Title;
            comboBoxField.ConfigSizeField();

            // DataSource
            comboBoxField.DataSource = Enum.GetValues(param.PropertyInfo.PropertyType).Cast <object>().ToList <object>();

            // Insert field in Form
            param.ConteneurFormulaire.Controls.Add(comboBoxField);
            return(comboBoxField);
        }
        /// <summary>
        /// CreateField in EntryForm
        ///
        /// </summary>
        /// <param name="param">
        /// param.PropertyInfo
        /// param.Location
        /// param.OrientationField
        /// param.SizeLabel
        /// param.SizeControl
        /// param.ConfigProperty
        /// param.TabIndex
        /// param.Service
        /// param.ConfigEntity
        /// param.TabControlForm
        /// param.Entity
        /// param.ConteneurFormulaire
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            StringField stringField = new StringField();

            stringField.StopAutoSizeConfig();
            stringField.Name             = param.PropertyInfo.Name;
            stringField.Location         = param.Location;
            stringField.OrientationField = param.OrientationField;
            stringField.SizeLabel        = param.SizeLabel;
            stringField.SizeControl      = param.SizeControl;
            if (param.ConfigProperty.EntryForm?.MultiLine == true)
            {
                stringField.IsMultiline = true;
                stringField.NombreLigne = param.ConfigProperty.EntryForm.NumberLine;
            }
            stringField.TabIndex   = param.TabIndex;
            stringField.Text_Label = param.ConfigProperty.DisplayProperty.Titre;
            stringField.ConfigSizeField();

            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(stringField);
            return(stringField);
        }
Exemplo n.º 11
0
 /// <summary>
 /// CreateField in EntryForm
 ///
 /// </summary>
 /// <param name="param">
 /// param.PropertyInfo
 /// param.Location
 /// param.OrientationField
 /// param.SizeLabel
 /// param.SizeControl
 /// param.ConfigProperty
 /// param.TabIndex
 /// param.Service
 /// param.ConfigEntity
 /// param.TabControlForm
 /// param.Entity
 /// param.ConteneurFormulaire
 /// </param>
 /// <returns>the created field</returns>
 public BaseField CreateField_In_EntryForm(CreateFieldParams param)
 {
     throw new GwinException("Field Many to Many Creation in EntryForm not yet implemented in Gwin Application");
 }
Exemplo n.º 12
0
        /// <summary>
        /// Field Creation
        /// </summary>
        private void CreateFieldIfNotGenerated()
        {
            // Create Field if not yet Created
            if (!this.AutoGenerateField || this.isGeneratedForm)
            {
                return;
            }
            this.isGeneratedForm = true;

            // Execute Befor Init Methode
            this.FormBeforInit();

            //
            // Container
            //
            // Create FlowLayout : it containe All Filed or GroupBox of Fileds
            this.flowLayoutPanelForm            = new FlowLayoutPanel();
            this.flowLayoutPanelForm.AutoScroll = true;
            this.flowLayoutPanelForm.Dock       = DockStyle.Fill;

            this.FlowLayoutContainer.Controls.Add(this.flowLayoutPanelForm);

            if (GwinApp.isRightToLeft)
            {
                this.flowLayoutPanelForm.FlowDirection = FlowDirection.RightToLeft;
                this.FlowLayoutContainer.RightToLeft   = RightToLeft.Yes;
            }

            else
            {
                this.FlowLayoutContainer.RightToLeft   = RightToLeft.No;
                this.flowLayoutPanelForm.FlowDirection = FlowDirection.LeftToRight;
            }



            // set flowLayoutPanelForm as Conteneurs du formulaire
            this.ConteneurFormulaire = this.flowLayoutPanelForm;

            #region Default Positions and  Size
            int         y_field         = 0;
            int         x_field         = 0;
            int         width_label     = 100;
            int         height_label    = 10;
            int         width_control   = 200;
            int         height_control  = 25;
            int         width_groueBox  = 100;
            int         height_groueBox = 200; // il ne sera pas utilisé
            Orientation orientation     = Orientation.Vertical;
            #endregion

            // Init interface with TabControl
            this.InitTabPageInterface();

            // Create GroupBoxes
            Dictionary <string, Control> GroupesBoxMainContainers = new Dictionary <string, Control>();
            this.CreateGroupesBoxes(GroupesBoxMainContainers, width_groueBox, height_groueBox);

            // L'index de la touche Entrer
            int TabIndex = 0;

            // Get Properties to show in Entry Form
            var listeProprite = from i in this.EntityBLO.TypeEntity.GetProperties()
                                where i.GetCustomAttribute(typeof(EntryFormAttribute)) != null
                                orderby((EntryFormAttribute)i.GetCustomAttribute(typeof(EntryFormAttribute))).Ordre
                                select i;

            // Create Field per Properites
            foreach (PropertyInfo item in listeProprite)
            {
                ConfigProperty configProperty = new ConfigProperty(item, this.ConfigEntity);

                // Field Size
                int width_control_config  = width_control;
                int height_control_config = height_control;
                if (configProperty.EntryForm?.WidthControl != 0)
                {
                    width_control_config = configProperty.EntryForm.WidthControl;
                }
                if (configProperty.EntryForm?.HeightControl != 0)
                {
                    height_control_config = configProperty.EntryForm.WidthControl;
                }

                // Orientation
                Orientation orientation_config = orientation;
                if (configProperty.EntryForm?.UseOrientationField == true)
                {
                    orientation_config = configProperty.EntryForm.OrientationField;
                }

                // FieldContainner
                Control FieldContainner = this.ConteneurFormulaire;
                if (configProperty.EntryForm?.GroupeBox != null && configProperty.EntryForm?.GroupeBox != string.Empty)
                {
                    FieldContainner = GroupesBoxMainContainers[configProperty.EntryForm?.GroupeBox];
                }

                BaseField baseField = null;

                // Params to Create Fields
                CreateFieldParams param = new CreateFieldParams();
                param.PropertyInfo     = item;
                param.Location         = new System.Drawing.Point(x_field, y_field);
                param.OrientationField = orientation_config;
                param.SizeLabel        = new Size(width_label, height_label);
                param.SizeControl      = new Size(width_control_config, height_control_config);
                param.ConfigProperty   = configProperty;
                param.TabIndex         = ++TabIndex;
                param.EntityBLO        = this.EntityBLO; //  used per ManyToOne Field
                                                         //  param.TabControlForm = this.tabControlForm; //  used per ManyToMany Field
                param.Entity = this.Entity;
                param.ConteneurFormulaire = FieldContainner;
                param.errorProvider       = errorProvider;

                // Create FieldTraitement Instance
                IFieldTraitements fieldTraitement = BaseFieldTraitement.CreateInstance(configProperty);

                // Invok Create Field Method
                baseField = fieldTraitement.CreateField_In_EntryForm(param);

                // Create Value Changed to Apply Business Role
                if (configProperty.BusinesRole != null)
                {
                    baseField.ValueChanged += ControlPropriete_ValueChanged;
                }

                // API Event
                if (this.EntityPLO != null)
                {
                    baseField.ValueChanged    += Presentation_ValueChanged;
                    baseField.ValidatingField += Presentation_ValidatingField;
                }


                // [Bug] Validation per FieldNature
                if (configProperty.EntryForm?.isRequired == true)
                {
                    baseField.ValidatingField += textBoxString_Validating;
                    GwinApp.Instance.Theme.RequiredField(baseField);
                }

                // Add Field to List
                this.Fields.Add(baseField.Name, baseField);

                // Execute After Init methode
            }// Fin de for

            // TabControl for Save and Cancel button
            this.btEnregistrer.TabIndex = ++TabIndex;
            this.btAnnuler.TabIndex     = ++TabIndex;

            // GroupeBox Style
            foreach (GroupBox item in this.ConteneurFormulaire.Controls.Cast <Control>().Where(c => c.GetType() == typeof(GroupBox)))
            {
                // item.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold);
                item.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
            }
            foreach (FlowLayoutPanel item in GroupesBoxMainContainers.Values)
            {
                item.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
            }

            this.FormAfterInit();
        }