zoukankan      html  css  js  c++  java
  • 今天晚上完成了一个登录功能

      今天在完成登录系统时,主要遇到了两个问题,

        一是让窗体获得按键,刚开始做的时候,窗体没有办法获得按键输入,原来是要设置this.KeyPreview = true;属性,窗体才能够获得按键输入;

        二是窗体的FormBorderStyle属性值的意义:

         Fixed3D 固定的三维边框。

         FixedDialog 固定的对话框样式的粗边框。

          FixedSingle 固定的单行边框。

          FixedToolWindow 不可调整大小的工具窗口边框。工具窗口不会显示在任务栏中也不会显示在当用户按 Alt+Tab 时出现的窗口中。尽管指定 FixedToolWindow 的窗体通常不显示在任务栏中,还是必须确保 ShowInTaskbar 属性设置为 false,因为其默认值为 true

          None 无边框

         Sizable 可调整大小边框

         SizeableToolWindow 可调整大小的工具窗口边框。工具窗口不会显示在任务栏中也不会显示在当用户按 Alt+Tab 时出现的窗口中。

         但对网上说的当把FormBorderStyle=None,在Win7窗体中不会有一些动态效果,还不是很理解。要加强学习



     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Configuration;
     5 using System.Data;
     6 using System.Data.SqlClient;
     7 using System.Drawing;
     8 using System.Linq;
     9 using System.Text;
    10 using System.Threading.Tasks;
    11 using System.Windows.Forms;
    12 
    13 namespace _01登录练习
    14 {
    15     public partial class frmLogin : Form
    16     {
    17         public frmLogin()
    18         {
    19             InitializeComponent();
    20         }
    21 
    22         private void btnXCancel_Click(object sender, EventArgs e)
    23         {
    24             DialogResult dr= MessageBox.Show("确定要退出吗?", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    25 
    26             if(dr==DialogResult.Yes )
    27             {
    28                 Application.Exit();
    29             }
    30 
    31         }
    32 
    33         private void btnXLogin_Click(object sender, EventArgs e)
    34         {
    35             CheckUid();
    36 
    37         }
    38 
    39         private void CheckUid()
    40         {
    41             string uid = txtXUid.Text.Trim();
    42             string pwd = txtXPwd.Text;
    43             if (uid.Length > 0 && pwd.Length > 0)
    44             {
    45                 string sql = "select count(*) from kdUser where uName=@uid and uPassword=@pwd";
    46                 SqlParameter[] ps =
    47                 {
    48                     new SqlParameter ("@uid",uid),
    49                     new SqlParameter ("@pwd",pwd)
    50                 };
    51                 int result = (int)SqlHelper.ExecuteScalar(sql, CommandType.Text, ps);
    52                 if (result > 0)
    53                 {
    54                     MessageBox.Show("登录成功", "消息");
    55                 }
    56                 else
    57                 {
    58                     MessageBox.Show("登录失败", "消息");
    59                     txtXPwd.Clear();
    60                     txtXUid.Clear();
    61                 }
    62 
    63             }
    64             else
    65             {
    66                 MessageBox.Show("请输入用户名或者密码");
    67                 txtXUid.Focus();
    68             }
    69         }
    70 
    71 
    72         private void frmLogin_KeyDown(object sender, KeyEventArgs e)
    73         {
    74 
    75         }
    76 
    77         private void btnXLogin1(object sender, KeyEventArgs e)
    78         {
    79             if(e.KeyData ==Keys.F5 )
    80             {
    81                CheckUid();
    82             }
    83         }
    84     }
    85 }
  • 相关阅读:
    普通文件的上传(表单上传和ajax文件异步上传)
    React Ant Design+Node.js Express+Mysql实现后端分页(带富文本编辑器)
    Express中增删改查相关的中间件
    React中使用富文本编辑器react-draft-wysiwyg
    Express中aixos请求的(批量)删除用POST方法,其它请求的(批量)删除可以用DELETE方法
    React中将字符串转义成html语句
    Vue中如何设置代理跨域请求数据
    React中如何设置代理跨域请求数据
    axios发送post请求,服务端无法正常获取参数(比如:node服务器无法通过req.body获取参数)解决方案
    LeetCode-162.寻找峰值
  • 原文地址:https://www.cnblogs.com/yolin/p/5218781.html
Copyright © 2011-2022 走看看