📄 frmnewclass.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Student
{
using Aptech.Student.DataAccess;
/// <summary>
/// frmNewClass 的摘要说明。
/// </summary>
public class frmNewClass : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtClassName;
private System.Windows.Forms.DateTimePicker txtEntranceDate;
private System.Windows.Forms.TextBox txtRemark;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Button btnClose;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmNewClass()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtClassName = new System.Windows.Forms.TextBox();
this.txtEntranceDate = new System.Windows.Forms.DateTimePicker();
this.txtRemark = new System.Windows.Forms.TextBox();
this.btnSubmit = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtRemark);
this.groupBox1.Controls.Add(this.txtEntranceDate);
this.groupBox1.Controls.Add(this.txtClassName);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(-8, -8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(488, 296);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "名称:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 48);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "入学日期:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.TabIndex = 2;
this.label3.Text = "备注:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtClassName
//
this.txtClassName.Location = new System.Drawing.Point(120, 16);
this.txtClassName.Name = "txtClassName";
this.txtClassName.Size = new System.Drawing.Size(160, 21);
this.txtClassName.TabIndex = 3;
this.txtClassName.Text = "";
//
// txtEntranceDate
//
this.txtEntranceDate.Location = new System.Drawing.Point(120, 48);
this.txtEntranceDate.Name = "txtEntranceDate";
this.txtEntranceDate.Size = new System.Drawing.Size(160, 21);
this.txtEntranceDate.TabIndex = 4;
//
// txtRemark
//
this.txtRemark.Location = new System.Drawing.Point(120, 80);
this.txtRemark.Multiline = true;
this.txtRemark.Name = "txtRemark";
this.txtRemark.Size = new System.Drawing.Size(320, 84);
this.txtRemark.TabIndex = 5;
this.txtRemark.Text = "";
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(152, 296);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(75, 22);
this.btnSubmit.TabIndex = 1;
this.btnSubmit.Text = "建立";
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(240, 296);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 22);
this.btnClose.TabIndex = 2;
this.btnClose.Text = "关闭";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// frmNewClass
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(472, 326);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(480, 360);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(480, 360);
this.Name = "frmNewClass";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "新建班";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Classs classs = new Classs();
try
{
classs.InsertClass(
txtClassName.Text,
txtEntranceDate.Value,
txtRemark.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
MessageBox.Show("创建成功。");
}
private void btnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -