コード例 #1
0
ファイル: Instanciador.cs プロジェクト: solutema/ultralight
                /// <summary>
                /// Crea un formulario de edición para el ElementoDeDatos proporcionado.
                /// </summary>
                /// <param name="elemento">El ElementoDeDatos que se quiere editar.</param>
                /// <returns>Un formulario derivado de Lfc.FormularioEdicion.</returns>
                public static Lfc.FormularioEdicion InstanciarFormularioEdicion(Lbl.IElementoDeDatos elemento)
                {
                        Lfc.FormularioEdicion Res = new Lfc.FormularioEdicion();
                        Type TipoControlEdicion = InferirControlEdicion(elemento.GetType());
                        if (TipoControlEdicion == null)
                                return null;

                        Res.ControlUnico = InstanciarControlEdicion(TipoControlEdicion);
                        Res.FromRow(elemento);

                        return Res;
                }
コード例 #2
0
ファイル: ControlEdicion.cs プロジェクト: solutema/ultralight
                // Compatibilidad con Lfc.FormularioEdicion
                public void FromRow(Lbl.IElementoDeDatos row)
                {
                        // Si todavía no conozco el tipo de elemento de este formulario, lo tomo de row
                        if (this.ElementoTipo == null || this.ElementoTipo == typeof(Lbl.ElementoDeDatos))
                                this.ElementoTipo = row.GetType();

                        this.Elemento = row;
                        this.ActualizarControl();
                }
コード例 #3
0
                private object ObtenerPropiedadElemento(Lbl.ElementoDeDatos elemento, string nombrePropiedad)
                {
                        // Intento obtener una propiedad por su nombre
                        if (nombrePropiedad == null || nombrePropiedad.Length == 0)
                                return null;

                        string[] Partes = nombrePropiedad.Split(new char[] { '.' }, 2);
                        if(Partes.Length == 0)
                                return null;

                        System.Reflection.PropertyInfo Prop = elemento.GetType().GetProperty(Partes[0]);
                        object Val = null;

                        if (Prop != null) {
                                Val = Prop.GetValue(elemento, null);
                        } else {
                                // No hay propiedad... busco un miembro público
                                System.Reflection.FieldInfo Fi = elemento.GetType().GetField(Partes[0]);
                                try {
                                        Val = elemento.GetType().InvokeMember(Fi.Name, System.Reflection.BindingFlags.GetField, null, elemento, null);
                                } catch {
                                        Val = null;
                                }
                        }

                        
                        if (Val == null) {
                                return null;
                        } else if (Val is Lbl.ElementoDeDatos && Partes.Length > 1) {
                                return ObtenerPropiedadElemento(Val as Lbl.ElementoDeDatos, Partes[1]);
                        } else {
                                return Val;
                        }
                }
コード例 #4
0
                public void FromRow(Lbl.IElementoDeDatos row)
                {
                        // Si todavía no conozco el tipo de elemento de este formulario, lo tomo de row
                        if (this.ElementoTipo == null || this.ElementoTipo == typeof(Lbl.ElementoDeDatos))
                                this.ElementoTipo = row.GetType();

                        this.ReadOnly = true;
                        this.Connection = row.Connection;
                        this.Elemento = row;

                        if (this.Encabezado.Visible && this.Encabezado.DisplayStyle.Icon == null) {
                                if (this.Elemento.Existe)
                                        this.StockImage = "editar";
                                else
                                        this.StockImage = "crear";
                        }

                        bool PuedeVerHistorial = Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(this.Elemento, Lbl.Sys.Permisos.Operaciones.Administrar) || Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(typeof(Lbl.Sys.Log.Entrada), Lbl.Sys.Permisos.Operaciones.Ver);
                        this.PanelAccionesTerciarias.FormActions["historial"].Visibility = (this.Elemento.Existe && PuedeVerHistorial) ? Lazaro.Pres.Forms.FormActionVisibility.Tertiary : Lazaro.Pres.Forms.FormActionVisibility.Hidden;
                        this.PanelAccionesTerciarias.FormActions["comentarios"].Visibility = this.Elemento.Existe ? Lazaro.Pres.Forms.FormActionVisibility.Tertiary : Lazaro.Pres.Forms.FormActionVisibility.Hidden;

                        Lbl.Atributos.Presentacion AttrMuestraPanel = this.ElementoTipo.GetAttribute<Lbl.Atributos.Presentacion>();
                        if (AttrMuestraPanel != null) {
                                EntradaComentarios.Visible = this.Elemento.Existe;
                                MuestraPanel = AttrMuestraPanel.PanelExtendido;
                                this.PanelAccionesTerciarias.FormActions["panelextendido"].Visibility = (MuestraPanel != Lbl.Atributos.PanelExtendido.Nunca) ? Lazaro.Pres.Forms.FormActionVisibility.Tertiary : Lazaro.Pres.Forms.FormActionVisibility.Hidden;
                        }

                        if (this.ControlUnico != null) {
                                this.ControlUnico.FromRow(row);
                                if (this.MuestraPanel != Lbl.Atributos.PanelExtendido.Nunca) {
                                        if (row is Lbl.IElementoConImagen) {
                                                EntradaImagen.Elemento = row;
                                                EntradaImagen.ActualizarControl();
                                                EntradaImagen.Visible = true;
                                        } else {
                                                EntradaImagen.Visible = false;
                                        }

                                        EntradaComentarios.Elemento = row;
                                        EntradaTags.Elemento = row;

                                        EntradaComentarios.ActualizarControl();
                                        EntradaTags.ActualizarControl();

                                        if (MuestraPanel == Lbl.Atributos.PanelExtendido.Siempre)
                                                PanelExtendido.Show();
                                }
                        }

                        Lbl.Atributos.Nomenclatura Attr = this.ElementoTipo.GetAttribute<Lbl.Atributos.Nomenclatura>();
                        if (row != null && row.Existe) {
                                if (Attr != null && Attr.PrefijarNombreConTipo)
                                        this.Text = Attr.NombreSingular + " " + row.ToString();
                                else
                                        this.Text = row.ToString();
                        } else {
                                if (Attr != null)
                                        this.Text = "Creando " + Attr.NombreSingular.ToLowerInvariant();
                                else
                                        this.Text = "Creando " + row.GetType().ToString();
                        }

                        this.ReadOnly = !this.PuedeEditar();

                        this.PanelAccionesPrimariasYSecundarias.FormActions["imprimir"].Visibility = this.PuedeImprimir() ? Lazaro.Pres.Forms.FormActionVisibility.Main : Lazaro.Pres.Forms.FormActionVisibility.Hidden;
                        this.ActualizarFormActions();
                        this.SetControlsChanged(this.Controls, false);
                }
コード例 #5
0
ファイル: Instanciador.cs プロジェクト: solutema/ultralight
 public static ImpresorElemento InstanciarImpresor(Lbl.IElementoDeDatos elemento, IDbTransaction transaction)
 {
         Type tipo = InferirImpresor(elemento.GetType());
         System.Reflection.ConstructorInfo TConstr = tipo.GetConstructor(new Type[] { typeof(Lbl.ElementoDeDatos), typeof(IDbTransaction) });
         return (ImpresorElemento)(TConstr.Invoke(new object[] { elemento, transaction }));
 }