Exemplo n.º 1
0
 private static void InyectarSqlDesdeRecurso(Lfx.Data.Connection dataBase, string archivo)
 {
     dataBase.RequiresTransaction = false;
     System.IO.Stream RecursoActualizacion = Lfx.Workspace.ObtenerRecurso(archivo);
     if (RecursoActualizacion != null)
     {
         System.IO.StreamReader Lector = new System.IO.StreamReader(RecursoActualizacion);
         string SqlActualizacion       = dataBase.CustomizeSql(Lector.ReadToEnd());
         RecursoActualizacion.Close();
         try {
             dataBase.ExecuteSql(SqlActualizacion);
         } catch {
             // Falló la ejecución... intento los comandos SQL de a uno, ignorando el que de un error
             do
             {
                 string Comando = Data.Connection.GetNextCommand(ref SqlActualizacion);
                 try {
                     dataBase.ExecuteSql(Comando);
                 } catch {
                     if (Lfx.Environment.SystemInformation.DesignMode)
                     {
                         throw;
                     }
                 }
             }while (SqlActualizacion.Length > 0);
         }
     }
 }
Exemplo n.º 2
0
        private void FormPrincipal_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.F10:
            case Keys.F12:
                if (e.Shift == false && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    if (FormInicio == null)
                    {
                        MostrarAyuda("Menú principal", "Utilice las teclas de cursor (flechas) para navegar el menú. Pulse <Intro> (o <Enter>) para ejecutar una opción.");
                        System.Windows.Forms.SendKeys.Send("%S");
                    }
                    else
                    {
                        MostrarAyuda("Pantalla de inicio", "Si no encuentra lo que busca en la pantalla de inicio utilice el menú en la parte superior.");
                        FormInicio.Focus();
                    }
                }
                break;

            case Keys.I:
                if (e.Control == true && e.Alt == true && Lbl.Sys.Config.Actual.UsuarioConectado.TieneAccesoGlobal())
                {
                    e.Handled = true;
                    System.Windows.Forms.OpenFileDialog DialogoArchivo = new System.Windows.Forms.OpenFileDialog();
                    DialogoArchivo.DefaultExt  = "sql";
                    DialogoArchivo.Filter      = "Archivo SQL|*.sql";
                    DialogoArchivo.Multiselect = false;
                    DialogoArchivo.Title       = "Inyectar SQL";
                    if (DialogoArchivo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        using (System.IO.Stream Archivo = System.IO.File.OpenRead(DialogoArchivo.FileName))
                            using (System.IO.StreamReader Lector = new System.IO.StreamReader(Archivo, System.Text.Encoding.Default))
                                using (Lfx.Data.Connection ConexionActualizar = Lfx.Workspace.Master.GetNewConnection("Inyectar SQL"))
                                    using (IDbTransaction Trans = ConexionActualizar.BeginTransaction()) {
                                        string SqlActualizacion = ConexionActualizar.CustomizeSql(Lector.ReadToEnd());
                                        do
                                        {
                                            string Comando = Lfx.Data.Connection.GetNextCommand(ref SqlActualizacion);
                                            try {
                                                ConexionActualizar.ExecuteSql(Comando);
                                            } catch (Exception ex) {
                                                Lfx.Workspace.Master.RunTime.Toast(Comando + System.Environment.NewLine + System.Environment.NewLine + ex.Message, "Error al inyectar datos");
                                            }
                                        }while (SqlActualizacion.Length > 0);
                                        Trans.Commit();
                                    }
                    }
                }
                break;

            case Keys.B:
                if (e.Control && e.Alt == false && e.Shift == false)
                {
                    e.Handled             = true;
                    BarraInferior.Visible = !BarraInferior.Visible;
                    Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Sistema", "Apariencia.BarraInformacion", BarraInferior.Visible ? 1 : 0);
                }
                break;

            case Keys.J:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    string Cmd = Lui.Forms.InputBox.ShowInputBox("Comando");
                    if (Cmd != null && Cmd.Length > 0)
                    {
                        Ejecutor.Exec(Cmd);
                    }
                }
                break;

            case Keys.F:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    Ejecutor.Exec("CREAR Lbl.Comprobantes.Factura");
                }
                break;

            case Keys.T:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    Ejecutor.Exec("CREAR Lbl.Comprobantes.Ticket");
                }
                break;

            case Keys.P:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    Ejecutor.Exec("CREAR Lbl.Comprobantes.Presupuesto");
                }
                break;

            case Keys.R:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    Ejecutor.Exec("CREAR Lbl.Comprobantes.ReciboDeCobro");
                }
                break;

            case Keys.L:
                if (e.Control == true && e.Alt == false && e.Shift == false)
                {
                    e.Handled = true;
                    Ejecutor.Exec("CALC");
                }
                break;
            }
        }