private static object ExecCrearEditar(bool crear, string comando) { string SubComando = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim(); System.Type TipoLbl = Lbl.Instanciador.InferirTipo(SubComando); Lbl.Atributos.Nomenclatura AtrNombre = TipoLbl.GetAttribute <Lbl.Atributos.Nomenclatura>(); if (crear && Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(TipoLbl, Lbl.Sys.Permisos.Operaciones.Crear) == false) { return(new Lfx.Types.NoAccessOperationResult()); } if (Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(TipoLbl, Lbl.Sys.Permisos.Operaciones.Ver) == false) { return(new Lfx.Types.NoAccessOperationResult()); } var ConnEditar = Lfx.Workspace.Master.GetNewConnection("Editar " + (AtrNombre == null ? SubComando : AtrNombre.NombreSingular)) as Lfx.Data.Connection; Lbl.IElementoDeDatos Elemento = null; if (crear) { Elemento = Lbl.Instanciador.Instanciar(TipoLbl, ConnEditar); Elemento.Crear(); } else { int ItemId = Lfx.Types.Parsing.ParseInt(Lfx.Types.Strings.GetNextToken(ref comando, " ")); Elemento = Lbl.Instanciador.Instanciar(TipoLbl, ConnEditar, ItemId); } Lfc.FormularioEdicion FormularioDeEdicion = Lfc.Instanciador.InstanciarFormularioEdicion(Elemento); FormularioDeEdicion.DisposeConnection = true; if (FormularioDeEdicion == null) { return(null); } return(FormularioDeEdicion); }
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); }