Exemplo n.º 1
0
        /// <summary>
        /// Adds a field for every argument that the DataMethos needs in order to be invoked
        /// </summary>
        /// <param name="method">DataMethod which parameters will be used as fields</param>
        public override void AddFields(MethodInfo method)
        {
            if (method == null)
            {
                throw new ArgumentNullException("dmethod");
            }
            uint order = 0;

            //add a field for each parameter
            foreach (ParameterInfo param in method.GetParameters())
            {
                FormField field;

                field = ObjectForm.CreateField(param.ParameterType);

                //set common values
                field.Container           = this;
                field.Name                = param.Name;
                field.Required            = !param.IsOptional && !param.IsOut;
                field.CaptionControl.Text = new System.Resources.ResourceManager(method.DeclaringType).GetString(method.GetFriendlyFullName().Replace('.', '_') + '_' + param.Name);
                field.SortOrder           = order++;

                Fields.Add(field);
            }
        }
Exemplo n.º 2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OKHOSTING.ORM.UI.InsertController"/> class.
		/// <para xml:lang="es">
		/// Inicilaiza una nueva instancia de la clase OKHOSTING.ORM.UI.InsertController, para el objeto especificado.
		/// </para>
		/// </summary>
		/// <param name="instance">Instance.</param>
		public InsertController(object instance)
		{
			if (instance == null)
			{
				throw new ArgumentNullException(nameof(instance));
			}

			DataType = instance.GetType();
			Instance = instance;
			Form = new ObjectForm();
		}
Exemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OKHOSTING.ORM.UI.InsertController"/> class.
		/// <para xml:lang="es">
		/// Inicializa una nueva instancia de la clase OKHOSTING.ORM.UI.InsertController, para el DataTipe especificado.
		/// </para>
		/// </summary>
		public InsertController(DataType dataType)
		{
			if (dataType == null)
			{
				throw new ArgumentNullException(nameof(dataType));
			}

			DataType = dataType;
			Instance = Activator.CreateInstance(DataType.InnerType);
			Form = new ObjectForm();
		}
Exemplo n.º 4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OKHOSTING.ORM.UI.UpdateController"/> class, for the object specified.
		/// <para xml:lang="es">
		/// Inicializa una nueva instancia de la clase OKHOSTING.ORM.UI.UpdateController, para el objeto especificado.
		/// </para>
		/// </summary>
		/// <param name="instance">Instance.</param>
		public UpdateController(object instance)
		{
			if (instance == null)
			{
				throw new ArgumentNullException(nameof(instance));
			}

			using (var db = DataBase.CreateDataBase())
			{
				Instance = db.SelectInherited(instance).Last();
			}

			DataType = Instance.GetType();
			Form = new ObjectForm();
			Form.RepeatColumns = 4;
		}
Exemplo n.º 5
0
        /// <summary>
        /// Creates a field for a DataMember
        /// </summary>
        public void AddFields(MemberInfo member)
        {
            //if there's no values defined, exit
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            //field
            FormField fieldMin, fieldMax;
            Type      returnType = MemberExpression.GetReturnType(member);

            //DateTime and numeric, create range fields
            if (returnType.Equals(typeof(DateTime)) || returnType.IsNumeric())
            {
                //create fields
                fieldMin = ObjectForm.CreateField(returnType);
                fieldMax = ObjectForm.CreateField(returnType);

                //set id
                fieldMin.Name += "_0";
                fieldMax.Name += "_1";

                //labels
                fieldMin.CaptionControl.Text += Resources.Strings.OKHOSTING_ORM_UI_Forms_FilterDataForm_Min;
                fieldMax.CaptionControl.Text += Resources.Strings.OKHOSTING_ORM_UI_Forms_FilterDataForm_Max;

                //set container
                fieldMin.Container = this;
                fieldMax.Container = this;

                //not required
                fieldMin.Required = false;
                fieldMax.Required = false;

                //set to false always
                fieldMin.TableWide = false;
                fieldMax.TableWide = false;

                //add
                Fields.Add(fieldMin);
                Fields.Add(fieldMax);
            }
            //single value fields
            else
            {
                //create field
                fieldMin = ObjectForm.CreateField(returnType);

                //set container
                fieldMin.Container = this;

                //not required
                fieldMin.Required = false;

                //set to false always
                fieldMin.TableWide = false;

                //add
                Fields.Add(fieldMin);
            }
        }