回 帖 发 新 帖 刷新版面

主题:[讨论]求帮我做一道c#编程题

添加一个“FrmInformation”窗体,用于设计一个用户登录界面,包括用户名和密码。例如:用户名:admin、密码:admin,输入正确时,显示登录成功,否则显示登录失败,请重新登录。在登录窗体上添加一个注册按钮,点击时弹出注册窗体。    谁帮我用C#语言帮我做这道题啊,谢谢了!

回复列表 (共4个回复)

沙发

@.@

板凳

呵呵,今年大二,正在学习中...............

3 楼

private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "admin" && txtPassword.Text == "admin")
            {
                //登陆后,进入主窗体
            }
            else
            {
                MessageBox.Show("您输入的用户名或密码不正确!");
            }
        }

        private void btnEnrol_Click(object sender, EventArgs e)
        {
            EnrolForm enrol = new EnrolForm();
            enrol.show();
        }

4 楼

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用户登录界面
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)//登录按钮
        {
            if (textBox1.Text == "123456" && textBox2.Text == "123")
            {
                MessageBox.Show("恭喜你,登录成功!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
            else if(textBox1.Text=="123456"&&textBox2.Text!="123")
            {
                MessageBox.Show("您输入的密码错误!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
            else if (textBox1.Text != "123456" && textBox2.Text == "123")
            {
                MessageBox.Show("您输入的用户名错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("您的用户名和密码错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button2_Click(object sender, EventArgs e)//取消按钮
        {
            Application.Exit();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//链接到注册网页
        {
            try
            {
                System.Diagnostics.Process.Start("www.baidu.com");
            }
            catch(Exception ex)
            {
                MessageBox.Show("链接网页出错啦!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);  
            }
        }
    }
}
textbox1是用来存储用户名的text
textbox2是用来存储密码的text
你自己创建一个Windows窗体,添加几个控件,主要有linklable控件、button控件、lable控件,然后你自己运行试试。我是运行出来啦!!代码没有错误!!!

我来回复

您尚未登录,请登录后再回复。点此登录或注册