Exemple #1
0
        private void btnProtegeCNX_Click(object sender, EventArgs e)
        {
            if (txtCadenaConexion.TextLength > 0)
            {
                CLS.Utilities objCnx = new CLS.Utilities();
                objCnx.ProtectConnectionString();
            }

            /*
             * try
             * {
             *  //Se abre el app.config para recuperar la seccion ConnectionStrings
             *  Configuration MiAppConfig = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
             *  //Se recupera la seccion ConnectionStrings
             *  ConnectionStringsSection MiSeccion = (ConnectionStringsSection)(MiAppConfig.GetSection("connectionStrings"));
             *  //Se protege la seccion, caso contrario se desprotege
             *  if (MiSeccion.SectionInformation.IsProtected)
             *      MiSeccion.SectionInformation.UnprotectSection();
             *  else
             *      MiSeccion.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
             *  //Se guarda los cambios
             *  MiAppConfig.Save();
             *  if (MiSeccion.SectionInformation.IsProtected)
             *      MessageBox.Show("Cadena de Conexion Protegida");
             *  else
             *      MessageBox.Show("No esta protegida");
             *
             * }catch (Exception ex){
             *  MessageBox.Show(ex.Message);
             * }
             */
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            CLS.Connection cnxValidate = new CLS.Connection();

            CLS.Utilities objConx   = new CLS.Utilities();
            string        newString = null;

            newString = objConx.SetConnectionStringComplete(txtServer.Text, uint.Parse(txtPort.Text), txtBD.Text, txtUser.Text, txtPass.Text);
            if (chkVerify.Checked)
            {
                if (cnxValidate.ValidarConexion(newString))
                {
                    MessageBox.Show("Conexión exitosa", "ConnectionSettings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (newString != null)
                    {
                        objConx.SaveConnectionString(newString);
                        objConx.ProtectConnectionString();

                        DBM.CLS.QUERY Query_ = new DBM.CLS.QUERY();
                        Query_.GetColumnWidth("pedido", "listo");
                        if (Query_.GetColumnWidth("pedido", "listo")["COLUMN_TYPE"].ToString().Trim() == "tinyint(1)")
                        {
                            DBM.CLS.Transaccion Trans = new DBM.CLS.Transaccion();
                            string query = "";
                            query = "ALTER TABLE `pedido` CHANGE `listo` `listo` TINYINT(2) NULL DEFAULT NULL;";

                            if (Trans.CreateTransaction(query))
                            {
                                MessageBox.Show("El campo LISTO ahora tiene un ancho de 2 ", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No se pudo establecer la conexión con el servidor." + saltoLinea + "Para guardar los datos sin comprobar la conexión desactive la casilla de verificación", "ConnectionSettings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (newString != null)
                {
                    objConx.SaveConnectionString(newString);
                    objConx.ProtectConnectionString();
                }
            }
        }