C# Winform制作一个登录系统

ops/2025/2/7 18:12:59/

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/ops/156498.html

相关文章

【再谈设计模式】命令模式~封装请求的指挥者

一、引言 在软件工程&#xff0c;软件开发过程中&#xff0c;高效的设计模式是构建灵活、可维护和可扩展系统的关键。命令模式作为一种行为型设计模式&#xff0c;为处理各种操作请求提供了一种巧妙的解决方案。它像是一个指挥中心&#xff0c;有条不紊地协调请求的发送者和执行…

物联网 STM32【源代码形式-使用以太网】连接OneNet IOT从云产品开发到底层MQTT实现,APP控制 【保姆级零基础搭建】

物联网&#xff08;IoT&#xff09;‌是指通过各种信息传感器、射频识别技术、全球定位系统、红外感应器等装置与技术&#xff0c;实时采集并连接任何需要监控、连接、互动的物体或过程&#xff0c;实现对物品和过程的智能化感知、识别和管理。物联网的核心功能包括数据采集与监…

unity学习28:灯光light相关 类型type,模式mode等

目录 1 场景里的默认灯光 1.1 默认灯光 1.2 可以添加多个灯光 2 灯光类型 2.0 灯光的类型 2.1 定向灯光 directional light&#xff08;想象成太阳&#xff09; 2.1.1 全局和局部 2.2 聚光 spot ---- 类手电筒的光线 2.2.1 控制效果 2.2.2 还可以控制 spot light的…

C# 程序计算圆的面积(Program to find area of a circle)

给定圆的半径&#xff0c;求该圆的面积。 可以使用以下公式简单地计算圆的面积。 其中 r 是圆的半径&#xff0c;它可能是浮点数&#xff0c;因为饼图的值为 3.14 方法&#xff1a;使用给定的半径&#xff0c;使用上述公式找到面积&#xff1a;&#xff08;pi * r * r&#…

无人机飞手光伏吊运、电力巡检、农林植保技术详解

无人机飞手在光伏吊运、电力巡检、农林植保等领域的技术应用&#xff0c;体现了无人机技术的广泛性和实用性。以下是对这三个领域技术的详细解析&#xff1a; 一、无人机飞手光伏吊运技术 1. 技术背景 光伏发电站作为可再生能源的重要组成部分&#xff0c;其建设和维护对效率…

基于Kamailio、MySQL、Redis、Gin、Vue.js的微服务架构

每个服务使用一台独立的服务器的可行部署方案&#xff0c;尤其是在高并发、高可用性要求较高的场景中。这种方案通常被称为分布式部署或微服务架构。以下是针对您的VoIP管理系统&#xff08;基于Kamailio、MySQL、Redis、Gin、Vue.js&#xff09;的详细分析和建议。 1. 分布式部…

MySQL —— 事务

概念 事务把组SQL语句打包成为个整体&#xff0c;在这组SQL的执行过程中&#xff0c;要么全部成功&#xff0c;要么全部失败。 这组SQL语句可以是条也可以是多条。 ACID 特性 原子性 Atomicity(原子性)&#xff1a;一个事务中的所有操作&#xff0c;要么全部成功&#xff0…

【测试用例翔实 栈】P8815 [CSP-J 2022] 逻辑表达式

本文涉及知识点 C栈 [CSP-J 2022] 逻辑表达式 题目描述 逻辑表达式是计算机科学中的重要概念和工具&#xff0c;包含逻辑值、逻辑运算、逻辑运算优先级等内容。 在一个逻辑表达式中&#xff0c;元素的值只有两种可能&#xff1a; 0 0 0&#xff08;表示假&#xff09;和 …