📄 nwst.cs
字号:
this.userXB.Size = new System.Drawing.Size(100, 20);
this.userXB.TabIndex = 3;
this.userXB.SelectedIndexChanged += new System.EventHandler(this.userXB_SelectedIndexChanged);
//
// label8
//
this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label8.ForeColor = System.Drawing.Color.MediumSlateBlue;
this.label8.Image = ((System.Drawing.Image)(resources.GetObject("label8.Image")));
this.label8.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label8.Location = new System.Drawing.Point(24, 328);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(64, 23);
this.label8.TabIndex = 12;
this.label8.Text = "学院";
//
// userXY
//
this.userXY.Items.AddRange(new object[] {
"计算机",
"软件",
"外国语",
"自动化",
"通信"});
this.userXY.Location = new System.Drawing.Point(104, 320);
this.userXY.Name = "userXY";
this.userXY.Size = new System.Drawing.Size(100, 20);
this.userXY.TabIndex = 5;
//
// label9
//
this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label9.ForeColor = System.Drawing.Color.MediumSlateBlue;
this.label9.Image = ((System.Drawing.Image)(resources.GetObject("label9.Image")));
this.label9.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label9.Location = new System.Drawing.Point(24, 376);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(64, 23);
this.label9.TabIndex = 14;
this.label9.Text = "电话";
//
// userDH
//
this.userDH.Location = new System.Drawing.Point(104, 368);
this.userDH.Name = "userDH";
this.userDH.TabIndex = 6;
this.userDH.Text = "";
//
// label10
//
this.label10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label10.ForeColor = System.Drawing.Color.MediumSlateBlue;
this.label10.Image = ((System.Drawing.Image)(resources.GetObject("label10.Image")));
this.label10.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label10.Location = new System.Drawing.Point(24, 416);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(64, 23);
this.label10.TabIndex = 16;
this.label10.Text = "地址";
//
// userDZ
//
this.userDZ.Location = new System.Drawing.Point(104, 416);
this.userDZ.Name = "userDZ";
this.userDZ.TabIndex = 7;
this.userDZ.Text = "";
//
// label11
//
this.label11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label11.ForeColor = System.Drawing.Color.MediumSlateBlue;
this.label11.Image = ((System.Drawing.Image)(resources.GetObject("label11.Image")));
this.label11.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label11.Location = new System.Drawing.Point(24, 272);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(64, 23);
this.label11.TabIndex = 18;
this.label11.Text = "生日";
//
// userSR
//
this.userSR.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.userSR.Location = new System.Drawing.Point(104, 272);
this.userSR.Name = "userSR";
this.userSR.Size = new System.Drawing.Size(100, 21);
this.userSR.TabIndex = 4;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(0, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(352, 48);
this.pictureBox2.TabIndex = 20;
this.pictureBox2.TabStop = false;
//
// button1
//
this.button1.BackColor = System.Drawing.Color.DeepSkyBlue;
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(56, 456);
this.button1.Name = "button1";
this.button1.TabIndex = 8;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.DeepSkyBlue;
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Location = new System.Drawing.Point(160, 456);
this.button2.Name = "button2";
this.button2.TabIndex = 9;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// NWST
//
this.AcceptButton = this.button1;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.LemonChiffon;
this.CancelButton = this.button2;
this.ClientSize = new System.Drawing.Size(352, 483);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.userSR);
this.Controls.Add(this.label11);
this.Controls.Add(this.userDZ);
this.Controls.Add(this.userDH);
this.Controls.Add(this.userPWD);
this.Controls.Add(this.userName);
this.Controls.Add(this.userXH);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.userXY);
this.Controls.Add(this.label8);
this.Controls.Add(this.userXB);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = "NWST";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "增加学生档案";
this.Load += new System.EventHandler(this.NWST_Load);
this.ResumeLayout(false);
}
#endregion
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{
string stuID=this.userXH.Text.Trim();
string stuPWD=this.userPWD.Text.Trim();
string stuName=this.userName.Text.Trim();
string stuSex=this.userXB.SelectedItem.ToString();
string stuClass=this.userXY.SelectedItem.ToString();
string stuTEL=this.userDH.Text.Trim();
string stuAddress=this.userDZ.Text.Trim();
System.DateTime dt1=this.userSR.Value;
System.DateTime dt=dt1.Date;
if(stuID=="")
{
MessageBox.Show("学号不能为空");
}
else if(stuPWD=="")
{
MessageBox.Show("密码不能为空");
}
else if(stuName=="")
{
MessageBox.Show("姓名不能为空");
}
else
{
DataAccess ds=new DataAccess();
string sql="insert into student (stuid,name,password,sex,class,tel,address,btime) values ('"+stuID+"','"+stuName+"','"+stuPWD+"','"+stuSex+"','"+stuClass+"','"+stuTEL+"','"+stuAddress+"','"+dt+"')";
if(ds.ExecuteSQL(sql))
{
MessageBox.Show("添加成功");
this.Close();
}
else
{
MessageBox.Show("添加失败");
}
}
}
private void userXB_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void NWST_Load(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -