Example #1
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            //Connection String
            SqlConnection con = new SqlConnection("Data Source=LAB402-18\\SQLEXPRESS;Initial Catalog=Neptuno;Integrated Security=True");
            SqlCommand    cmd = new SqlCommand("select nombre, clave from Usuarios where nombre = @name and clave = @clave", con);

            cmd.Parameters.AddWithValue("@name", txtName.Text);
            cmd.Parameters.AddWithValue("@clave", txtClave.Text);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            //Connection open here
            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Loggeado con éxito");
                //after successful it will redirect  to next page .
                this.Hide();
                FrmPrincipal f1 = new FrmPrincipal();
                f1.Show();
            }
            else
            {
                MessageBox.Show("Incorrecto");
            }
        }
Example #2
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            string usuario= textBox1.Text;
            string contrasenia = textBox2.Text;
            string time = DateTime.Now.ToString();

            if (VerificacionUsuario(usuario, contrasenia) == true)
            {
                //MessageBox.Show(usuario + "\n" + contrasenia + "\n" + time);
                refresTimeInDataBase(usuario);
                FrmPrincipal principal = new FrmPrincipal();
                principal.Show();
                this.Dispose(false);
            }
            else
            {
                MessageBox.Show("Error de validacion");
            }

            
        }