public Clsconf()
        {
            // frmConfiguracion confi = new frmConfiguracion();
            //confi.Show();
            ClsDatos    datos    = new ClsDatos();
            ClsInicio   inicio   = new ClsInicio();
            ClsConexion conexion = new ClsConexion();

            string sFileName = @"C:\datos\feedback.ini";


            if (File.Exists(sFileName))
            {
                FileStream   fs = new FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                StreamReader sr = new StreamReader(fs);

                string sContent;
                sContent = sr.ReadLine();

                conexion.cadenadesencriptada = datos.Desencriptar(sContent);
                String cad = conexion.cadenadesencriptada;
                fs.Close();
                sr.Close();
                string[] cadenas = { };

                cadenas = cad.Split('=', ';');

                conexion.bd       = cadenas[3];
                conexion.pass     = cadenas[7];
                conexion.servidor = cadenas[1];
                conexion.user     = cadenas[5];
                string cadena = "Server=" + conexion.servidor + ";Database=" + conexion.bd + "; User Id=" + conexion.user + ";Password=" + conexion.pass;

                conexion.cadenadesencriptada = cadena;
                if (conexion.conexion())
                {
                    //frmsplash splash = new frmsplash();
                    //splash.Show();

                    frmLogin log = new frmLogin();
                    log.Show();

                    conexion.conectar.Close();
                }
                else if (conexion.conexion() == false)
                {
                    frmConfiguracion s = new frmConfiguracion();
                    s.Show();
                    conexion.conectar.Close();
                }
            }
            else
            {
                frmConfiguracion confi = new frmConfiguracion();
                confi.Show();
                conexion.conectar.Close();
            }
        }
Exemple #2
0
        private void btnAbrirConexion_Click(object sender, EventArgs e)
        {
            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "Files *.ini (*.ini)|*.ini";//|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        string DirectoryName = openFileDialog1.FileName;
                        lblDirectorio.Text = DirectoryName;
                        StreamReader reader   = new StreamReader(@"" + DirectoryName);
                        ClsConexion  conexion = new ClsConexion();
                        ClsDatos     dat      = new ClsDatos();
                        //conexion.cadenadesencriptada = reader.ReadToEnd();

                        string   file    = reader.ReadToEnd();
                        string[] cadenas = { };

                        string cadena = dat.Desencriptar(file);
                        cadenas           = cadena.Split('=', ';');
                        txtServidor.Text  = cadenas[1];
                        txtBaseDatos.Text = cadenas[3];
                        txtUsuario.Text   = cadenas[5];
                        txtPassword.Text  = cadenas[7];

                        // Insert code to read the stream here.
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Exemple #3
0
        public string datosBaseDatos()
        {
            sFileName = @"C:\datos\feedback.ini";


            string cadenas = "";

            if (File.Exists(sFileName))
            {
                ClsConexion  conexion = new ClsConexion();
                ClsDatos     datos    = new ClsDatos();
                FileStream   fs       = new FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                StreamReader sr       = new StreamReader(fs);
                string       sContent = sr.ReadToEnd();
                conexion.cadenadesencriptada = datos.Desencriptar(sContent);
                cadenas = conexion.cadenadesencriptada;
                fs.Close();
                sr.Close();
            }
            return(cadenas);
        }