예제 #1
0
        private void GuardarDatosXAMPP(ConexionLocalHost con)
        {
            XmlDocument xml = new XmlDocument();

            try
            {
                xml.Load("Conexiones.xml");
                foreach (XmlNode nodoC in xml.GetElementsByTagName("Conexiones")[0].ChildNodes)
                {
                    if (nodoC.Name == "Server")
                    {
                        nodoC.InnerText = con.Server;
                    }

                    if (nodoC.Name == "Database")
                    {
                        nodoC.InnerText = con.DataBase;
                    }

                    if (nodoC.Name == "UsuarioBD")
                    {
                        nodoC.InnerText = con.User;
                    }

                    if (nodoC.Name == "PasswordBD")
                    {
                        nodoC.InnerText = con.Password;
                    }
                }
            }
            catch (Exception) { MessageBox.Show("Error al tratar de guardar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            xml.Save("ConexionLocalHost.xml");
        }
예제 #2
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (probado)
     {
         ConexionLocalHost con = new ConexionLocalHost();
         con.Server   = txtServer.Text;
         con.DataBase = txtDB.Text;
         con.User     = txtUser.Text;
         con.Password = txtPass.Text;
         GuardarDatosXAMPP(con);
         btnGuardar.Enabled = false;
         btnProbar.Enabled  = true;
         DialogResult       = DialogResult.OK;
     }
 }