zoukankan      html  css  js  c++  java
  • 用户登录模块--代码

    界面:

    代码(账户:100001  密码:200002):

     1         /// <summary>
     2         /// 登陆事件
     3         /// </summary>
     4         private void btn_OK_Click(object sender, EventArgs e)
     5         {
     6             if (this.txt_Pwd.Text.Trim() == "" && this.txt_User.Text.Trim() == "")
     7             {
     8                 MessageBox.Show("不能为空!", "提示");
     9             }
    10             else
    11             {
    12                 int i = 0;
    13 
    14                 string sql = string.Empty;
    15 
    16                 SqlParameter[] para = null;
    17 
    18                 SqlHelper shl = new SqlHelper();
    19 
    20                 sql = "select * from UserLogin where UserAccount = @User";
    21 
    22                 para = new SqlParameter[]
    23                 {
    24                     new SqlParameter("@User", this.txt_User.Text.Trim())
    25                 };
    26 
    27                 i = shl.ExecuteScalar(sql, para, CommandType.Text);
    28 
    29                 if (i == 1)
    30                 {
    31             sql = "select * from UserLogin where UserAccount = @User and UserPwd = @Pwd";
    32 
    33                     para = new SqlParameter[]
    34                     {
    35                         new SqlParameter("@User", this.txt_User.Text.Trim()),
    36                         new SqlParameter("@Pwd", this.txt_Pwd.Text.Trim())
    37                     };
    38 
    39                     i = shl.ExecuteScalar(sql, para, CommandType.Text);
    40 
    41                     if (i != 1)
    42                     {
    43                         MessageBox.Show("登陆失败,请检查账户和密码!", "提示");
    44                     }
    45                     else
    46                     {
    47                         Temp Tm = new Temp();
    48 
    49                         Tm.Show();
    50 
    51                         this.Close();
    52                     }
    53                 }
    54                 else
    55                 {
    56                     MessageBox.Show("账户不存在,请重新输入!", "提示");
    57                 }
    58             }
    59         }

    完成。

  • 相关阅读:
    [Linux]软件目录
    [Linux]查看Linux内核及发行版本
    [S7706]华为ACL
    [S7706]华为配置DHCP
    QML-密码管理器
    QML-AES加解密小工具
    LaTex中文article模板(支持代码、数学、TikZ)
    Memo-Tech
    VIM学习笔记
    CodeForces 674C Levels and Regions
  • 原文地址:https://www.cnblogs.com/KTblog/p/4428959.html
Copyright © 2011-2022 走看看