密碼登入

王ys發表於2024-06-22
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 WindowsFormsApplication1
{
    
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();

        }

        
        private void button3_Click(object sender, EventArgs e)
        {
            string name = "wangyueshuo";
            string _password = "123456";
            label5.Text = "";
            label6.Text = "";
            if (textBox1.Text == "")
            {
                label5.Text = "請輸入你的賬號";
                return;
            }
            
            if (textBox2.Text == "")
            {
                label6.Text = "請輸入你的密碼";
                return;
            }
           
            
            if (textBox1.Text ==name&&textBox2.Text==_password)
            {
                label4.ForeColor = Color.Green;
                label4.Text = "登陸成功,請稍後...";
            }
            else
            {
                label4.ForeColor = Color.Red;
                label4.Text = "密碼或賬號錯誤";
            }
        }   
    }
}

  

相關文章