private void Password_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         LogIn.PerformClick();
         UseName.Text  = "";
         password.Text = "";
         UseName.Focus();
     }
 }
Example #2
0
 // Algoritmo de pesquisa recursiva de ficheiros, invoca delegate useName para cada
 // ficheiro encontrado, criando assim independência entre a pesquisa e o processamento
 // dos resultados, sem ter de armazenar os resultados numa colecção intermédia e adiar
 // o seu processamento para o final da pesquisa.
 //
 private static void FindFiles(string folder, string pattern, UseName useName)
 {
     Console.WriteLine("FOLDER: " + folder);
     try
     {
         foreach (string filename in Directory.EnumerateFiles(folder, pattern))
         {
             Console.WriteLine("File: " + filename);
             useName(filename);
         }
         foreach (string subfolder in Directory.EnumerateDirectories(folder))
         {
             FindFiles(subfolder, pattern, useName);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(Properties.Settings.Default.conString))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT UserName, Password FROM t_register  WHERE UserName = '******'" +
                                                           "AND Password='******' "))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = con;
                        con.Open();
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            sdr.Read();
                            string use = sdr["UserName"].ToString();
                            String paw = sdr["Password"].ToString();



                            if (use == UseName.Text.ToString() && paw == password.Text.ToString())
                            {
                                MessageBox.Show("Success !!");

                                this.Hide();
                                sAoPage ss = new sAoPage();
                                ss.Show();
                            }
                        }
                        con.Close();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid User Name / Password");
            }
            UseName.Text  = "";
            password.Text = "";
            UseName.Focus();
        }
Example #4
0
 private void OKBtn_Click(object sender, RoutedEventArgs e)
 {
     if (UseName.Text == "")
     {
         MessageBox.Show("请输入用户名");
     }
     else if (key1.Text == "" || key2.Text == "" || key3.Text == "" || key4.Text == "")
     {
         MessageBox.Show("请输入完整的注册号码!");
     }
     else
     {
         try
         {
             using (SqlConnection conn = new SqlConnection(conStr))
             {
                 conn.Open();
                 using (SqlCommand cmd = new SqlCommand("", conn))
                 {
                     string regID = key1.Text + key2.Text + key3.Text + key4.Text;
                     //string regID = "MMACS00500WH339GH68M";
                     byte[] bregID;
                     bregID          = AES.AESEncrypt(regID);
                     cmd.CommandText = "select * from RegTable where RegID=@RegID";
                     cmd.Parameters.Clear();
                     cmd.Parameters.AddWithValue("RegID", bregID);
                     SqlDataReader dr = cmd.ExecuteReader();
                     if (!dr.Read())
                     {
                         MessageBox.Show("输入的注册码不正确!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                     }
                     else
                     {
                         dr.Close();
                         cmd.CommandText = "select AutherPWD from AuthorTable where Name=@Name";
                         cmd.Parameters.Clear();
                         cmd.Parameters.AddWithValue("Name", UseName.Text);
                         dr = cmd.ExecuteReader();
                         if (!dr.Read())
                         {
                             MessageBox.Show("该用户不存在,请先注册或检查输入的用户名是否正确");
                         }
                         else
                         {
                             string pwd     = AES.AESDecrypt((byte[])dr[0]);
                             string message = "您的登录密码为:" + pwd;
                             MessageBox.Show(message);
                             UseName.Clear();
                             key1.Clear();
                             key2.Clear();
                             key3.Clear();
                             key4.Clear();
                         }
                     }
                 }
             }
         }
         catch
         {
             MessageBox.Show("无法连接数据库!");
             this.Close();
         }
     }
 }