Ejemplo n.º 1
0
        //public void SubmitButton()
        //{ while (pwd == 10)
        //    {

        //    }
        //    do
        //    {
        //        SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\source\repos\VIAApp2Demo\VIAApp2Demo\DB\DatabaseStudents.mdf;Integrated Security=True;Connect Timeout=30");
        //        try
        //        {


        //            if (conn.State == System.Data.ConnectionState.Closed)
        //                conn.Open();
        //            String query = "SELECT COUNT (*) FROM Login WHERE pwd=@pwd";
        //            SqlCommand cmd = new SqlCommand(query, conn);
        //            cmd.CommandType = CommandType.Text;


        //            SqlParameter Pwd = cmd.Parameters.AddWithValue("@pwd", SqlDbType.Int);
        //            cmd.Parameters["@pwd"].Value = pwd;
        //            if (Pwd == null)
        //            {
        //                Pwd.Value = DBNull.Value;
        //            }
        //            SqlDataReader reader = cmd.ExecuteReader();


        //            int count = Convert.ToInt32(cmd.ExecuteScalar());
        //            if (count > 0)
        //            {


        //                MainWindow main = new MainWindow();
        //                main.Show();

        //            }
        //            else
        //            {
        //                MessageBox.Show("Username or password is incorrect!");

        //            }

        //        }
        //        catch (Exception ex)
        //        {
        //            MessageBox.Show(ex.Message);
        //        }
        //        finally
        //        {
        //            conn.Close();
        //        }



        //    } while (pwd == 10);
        //}
        public static bool IsValidLogin(string password)
        {
            new Thread(() =>
            {
                try
                {
                    Thread.CurrentThread.IsBackground = true;
                    password = CreatePasswordHash(password);
                    using (DatabaseStudentsEntitiesLastStand db = new DatabaseStudentsEntitiesLastStand())
                    {
                        do
                        {
                            var query = (from u in db.RegisterTeachers where u.pwd.Equals(password) select u);
                        } while (password.Length == 10);
                        Thread.Sleep(500);
                        if (password.Length == 10 && password.Equals(pwd))
                        {
                            MessageBox.Show("Logged in succesfully,please wait...");
                            MainWindow mv = new MainWindow();
                            mv.Show();
                            mv.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Error!Password is incorrect");
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            });
            return(true);
        }
Ejemplo n.º 2
0
 private async void AccessData()
 {
     await Task.Factory.StartNew(() =>
     {
         foreach (var item in Items)
         {
             if (txtBox == SerialN)
             {
                 using (DatabaseStudentsEntitiesLastStand db = new DatabaseStudentsEntitiesLastStand())
                 {
                     var students = (from d in db.RegisterStudents
                                     select new { SerialN = d.SN, firstName = d.fName, lastName = d.lName, studentNr = d.sNr }).ToList();
                 };
             }
         }
         return(new List <AttendanceList>());
     });
 }