• winform窗体 小程序【登录窗体】【恶搞程序】


    登录窗体

    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    
    namespace WindowsFormsApplication2.App_Code
    {
        public class UserData
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
    
            public UserData()
            {
                conn = new SqlConnection("server=.;database=Data0216;user=sa;pwd=123");
                cmd = conn.CreateCommand();
            }
    
            public bool HasUser(string uname, string pwd)
            {
                bool has = false;
    
                cmd.CommandText = "select *from Users where UserName = @a and PassWord = @b";
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@a", uname);
                cmd.Parameters.Add("@b", pwd);
    
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    has = true;
                }
                conn.Close();
                return has;
            }
    
        }
    }
    App_Code,UserData
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using WindowsFormsApplication2.App_Code;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (new UserData().HasUser(textBox1.Text, textBox2.Text))
                    MessageBox.Show("登录成功!");
                else
                    MessageBox.Show("失败!!!");
            }
        }
    }
    窗体的源代码

    恶搞程序

    步骤

    1、启动最大化                            -- WindowState : Maximized

    2、去边框                                 -- FormBorderStyle : none 

    3、置顶(最高层级)                   -- TopMost : true

    4、不在任务栏显示                      -- ShowInTaskbar : false

    5、不在任务管理器中显示            -- Text 变为空   

    6-1、背景无图片,设置透明度为 1%  

                                                      -- Opacity : 1%

    6-2、背景有图片,屏蔽 alt + f4  屏蔽 win键

     屏蔽之前先设置退出的快捷键

            MenuStrip      --菜单栏

            在菜单栏按钮中设置      this Close();  -- 退出

            在按钮的   ShortcutKeys  属性中 设置 快捷键 

            MenuStrip  的属性  Visible : false   -- 是否可见

  • 相关阅读:
    HDU 2236 无题II
    P2220 [HAOI2012]容易题
    UVA11383 Golden Tiger Claw
    AT2272 [ARC066B] Xor Sum
    CentOS7 静默安装oracle12c
    SNAT与DNAT
    Linux下离线安装Docker
    TJOI2017 DNA 和 BJOI2015 隐身术
    LOJ6169 相似序列
    BJOI2019 删数
  • 原文地址:https://www.cnblogs.com/Tanghongchang/p/6794664.html
Copyright © 2020-2023  润新知