Beispiel #1
0
        protected void cmdrecuperar_Click(object sender, EventArgs e)
        {
            string correo = txtmail.Text;

            try
            {

                Conexion conn = new Conexion();
                conn.IniciarConexion();
                string sql = "select log.password from log inner join user on log.id_user = user.id_user where user.email like '" + correo + "'";
                string password = "";
                MySql.Data.MySqlClient.MySqlDataAdapter adapter = new MySql.Data.MySqlClient.MySqlDataAdapter(sql , conn.GetConexion);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                DataTable tabla = ds.Tables[0];
                foreach (DataRow dr in tabla.Rows)
                    password = dr.Field<string>("password", DataRowVersion.Default);

                conn.CerrarConexion();
                adapter.Dispose();
                ds.Dispose();
                tabla.Dispose();

                MailMessage mail = new MailMessage();
                mail.To.Add(correo);
                mail.From = new MailAddress("*****@*****.**");
                mail.Subject = "My pisarron 2 Recuperar contraseña ";

                string Body = "Hola " + Environment.NewLine +
                              "su contraseña es <b>" + password + "</b>";

                mail.Body = Body;

                mail.IsBodyHtml = true;

                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.live.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new System.Net.NetworkCredential
                ("*****@*****.**", "linux2012" );
                smtp.EnableSsl = true;
                smtp.Send(mail);
            }
            catch(Exception ex)
            {
                Log.Set_Log_Error(ex.Message, "Recuperar contraseña");
                exito.InnerHtml = "<p><b>Ocurrio un error al momento de procesar su solicitud</b></p>";

            }
            exito.InnerHtml = "<p>Se le ha enviado un correo con su contraseña ... revisar  <b>" + correo + "</b></p>";
        }
Beispiel #2
0
        protected void cmdrecuperar_Click(object sender, EventArgs e)
        {
            string correo = txtmail.Text;

            try
            {
                Conexion conn = new Conexion();
                conn.IniciarConexion();
                string sql      = "select log.password from log inner join user on log.id_user = user.id_user where user.email like '" + correo + "'";
                string password = "";
                MySql.Data.MySqlClient.MySqlDataAdapter adapter = new MySql.Data.MySqlClient.MySqlDataAdapter(sql, conn.GetConexion);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                DataTable tabla = ds.Tables[0];
                foreach (DataRow dr in tabla.Rows)
                {
                    password = dr.Field <string>("password", DataRowVersion.Default);
                }

                conn.CerrarConexion();
                adapter.Dispose();
                ds.Dispose();
                tabla.Dispose();

                MailMessage mail = new MailMessage();
                mail.To.Add(correo);
                mail.From    = new MailAddress("*****@*****.**");
                mail.Subject = "My pisarron 2 Recuperar contraseña ";

                string Body = "Hola " + Environment.NewLine +
                              "su contraseña es <b>" + password + "</b>";

                mail.Body = Body;

                mail.IsBodyHtml = true;

                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.live.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential
                                                 ("*****@*****.**", "linux2012");
                smtp.EnableSsl = true;
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                Log.Set_Log_Error(ex.Message, "Recuperar contraseña");
                exito.InnerHtml = "<p><b>Ocurrio un error al momento de procesar su solicitud</b></p>";
            }
            exito.InnerHtml = "<p>Se le ha enviado un correo con su contraseña ... revisar  <b>" + correo + "</b></p>";
        }
Beispiel #3
0
        public DataTable QueryToDataTable(string pQuery)
        {
            if (mMySqlConn.State == ConnectionState.Open)
            {
                DataTable retVal = new DataTable();

                MySql.Data.MySqlClient.MySqlDataAdapter mySqlDataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter(pQuery, mMySqlConn);
                mySqlDataAdapter.Fill(retVal);
                mySqlDataAdapter.Dispose();

                return(retVal);
            }
            throw new TimeoutException("Can't connect to the server.");
        }
 // Dispose(bool disposing) executes in two distinct scenarios.
 // If disposing equals true, the method has been called directly
 // or indirectly by a user's code. Managed and unmanaged resources
 // can be disposed.
 // If disposing equals false, the method has been called by the
 // runtime from inside the finalizer and you should not reference
 // other objects. Only unmanaged resources can be disposed.
 protected virtual void Dispose(bool disposing)
 {
     // Check to see if Dispose has already been called.
     if (!this.disposed)
     {
         // If disposing equals true, dispose all managed
         // and unmanaged resources.
         if (disposing)
         {
             // Dispose managed resources.
             //if (_MyConnection != null)
             //{
             //    if (_MyConnection.State == ConnectionState.Open)
             //        _MyConnection.Close();
             //    _MyConnection.Dispose();
             //    _MyConnection = null;
             //}
             if (_MyCommand != null)
             {
                 if (_MyCommand.Parameters.Count > 0)
                 {
                     _MyCommand.Parameters.Clear();
                 }
                 _MyCommand.Dispose();
             }
             if (_MyDataAdaptor != null)
             {
                 _MyDataAdaptor.Dispose();
             }
         }
         // Release unmanaged resources. If disposing is false,
         // only the following code is executed.
         CloseHandle(handle);
         handle = System.IntPtr.Zero;
         // Note that this is not thread safe.
         // Another thread could start disposing the object
         // after the managed resources are disposed,
         // but before the disposed flag is set to true.
         // If thread safety is necessary, it must be
         // implemented by the client.
     }
     disposed = true;
 }
 private void SearchB_Click(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
     {
         if (CByName.IsChecked == true)
         {
             Pb.Visibility = Visibility.Visible;
             mT.Clear();
             mA.Dispose();
             mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM medics WHERE `Name` = '" + SearchBox.Text + "'ORDER BY Name", Database.DataHolder.MySqlConnection);
             mT = new System.Data.DataTable();
             mA.Fill(mT);
             if (mA == null)
             {
                 return;
             }
             if (mT.Rows.Count == 0)
             {
                 mT.Rows.Add(new object[mT.Columns.Count]);
             }
             DataGrid.ItemsSource = mT.DefaultView;
             Pb.Visibility        = Visibility.Hidden;
         }
         else if (CByBar.IsChecked == true)
         {
             Pb.Visibility = Visibility.Visible;
             mT.Clear();
             mA.Dispose();
             mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM medics WHERE `Barcode` = '" + SearchBox.Text + "'ORDER BY Name", Database.DataHolder.MySqlConnection);
             mT = new System.Data.DataTable();
             mA.Fill(mT);
             if (mA == null)
             {
                 return;
             }
             if (mT.Rows.Count == 0)
             {
                 mT.Rows.Add(new object[mT.Columns.Count]);
             }
             DataGrid.ItemsSource = mT.DefaultView;
             Pb.Visibility        = Visibility.Hidden;
         }
         else if (CBySub.IsChecked == true)
         {
             Pb.Visibility = Visibility.Visible;
             mT.Clear();
             mA.Dispose();
             mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM medics WHERE `ScientificName` = '" + SearchBox.Text + "'ORDER BY Name", Database.DataHolder.MySqlConnection);
             mT = new System.Data.DataTable();
             mA.Fill(mT);
             if (mA == null)
             {
                 return;
             }
             if (mT.Rows.Count == 0)
             {
                 mT.Rows.Add(new object[mT.Columns.Count]);
             }
             DataGrid.ItemsSource = mT.DefaultView;
             Pb.Visibility        = Visibility.Hidden;
         }
     });
 }
Beispiel #6
0
        private System.Data.Common.DbDataReader SelectReaderQuery(string sqlquery)
        {
            //MySql.Data.MySqlClient.MySqlConnection.ClearPool(sqlConnection);
            Stopwatch timer = new Stopwatch();
            timer.Start();

            queryCount++;
            sqlquery = sqlquery.Replace("\\", "\\\\");

            Connect();

            MySql.Data.MySqlClient.MySqlDataAdapter dataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter();
            dataAdapter.SelectCommand = new MySql.Data.MySqlClient.MySqlCommand(sqlquery, sqlConnection);
            System.Data.Common.DbDataReader resultReader = dataAdapter.SelectCommand.ExecuteReader();
            dataAdapter.SelectCommand.Dispose();
            dataAdapter.Dispose();

            timer.Stop();
            queryTime += timer.ElapsedTicks;
            PushQuery(sqlquery, timer.ElapsedTicks / 10000000.0);

            return resultReader;
        }
Beispiel #7
0
        private DataTable SelectQuery(string sqlquery)
        {
            //MySql.Data.MySqlClient.MySqlConnection.ClearPool(sqlConnection);
            Stopwatch timer = new Stopwatch();
            timer.Start();

            queryCount++;
            sqlquery = sqlquery.Replace("\\", "\\\\");

            Connect();

            DataTable resultTable = new DataTable();
            try
            {
                PushQuery(sqlConnection.State.ToString(), 0.0);

                //DataSet resultSet = new DataSet();
                MySql.Data.MySqlClient.MySqlDataAdapter dataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter();
                dataAdapter.SelectCommand = new MySql.Data.MySqlClient.MySqlCommand(sqlquery, sqlConnection);
                long qt = timer.ElapsedTicks;
                PushQuery("Query", qt / 10000000.0);
                //dataAdapter.Fill(resultSet);
                System.Data.Common.DbDataReader resultReader = dataAdapter.SelectCommand.ExecuteReader();
                resultTable.Load(resultReader);
                resultReader.Close();
                resultReader.Dispose();
                PushQuery("Fill", (timer.ElapsedTicks - qt) / 10000000.0);
                dataAdapter.SelectCommand.Dispose();
                dataAdapter.Dispose();

                //resultTable = resultSet.Tables[0];

                timer.Stop();
                queryTime += qt;
                PushQuery(sqlquery, timer.ElapsedTicks / 10000000.0);

                return resultTable;
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                PushQuery(sqlquery, 0.0);
                throw new System.Exception(ex.ToString());
            }
            catch (System.Exception ex)
            {
                PushQuery(sqlquery, 0.0);
                throw new System.Exception(ex.ToString());
            }
        }