好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

账号密码管理系统Access版本

哈哈,花了我整整五天时间, 账号 密码 管理 系统 软件终于成功编写完成了。由于我的各大论坛的 账号 密码 特别多,记性又不好。所以一直以来都想要这么一个软件的,但是以前学习的都是面向过程的编程语言,一直无法实现这个想法。这个暑假为了做一个程序项

哈哈,花了我整整五天时间, 账号 密码 管理 系统 软件终于成功编写完成了。由于我的各大论坛的 账号 密码 特别多,记性又不好。所以一直以来都想要这么一个软件的,但是以前学习的都是面向过程的编程语言,一直无法实现这个想法。这个暑假为了做一个程序项目,对记事本实现图形用户界面增删改查操作,所以开始学习C#编程。在花了整整二十天学习Winform编程和研究文件读写流(大多数时间在学习文件读写流上,Winform编程也就学会了几个常用的控件,文件读写流这个边读边写刚开始不会,特别蛋疼),好在经过一番努力学习后终于实现了。在完成这个后,突然想起一直以来想要的这个软件,于是开始动手编写,在快开学的这五天内,简单匆忙简单学习了下Winform数据库编程( 账号 密码 想法是放在数据库里比较好)。编写这个软件刚开始使用的SQL server数据库,但是当我花了三天左右完成时,才发现竟然蛋疼的无法脱机使用。查了资料后知道了用Access数据库可以实现脱机使用。而且之前用过的御剑、啊D、明小子之类渗透软件也大都是用的Access数据库,可移植性很好。因此只好开始又想法将SQL server更换成Access数据库。不停地在百度上转啊转,搞了半天才知道更换也很简单,只要将连接数据库语句更换下,再把Sql换成OleDb即可。更换期间也出了很多未知的蛋疼的问题,编译器查不出来哪里的问题,代码页看出出来哪里不对。搞了半天才知道原来数据库名称和字段名称不小心和access数据库中关键词冲突了。不过不管怎么说,终于搞定了。但是完成后安全性还是个问题,那么多 账号 密码 明文存放access数据库,那也太不安全了。因此又开始给程序增加加密算法。菜鸟学艺不精,而且时间有限,只好直接引用现成的加密算法了,程序界面登陆不需要查看 账号 密码 ,因此最后考虑后采用了单向加密的MD5 32位加密算法加密,而数据库内存储的 账号 密码 信息信息还需要显示出来,而MD5虽然安全但是不可逆,只能加密对比后台登陆使用,因此最终采用了DES加密算法和MD5混合加密的方法,当然加密算法是我copy的,我是菜鸟还没那个本事自己编写。

嘿嘿。废话说了一大堆,现在开始言归正传。

由于在下 的各种论坛 账号 密码 特别多,记性又不好,为了方便 账号 密码 的 管理 而编写的这个小软件。

使用说明:

1. 本程序由本人星云用Winform编程+Access数据库编写;(程序运行需安装有.net2.0环境和access软件)

2.登陆界面有四次登陆机会,连续四次登陆四次错误,程序将会锁定禁止使用,防止 密码 被暴力破解。

3.解锁方法:

用户名+秘钥:用户提供修改后的用户名配合本人在程序中设置的一个秘钥才可以解锁。(缺一不可。)

4.登陆界面 账号 密码 初始 密码 都为:root, 采用不可逆的单向加密MD5加密算法进行加密.

5.为了 账号 安全,请登陆后后立即点击 系统 维护按钮,进入登陆 密码 修改界面。

6.为了防止直接打开ACCESS数据库文件,对此打开进行了数据库 密码 设置, 密码 采用不可逆的MD5加密。

7.关于软件是否开源问题,考虑后觉得[交流即分享,分享才能进步[,因此最终决定开源,况且这也没什么技术含量。

8.源码公开后软件 账号 密码 安全性问题,在下决定在源码中对程序中涉及到的关键敏感 密码 处加以更改。

程序截图:

查询方式有两种,下拉菜单查询以及搜索查询。

基本功能添加修改删除

系统 维护界面:

软件下载地址:http://pan.baidu测试数据/s/1i3uuCKH 密码 :7u2y

文章中的公开项目源码下载:http://pan.baidu测试数据/s/1qWNS3Bu 密码 :s05u

程序源码:

Form窗体1如下:

 using   System;
  using   System.Windows.Forms;
  using   System.Data.OleDb;
  using   System.Security.Cryptography;
  using   System.Text;

  namespace    账号  密码  管理  系统 1._0
{
      public   partial   class   Form1 : Form
    {
          public   Form1()
        {
            InitializeComponent();
        }

          //  登陆错误时调用此函数:错误次数加一 
         private   void   IncErrortimes()
        {
              //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建数据库命令语句,更新错误次数加一 
                     using  (OleDbCommand UpdateCmd =  conn.CreateCommand())
                    {
                        UpdateCmd.CommandText  =  "  update T_system Set Errortimes=Errortimes+1 where sys_username=@name  "  ;
                        UpdateCmd.Parameters.Add(  new  OleDbParameter( "  name  "  , textBox1.Text));
                        UpdateCmd.ExecuteNonQuery();

                    }
                }
            }
        }

          //  登陆成功时调用此函数:重置错误次数 
         private   void   ResetErrotimes()
        {
              //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建数据库命令语句 
                     using  (OleDbCommand UpdateCmd =  conn.CreateCommand())
                    {
                        UpdateCmd.CommandText  =  "  update T_system Set Errortimes=0 where sys_username=@name  "  ;
                        UpdateCmd.Parameters.Add(  new  OleDbParameter( "  name  "  , textBox1.Text));
                        UpdateCmd.ExecuteNonQuery();

                    }
                }
            }
        }

          //  秘钥清除使用 
         private   void   RecoverErrotimes()
        {
              //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句,重置错误次数为0 
                     using  (OleDbCommand UpdateCmd =  conn.CreateCommand())
                    {
                        UpdateCmd.CommandText  =  "  update T_system Set Errortimes=0 where sys_username=@name  "  ;
                        UpdateCmd.Parameters.Add(  new  OleDbParameter( "  name  "  , textBox1.Text));
                        UpdateCmd.ExecuteNonQuery();

                    }

                      //  创建SQL命令语句,恢复默认 密码 为root 
                     using  (OleDbCommand UpdateCmd =  conn.CreateCommand())
                    {
                        UpdateCmd.CommandText  =  "  update T_system Set sys_password='63a9f0ea7bb98050796b649e85481845' where sys_username=@name  "  ;
                        UpdateCmd.Parameters.Add(  new  OleDbParameter( "  name  "  , textBox1.Text));
                        UpdateCmd.ExecuteNonQuery();

                    }
                }
            }
        }

          //  当单击"登陆"按钮时执行以下事件处理程序 
         private   void  button1_Click( object   sender, EventArgs e)
        {
              //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                        cmd.CommandText  =  "  select * from T_system where sys_username=@name  "  ;
                        cmd.Parameters.Add(  new  OleDbParameter( "  name  "  , GetMD5(textBox1.Text)));

                          //  读取数据库查询结果进行用户名和 密码 判断 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if  (reader.Read()) //  用户名输入正确 
                             {
                                  int  errortimes = reader.GetInt32(reader.GetOrdinal( "  Errortimes  "  ));
                                  if  (errortimes >  3  )
                                {

                                      if  (textBox2.Text ==  "  解锁 秘钥字符串,此处已经修改  "  )
                                    {
                                        RecoverErrotimes();
                                        MessageBox.Show(  "  程序解锁成功,程序即将重新启动!  "  );
                                        Application.Exit();
                                          return  ;
                                    }
                                      else  
                                    {
                                        MessageBox.Show(  "   密码 错误次数太多,程序已经被锁定禁用!  "  );
                                        Application.Exit();
                                          return  ;

                                    }
                                }
                                  string  dbpassword = reader.GetString(reader.GetOrdinal( "  sys_password  "  ));
                                  if  (dbpassword == GetMD5(textBox2.Text)) //  登陆成功! 
                                 {
                                    ResetErrotimes();  //  登陆成功,错误次数清零 
                                    Form2 fm2 =  new   Form2();
                                      this  .Hide();
                                    fm2.Show(); 
                                }
                                  else  
                                {
                                    MessageBox.Show(  "  登陆失败!  "  );
                                    IncErrortimes();
                                }
                            }
                              else     //  用户输入错误 
                             {
                                MessageBox.Show(  "  用户名不存在!  "  );

                            }
                        }
                    }
                }
            }
        }
          //  MD5加密算法 
         public   static   string  GetMD5( string   str)
        {
            MD5 md5  =  MD5.Create();
              byte [] buffer =  Encoding.Default.GetBytes(str);
              byte [] MD5buffer =  md5.ComputeHash(buffer);
              string  strnew =  ""  ;
              for  ( int  i =  0 ; i  )
            {
                strnew  += MD5buffer[i].ToString( "  x2  "  );
            }
              return   strnew;
        }
          // 
         private   void  label4_Click( object   sender, EventArgs e)
        {
              string  information =  "  \t欢迎使用 账号  密码  管理  系统 \n\n1.初始 账号 :root  密码 : root \n\n2.登陆后请立即修改登陆 账号 和 密码 \n\n3. 账号 和 密码 打死也不能忘记和告诉其他人\n\n4.连续登陆错误次数多于4次,此程序将会被锁定禁用\n\n5.解锁需要用户和作者合作才能解锁成功!\n\n6.用户需提供用户名,作者提供清除错误次数秘钥,\n\n还原默认 密码 合作才能完成\n\n6.为了防止 密码 暴力破解以及 系统 锁定后无法使用,\n\n作者掌握清除错误次数和还原 系统 默认 密码 秘钥,但无法修改登陆 账号 \n\n因此如果登陆 账号 也忘记,作者也回天无力。\n\n7.联系作者:xingyun2684@gmail测试数据  "  ;
            MessageBox.Show(  null , information,  "  使用说明:  "  );

        }

          //  当单击"重置"按钮时执行以下事件处理程序 
         private   void  button2_Click( object   sender, EventArgs e)
        {
            textBox1.Text  =  ""  ;
            textBox2.Text  =  ""  ;
        }
    }
}  

Form2窗体源码:

 using   System;
  using   System.Windows.Forms;
  using   System.Data.SqlClient;
  using   System.Data.OleDb;
  using   System.Security.Cryptography;
  using   System.Text;
  using   System.IO;

  namespace    账号  密码  管理  系统 1._0
{
      public   partial   class   Form2 : Form
    {
          public   Form2()
        {
            InitializeComponent();

              //  combox1 下拉条内容初始化 
             /*  ********************************************************  */ 
           
             //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                          //  SQL查询语句 
                        cmd.CommandText =  "  select account_type from T_users  "  ;
                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              while   (reader.Read())
                            {
                                comboBox1.Items.Add((reader.GetString(reader.GetOrdinal(  "  account_type  "  ))));
                            }
                        }
                    }
                }
            }
              /*  *******************************************************  */  
        }

          /*  ************************************************************************
               * 
               *               算法加密模块 
               * 
               * 登陆 账号  密码 采用md5加密算法进行加密。
               * 
               * 信息内容采用 DES加密算法+MD5混合加密算法
               *  
               * 所有 账号 信息将调用此函数进行数据加密
               *
               *  调用方法:EncryptDES(string 明文字符串, string 秘钥字符串);
               *
               *            DecryptDES(string 密文字符串, string 秘钥字符串);
               *                                     
               * ********************************************************************  */ 
       
         //  DES普通加密解密算法
        
          //   DES加密字符串 
         private   static   byte [] Keys = {  0x12 ,  0x34 ,  0x56 ,  0x78 ,  0x90 ,  0xAB ,  0xCD ,  0xEF   };

          /*  ***********************************************************************
         *  
         * 解密函数:DecryptDES(string 密文字符串, string 秘钥字符串);
         * 
         * encryptString       待加密的字符串
         * 
         * encryptKey          加密密钥,要求为8位
         * 
         * 加密返回值        加密后的字符串,失败返回源串 
         * 
         * **************************************************************************  */ 
         public   static   string  EncryptDES( string  encryptString,  string   encryptKey)
        {
              try  
            {
                  byte [] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring( 0 ,  8  ));
                  byte [] rgbIV =  Keys;
                  byte [] inputByteArray =  Encoding.UTF8.GetBytes(encryptString);
                DESCryptoServiceProvider dCSP  =  new   DESCryptoServiceProvider();
                MemoryStream mStream  =  new   MemoryStream();
                CryptoStream cStream  =  new   CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
                cStream.Write(inputByteArray,   0  , inputByteArray.Length);
                cStream.FlushFinalBlock();
                  return   Convert.ToBase64String(mStream.ToArray());
            }
              catch  
            {
                  return   encryptString;
            }
        }

          /*   ********************************************************************************  */ 

         /*   DES解密函数 DecryptDES(string 密文字符串, string 秘钥字符串);
         * 
         *        decryptString : 待解密的字符串
         * 
         *           decryptKey :   解密密钥,要求为8位,和加密密钥相同
         *        
         *                返回值:      解密成功返回解密后的字符串,失败返源串
         *
         ***********************************************************************************  */ 
         public   static   string  DecryptDES( string  decryptString,  string   decryptKey)
        {
              try  
            {
                  byte [] rgbKey =  Encoding.UTF8.GetBytes(decryptKey);
                  byte [] rgbIV =  Keys;
                  byte [] inputByteArray =  Convert.FromBase64String(decryptString);
                DESCryptoServiceProvider DCSP  =  new   DESCryptoServiceProvider();
                MemoryStream mStream  =  new   MemoryStream();
                CryptoStream cStream  =  new   CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
                cStream.Write(inputByteArray,   0  , inputByteArray.Length);
                cStream.FlushFinalBlock();
                  return   Encoding.UTF8.GetString(mStream.ToArray());
            }
              catch  
            {
                  return   decryptString;
            }
        }
          //  添加数据  
/*  ************************************************************************  */ 
         private   void  button1_Click( object   sender, EventArgs e)
        {
             //   1. 判断是否数据库内已经有该条记录 
         /*  ***************************************************************  */ 
             //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改。  "  ;
            {
                      using  (OleDbConnection conn2 =  new   OleDbConnection(connectionString)) 
                    {
                    conn2.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn2.CreateCommand())
                    {
                          //  SQL查询语句加密后查询 
                        cmd.CommandText =  "  select account_type from T_users where account_type='  "  + textBox1.Text +  "  '  "  ;
                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if  (reader.Read()) //  如果存在 
                             {
                                MessageBox.Show(  "  对不起,同一类型的 账号 只能添加一次!  " ,  "  添加失败提示  "  );

                                  //  清空内容 
                                textBox1.Text =  ""  ;
                                textBox2.Text  =  ""  ;
                                textBox3.Text  =  ""  ;
                                textBox4.Text  =  ""  ;
                                textBox5.Text  =  ""  ;
                                  return  ;
                            }
                              else   //  数据库中不存在此类型 账号 则将其添加 
                             {

                                  //    更新combox 下拉选项  
                                 comboBox1.Items.Add(textBox1.Text);
                                  //  添加信息插入到数据库内   
                                 /*  *********************************************************************  */ 
                                 //  与数据库建立连接 
                                 string  connectionString2 =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
                                {
                                      using  (OleDbConnection conn =  new   OleDbConnection(connectionString2))
                                    {
                                        conn.Open();  //  打开连接

                                          //  创建SQL命令语句,添加内容都将会调用MD5算法进行加密,然后保存到数据库内。 
                                         using  (OleDbCommand insert_cmd =  conn.CreateCommand())
                                        {
                                              //  SQL查询语句 
                                            insert_cmd.CommandText =  "  insert into T_users (account_type,account_website,account_username,account_password)values('  "  + textBox1.Text +  "  ','  "  + EncryptDES(textBox2.Text,  "  信息md5加密字符串  " ) +  "  ','  "  + EncryptDES(textBox3.Text,  "  信息md5加密字符串  " ) +  "  ','  "  + EncryptDES(textBox4.Text,  "  信息md5加密字符串  " ) +  "  ');  "  ;
                                            insert_cmd.ExecuteNonQuery();
                                        }

                                    }
                                      /*  ************************************************  */  
                                    textBox1.Text  =  ""  ;
                                    textBox2.Text  =  ""  ;
                                    textBox3.Text  =  ""  ;
                                    textBox4.Text  =  ""  ;
                                    textBox5.Text  =  ""  ;
                                    MessageBox.Show(  "  插入成功!  " ,  "  插入提示  "  );
                                }
                            }
                        }
                    }
                }
            }
            }
        
  /*  **********************************************************************  */ 

         //  修改更新数据实现  
/*  *********************************************************  */ 
         private   void  button2_Click( object   sender, EventArgs e)
        {
              //  判断是否库中是否有此记录,有才可以修改。 
             /*  **********************************************************  */ 
             //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                          //  SQL查询语句 
                        cmd.CommandText =  "  select account_type from T_users where account_type='  "  + textBox1.Text +  "  ';  "  ;
                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if   (reader.Read())
                            {
                                  //  与数据库建立连接 
                                 string  connectionString2 =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
                                {
                                      using  (OleDbConnection conn2 =  new   OleDbConnection(connectionString2))
                                    {
                                        conn2.Open();  //  打开连接

                                          //  创建SQL命令语句 
                                         using  (OleDbCommand modify_cmd =  conn2.CreateCommand())
                                        {
                                              //  SQL查询语句 
                                            modify_cmd.CommandText =  "  update T_users set account_website='  "  + EncryptDES(textBox2.Text,  "  信息md5加密字符串  " ) +  "  ',account_username='  "  + EncryptDES(textBox3.Text,  "  信息md5加密字符串  " ) +  "  ',account_password='  "  + EncryptDES(textBox4.Text,  "  信息md5加密字符串  " ) +  "  ' where account_type='  "  + textBox1.Text +  "  ';  "  ;
                                            modify_cmd.ExecuteNonQuery();

                                              //  修改成功清空内容 
                                            textBox1.Text =  ""  ;
                                            textBox2.Text  =  ""  ;
                                            textBox3.Text  =  ""  ;
                                            textBox4.Text  =  ""  ;
                                            textBox5.Text  =  ""  ;
                                            MessageBox.Show(  "  修改成功!  " ,  "  修改提示  "  );
                                        }
                                    }
                                }
                            }
                              else  
                            {
                                MessageBox.Show(  "  数据库内没有该 账号 类型,无法修改!  " ,  "  修改失败提示  "  );
                                  return  ;
                            }
                        }
                    }
                }
            }
        }

        /*  *******************************************************  */ 
                
 /*  *********************************************************  */ 

         //  删除数据实现  
/*  ******************************************************  */ 
         private   void  button3_Click( object   sender, EventArgs e)
        {
              /*  ********************************************************  */ 
             //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {

                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                          //  SQL查询语句 
                        cmd.CommandText =  "  select account_type from T_users where account_type='  "  + textBox1.Text +  "  ';  "  ;
                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if  (reader.Read()) //  存在该条记录 
                             {
                                  //  执行删除操作 
                                 /*  *******************************************************  */ 
                                 //  与数据库建立连接 
                                 string  connectionString2 =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
                                {
                                      using  (OleDbConnection conn2 =  new   OleDbConnection(connectionString2))
                                    {
                                        conn2.Open();  //  打开连接

                                          //  创建SQL命令语句 
                                         using  (OleDbCommand delete_cmd =  conn2.CreateCommand())
                                        {
                                              //  SQL查询语句 
                                            delete_cmd.CommandText =  "  delete from T_users where account_type='  "  + textBox1.Text+  "  ';  "  ;
                                            delete_cmd.ExecuteNonQuery();
                                        }
                                    }
                                }
                                  //  删除此combox选项 
                                 if  (comboBox1.Text ==  textBox1.Text)
                                {
                                    comboBox1.Items.Remove(comboBox1.Text);
                                }
                                  //  删除成功清空内容 
                                textBox1.Text =  ""  ;
                                textBox2.Text  =  ""  ;
                                textBox3.Text  =  ""  ;
                                textBox4.Text  =  ""  ;
                                textBox5.Text  =  ""  ;
                                MessageBox.Show(  "  删除成功!  " ,  "  删除成功提示  "  );
                            }
                              else  
                            {
                                MessageBox.Show(  "  删除失败!  " ,  "  删除失败提示  "  );
                                  return  ;
                            }
                        }
                    }
                }
            }
        }
  /*  ************************************************************  */ 

         //  清空  
/*  ***********************************************************************  */ 
         private   void  button6_Click( object   sender, EventArgs e)
        {
            textBox1.Text  =  ""  ;
            textBox2.Text  =  ""  ;
            textBox3.Text  =  ""  ;
            textBox4.Text  =  ""  ;
            textBox5.Text  =  ""  ;
        }
  /*  ***********************************************************************  */ 
        
         //  关键词搜索 
         private   void  button4_Click( object   sender, EventArgs e)
        {
              //  与数据库建立连接 
             string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                          //  SQL查询语句 
                        cmd.CommandText =  "  select * from T_users where account_type='  "  + textBox5.Text +  "  ';  "  ;

                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if  (reader.Read()) //   账号 类型存在存在 
                             {
                                  string  db_type = reader.GetString(reader.GetOrdinal( "  account_type  "  ));
                                  string  db_website = reader.GetString(reader.GetOrdinal( "  account_website  "  ));
                                  string  db_username = reader.GetString(reader.GetOrdinal( "  account_username  "  ));
                                  string  db_password = reader.GetString(reader.GetOrdinal( "  account_password  "  ));
                                textBox1.Text  = db_type;
                                textBox2.Text  = DecryptDES(db_website,  "  信息md5加密字符串  "  );
                                textBox3.Text  = DecryptDES(db_username,  "  信息md5加密字符串  "  );
                                textBox4.Text  = DecryptDES(db_password,  "  信息md5加密字符串  "  );
                            }
                              else   //  reader返回false,搜索没有找到 
                             {
                                MessageBox.Show(  "  对不起,没有找到!  " ,  "  搜索提示  "  );
                                  return  ;
                            }
                        }
                    }
                }
            }

        }
        
          //  下拉框搜索 
         private   void  comboBox1_SelectedIndexChanged( object   sender, EventArgs e)
        {
              string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
            {
                  using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                {
                    conn.Open();  //  打开连接

                      //  创建SQL命令语句 
                     using  (OleDbCommand cmd =  conn.CreateCommand())
                    {
                          //  SQL查询语句 
                        cmd.CommandText =  "  select * from T_users where account_type='  "  + comboBox1.Text + "  '  "  ;
                          //  读取查询结果内容 
                         using  (OleDbDataReader reader =  cmd.ExecuteReader())
                        {
                              if   (reader.Read())
                            {
                                textBox1.Text  =reader.GetString(reader.GetOrdinal( "  account_type  "  ));
                                textBox2.Text  = DecryptDES((reader.GetString(reader.GetOrdinal( "  account_website  " ))),  "  信息md5加密字符串  "  );
                                textBox3.Text  = DecryptDES((reader.GetString(reader.GetOrdinal( "  account_username  " ))),  "  信息md5加密字符串  "  );
                                textBox4.Text  = DecryptDES((reader.GetString(reader.GetOrdinal( "  account_password  " ))),  "  信息md5加密字符串  "  );
                            }
                              else  
                            {
                                comboBox1.Items.Remove(comboBox1.Text);
                                  return  ;
                            }
                        }
                    }
                }
            }
        }

        
          /*   在winform中, 系统 默认是不能够禁用窗体的关闭功能,
         * 但是,有时我们需要这种功能来屏蔽用户"随便"或不小心关闭造成的 系统 问题。 
         * 该方法操作起来十分简便,只要将以下一段代码添加到窗体累中就可以实现禁止窗体关闭按钮
         * 该方法让窗体的关闭按钮还是存在的,但是,鼠标操作关闭按钮是没有效果的。
           */ 
     /*  **************************************************************************  */ 
         //  禁用鼠标右上角关闭按钮 
         protected   override   void  WndProc( ref     Message m)
        {
              const   int  WM_SYSCOMMAND =  0x0112  ;
              const   int  SC_CLOSE =  0xF060  ;
              if  (m.Msg == WM_SYSCOMMAND && ( int )m.WParam ==  SC_CLOSE)
            {
                  return  ;
            }
              base .WndProc( ref   m);
        }
     /*  *********************************************************************  */ 

         //   系统 维护 
         private   void  button5_Click( object   sender, EventArgs e)
        {
            Form3 fm3  =  new   Form3();
              this  .Hide();
            fm3.Show();
        }

          //  退出 系统  
         private   void  button7_Click( object   sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}  

窗体三源码:

 using   System;
  using   System.Windows.Forms;
  using   System.Data.SqlClient;
  using   System.Data.OleDb;
  using   System.Security.Cryptography;
  using   System.Text;

  namespace    账号  密码  管理  系统 1._0
{
      public   partial   class   Form3 : Form
    {
          public   Form3()
        {
            InitializeComponent();
        }

          //  重置 
         private   void  button2_Click( object   sender, EventArgs e)
        {
            textBox1.Text  =  ""  ;
            textBox2.Text  =  ""  ;
            textBox3.Text  =  ""  ;
            textBox4.Text  =  ""  ;
            textBox5.Text  =  ""  ;
        }

          //  修改 
         private   void  button1_Click( object   sender, EventArgs e)
        {
              if  (textBox4.Text ==  textBox5.Text)
            {
                  //  与数据库建立连接 
                 string  connectionString =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
                {
                      using  (OleDbConnection conn =  new   OleDbConnection(connectionString))
                    {
                        conn.Open();  //  打开连接

                          //  创建SQL命令语句 
                         using  (OleDbCommand cmd =  conn.CreateCommand())
                        {
                              //  SQL查询语句 
                            cmd.CommandText =  "  select * from T_system where sys_username='  "  + GetMD5(textBox1.Text) +  "  ';  "  ;
                              //  读取查询结果内容 
                             using  (OleDbDataReader reader =  cmd.ExecuteReader())
                            {
                                  if  (reader.Read()) //  判断用户名是否存在 
                                 {
                                      string  dbpassword = reader.GetString(reader.GetOrdinal( "  sys_password  "  ));
                                      if  (dbpassword == GetMD5(textBox2.Text))  //  原来 密码 输入正确 
                                     {
                                          //  更新数据库
                                          //  添加信息插入到数据库内   
                                         /*  *********************************************************************  */ 
                                         //  与数据库建立连接 
                                         string  connectionString2 =  "  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account_System.mdb;Jet OLEDB:Database Password=数据库 密码 设置处,此处已经修改  "  ;
                                        {
                                              using  (OleDbConnection conn2 =  new   OleDbConnection(connectionString2))
                                            {
                                                conn2.Open();  //  打开连接

                                                  //  创建SQL命令语句 
                                                 using  (OleDbCommand insert_cmd =  conn2.CreateCommand())
                                                {
                                                      //  SQL查询语句 
                                                    insert_cmd.CommandText =  "  update T_system set sys_username='  "  + GetMD5(textBox3.Text) +  "  ',sys_password='  "  + GetMD5(textBox4.Text) +  "  ';  "  ;
                                                    insert_cmd.ExecuteNonQuery();
                                                }
                                            }
                                        }
                                        MessageBox.Show(  "  恭喜您,修改成功!  " ,  "   系统 维护提示  "  );

                                    }
                                      else  //  原 密码 输入错误  
                                     {
                                        MessageBox.Show(  "  对不起,原 密码 输入错误  "  );
                                          return  ;
                                    }
                                }
                                  else  
                                {
                                    MessageBox.Show(  "  原用户名输入错误!  "  );
                                      return  ;
                                }
                            }
                        }

                    }
                }
            }
              else  
            {
                MessageBox.Show(  "  修改失败,新 密码 与确认 密码 不一致!  " ,  "  修改错误提示  "  );
                  return  ;
            }

        }
          //  MD5加密算法 
         public   static   string  GetMD5( string   str)
        {
            MD5 md5  =  MD5.Create();
              byte [] buffer =  Encoding.Default.GetBytes(str);
              byte [] MD5buffer =  md5.ComputeHash(buffer);
              string  strnew =  ""  ;
              for  ( int  i =  0 ; i  )
            {
                strnew  += MD5buffer[i].ToString( "  x2  "  );
            }
              return   strnew;
        }

          private   void  button3_Click( object   sender, EventArgs e)
        {
            Form2 fm2  =  new   Form2();
              this  .Hide();
            fm2.Show();  
        }
    }
}  

查看更多关于账号密码管理系统Access版本的详细内容...

  阅读:36次