首页 > 编程语言 >C#上位机登录界面设计-账号注册、密码修改功能(三)

C#上位机登录界面设计-账号注册、密码修改功能(三)

时间:2024-03-21 16:01:08浏览次数:23  
标签:界面设计 账号 C# Text void System private FormLogin using

        C#上位机登录界面设计-界面跳转(二)是讲述的如何登入主界面,下一步是修改账号、密码及注册新的账号、密码。

C#上位机登录界面设计-界面设计(一)

C#上位机登录界面设计-界面跳转(二)

一、窗体设计

1、添加修改密码窗体

        右键点击右侧解决方案下面的项目名,弹出菜单“添加”-“Window窗体”,设置好新窗体信息后可新增窗体。

1.1、添加控件

在界面添加需要的控件,并设置属性值;

类型

命名

属性

属性值

Form

FormModify

text

修改密码

Label

Label1

Text

请输入密码:

Label

Label2

Text

再次输入:

Label

Label3

Text

Button

btnCModify

text

 确定修改

TextBox

txtPwd1

text

TextBox

txtPwd2

text

1.2、添加程序

双击按键,进入程序界面。

private void btnCModify_Click(object sender, EventArgs e)
{
    if (txtPwd1.Text != "")
    {
        if (txtPwd1.Text == txtPwd2.Text)
        {
            FormLogin.MIMA[FormLogin.x] = txtPwd1.Text;
            FormLogin fl = new FormLogin();
            this.Hide();
            fl.Show();
        }
        else
        {
            label3.Text = "两次密码输入不一致!请重新输入";
        }
    }
}

2、添加注册账号窗体

2.1、添加控件

在界面添加需要的控件,并设置属性值;

类型

命名

属性

属性值

Form

FormRAccount

text

注册账号

Label

Label1

Text

请输入账号:

Label

Label2

Text

请输入密码:

Label

Label3

Text

Button

button1

text

 确定

Buttonbutton2text返回

TextBox

txtAccount

text

TextBox

txtPwd

text

2.2、添加程序

a、双击确定按键,进入程序界面。

private void button1_Click(object sender, EventArgs e)
{
    int n = FormLogin.ZHANGHAO.Length;
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        if (FormLogin.ZHANGHAO[i] == txtAccount.Text)
        {
            label3.Text = "该账号已被存在";
            label3.ForeColor = Color.Red;//错误显示红色
            return;
        }
        if (FormLogin.ZHANGHAO[i] != null)
        { j++; }
    }
    FormLogin.ZHANGHAO[j] = txtAccount.Text;
    FormLogin.MIMA[j] = txtPwd.Text;
    label3.Text = "注册成功";
    label3.ForeColor = Color.LimeGreen;//正确显示亮绿色
}

b、双击返回按键,进入程序界面。

private void button2_Click(object sender, EventArgs e)
{
    FormLogin fl = new FormLogin();
    this.Hide();
    fl.Show();
}

3、修改登录窗体

3.1、添加控件

在界面添加需要的控件,并设置属性值;

类型

命名

属性

属性值

ButtonbtnCPwd

text

修改密码

ButtonbtnRAccount

Text

注册账号

3.2、添加程序

a、双击修改密码按键,进入程序界面。

 private void btnCPwd_Click(object sender, EventArgs e)
 {
     FormModify fmm = new FormModify();

     this.Hide();

     fmm.Show();
 }

b、双击注册账号按键,进入程序界面。

private void btnRAccount_Click(object sender, EventArgs e)
{
    FormRAccount fra = new FormRAccount();

    this.Hide();

    fra.Show();
}

二、运行展示

三、完整程序

FormLogin.cs程序:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace 登录窗口实例
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        
        //变量设置为公共全局静态变量
        public static string[] ZHANGHAO = new string[10];//初始用户名数组

        public static string[] MIMA = new string[10];//初始密码数组

        public static string SHOWME = "";
          

        public static int x = 0;
        
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtAccount.Text != "" && txtPwd.Text != "")
            {
                int n = ZHANGHAO.Length;
                SHOWME = txtAccount.Text;
                FormMain fm = new FormMain();
                for (int i = 0; i < n; i++)
                {
                    if (txtAccount.Text == ZHANGHAO[i])
                    {
                        if (txtPwd.Text == MIMA[i])
                        {
                            label1.Text = "欢迎使用本系统!";
                            label1.ForeColor = Color.LimeGreen;//正确显示亮绿色
                            btnCPwd.Visible = true;
                            this.Hide();
                            fm.Show();
                            x = i;
                        }
                        else
                        {
                            label1.Text = "密码错误,请重新输入";
                            label1.ForeColor = Color.Red;//错误显示红色
                        }
                    }
                    else
                    {
                        label1.Text = "账号错误,请重新输入";
                        label1.ForeColor = Color.Red;//错误显示红色
                     }
                }
            }
            else
            {
                label1.Text = "账号为空,请注册账号";
                label1.ForeColor = Color.Red;//错误显示红色
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnCPwd_Click(object sender, EventArgs e)
        {
            FormModify fmm = new FormModify();

            this.Hide();

            fmm.Show();
        }

        private void btnRAccount_Click(object sender, EventArgs e)
        {
            FormRAccount fra = new FormRAccount();

            this.Hide();

            fra.Show();
        }
    }
}

FormMain.cs程序:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;

namespace 登录窗口实例
{
    public partial class FormMain : Form
    {
        
        public FormMain()
        {
            InitializeComponent();
            //textBox1.Text = FormLogin.ZHANGHAO[FormLogin.x];
            textBox1.Text = FormLogin.SHOWME;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FormLogin fl = new FormLogin();
            this.Hide();
            fl.Show();
        }
    }
}

FormModify.cs程序:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace 登录窗口实例
{
    public partial class FormModify : Form
    {
        public FormModify()
        {
            InitializeComponent();
        }

        private void btnCModify_Click(object sender, EventArgs e)
        {
            if (txtPwd1.Text != "")
            {
                if (txtPwd1.Text == txtPwd2.Text)
                {
                    FormLogin.MIMA[FormLogin.x] = txtPwd1.Text;
                    FormLogin fl = new FormLogin();
                    this.Hide();
                    fl.Show();
                }
                else
                {
                    label3.Text = "两次密码输入不一致!请重新输入";
                }
            }
        }
    }
}

FormRAccount.cs程序:

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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace 登录窗口实例
{
    public partial class FormRAccount : Form
    {
        public FormRAccount()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int n = FormLogin.ZHANGHAO.Length;
            int j = 0;
            for (int i = 0; i < n; i++)
            {
                if (FormLogin.ZHANGHAO[i] == txtAccount.Text)
                {
                    label3.Text = "该账号已被存在";
                    label3.ForeColor = Color.Red;//错误显示红色
                    return;
                }
                if (FormLogin.ZHANGHAO[i] != null)
                { j++; }
            }
            FormLogin.ZHANGHAO[j] = txtAccount.Text;
            FormLogin.MIMA[j] = txtPwd.Text;
            label3.Text = "注册成功";
            label3.ForeColor = Color.LimeGreen;//正确显示亮绿色
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FormLogin fl = new FormLogin();
            this.Hide();
            fl.Show();
        }
    }
}

标签:界面设计,账号,C#,Text,void,System,private,FormLogin,using
From: https://blog.csdn.net/Silent_you/article/details/136810131

相关文章

  • 探索AI运用:如何使用ChatGPT解决问题(一)
    前言:本篇文章是我小白的学习之路,我走过很多弯路,花过很多冤枉的时间,写这篇文章也是我希望各位小白能够少走弯路,虽然站在巨人的肩膀上看的更远,但是踩在我的经历上小白的你,能节约找素材很多时间。第一部分:AI运用的基础知识人工智能(ArtificialIntelligence,简称AI)是一项涉及模......
  • 实现一个自定义MVC
    在Spring核心思想之AOP:在自定义容器基础上实现AOP功能的容器上实现类似SpringMVC的功能。先分析下SpringMVC功能,在SpringMVC快速搭建初体验中:1、web.xml配置的功能被实现了WebApplicationInitializer的类替代,即不用解析web.xml配置文件直接执行WebApplicationIniti......
  • Swift Structured Concurrency
    异步函数异步函数概念异步和并发是两个不同的概念,并发(Concurrency)是指多个任务同时执行,这里的同时不是严格意义上的同一时刻,而是在稍大时间粒度上,多个任务可以同时推进,并发的实现可以是单线程,也可以是多线程、多核、多设备。在Swift中,异步函数是一种特殊的函数,它可以在执行过......
  • react router v6实现嵌套路由
    做一个简单的笔记有两种方式可以实现使用标签BrowserRouter来实现使用APIcreateBrowserRouter来实现注意:createBrowserRouter是6.4版本才引入的这是官方文档注意,这两个是不兼容的使用标签BrowserRouter来实现创建路由//src/router/index.tsxconstrouter=[......
  • ElasticSearch中使用ik分词器进行实现分词操作
    简介:在默认的情况下,ES中只存在Stander分词器,但是这个分词器往往不满足我们的分词需求,这里通过ik分词器进行自定义我们的分词操作1、第一步将ik分词器进行下载下载地址:https://github.com/medcl/elasticsearch-analysis-ik需要注意,需要选择和自己的ES版本对应的版本2、将ik分词......
  • mysql的my.cnf解释说明
    这个关乎配置文件,需要了解后,对数据库管理有很大的帮助。#***clientoptions相关选项***##以下选项会被MySQL客户端应用读取。注意只有MySQL附带的客户端应用程序保证可以读取这段内容。如果你想你自己的MySQL应用程序获取这些值。需要在MySQL客户端库初始化的时候指定这些选......
  • 重新记录一下ArcGisEngine安装的过程
    前言好久不用Arcgis,突然发现想用时,有点不会安装了,所以这里记录一下安装过程。下载Arcgis首先,下载一个arcgis版本,我这里下的是10.1。推荐【gis思维(公众号)】,【麻辣GIS(网站)】。当然了,这都是很旧很旧的版本了,基本上没有三维功能。一定要下载带注册机的。arcgis的压缩包包含3......
  • Step by Step Data Replication Using Oracle GoldenGate
    1、Quickstarts2、ConfigureDeployments3、ManageDeploymentsfromtheServiceManager 4、ConfigureDataReplicationProcessesfromtheAdministrationService 5、ConfigurePathstoTransportTraiData 6、MonitorPathsandTrailsfromtheReceiver......
  • m基于FPGA的电子钟verilog实现,可设置闹钟,包含testbench测试文件
    1.算法仿真效果本系统进行Vivado2019.2平台的开发,测试结果如下所示:   2.算法涉及理论知识概要       电子钟是现代生活中常见的计时工具,其准确性和功能性不断提高。基于FPGA的电子钟设计不仅具有灵活的可定制性,还能通过集成其他功能(如闹钟)来增强实用性。Verilog......
  • oracle 还原 .dmp 格式备份文件
     CONNsystem/你设置的密码@你的数据库名字showparametername-----查看你登入的数据库是否是你要导入的数据库---------先创建oracle用户(数据库)createuserorcladminidentifiedbymanager;--创建用户grantdbatoorcladmin;--给orcladmin权限---------创建表空间t......