第一章魔兽窗口
Posted MyBatis
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第一章魔兽窗口相关的知识,希望对你有一定的参考价值。
开始显示第一个窗体
用户直接点登陆的话就会提示用户名不能为空密码不能为空
没有账号的话只能先注册,点击蓝色摁钮进入下一个窗体
这里有判断是否为空,注册成功后利用窗体传值,并且打开第一个窗口
把注册的用户名和密码写上去就可以的登陆到这个了
窗口一代码:
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11 namespace Loging 12 { 13 public partial class Form2 : Form 14 { 15 public string mile; 16 public string pwd; 17 public Form2() 18 { 19 InitializeComponent(); 20 } 21 22 private void Form2_Load(object sender, EventArgs e) 23 { 24 25 } 26 27 private void button1_Click(object sender, EventArgs e) 28 { 29 Form3 f3=new Form3(); 30 31 if (textBox1.Text == "" || textBox2.Text == "") { 32 MessageBox.Show("用户名或密码不能为空!", "提示"); 33 } 34 else if (textBox1.Text == mile && textBox2.Text ==pwd) 35 { 36 37 Form1 f1=new Form1(); 38 f1.Show(); 39 } 40 41 } 42 43 private void pictureBox1_Click(object sender, EventArgs e) 44 { 45 this.Close(); 46 } 47 48 private void label4_Click(object sender, EventArgs e) 49 { 50 Form3 f3 = new Form3(); 51 f3.Show(); 52 } 53 } 54 }
窗口二代码:
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11 namespace Loging 12 { 13 public partial class Form3 : Form 14 { 15 16 public Form3() 17 { 18 InitializeComponent(); 19 } 20 public static string mile; 21 public static string pwd; 22 private void lbls_Click(object sender, EventArgs e) 23 { 24 25 } 26 27 private void lblpwd_Click(object sender, EventArgs e) 28 { 29 30 } 31 32 private void button1_Click(object sender, EventArgs e) 33 { 34 if (textBox1.Text == "") 35 { 36 MessageBox.Show("姓名不能为空", "提示"); 37 38 } 39 else if (textBox3.Text == "") { 40 MessageBox.Show("身份证号不能为空", "提示"); 41 } 42 else if (textBox2.Text == "") { 43 44 MessageBox.Show("邮箱地址不能为空", "提示"); 45 } 46 else if (textBox4.Text == "") 47 { 48 MessageBox.Show("密码不能为空", " 提示"); 49 } 50 else if (textBox5.Text == "") { 51 MessageBox.Show("请再次输入邮箱", "提示"); 52 } 53 else if (textBox6.Text == "") 54 { 55 MessageBox.Show("请再次输入密码", "提示"); 56 } 57 else { 58 59 MessageBox.Show("注册成功", "提示"); 60 61 Form2 f2 = new Form2(); 62 f2.mile = textBox2.Text; 63 f2.pwd = textBox4.Text; 64 f2.Show(); 65 } 66 } 67 68 private void button2_Click(object sender, EventArgs e) 69 { 70 this.Close(); 71 } 72 73 private void Form3_Load(object sender, EventArgs e) 74 { 75 76 } 77 78 } 79 }
窗口三代码:
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 Loging { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } } }
以上是关于第一章魔兽窗口的主要内容,如果未能解决你的问题,请参考以下文章