C# Winform制作一个登录系统

server/2025/2/1 22:39:56/

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/server/164182.html

相关文章

DeepSeek本地版安装简易教程(windows)

第一步&#xff1a;下载 第二步&#xff1a;安装 先安装ollama&#xff0c;安装完毕保持ollama运行&#xff0c;设置ollama通过防火墙&#xff0c;再安装deepseek&#xff0c;7b代表下载的r1版本&#xff0c;版本越高消耗资源越大 第三步&#xff1a;开放windows防火墙 第四步…

OpenAI掀桌子!免费版ChatGPT,提供o3-mini模型!

逆天免费用 今天凌晨&#xff0c;OpenAI联合创始人兼首席执行官Sam Altman宣布了一个大消息——免费版ChatGPT&#xff0c;将提供o3-mini模型&#xff01; 网页们纷纷不淡定了 看来OpenAI&#xff0c;这o3-mini还没正式上线呢&#xff0c;就免费开放使用了。 不过还是要感谢…

【Java数据结构】了解排序相关算法

基数排序 基数排序是桶排序的扩展&#xff0c;本质是将整数按位切割成不同的数字&#xff0c;然后按每个位数分别比较最后比一位较下来的顺序就是所有数的大小顺序。 先对数组中每个数的个位比大小排序然后按照队列先进先出的顺序分别拿出数据再将拿出的数据分别对十位百位千位…

HTTPS 协议原理

&#x1f308; 个人主页&#xff1a;Zfox_ &#x1f525; 系列专栏&#xff1a;Linux 目录 一&#xff1a;&#x1f525; HTTPS 是什么&#x1f98b; 定义 二&#xff1a;&#x1f525; 概念准备&#x1f98b; 什么是"加密"&#x1f98b; 为什么要加密&#x1f98b; …

使用 postman 测试思源笔记接口

思源笔记 API 权鉴 官方文档-中文&#xff1a;https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md 权鉴相关介绍截图&#xff1a; 对应的xxx&#xff0c;在软件中查看 如上图&#xff1a;在每次发送 API 请求时&#xff0c;需要在 Header 中添加 以下键值对&a…

「全网最细 + 实战源码案例」设计模式——原型模式

核心思想 原型模式&#xff08;Prototype Pattern&#xff09;是一种创建型设计模式。它通过复制现有对象来创建新的对象&#xff0c;而不是通过实例化类。原型模式适用于创建成本较高或复杂的对象&#xff0c;或者需要避免暴露类内部复杂结构的场景。核心思想是“克隆”。 结…

基于Flask的哔哩哔哩综合指数UP榜单数据分析系统的设计与实现

【Flask】基于Flask的哔哩哔哩综合指数UP榜单数据分析系统的设计与实现&#xff08;完整系统源码开发笔记详细部署教程&#xff09;✅ 目录 一、项目简介二、项目界面展示三、项目视频展示 一、项目简介 该系统旨在通过大数据分析和数据挖掘技术&#xff0c;结合Flask轻量级We…

记录一次,PyQT的报错,多线程Udp失效,使用工具如netstat来检查端口使用情况。

1.问题 报错Exception in thread Thread-1: Traceback (most recent call last): File "threading.py", line 932, in _bootstrap_inner File "threading.py", line 870, in run File "main.py", line 456, in udp_recv IndexError: list…