Ejemplo n.º 1
0
        private Label getLabel(DtoDefAttribute def)
        {
            Label lbl = new Label();

            lbl.Text = def.Label;
            reajustLastControl(lbl, false);
            return(lbl);
        }
Ejemplo n.º 2
0
        private Control getControl(PropertyInfo prop, DtoDefAttribute def)
        {
            Control ctr = getControlByType(prop, def);

            ctr.Enabled = (inType == InputType.Update && def.AllowUpdate) || (inType == InputType.Insert && def.AllowInsert);

            reajustLastControl(ctr, true);
            return(ctr);
        }
Ejemplo n.º 3
0
        private Control getControlByType(PropertyInfo prop, DtoDefAttribute def)
        {
            switch (def.Type)
            {
            case FieldType.String:
            {
                TextBox txt = new TextBox();
                if (def.AllowInsert || def.AllowUpdate)
                {
                    setters.Add(() => prop.SetValue(instance, def.GetNullDefault(txt.Text)));
                }

                if (inType != InputType.Insert)
                {
                    txt.Text = prop.GetValue(instance).ToString();
                }

                return(txt);
            }

            case FieldType.Integer:
            {
                MaskedTextBox mTxt = new MaskedTextBox();
                if (def.AllowInsert || def.AllowUpdate)
                {
                    setters.Add(() => prop.SetValue(instance, Int32.Parse(def.GetNullDefault(mTxt.Text).ToString())));
                }
                mTxt.Mask = "0000000000";

                if (inType != InputType.Insert)
                {
                    mTxt.Text = prop.GetValue(instance).ToString();
                }

                return(mTxt);
            }

            case FieldType.Boolean:
            {
                CheckBox chk = new CheckBox();
                if (def.AllowInsert || def.AllowUpdate)
                {
                    setters.Add(() => prop.SetValue(instance, def.GetNullDefault(chk.Checked)));
                }

                if (inType != InputType.Insert)
                {
                    chk.Checked = (bool)prop.GetValue(instance);
                }

                return(chk);
            }

            case FieldType.Date:
            {
                DateTimePicker dtp = new DateTimePicker();
                if (def.AllowInsert || def.AllowUpdate)
                {
                    setters.Add(() => prop.SetValue(instance, def.GetNullDefault(dtp.Value.Date)));
                }

                if (inType != InputType.Insert)
                {
                    dtp.Value = (DateTime)prop.GetValue(instance);
                }

                return(dtp);
            }

            case FieldType.Money:
            {
                MaskedTextBox mTxt = new MaskedTextBox();
                if (def.AllowInsert || def.AllowUpdate)
                {
                    setters.Add(() => prop.SetValue(instance, Convert.ToDecimal(def.GetNullDefault(mTxt.Text).ToString())));
                }

                if (inType != InputType.Insert)
                {
                    mTxt.Text = prop.GetValue(instance).ToString();
                }


                return(mTxt);
            }

            default:
                throw new ArgumentException("Non valid definition");
            }
        }