📄 displaystudentdetails.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace ApplicationForm
{
/// <summary>
/// Summary description for DisplayDetails.
/// </summary>
public class DisplayStudentDetailsForm : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnFinish;
private System.Windows.Forms.Button btnSaveDetails;
protected internal System.Windows.Forms.Label lblCourseTypeDetail;
protected internal System.Windows.Forms.Label lblCourseType;
protected internal System.Windows.Forms.Label lblCoursesDetail;
protected internal System.Windows.Forms.Label lblTelephoneDetail;
protected internal System.Windows.Forms.Label lblPerAddressDetail;
protected internal System.Windows.Forms.Label lblAddressDetail;
protected internal System.Windows.Forms.Label lblSexDetail;
protected internal System.Windows.Forms.Label lblNameDetails;
private System.Windows.Forms.Label lblSex;
private System.Windows.Forms.Label lblPerAddress;
private System.Windows.Forms.Label lblCourseSelected;
protected internal System.Windows.Forms.Label lblStdEnNo;
protected internal System.Windows.Forms.Label lblStdEnNoDetail;
private System.Windows.Forms.Label lblTelephone;
private System.Windows.Forms.Label lblAddress;
private System.Windows.Forms.Label lblName;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public DisplayStudentDetailsForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lblCourseTypeDetail = new System.Windows.Forms.Label();
this.lblCourseType = new System.Windows.Forms.Label();
this.lblCoursesDetail = new System.Windows.Forms.Label();
this.lblTelephoneDetail = new System.Windows.Forms.Label();
this.lblPerAddressDetail = new System.Windows.Forms.Label();
this.lblAddressDetail = new System.Windows.Forms.Label();
this.lblSexDetail = new System.Windows.Forms.Label();
this.lblNameDetails = new System.Windows.Forms.Label();
this.lblSex = new System.Windows.Forms.Label();
this.lblPerAddress = new System.Windows.Forms.Label();
this.lblCourseSelected = new System.Windows.Forms.Label();
this.lblStdEnNo = new System.Windows.Forms.Label();
this.lblStdEnNoDetail = new System.Windows.Forms.Label();
this.lblTelephone = new System.Windows.Forms.Label();
this.lblAddress = new System.Windows.Forms.Label();
this.lblName = new System.Windows.Forms.Label();
this.btnFinish = new System.Windows.Forms.Button();
this.btnSaveDetails = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lblCourseTypeDetail);
this.groupBox1.Controls.Add(this.lblCourseType);
this.groupBox1.Controls.Add(this.lblCoursesDetail);
this.groupBox1.Controls.Add(this.lblTelephoneDetail);
this.groupBox1.Controls.Add(this.lblPerAddressDetail);
this.groupBox1.Controls.Add(this.lblAddressDetail);
this.groupBox1.Controls.Add(this.lblSexDetail);
this.groupBox1.Controls.Add(this.lblNameDetails);
this.groupBox1.Controls.Add(this.lblSex);
this.groupBox1.Controls.Add(this.lblPerAddress);
this.groupBox1.Controls.Add(this.lblCourseSelected);
this.groupBox1.Controls.Add(this.lblStdEnNo);
this.groupBox1.Controls.Add(this.lblStdEnNoDetail);
this.groupBox1.Controls.Add(this.lblTelephone);
this.groupBox1.Controls.Add(this.lblAddress);
this.groupBox1.Controls.Add(this.lblName);
this.groupBox1.Location = new System.Drawing.Point(10, 9);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(451, 551);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "学生详细信息";
//
// lblCourseTypeDetail
//
this.lblCourseTypeDetail.Location = new System.Drawing.Point(160, 508);
this.lblCourseTypeDetail.Name = "lblCourseTypeDetail";
this.lblCourseTypeDetail.Size = new System.Drawing.Size(240, 25);
this.lblCourseTypeDetail.TabIndex = 28;
//
// lblCourseType
//
this.lblCourseType.Location = new System.Drawing.Point(19, 508);
this.lblCourseType.Name = "lblCourseType";
this.lblCourseType.Size = new System.Drawing.Size(96, 26);
this.lblCourseType.TabIndex = 27;
this.lblCourseType.Text = "课程类型:";
//
// lblCoursesDetail
//
this.lblCoursesDetail.Location = new System.Drawing.Point(161, 419);
this.lblCoursesDetail.Name = "lblCoursesDetail";
this.lblCoursesDetail.Size = new System.Drawing.Size(252, 69);
this.lblCoursesDetail.TabIndex = 24;
//
// lblTelephoneDetail
//
this.lblTelephoneDetail.Location = new System.Drawing.Point(158, 375);
this.lblTelephoneDetail.Name = "lblTelephoneDetail";
this.lblTelephoneDetail.Size = new System.Drawing.Size(240, 25);
this.lblTelephoneDetail.TabIndex = 23;
//
// lblPerAddressDetail
//
this.lblPerAddressDetail.Location = new System.Drawing.Point(158, 282);
this.lblPerAddressDetail.Name = "lblPerAddressDetail";
this.lblPerAddressDetail.Size = new System.Drawing.Size(252, 78);
this.lblPerAddressDetail.TabIndex = 21;
//
// lblAddressDetail
//
this.lblAddressDetail.Location = new System.Drawing.Point(163, 181);
this.lblAddressDetail.Name = "lblAddressDetail";
this.lblAddressDetail.Size = new System.Drawing.Size(252, 79);
this.lblAddressDetail.TabIndex = 18;
//
// lblSexDetail
//
this.lblSexDetail.Location = new System.Drawing.Point(163, 129);
this.lblSexDetail.Name = "lblSexDetail";
this.lblSexDetail.Size = new System.Drawing.Size(67, 25);
this.lblSexDetail.TabIndex = 16;
//
// lblNameDetails
//
this.lblNameDetails.Location = new System.Drawing.Point(163, 78);
this.lblNameDetails.Name = "lblNameDetails";
this.lblNameDetails.Size = new System.Drawing.Size(240, 24);
this.lblNameDetails.TabIndex = 15;
//
// lblSex
//
this.lblSex.Location = new System.Drawing.Point(19, 129);
this.lblSex.Name = "lblSex";
this.lblSex.Size = new System.Drawing.Size(66, 25);
this.lblSex.TabIndex = 25;
this.lblSex.Text = "性别:";
//
// lblPerAddress
//
this.lblPerAddress.Location = new System.Drawing.Point(19, 282);
this.lblPerAddress.Name = "lblPerAddress";
this.lblPerAddress.Size = new System.Drawing.Size(77, 35);
this.lblPerAddress.TabIndex = 20;
this.lblPerAddress.Text = "户籍地址:";
//
// lblCourseSelected
//
this.lblCourseSelected.Location = new System.Drawing.Point(19, 422);
this.lblCourseSelected.Name = "lblCourseSelected";
this.lblCourseSelected.Size = new System.Drawing.Size(87, 40);
this.lblCourseSelected.TabIndex = 26;
this.lblCourseSelected.Text = "课程选择:";
//
// lblStdEnNo
//
this.lblStdEnNo.Location = new System.Drawing.Point(19, 32);
this.lblStdEnNo.Name = "lblStdEnNo";
this.lblStdEnNo.Size = new System.Drawing.Size(96, 26);
this.lblStdEnNo.TabIndex = 30;
this.lblStdEnNo.Text = "注册编号";
//
// lblStdEnNoDetail
//
this.lblStdEnNoDetail.Location = new System.Drawing.Point(164, 34);
this.lblStdEnNoDetail.Name = "lblStdEnNoDetail";
this.lblStdEnNoDetail.Size = new System.Drawing.Size(192, 25);
this.lblStdEnNoDetail.TabIndex = 29;
//
// lblTelephone
//
this.lblTelephone.Location = new System.Drawing.Point(19, 375);
this.lblTelephone.Name = "lblTelephone";
this.lblTelephone.Size = new System.Drawing.Size(77, 17);
this.lblTelephone.TabIndex = 22;
this.lblTelephone.Text = "电话:";
//
// lblAddress
//
this.lblAddress.Location = new System.Drawing.Point(19, 181);
this.lblAddress.Name = "lblAddress";
this.lblAddress.Size = new System.Drawing.Size(66, 25);
this.lblAddress.TabIndex = 19;
this.lblAddress.Text = "地址:";
//
// lblName
//
this.lblName.Location = new System.Drawing.Point(19, 78);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(66, 24);
this.lblName.TabIndex = 17;
this.lblName.Text = "姓名:";
//
// btnFinish
//
this.btnFinish.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnFinish.Location = new System.Drawing.Point(371, 576);
this.btnFinish.Name = "btnFinish";
this.btnFinish.Size = new System.Drawing.Size(90, 25);
this.btnFinish.TabIndex = 11;
this.btnFinish.Text = "完成(&F)";
//
// btnSaveDetails
//
this.btnSaveDetails.Location = new System.Drawing.Point(240, 576);
this.btnSaveDetails.Name = "btnSaveDetails";
this.btnSaveDetails.Size = new System.Drawing.Size(115, 25);
this.btnSaveDetails.TabIndex = 12;
this.btnSaveDetails.Text = "创建实例(&C)";
this.btnSaveDetails.Click += new System.EventHandler(this.btnSaveDetails_Click);
//
// DisplayStudentDetailsForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(470, 608);
this.Controls.Add(this.btnSaveDetails);
this.Controls.Add(this.btnFinish);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DisplayStudentDetailsForm";
this.ShowInTaskbar = false;
this.Text = "显示详细信息";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnFinish_Click(object sender, System.EventArgs e)
{
this.Close();
}
//create instance of Student type
private void btnSaveDetails_Click(object sender, System.EventArgs e)
{
string existsCourses = this.lblCoursesDetail.Text.Trim();
string courseType = "";
if(string.Compare(this.lblCourseTypeDetail.Text,Student.StudentType.FullTime.ToString(),false)==0)
{
courseType = Student.StudentType.FullTime.ToString();
}
else if(string.Compare(this.lblCourseTypeDetail.Text,Student.StudentType.PartTime.ToString(),false)==0)
{
courseType = Student.StudentType.PartTime.ToString();
}
Student objStud = new Student(this.lblStdEnNoDetail.Text,this.lblNameDetails.Text,long.Parse(this.lblTelephoneDetail.Text),this.lblAddressDetail.Text,this.lblPerAddressDetail.Text,existsCourses,courseType);
MessageBox.Show("包含所有学生详细信息的 student 实例已创建");
btnSaveDetails.Enabled = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -