zoukankan      html  css  js  c++  java
  • 回车 登录

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
     
    namespace PDAExample
    {
        /// <summary>
        /// 登录
        /// @Author cluo
        /// @Date 2011-12-23
        /// </summary>
        public partial class FrmLogin : Form
        {
            public FrmLogin()
            {
                InitializeComponent();
            }
     
            // 输入验证
            private bool ValidateInput()
            {
                if (string.IsNullOrEmpty(txtLoginID.Text.Trim()))
                {
                    MessageBox.Show("请输入用户名");
                    txtLoginID.SelectAll();
                    txtLoginID.Focus();
                    return false;
                }
                else if (string.IsNullOrEmpty(txtLoginPwd.Text.Trim()))
                {
                    MessageBox.Show("请输入密码");
                    txtLoginPwd.SelectAll();
                    txtLoginPwd.Focus();
                    return false;
                }
                return true;
            }
     
            // 用户名校验
            private void txtLoginID_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar != 13) return;
                ValidateInput();
            }
     
            // 密码校验
            private void txtLoginPwd_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar != 13) return;
                if (ValidateInput()) btnLogin_Click(null, null);
            }
     
            // 登录
            private void btnLogin_Click(object sender, EventArgs e)
            {
                if (ValidateInput())
                {
                    MessageBox.Show("登录成功");
                }
            }
     
            // 取消
            private void btnCancel_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
        }
    }
  • 相关阅读:
    Windows平台下Android应用抓包挖掘漏洞方法
    长城宽带核心系统存严重漏洞,数十万用户、账单信息存泄露风险
    互联网公司站点通病之弱口令
    【Python】python-一个class继承的小case
    【Python】Python-skier游戏[摘自.与孩子一起学编程]
    【Python】一个python实例:给重要的文件创建备份.摘自crossin-python简明教程
    【JMeter】JMeter完成一个java请求的压测
    【Tcpcopy】离线回放功能
    【JMeter】Jmeter-完成一个http压力测试
    Apache-AB压力测试实例
  • 原文地址:https://www.cnblogs.com/x666066/p/11407829.html
Copyright © 2011-2022 走看看