📄 stms_stutest.cs
字号:
this.button4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button4.BackgroundImage")));
this.button4.Cursor = System.Windows.Forms.Cursors.Hand;
this.button4.Location = new System.Drawing.Point(488, 360);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(80, 32);
this.button4.TabIndex = 19;
this.button4.Text = "退 出";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// groupBox1
//
this.groupBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("groupBox1.BackgroundImage")));
this.groupBox1.Controls.Add(this.textBox8);
this.groupBox1.Controls.Add(this.textBox7);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Location = new System.Drawing.Point(328, 232);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(160, 80);
this.groupBox1.TabIndex = 38;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "条件";
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(88, 48);
this.textBox8.Name = "textBox8";
this.textBox8.ReadOnly = true;
this.textBox8.Size = new System.Drawing.Size(72, 21);
this.textBox8.TabIndex = 3;
this.textBox8.Text = "";
this.textBox8.TextChanged += new System.EventHandler(this.textBox8_TextChanged);
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(0, 48);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(72, 21);
this.textBox7.TabIndex = 2;
this.textBox7.Text = "";
//
// label10
//
this.label10.Image = ((System.Drawing.Image)(resources.GetObject("label10.Image")));
this.label10.Location = new System.Drawing.Point(96, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(56, 16);
this.label10.TabIndex = 1;
this.label10.Text = "考勤编号";
//
// label9
//
this.label9.Image = ((System.Drawing.Image)(resources.GetObject("label9.Image")));
this.label9.Location = new System.Drawing.Point(8, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(56, 16);
this.label9.TabIndex = 0;
this.label9.Text = "输入学号";
//
// button5
//
this.button5.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button5.BackgroundImage")));
this.button5.Cursor = System.Windows.Forms.Cursors.Hand;
this.button5.Location = new System.Drawing.Point(488, 280);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(80, 32);
this.button5.TabIndex = 39;
this.button5.Text = "查 询";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Image = ((System.Drawing.Image)(resources.GetObject("button6.Image")));
this.button6.Location = new System.Drawing.Point(488, 240);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(80, 32);
this.button6.TabIndex = 40;
this.button6.Text = "浏 览";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// STMS_StuTest
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(584, 397);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.label6);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label5);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.dg);
this.Controls.Add(this.button3);
this.Controls.Add(this.button4);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = "STMS_StuTest";
this.Text = "学生考勤";
((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
System.Data.SqlClient.SqlConnection cn;
System.Data.SqlClient.SqlDataAdapter da;
System.Data.SqlClient.SqlCommand myCommand;
System.Data.DataSet ds = new DataSet();
private void conn()
{
string cnString;
cnString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student;Data Source=(local);";
cn = new SqlConnection(cnString);
cn.Open();
myCommand = new SqlCommand();
da = new SqlDataAdapter(myCommand.CommandText,cn);
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
conn();
textBox8.ReadOnly=false;
myCommand.Connection = cn;
myCommand.CommandText = "insert_stm";
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter sampParm;
sampParm = myCommand.Parameters.Add("@Student_No",SqlDbType.Int,4);
sampParm.Value = textBox7.Text;
sampParm = myCommand.Parameters.Add("@Student_id", SqlDbType.Int);
sampParm.Value = textBox8.Text;
sampParm = myCommand.Parameters.Add("@Lateness", SqlDbType.Char,10);
sampParm.Value = textBox1.Text;
sampParm = myCommand.Parameters.Add("@Absence", SqlDbType.Char,10);
sampParm.Value = textBox3.Text;
sampParm = myCommand.Parameters.Add("@InCl", SqlDbType.Char,10);
sampParm.Value = textBox2.Text;
sampParm = myCommand.Parameters.Add("@Month", SqlDbType.Int);
sampParm.Value = comboBox2.Text;
sampParm = myCommand.Parameters.Add("@Term", SqlDbType.Char,10);
sampParm.Value = comboBox1.Text;
sampParm = myCommand.Parameters.Add("@Score", SqlDbType.Float);
sampParm.Value = textBox4.Text;
da.SelectCommand = myCommand;
da.Fill(ds);
myCommand.ExecuteNonQuery();
// dg.Refresh();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally{MessageBox.Show("您增加的行已输入表中,请浏览!");}
}
private void button3_Click(object sender, System.EventArgs e)
{
if (textBox2.Text !="")
{
if (textBox3.Text !="")
{
if (textBox4.Text !="")
{
try
{
conn();
myCommand.Connection = cn;
myCommand.CommandText = "delect_stm";
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter sampParm;
sampParm = myCommand.Parameters.Add("@Student_no", SqlDbType.Int, 4);
sampParm.Value = textBox7.Text;
da.SelectCommand = myCommand;
da.Fill (ds);
myCommand.ExecuteNonQuery();
this.dg.DataSource = ds.Tables[0];
myCommand.Connection.Close();
}
finally
{
MessageBox.Show("该记录已删除,请重新浏览表!");
}
}
else
{}
}
else
{}
}
else
{
MessageBox.Show("请输入相关信息!");
}
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
conn();
myCommand.Connection = cn;
myCommand.CommandText = "delect_stm";
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter sampParm;
sampParm = myCommand.Parameters.Add("@Student_no", SqlDbType.Int ,4);
sampParm.Value = textBox7.Text;
da.SelectCommand = myCommand;
da.Fill (ds);
myCommand.ExecuteNonQuery();
this.dg.DataSource = ds.Tables[0];
myCommand.Connection.Close();
}
finally
{
MessageBox.Show("该记录已删除,请重新浏览表!");
}
}
private void button5_Click(object sender, System.EventArgs e)
{
try
{
conn();
myCommand.Connection = cn;
myCommand.CommandText = "search_STM";
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter sampParm;
sampParm = myCommand.Parameters.Add("@Student_no", SqlDbType.Int, 4);
sampParm.Value = textBox7.Text;
da.SelectCommand = myCommand;
ds.Clear();
da.Fill (ds);
myCommand.ExecuteNonQuery();
this.dg.DataSource = ds.Tables[0];
myCommand.Connection.Close();
}
finally
{
MessageBox.Show("查寻结果已完成!");
}
}
private void button4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
// if(this.radioButton1.Checked = True)
{
}
// else
{
}
}
private void button6_Click(object sender, System.EventArgs e)
{
conn();
myCommand.Connection = cn;
myCommand.CommandText = "select_stm";
myCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand =myCommand;
ds.Clear();
da.Fill(ds);
dg.DataSource = ds.Tables[0];
textBox8.ReadOnly=false;
}
private void textBox8_TextChanged(object sender, System.EventArgs e)
{
textBox8.ReadOnly=false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -