日期:2014-05-17 浏览次数:20504 次
private void btnUpdate_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(Properties.Settings.Default.XkConnectionString);
string sql = "DELETE FROM StuCou WHERE StuNo=@StuNo";
SqlCommand cmd = new SqlCommand(sql,cn);
cmd.Parameters.Add("@StuNo", SqlDbType.NVarChar, 8).Value = CPublic.LoginInfo["StuNo"].ToString();
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
for (int i = 0; i < dgvSelectCourse.Rows.Count; i++)
{
sql = "insert StuCou(StuNo,CouNo,WillOrder,State) values(@StuNo,@CouNo,@WillOrder,@State)";
cmd = new SqlCommand(sql,cn);
cmd.Parameters.Add("@StuNo",SqlDbType.NVarChar,8).Value=CPublic.LoginInfo["StuNo"].ToString();
cmd.Parameters.Add("@CouNo", SqlDbType.NVarChar, 8).Value = dgvSelectCourse.Rows[i].Cells["SelectCouNo"].Value;
cmd.Parameters.Add("@WillOrder",SqlDbType.SmallInt).Value=i+1;
cmd.Parameters.Add("@State", SqlDbType.NVarChar, 2).Value = "报名";
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
ds.Tables["StuCou"].Clear();
getStuCou();
}