(1)系统运行时,首先进入如图所示的界面。
(2)用户点击“注册”菜单下的“用户注册”,将在图7-4所示的主界面中打开一个有关“学生成绩管理系统”注册协议的文本控件,如图所示。
实现代码:
Form1:
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
{
Form2 formone;
public Form1()
{
InitializeComponent();
}
private void 用户注册ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = true;
textBox1.Visible = true;
button1.Visible = true;
textBox1.Text = "(1)提供及时,准确及详尽的个人资料n (2)不断更新注册资料, 符合及时详尽准确的要求,所有原始键入的资料将引用为注册资料";
}
private void button1_Click(object sender, EventArgs e)
{
formone = new Form2();
formone.Show();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
用户点击“我同意”按钮后,将弹出另外一个“用户注册”窗体,用户将在该窗体中完成用户基本信息的输入。“用户注册”窗体中,“密码”与“再次输入密码”文本框中输入的文字要求使用密码屏蔽,并且在用户点击“提交”按钮时,如果两次输入的密码不一致,将给出提示信息。
在“用户注册”窗体中,“所在院系”以及“所属专业”是两个ComboBox控件,“所在院系”包括:软件学院、石油工程学院、计算机学院。
如果在“所在院系”中选择“软件学院”,则在“所属专业”组合框的下拉列表中将显示“软件工程专业”、“数字媒体专业”。
如果在“所在院系”中选择“石油工程学院”,则在“所属专业”组合框的下拉列表中将显示“石油工程专业”、“储运工程专业”。
如果在“所在院系”中选择“计算机学院”,则在“所属专业”组合框的下拉列表中将显示“计算机工程专业”、“电子信息专业”。
实现代码:
Form2:
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 Form2 : Form
{
Form3 formone;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string name = "";
string gender = "";
string password = "";
string apartment1 = "";
string speciality1 = "";
if (textname.Text == "")
{
MessageBox.Show("用户名不能为空");
textname.Focus();
return;
}
else
name = textname.Text;
if (male.Checked)
gender = "男";
else
gender = "女";
apartment1 = apartment.Text;
speciality1 = speciality.Text;
if (textpassword.Text != passwordagain.Text)
{
MessageBox.Show("密码错误");
passwordagain.Clear();
passwordagain.Focus();
}
else
password = textpassword.Text;
formone = new Form3();
formone.Show();
formone.textBox2.Text= "姓名:" + name + Environment.NewLine + "性别:" +gender + Environment.NewLine + "密码:" + password + Environment.NewLine + "学院:" + apartment1 + Environment.NewLine + "专业:" + speciality1;
}
private void Form2_Load(object sender, EventArgs e)
{
apartment.Items.Clear();
apartment.Items.Add("软件学院");
apartment.Items.Add("石油工程学院");
apartment.Items.Add("计算机学院");
}
private void apartment_SelectedIndexChanged(object sender, EventArgs e)
{
switch (apartment.SelectedIndex)
{
case 0:
speciality.Items.Clear();
speciality.Items.Add("软件工程专业");
speciality.Items.Add("数字媒体专业");
break;
case 1:
speciality.Items.Clear();
speciality.Items.Add("石油工程专业");
speciality.Items.Add("储运工程专业");
break;
case 2:
speciality.Items.Clear();
speciality.Items.Add("计算机工程专业");
speciality.Items.Add("电子信息专业");
break;
}
}
}
}
(5)用户点击“提交”按钮后,将弹出“注册信息确认”窗体。在该消息框中,有“是”和“否”两个按钮,当用户点击“是”按钮时,整个应用程序退出(Application.Exit();)。当用户点击“否”按钮时,将“注册信息确认”窗体退出,重返到图7-8状态。
实现代码:
Form3:
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 Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result;
result = MessageBox.Show("真的确定吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (result == DialogResult.Yes)
{
Application.Exit();
}
else if (result == DialogResult.No)
{
this.Close();
}
}
}
}



