示例#1
0
        private void Button_Back(object sender, RoutedEventArgs e)
        {
            Home_Screen home = new Home_Screen();

            home.Show();
            this.Close();
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //DataAccessClass db = new DataAccessClass();
            //DataAccessClass.ExecuteSQL("INSERT INTO Classroom (Classroom_ID, Remarks, Status)  VALUES (2, 'None', 'true')");
            DataClassesLinqDataContext db = new DataClassesLinqDataContext(DataAccessClassLinq.connectionStringLinq);
            var t = from a in db.Admins
                    select a;

            bool b = false;

            try
            {
                foreach (Admin obj in t)
                {
                    if (obj.Admin_ID.Equals(UserName.Text) && obj.Pasword.Equals(UserPass.Password))
                    {
                        b = true;

                        //Login l = new Login(UserName.Text, UserPass.Password);
                        Login.setIDPass(UserName.Text, UserPass.Password);

                        Home_Screen home = new Home_Screen();
                        home.Show();
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                b = true;
                MessageBox.Show("You forgot to write your name and id!");
            }

            if (b == false)
            {
                MessageBox.Show("Wrong username or password!");
            }
        }