// Ubica la ventana con respecto al ControlDestino public void Ubicar() { if (ControlDestino != null && ControlDestino.Created) { this.Location = ControlDestino.PointToScreen(new Point(0, ControlDestino.Height - 2)); } }
public Lfx.Types.OperationResult Save() { if (this.ReadOnly) { return(new Lfx.Types.FailureOperationResult("No se puede guardar porque es un formulario sólo-lectura")); } Lfx.Types.OperationResult Resultado = this.ControlUnico.ValidarControl(); if (Resultado.Success == false) { return(Resultado); } Resultado = this.ControlUnico.BeforeSave(); if (Resultado.Success == false) { return(Resultado); } bool WasNew = !this.Elemento.Existe; this.Elemento = this.ToRow(); if (this.GetControlsChanged(this.Controls) || this.Elemento.Modificado) { // Guardo sólo si hubo cambios IDbTransaction Trans = null; if (this.Elemento.Connection.InTransaction == false) { Trans = this.Elemento.Connection.BeginTransaction(IsolationLevel.Serializable); } if (Lfx.Workspace.Master.DebugMode) { Resultado = this.Elemento.Guardar(); } else { try { Resultado = this.Elemento.Guardar(); } catch (Lfx.Types.DomainException dex) { if (Trans != null) { Trans.Rollback(); } Resultado = new Lfx.Types.FailureOperationResult(dex.Message); } catch (Exception ex) { if (Trans != null) { Trans.Rollback(); } if (this.Elemento != null && this.Name != null) { ex.HelpLink = this.Name + ".Save: " + this.ElementoTipo.ToString(); } throw ex; } } if (Resultado.Success) { this.ControlUnico.AfterSave(Trans); if (Trans != null) { Trans.Commit(); } } else { if (Trans != null) { Trans.Rollback(); } } } if (Resultado.Success) { this.SetControlsChanged(this.Controls, false); if (WasNew) { if (ControlDestino != null) { ControlDestino.Text = this.Elemento.Id.ToString(); ControlDestino.Focus(); } Lbl.Atributos.Presentacion AttrMuestraMsg = this.ElementoTipo.GetAttribute <Lbl.Atributos.Presentacion>(); if (AttrMuestraMsg != null && AttrMuestraMsg.MensajeAlCrear) { Lui.Forms.MessageBox.Show("Acaba de crear " + this.Elemento.ToString(), "Crear"); } } if (FormOpener != null) { FormOpener.Focus(); FormOpener.Activate(); } this.DialogResult = DialogResult.OK; } return(Resultado); }