예제 #1
0
        private void registration()
        {
            string login = "";
            string pass  = "";
            string email = "";
            string name  = "";
            string phone = "";

            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                login = tbLoginNew.Text;
                pass = tbPass.Password;
                email = tbEmail.Text;
                name = tbName.Text;
                phone = tbPhone.Text;
            }));
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                SQLWorker.SQL = "SELECT COUNT(email), COUNT(log) FROM users WHERE email = '" + email + "' OR log = '" + login + "'";
                List <List <string> > count = SQLWorker.SQLQuery();

                if (Convert.ToInt32(count[0][0]) == 0)
                {
                    while (conn.State != ConnectionState.Open)
                    {
                        try
                        {
                            SQLWorker.SQL = "INSERT INTO users(log,pass,email,name,phone) VALUES('" + login + "','" +
                                            pass + "','" + email + "','" + name + "','" + phone + "')";
                            SQLWorker.SQLNonQuery();

                            Application.Current.Dispatcher.Invoke((Action)(() =>
                            {
                                BtnSelecting_Click(null, null);
                                tbLoginNew.Text = "";
                                tbPass.Password = "";
                                tbEmail.Text = "";
                                tbName.Text = "";
                                tbPhone.Text = "";
                            }));
                            conn.Close();
                            try
                            {
                                Thread.CurrentThread.Abort();
                            }
                            catch
                            {
                                MessageBox.Show("Регистрация прошла успешно!");
                            }
                        }
                        catch (MySqlException ex)
                        {
                            MessageBox.Show(ex.Message);
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Данный адрес электронной почты или логин занят!");
                }
            }
            else
            {
                MessageBox.Show("Нет соединения!");
            }
        }
예제 #2
0
 public void SendMessageAboutPass()
 {
     if (email.IsMatch(Email) || login.IsMatch(Email))
     {
         if (!email.IsMatch(Email))
         {
             SQLWorker.SQL = "SELECT email, pass FROM users WHERE log = '" + Email + "'";
             List <List <string> > buf = SQLWorker.SQLQuery();
             if (buf.Count != 0)
             {
                 Email   = buf[0][0];
                 Message = "Вы попросили напомнить вам пароль. Вот он: " + buf[0][1];
             }
             else
             {
                 Email = "";
             }
         }
         else
         {
             SQLWorker.SQL = "SELECT email, pass FROM users WHERE email = '" + Email + "'";
             List <List <string> > buf = SQLWorker.SQLQuery();
             if (buf.Count != 0)
             {
                 Email   = buf[0][0];
                 Message = "Вы попросили напомнить вам пароль. Вот он: " + buf[0][1];
             }
             else
             {
                 Email = "";
             }
         }
         if (Email != "")
         {
             try
             {
                 try
                 {
                     MailAddress from = new MailAddress("*****@*****.**", "Администратор FTP клиента Sudy +");
                     MailAddress to   = new MailAddress(Email);
                     MailMessage m    = new MailMessage(from, to);
                     m.Subject = "Восстановление пароля";
                     m.Body    = Message;
                     SmtpClient smtp = new SmtpClient("smtp.yandex.ru", 25);
                     smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Qwerty21");
                     smtp.EnableSsl   = true;
                     smtp.Send(m);
                     try
                     {
                         Thread.CurrentThread.Abort();
                     }
                     catch
                     { }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
             catch
             { }
         }
         else
         {
             MessageBox.Show("Email или логин не найден!");
         }
     }
     else
     {
         MessageBox.Show("Некорректный email или логин!");
     }
 }