Exemplo n.º 1
0
        private void BotonAceptar_Click(System.Object sender, System.EventArgs e)
        {
            if (EntradaServidor.Text.Length == 0)
            {
                Lui.Forms.MessageBox.Show("Por favor escriba el nombre del Servidor.", "Error");
                return;
            }
            if (EntradaConexion.TextKey != "odbc" && EntradaUsuario.Text.Length == 0)
            {
                Lui.Forms.MessageBox.Show("Por favor escriba el nombre del Usuario.", "Error");
                return;
            }

            this.Hide();

            Lfx.Workspace.Master.ConnectionParameters.ServerName = EntradaServidor.Text;
            switch (EntradaConexion.TextKey)
            {
            case "odbc":
                Lfx.Data.DatabaseCache.DefaultCache.AccessMode = Lfx.Data.AccessModes.Odbc;
                break;

            case "myodbc":
            case "mysql":
                Lfx.Data.DatabaseCache.DefaultCache.AccessMode = Lfx.Data.AccessModes.MySql;
                break;

            case "npgsql":
                Lfx.Data.DatabaseCache.DefaultCache.AccessMode = Lfx.Data.AccessModes.Npgsql;
                break;

            case "mssql":
                Lfx.Data.DatabaseCache.DefaultCache.AccessMode = Lfx.Data.AccessModes.MSSql;
                break;

            case "sqlite":
                Lfx.Data.DatabaseCache.DefaultCache.AccessMode = Lfx.Data.AccessModes.SQLite;
                break;
            }

            Lfx.Workspace.Master.ConnectionParameters.DatabaseName = EntradaBD.Text;
            Lfx.Workspace.Master.ConnectionParameters.UserName     = EntradaUsuario.Text;
            Lfx.Workspace.Master.ConnectionParameters.Password     = EntradaContrasena.Text;

            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "DataSource", Lfx.Workspace.Master.ConnectionParameters.ServerName);
            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "ConnectionType", EntradaConexion.TextKey);
            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "DatabaseName", EntradaBD.Text);
            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "User", EntradaUsuario.Text);
            string pass = Lfx.Encrypt.EncryptString(EntradaContrasena.Text, "donjuan3e3");

            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "Password", pass);
            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Data", "SlowLink", Lfx.Data.DatabaseCache.DefaultCache.SlowLink ? "1" : "0");
            Lfx.Workspace.Master.CurrentConfig.WriteLocalSetting("Company", "Branch", EntradaSucursal.Text);

            Aplicacion.AbrirConexion();
            this.DialogResult = DialogResult.Retry;
        }