C# Winform制作一个登录系统

embedded/2025/2/7 17:44:37/

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace 登录
{public partial class Form1 : Form{public Form1(){InitializeComponent();}public ArrayList UserName=new ArrayList();public ArrayList Password=new ArrayList();private void button2_Click(object sender, EventArgs e){if(textBox1.Text == ""){label4.Text = "账号不能为空";label4.ForeColor = Color.Red;return;}if(textBox2.Text ==""){label4.Text = "";label5.Text = "密码不能为空";label5.ForeColor = Color.Red;return;}label5.Text = "";bool IsEdit=false;for(int i = 0; i < UserName.Count; i++){if((string)UserName[i] ==textBox1.Text){IsEdit = true;break;  }}if(IsEdit){MessageBox.Show("账号已注册");}else{MessageBox.Show("账号注册成功");UserName.Add(textBox1.Text);Password.Add(textBox2.Text);//textBox1.Clear();//textBox2.Clear();}}private void button1_Click(object sender, EventArgs e){bool isSiccess = false;for (int i = 0; i < UserName.Count; i++){if (textBox1.Text.Equals(UserName[i]) && textBox2.Text.Equals(Password[i])){isSiccess = true;break;}}if (isSiccess){Form2 form2 = new Form2();form2.Show();this.Hide();}else{MessageBox.Show("账号或密码错误");}}private void button3_Click(object sender, EventArgs e){this.Close();}private void textBox1_KeyDown(object sender, KeyEventArgs e){if (e.KeyCode == Keys.Enter){this.textBox2.Focus();}}private void textBox2_KeyPress(object sender, KeyPressEventArgs e){if(e.KeyChar==(char)Keys.Enter){this.button1_Click(sender, e);}}}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace 登录
{public partial class Form2 : Form{public Form2(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){Label label = new Label();label.Text = "Suprise!";label.Font = new Font("微软雅黑", 70);label.ForeColor = Color.Red;label.Location = new Point(180, 200);label.AutoSize = true;label.ImageAlign = ContentAlignment.MiddleCenter;this.Controls.Add(label);button1.Visible = false;}}
}


http://www.ppmy.cn/embedded/160359.html

相关文章

硬盘接入电脑提示格式化?是什么原因?怎么解决?

有时候&#xff0c;当你将硬盘接入电脑时&#xff0c;看到系统弹出“使用驱动器中的光盘之前需要将其格式化”的提示&#xff0c;肯定会感到十分困惑和焦虑。这种情况不仅让人担心数据丢失&#xff0c;也可能影响正常使用。为什么硬盘会突然要求格式化&#xff1f;是硬盘出了问…

DeepSeek 遭 DDoS 攻击背后:DDoS 攻击的 “千层套路” 与安全防御 “金钟罩”_deepseek ddos

当算力博弈升级为网络战争&#xff1a;拆解DDoS攻击背后的技术攻防战——从DeepSeek遇袭看全球网络安全新趋势 在数字化浪潮席卷全球的当下&#xff0c;网络已然成为人类社会运转的关键基础设施&#xff0c;深刻融入经济、生活、政务等各个领域。从金融交易的实时清算&#xf…

c++ stl 遍历算法和查找算法

概述&#xff1a; 算法主要由头文件<algorithm> <functional> <numeric> 提供 <algorithm> 是所有 STL 头文件中最大的一个&#xff0c;提供了超过 90 个支持各种各样算法的函数&#xff0c;包括排序、合并、搜索、去重、分解、遍历、数值交换、拷贝和…

Safari常用快捷键

一、书签边栏 1、显示或隐藏书签边栏&#xff1a;Control-Command-1 2、选择下一个书签或文件夹&#xff1a;向上头键或向下头键 3、打开所选书签&#xff1a;空格键 4、打开所选文件夹&#xff1a;空格键或右箭头键 5、关闭所选文件夹&#xff1a;空格键或左箭头键 6、更…

基于多重算法的医院增强型50G全光网络设计与实践:构建智慧医疗新基石(下)

四、关键算法在医院 50G 全光网络中的应用场景 4.1 智能流量调度算法 4.1.1 基于 DQN 的流量分类 深度 Q 网络&#xff08;DQN&#xff09;是一种将深度学习与 Q 学习相结合的算法&#xff0c;它在医院 50G 全光网络的流量分类中发挥着重要作用。其核心原理是通过构建深度神…

Linux学习笔记16---高精度延时实验

延时函数是很常用的 API 函数&#xff0c;在前面的实验中我们使用循环来实现延时函数&#xff0c;但是使用循环来实现的延时函数不准确&#xff0c;误差会很大。虽然使用到延时函数的地方精度要求都不会很严格( 要求严格的话就使用硬件定时器了 ) &#xff0c;但是延时函数肯定…

CLK敏感源和完整GND平面

SPI Flash芯片辐射发射&#xff08;RE&#xff09;问题: 某款产品在3米法电波暗室进行辐射&#xff08;RE&#xff09;发射测试时,发现多个频点余量不满足6dB管控要求. 通过频谱分析仪近场探头分析定位到干扰频点来自于SPI Flash时钟信号的高次谐波干扰&#xff0c;深入分析发…

【deepseek实战】绿色好用,不断网

前言 最佳deepseek火热网络&#xff0c;我也开发一款windows的电脑端&#xff0c;接入了deepseek&#xff0c;基本是复刻了网页端&#xff0c;还加入一些特色功能。 助力国内AI&#xff0c;发出自己的热量 说一下开发过程和内容的使用吧。 目录 一、介绍 二、具体工作 1.1、引…