Ejemplo n.º 1
0
 private void BTN_CHANGEPASS_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
     if (!(string.IsNullOrEmpty(TXT_OLDPASS.Password.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_NEWPASS.Password.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_RE_NEWPASS.Password.Trim().Replace('\'', ' '))))
     {
         Connection.ChangeTable("USR_USUARIOS", "USR_ID_PK");
         Connection.ChangeSelect("SELECT * FROM USR_USUARIOS WHERE BINARY USR_NICK = '" + Padre.TXT_USUARIO.Text + "'");
         Connection.Update_String("UPDATE USR_USUARIOS SET USR_PASSWORD = '******'\'', ' ')) + "' WHERE BINARY USR_NICK = '" + Padre.TXT_USUARIO.Text + "'");
         Connection.Conectar();
         if ((Connection.getData(0, 2) == EncriptarMD5.Encript(TXT_OLDPASS.Password.Trim().Replace('\'', ' '))) && (TXT_NEWPASS.Password.Trim().Replace('\'', ' ') == TXT_RE_NEWPASS.Password.Trim().Replace('\'', ' ')))
         {
             Connection.Update_Execute();
             Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                      "'ChangePass','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "'," + Padre.getUsrID() + ")");
             Connection.Insert_Execute();
             Connection.Desconectar();
             MessageBox.Show("Contraseña cambiada correctamente !", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
             Padre.elementHost.Child = new Profile(Padre, Connection);
         }
         else
         {
             Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                      "'Bad ChangePass','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "'," + Padre.getUsrID() + ")");
             Connection.Insert_Execute();
             Connection.Desconectar();
             MessageBox.Show("Error, comprueba si has escrito bien las contraseñas !", "Información", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
     }
     else
     {
         MessageBox.Show("Error, debes rellenar todos los campos !", "Información", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
     System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
 }
Ejemplo n.º 2
0
        private void BTN_Identificarse_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            if (Connection.testConnection())
            {
                if (!(string.IsNullOrEmpty(TXT_USUARIO.Text.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_PASSWORD.Password.Trim().Replace('\'', ' '))))
                {
                    Connection.ChangeTable("USR_USUARIOS", null);
                    Connection.ChangeSelect("SELECT * FROM USR_USUARIOS WHERE BINARY USR_NICK = '" + TXT_USUARIO.Text.Trim().Replace('\'', ' ') + "' AND BINARY USR_PASSWORD  = '******'\'', ' ')) + "'");
                    if (Connection.Conectar())
                    {
                        if (Connection.countRows() == 1)
                        {
                            if (Connection.getData(0, 9) == "Activo")
                            {
                                Padre.menuHoy.Visible          = true;
                                Padre.menuTareas.Visible       = true;
                                Padre.menuPlanificador.Visible = true;
                                Padre.menuPerfil.Visible       = true;
                                Padre.TXT_USUARIO.Text         = TXT_USUARIO.Text.Trim().Replace('\'', ' ');
                                Padre.setUsrID(int.Parse(Connection.getData(0, 0)));

                                Connection.Update_String("UPDATE USR_USUARIOS SET USR_F_ULTIMA_V = '" + DateTime.Now.ToString("yyyyMMdd") + "', USR_LAST_IP = '" + ObtenerIP.ExternalIPAddress.ToString() + "' WHERE USR_ID_PK = " + Padre.getUsrID());
                                Connection.Update_Execute();

                                Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                                         "'Login','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "'," + Padre.getUsrID() + ")");
                                Connection.Insert_Execute();

                                Padre.elementHost.Child = new Today(Padre, Connection);
                            }
                            else
                            {
                                Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                                         "'Inactive Login','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "'," + Connection.getData(0, 0) + ")");
                                Connection.Insert_Execute();
                                MessageBox.Show("Error, tu cuenta de usuario no está activada.\nSolicita a un administrador su activación", "Información");
                            }
                        }
                        else
                        {
                            Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                                     "'Bad Login','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "', 0)");
                            Connection.Insert_Execute();
                            MessageBox.Show("Error, usuario y/o contraseña incorrectos.\nRecuerda que ambos campos son sensibles a mayúsculas y minúsculas.", "Información");
                            TXT_PASSWORD.Password = "";
                        }
                        Connection.Desconectar();
                    }
                }
                else
                {
                    MessageBox.Show("¡Debes introducir el usuario y la contraseña!", "Información");
                }
            }
            else
            {
                MessageBox.Show("Error, no se ha podido establecer conexión con el servidor", "Información");
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
        }
Ejemplo n.º 3
0
 private void BTN_CREATE_ACCOUNT_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
     if (Connection.testConnection())
     {
         if (!(string.IsNullOrEmpty(TXT_NICK.Text.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_PASSWORD.Password.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_RE_PASSWORD.Password.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_NOMBRE.Text.Trim().Replace('\'', ' '))) && !(string.IsNullOrEmpty(TXT_EMAIL.Text.Trim().Replace('\'', ' '))))
         {
             if (TXT_PASSWORD.Password.Trim().Replace('\'', ' ') == TXT_RE_PASSWORD.Password.Trim().Replace('\'', ' '))
             {
                 Connection.ChangeTable("USR_USUARIOS", null);
                 Connection.ChangeSelect("SELECT USR_NICK FROM USR_USUARIOS WHERE BINARY UPPER(USR_NICK) = '" + TXT_NICK.Text.ToUpper().Trim().Replace('\'', ' ') + "'");
                 if (Connection.Conectar())
                 {
                     Connection.Desconectar();
                 }
                 if (!(Connection.countRows() > 0))
                 {
                     Connection.Conectar();
                     Connection.Insert_String("INSERT INTO USR_USUARIOS (USR_NICK,USR_PASSWORD,USR_NOMBRE,USR_EMAIL,USR_F_REGISTRO,USR_F_ULTIMA_V,USR_LAST_IP) VALUES (" +
                                              "'" + TXT_NICK.Text.Trim().Replace('\'', ' ') + "','" + EncriptarMD5.Encript(TXT_PASSWORD.Password.Trim().Replace('\'', ' ')) + "','" + TXT_NOMBRE.Text.Trim().Replace('\'', ' ') + "','" + TXT_EMAIL.Text.Trim().Replace('\'', ' ') + "','" + DateTime.Now.ToString("yyyyMMdd") + "','" + DateTime.Now.ToString("yyyyMMdd") + "','" + ObtenerIP.ExternalIPAddress.ToString() + "')");
                     Connection.Insert_Execute();
                     Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                              "'Register User','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "', 0)");
                     Connection.Insert_Execute();
                     Connection.Desconectar();
                     MessageBox.Show("¡Cuenta creada!\nRecuerda que es necesario que un administrador la active para poder usarla", "Información");
                     Padre.elementHost.Child = new Login(Padre, Connection);
                 }
                 else
                 {
                     if (Connection.Conectar())
                     {
                         Connection.Insert_String("INSERT INTO LOG_REGISTROS (LOG_TIPO,LOG_DESCRIPCION,LOG_IP,LOG_FECHA,LOG_USR_ID_PK) VALUES (" +
                                                  "'Bad Register User','USR: "******"','" + ObtenerIP.ExternalIPAddress.ToString() + "','" + DateTime.Now.ToString("yyyyMMdd") + "', 0)");
                         Connection.Insert_Execute();
                         Connection.Desconectar();
                     }
                     MessageBox.Show("Lo siento, ese nick ya está siendo utilizado", "Información");
                     TXT_NICK.Text            = "";
                     TXT_PASSWORD.Password    = "";
                     TXT_RE_PASSWORD.Password = "";
                 }
             }
             else
             {
                 MessageBox.Show("¡No has introducido correctamente ambas contraseñas!", "Información");
                 TXT_PASSWORD.Password    = "";
                 TXT_RE_PASSWORD.Password = "";
             }
         }
         else
         {
             MessageBox.Show("¡Debes rellenar todos los datos!", "Información");
             TXT_PASSWORD.Password    = "";
             TXT_RE_PASSWORD.Password = "";
         }
     }
     else
     {
         MessageBox.Show("Error, no se ha podido establecer conexión con el servidor", "Información");
     }
     System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
 }