📄 stms_jc.cs
字号:
this.label5.TabIndex = 17;
this.label5.Text = "奖 分";
//
// tbscore
//
this.tbscore.Location = new System.Drawing.Point(88, 384);
this.tbscore.Name = "tbscore";
this.tbscore.Size = new System.Drawing.Size(152, 21);
this.tbscore.TabIndex = 16;
this.tbscore.Text = "";
//
// label9
//
this.label9.Font = new System.Drawing.Font("华文行楷", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label9.Image = ((System.Drawing.Image)(resources.GetObject("label9.Image")));
this.label9.Location = new System.Drawing.Point(296, 384);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(80, 23);
this.label9.TabIndex = 19;
this.label9.Text = " 惩 分";
//
// tbpscrose
//
this.tbpscrose.Location = new System.Drawing.Point(392, 384);
this.tbpscrose.Name = "tbpscrose";
this.tbpscrose.Size = new System.Drawing.Size(136, 21);
this.tbpscrose.TabIndex = 18;
this.tbpscrose.Text = "";
//
// button6
//
this.button6.BackColor = System.Drawing.SystemColors.HighlightText;
this.button6.Cursor = System.Windows.Forms.Cursors.Hand;
this.button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button6.Font = new System.Drawing.Font("华文行楷", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button6.Image = ((System.Drawing.Image)(resources.GetObject("button6.Image")));
this.button6.Location = new System.Drawing.Point(432, 0);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(96, 32);
this.button6.TabIndex = 20;
this.button6.Text = "浏 览";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// STMS_JC
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(550, 491);
this.Controls.Add(this.button6);
this.Controls.Add(this.label9);
this.Controls.Add(this.tbpscrose);
this.Controls.Add(this.tbscore);
this.Controls.Add(this.tbstno);
this.Controls.Add(this.tbc);
this.Controls.Add(this.tbstname);
this.Controls.Add(this.tba);
this.Controls.Add(this.tbp);
this.Controls.Add(this.label5);
this.Controls.Add(this.label8);
this.Controls.Add(this.dt);
this.Controls.Add(this.cb);
this.Controls.Add(this.label7);
this.Controls.Add(this.button5);
this.Controls.Add(this.label6);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button3);
this.Controls.Add(this.button4);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "STMS_JC";
this.Text = "奖惩情况";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += new System.EventHandler(this.STMS_JC_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
System.Int32 fmval;
System.Int32 ic;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
// [STAThread]
// static void Main()
// {
// Application.Run(new STMS_JC());
// }
System.Data.DataSet dss;
System.Data.DataSet dsval;
private void STMS_JC_Load(object sender, System.EventArgs e)
{
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{
if (this.tbstname.Text !="" )
{
if(this.tbstno.Text !="")
{
if(this.cb.Text !="")
{
WindowsApplication1.stumclass cla;
cla = new WindowsApplication1.stumclass();
System.Double ascore =Convert.ToInt32(this.tbpscrose.Text);
System.Double bscrore =Convert.ToInt32(this.tbscore.Text);
System.Int32 stutbno =System.Convert.ToInt32(this.tbstno.Text);
System.DateTime fdate = Convert.ToDateTime(this.dt.Text);
cla.STMS_JC(this.tbstname.Text ,stutbno ,this.tba.Text ,this.tbp.Text,fdate ,this.cb.Text,bscrore ,ascore);
this.tbstno.Text ="";
this.tbstname.Text ="";
this.tbscore.Text ="";
this.tbpscrose.Text ="";
this.tbp.Text ="";
this.tba.Text ="";
}
else
{
MessageBox.Show("输入学期!");
}
}
else
{
MessageBox.Show("输入学号!");
}
}
else
{
MessageBox.Show("请输入姓名!");
}
}
private void button4_Click(object sender, System.EventArgs e)
{
if (this.tbstname.Text !="" )
{
if(this.tbstno.Text !="")
{
if(this.cb.Text !="")
{
WindowsApplication1.stumclass cla;
cla = new WindowsApplication1.stumclass();
System.Int32 stutbno =System.Convert.ToInt32(this.tbstno.Text);
cla.STMS_JCDELE(stutbno);
}
else
{
MessageBox.Show("输入学期!");
}
}
else
{
MessageBox.Show("输入学号!");
}
}
else
{
MessageBox.Show("请输入姓名!");
}
//==============================================================================
System.Data.DataSet ds = new DataSet();
SqlConnection cn;
System.Data.SqlClient.SqlDataAdapter da = new SqlDataAdapter();
System.Data.SqlClient.SqlCommand cmd = new SqlCommand();
cn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student;Data Source=(local);");
try
{
cmd = new SqlCommand("dbo.allval",cn);
cmd.CommandType =CommandType.StoredProcedure;
da.SelectCommand =cmd;
da.Fill(ds);
dsval = ds;
ic =2;
this.dataGrid1.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button5_Click(object sender, System.EventArgs e)
{
if(this.tbc.Text != "")
{
WindowsApplication1.stumclass cla;
cla = new WindowsApplication1.stumclass();
cla.ds.Clear();
cla.f =1;
System.Int32 stutbno = System.Convert.ToInt32(this.tbc.Text);
cla.STMS_Dbkation("","",stutbno);
ic =1;
this.dataGrid1.DataSource = cla.ds.Tables[0];
dss=cla.ds;
cla.f =0;
}
else
{
MessageBox.Show("学号不能为空!");
}
}
private void dataGrid_CurrentCellChanged(object sender,System.EventArgs e)
{
WindowsApplication1.stumclass cla;
cla = new WindowsApplication1.stumclass();
System.Data.DataRow[] Row;
System.Windows.Forms.DataGridCell SELCELL = dataGrid1.CurrentCell;
string id = Convert.ToString(dataGrid1[SELCELL.RowNumber,0]);
fmval = Convert.ToInt32(id);
Row = cla.ds.Tables["RePunishment"].Select("Student_id='" + id + "'");
this.tbstname.Text=Convert.ToString(Row[0].ItemArray[1]);
this.tbstno.Text=Convert.ToString(Row[0].ItemArray[2]);
this.tba.Text =Convert.ToString(Row[0].ItemArray[3]);
this.tbp.Text =Convert.ToString(Row[0].ItemArray[4]);
this.tbscore.Text =Convert.ToString(Row[0].ItemArray[7]);
this.tbpscrose.Text =Convert.ToString(Row[0].ItemArray[8]);
}
private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
//this.tbstname.Text = this.dataGrid1.it(dataGrid1.CurrentCell.RowNumber,1);
// Me.DTPB.Value = Me.DGAbook.Item(DGAbook.CurrentCell.RowNumber, 3).ToString;
// Me.TBfem.Text = Me.DGAbook.Item(DGAbook.CurrentCell.RowNumber, 2).ToString;
// Me.TBRemk.Text = Me.DGAbook.Item(DGAbook.CurrentCell.RowNumber, 4).ToString;
}
private void button2_Click(object sender, System.EventArgs e)
{
System.Double ascore =0;
System.Double bscrore =0;
if (this.tbscore.Text !="")
{
if(this.tbpscrose.Text !="")
{
ascore =Convert.ToInt32(this.tbpscrose.Text);
bscrore =Convert.ToInt32(this.tbscore.Text);
}
else
{
ascore =0;
}
}
else
{
bscrore=0;
}
System.DateTime fdate = Convert.ToDateTime(this.dt.Text);
System.Int32 stutbno =System.Convert.ToInt32(this.tbstno.Text);
try
{
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("update RePunishment set Student_name = '"+ this.tbstname.Text +"',Student_No ='"+stutbno +"' ,Awards = '"+ this.tba.Text +"',PunItem ='"+ this.tbp.Text +"',StDate ='"+ fdate +"',Term ='"+ this.cb.Text +"',AwardsSore ='"+bscrore +"',PunItemScore ='"+ ascore+"' where student_id ='"+ fmval +"'",cn);
cmd.ExecuteNonQuery();
MessageBox.Show("更新成功!");
cn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
{
WindowsApplication1.stumclass cla;
cla = new WindowsApplication1.stumclass();
System.Data.DataRow[] Row;
System.Windows.Forms.DataGridCell SELCELL = dataGrid1.CurrentCell;
string id = Convert.ToString(dataGrid1[SELCELL.RowNumber,0]);
fmval =Convert.ToInt32(id);
// System.Int32 i = this.dataGrid1.CurrentRowIndex;
if (ic == 1)
{
Row = dss.Tables[0].Select("学生编号='" + id + "'");
}
else
{
Row = dsval.Tables[0].Select("学生编号='" + id + "'");
}
this.tbstname.Text=Convert.ToString(Row[0].ItemArray[1]);
this.tbstno.Text=Convert.ToString(Row[0].ItemArray[2]);
this.tba.Text =Convert.ToString(Row[0].ItemArray[3]);
this.tbp.Text =Convert.ToString(Row[0].ItemArray[4]);
this.tbscore.Text =Convert.ToString(Row[0].ItemArray[7]);
this.tbpscrose.Text =Convert.ToString(Row[0].ItemArray[8]);
}
private void dataGrid1_Navigate_1(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
private void button6_Click(object sender, System.EventArgs e)
{
System.Data.DataSet ds = new DataSet();
SqlConnection cn;
System.Data.SqlClient.SqlDataAdapter da = new SqlDataAdapter();
System.Data.SqlClient.SqlCommand cmd = new SqlCommand();
cn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student;Data Source=(local);");
try
{
cmd = new SqlCommand("dbo.allval",cn);
cmd.CommandType =CommandType.StoredProcedure;
da.SelectCommand =cmd;
da.Fill(ds);
dsval = ds;
ic =2;
this.dataGrid1.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -