📄 stms_newstu.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
/// <summary>
/// STMS_newstu 的摘要说明。
/// </summary>
public class STMS_newstu : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox TB2;
private System.Windows.Forms.TextBox TB4;
private System.Windows.Forms.TextBox TB6;
private System.Windows.Forms.TextBox TB7;
private System.Windows.Forms.TextBox TB8;
private System.Windows.Forms.TextBox TB5;
private System.Windows.Forms.TextBox TB1;
private System.Windows.Forms.TextBox TB3;
private System.Windows.Forms.ComboBox CB1;
private System.Windows.Forms.DateTimePicker DP;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public STMS_newstu()
{
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(STMS_newstu));
this.TB2 = new System.Windows.Forms.TextBox();
this.TB4 = new System.Windows.Forms.TextBox();
this.TB6 = new System.Windows.Forms.TextBox();
this.TB7 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.TB8 = new System.Windows.Forms.TextBox();
this.TB5 = new System.Windows.Forms.TextBox();
this.TB1 = new System.Windows.Forms.TextBox();
this.TB3 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.CB1 = new System.Windows.Forms.ComboBox();
this.DP = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// TB2
//
this.TB2.Location = new System.Drawing.Point(288, 32);
this.TB2.Name = "TB2";
this.TB2.Size = new System.Drawing.Size(136, 21);
this.TB2.TabIndex = 30;
this.TB2.Text = "";
//
// TB4
//
this.TB4.Location = new System.Drawing.Point(288, 64);
this.TB4.Name = "TB4";
this.TB4.Size = new System.Drawing.Size(136, 21);
this.TB4.TabIndex = 31;
this.TB4.Text = "";
//
// TB6
//
this.TB6.Location = new System.Drawing.Point(288, 104);
this.TB6.Name = "TB6";
this.TB6.Size = new System.Drawing.Size(136, 21);
this.TB6.TabIndex = 28;
this.TB6.Text = "";
//
// TB7
//
this.TB7.Location = new System.Drawing.Point(288, 140);
this.TB7.Name = "TB7";
this.TB7.Size = new System.Drawing.Size(136, 21);
this.TB7.TabIndex = 29;
this.TB7.Text = "";
//
// label3
//
this.label3.Image = ((System.Drawing.Image)(resources.GetObject("label3.Image")));
this.label3.Location = new System.Drawing.Point(215, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(55, 16);
this.label3.TabIndex = 34;
this.label3.Text = "籍 贯";
//
// label4
//
this.label4.Image = ((System.Drawing.Image)(resources.GetObject("label4.Image")));
this.label4.Location = new System.Drawing.Point(215, 32);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 16);
this.label4.TabIndex = 35;
this.label4.Text = "专 业";
//
// label5
//
this.label5.Image = ((System.Drawing.Image)(resources.GetObject("label5.Image")));
this.label5.Location = new System.Drawing.Point(215, 140);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 16);
this.label5.TabIndex = 32;
this.label5.Text = "电 话";
//
// label6
//
this.label6.Image = ((System.Drawing.Image)(resources.GetObject("label6.Image")));
this.label6.Location = new System.Drawing.Point(210, 104);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(60, 16);
this.label6.TabIndex = 33;
this.label6.Text = " 民 族";
//
// button3
//
this.button3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button3.BackgroundImage")));
this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image")));
this.button3.Location = new System.Drawing.Point(335, 245);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(88, 35);
this.button3.TabIndex = 27;
this.button3.Text = "退 出";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button2.BackgroundImage")));
this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Location = new System.Drawing.Point(190, 245);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(88, 35);
this.button2.TabIndex = 26;
this.button2.Text = "重 置";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button1.BackgroundImage")));
this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Location = new System.Drawing.Point(48, 245);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 35);
this.button1.TabIndex = 25;
this.button1.Text = "录 入";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
this.label1.Location = new System.Drawing.Point(12, 140);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(52, 18);
this.label1.TabIndex = 24;
this.label1.Text = "性 别";
//
// TB8
//
this.TB8.Location = new System.Drawing.Point(288, 175);
this.TB8.Name = "TB8";
this.TB8.Size = new System.Drawing.Size(136, 21);
this.TB8.TabIndex = 15;
this.TB8.Text = "";
//
// TB5
//
this.TB5.Location = new System.Drawing.Point(72, 104);
this.TB5.Name = "TB5";
this.TB5.Size = new System.Drawing.Size(136, 21);
this.TB5.TabIndex = 13;
this.TB5.Text = "";
//
// TB1
//
this.TB1.Location = new System.Drawing.Point(72, 32);
this.TB1.Name = "TB1";
this.TB1.Size = new System.Drawing.Size(136, 21);
this.TB1.TabIndex = 14;
this.TB1.Text = "";
//
// TB3
//
this.TB3.Location = new System.Drawing.Point(72, 72);
this.TB3.Name = "TB3";
this.TB3.Size = new System.Drawing.Size(136, 21);
this.TB3.TabIndex = 18;
this.TB3.Text = "";
//
// label2
//
this.label2.Image = ((System.Drawing.Image)(resources.GetObject("label2.Image")));
this.label2.Location = new System.Drawing.Point(12, 175);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 16);
this.label2.TabIndex = 22;
this.label2.Text = "出生年月";
//
// label7
//
this.label7.Image = ((System.Drawing.Image)(resources.GetObject("label7.Image")));
this.label7.Location = new System.Drawing.Point(210, 175);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(60, 16);
this.label7.TabIndex = 23;
this.label7.Text = "家庭住址";
//
// label9
//
this.label9.Image = ((System.Drawing.Image)(resources.GetObject("label9.Image")));
this.label9.Location = new System.Drawing.Point(12, 112);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(52, 18);
this.label9.TabIndex = 21;
this.label9.Text = "姓 名";
//
// label10
//
this.label10.Image = ((System.Drawing.Image)(resources.GetObject("label10.Image")));
this.label10.Location = new System.Drawing.Point(12, 72);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(52, 18);
this.label10.TabIndex = 19;
this.label10.Text = "班 级";
//
// label11
//
this.label11.Image = ((System.Drawing.Image)(resources.GetObject("label11.Image")));
this.label11.Location = new System.Drawing.Point(12, 32);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(53, 18);
this.label11.TabIndex = 20;
this.label11.Text = "学 号";
//
// CB1
//
this.CB1.Items.AddRange(new object[] {
"男",
"女"});
this.CB1.Location = new System.Drawing.Point(70, 135);
this.CB1.Name = "CB1";
this.CB1.Size = new System.Drawing.Size(135, 20);
this.CB1.TabIndex = 36;
this.CB1.Text = "男";
//
// DP
//
this.DP.Location = new System.Drawing.Point(70, 170);
this.DP.Name = "DP";
this.DP.Size = new System.Drawing.Size(136, 21);
this.DP.TabIndex = 37;
//
// STMS_newstu
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(464, 309);
this.Controls.Add(this.DP);
this.Controls.Add(this.CB1);
this.Controls.Add(this.TB2);
this.Controls.Add(this.TB4);
this.Controls.Add(this.TB6);
this.Controls.Add(this.TB7);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.label6);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.TB8);
this.Controls.Add(this.TB5);
this.Controls.Add(this.TB1);
this.Controls.Add(this.TB3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label7);
this.Controls.Add(this.label9);
this.Controls.Add(this.label10);
this.Controls.Add(this.label11);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "STMS_newstu";
this.Text = "新生注册";
this.Load += new System.EventHandler(this.STMS_newstu_Load);
this.ResumeLayout(false);
}
#endregion
private void STMS_newstu_Load(object sender, System.EventArgs e)
{
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.TB1.Text ="";
this.TB2.Text ="";
this.TB3.Text ="";
this.TB4.Text ="";
this.TB5.Text ="";
this.TB6.Text ="";
this.TB7.Text ="";
this.TB8.Text ="";
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
if(this.TB1.Text !="")
{
if (this.TB3 .Text !="")
{
if (this.TB5.Text !="")
{
if (this.TB8.Text !="")
{
System.Data.SqlClient.SqlConnection cn;
string str ="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student;Data Source=(local);";
cn = new System.Data.SqlClient.SqlConnection(str);
cn.Open();
System.Data.SqlClient.SqlCommand cmd;
cmd = new System.Data.SqlClient.SqlCommand("insert into Student(student_no,student_name,sex,birthday,[naative palace],department,tel,address,folk,class,Appearance) VALUES ('"+ this.TB1.Text +"','"+ this.TB5.Text +"','"+ this.CB1.Text +"','"+ this.DP.Text +"' ,'"+ this.TB4.Text +"','"+ this.TB2.Text +"','"+ this.TB7.Text +"','"+ this.TB8.Text +"','"+ this.TB6.Text +"','"+ this.TB3.Text +"','在校')",cn);
cmd.ExecuteNonQuery();
MessageBox.Show("成功!");
cn.Close();
}
else
{
MessageBox.Show("输入正确的电话格式!");
}
}
else
{
MessageBox.Show("姓名不能为空!");
}
}
else
{
MessageBox.Show("班级不能为空!");
}
}
else
{
MessageBox.Show("学号不能为空!");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button4_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -