Esempio n. 1
0
        private void Account_Click(object sender, RoutedEventArgs e)
        {
            userdata data = new userdata();

            data.user_id  = id;
            frame.Content = data;
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            userdata us = new userdata();

            us.user_id = txtUsuario.Text;
            try
            {
                if (sqlCon.State == ConnectionState.Closed)
                {
                    sqlCon.Open();
                }
                string     consulta = "SELECT * FROM tbusuarios WHERE Login=@Username AND Password=@Password";
                SqlCommand sqlCmd   = new SqlCommand(consulta, sqlCon);
                sqlCmd.CommandType = CommandType.Text;
                sqlCmd.Parameters.AddWithValue("@Username", txtUsuario.Text);
                sqlCmd.Parameters.AddWithValue("@Password", txtContrasena.Password);
                SqlDataReader rd = sqlCmd.ExecuteReader();
                if (rd != null)
                {
                    Dashboard menu = new Dashboard();
                    menu.id = txtUsuario.Text;
                    while (rd.Read())
                    {
                        menu.usr = rd["Nombre"].ToString() + " " + rd["Apellido"].ToString();
                    }
                    menu.Show();
                    Close();
                }
                else
                {
                    MessageBox.Show("Usuario o contraseña incorrecta.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sqlCon.Close();
            }
        }