C# Winform制作一个登录系统

devtools/2025/2/3 3:32:21/

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/devtools/155613.html

相关文章

android获取EditText内容,TextWatcher按条件触发

android获取EditText内容&#xff0c;TextWatcher按条件触发 背景&#xff1a;解决方案&#xff1a;效果&#xff1a; 背景&#xff1a; 最近在尝试用原生安卓实现仿element-ui表单校验功能&#xff0c;其中涉及到EditText组件内容的动态校验&#xff0c;初步实现功能后&#…

pytorch使用SVM实现文本分类

人工智能例子汇总:AI常见的算法和例子-CSDN博客 完整代码: import torch import torch.nn as nn import torch.optim as optim import jieba import numpy as np from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import Tfid…

Python | Pytorch | 什么是 Inplace Operation(就地操作)?

如是我闻&#xff1a; 在 PyTorch 中&#xff0c;Inplace Operation&#xff08;就地操作&#xff09;是指直接修改 Tensor 本身&#xff0c;而不是创建新的 Tensor 的操作。PyTorch 中的 Inplace 操作通常会在函数名后加上 _ 作为后缀&#xff0c;例如&#xff1a; tensor.ad…

MongoDB 删除文档

常用的删除文档方法包括 deleteOne()、deleteMany() 以及 findOneAndDelete()。 使用场景&#xff1a; 数据清理&#xff1a;删除不再需要的旧数据或无效数据。数据修正&#xff1a;在数据修正过程中删除错误的或重复的文档。自动化任务&#xff1a;在自动化脚本或任务中&…

Games104——游戏引擎Gameplay玩法系统:基础AI

这里写目录标题 寻路/导航系统NavigationWalkable AreaWaypoint NetworkGridNavigation Mesh&#xff08;寻路网格&#xff09;Sparse Voxel Octree Path FindingDijkstra Algorithm迪杰斯特拉算法A Star&#xff08;A*算法&#xff09; Path Smoothing Steering系统Crowd Simu…

答疑解惑:如何监控EMC unity存储系统磁盘重构rebuild进度

近期有个朋友咨询的问题&#xff0c;这个其实很有代表性的&#xff0c;以前在VNX存储中&#xff0c;通过磁盘的属性是可以看到rebuild的进度的。到了unity年代&#xff0c;更换了一个磁盘&#xff0c;如何查询重构的进度&#xff0c;从图形界面好像没有找到合适的地方去查看。 …

kamailio-ACC_JSON模块详解

ACC_JSON 模块 作者 Julien Chavanton jchavantongmail.com Julien Chavanton flowroute.com jchavantongmail.com 编辑 Julien Chavanton flowroute.com jchavantongmail.com 版权 © 2018 Flowroute.com 目录 管理员指南 概述依赖 2.1 Kamailio 模块 2.2 外部库或应用…

蓝桥杯刷题DAY1:前缀和

所谓刷题&#xff0c;讲究的就是细心 帕鲁服务器崩坏【算法赛】 “那个帕鲁我已经观察你很久了&#xff0c;我对你是有些失望的&#xff0c;进了这个营地&#xff0c;不是把事情做好就可以的&#xff0c;你需要有体系化思考的能力。” 《幻兽帕鲁》火遍全网&#xff0c;成为…