đây là code nhập vào SQL - mình dùng store
If (cbthu_2.Checked = True And cbthu_3.Checked = True And cbthu_4.Checked = True And cbthu_5.Checked = True And cbthu_6.Checked = True And cbthu_7.Checked = True And cbthu_cn.Checked = True) Or (cbthu_2.Checked = True Or cbthu_3.Checked = True Or cbthu_4.Checked = True Or cbthu_5.Checked = True Or cbthu_6.Checked = True Or cbthu_7.Checked = True Or cbthu_cn.Checked = True) Then
If (cbca_s.Checked = True) Then
cmd.Connection = cnn
cmd.CommandText = sql1
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@ID_Monhoc", SqlDbType.NVarChar).Value = ddlmonhoc.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Giaovien", SqlDbType.NVarChar).Value = ddlgv.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Lop", SqlDbType.NVarChar).Value = ddllop.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Phong", SqlDbType.NVarChar).Value = ddlphong.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@Ca", SqlDbType.NVarChar).Value = Ca.Trim()
cmd.Parameters.AddWithValue("@Tu", SqlDbType.Date).Value = Convert.ToDateTime(aspxdetu.Value.ToString())
cmd.Parameters.AddWithValue("@Den", SqlDbType.Date).Value = Convert.ToDateTime(aspxdeden.Value.ToString())
cmd.Parameters.AddWithValue("@Thu2", SqlDbType.NVarChar).Value = Tietthu2.Trim()
cmd.Parameters.AddWithValue("@Thu3", SqlDbType.NVarChar).Value = Tietthu3.Trim()
cmd.Parameters.AddWithValue("@Thu4", SqlDbType.NVarChar).Value = Tietthu4.Trim()
cmd.Parameters.AddWithValue("@Thu5", SqlDbType.NVarChar).Value = Tietthu5.Trim()
cmd.Parameters.AddWithValue("@Thu6", SqlDbType.NVarChar).Value = Tietthu6.Trim()
cmd.Parameters.AddWithValue("@Thu7", SqlDbType.NVarChar).Value = Tietthu7.Trim()
cmd.Parameters.AddWithValue("@Chunhat", SqlDbType.NVarChar).Value = Tietchunhat.Trim()
MsgBox(sql1)
cmd.ExecuteNonQuery()
Response.Write("Nhập thành công")
End If
If (cbca_c.Checked = True) Then
cmd.Connection = cnn
cmd.CommandText = "nhaptkb"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@ID_Monhoc", SqlDbType.NVarChar).Value = ddlmonhoc.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Giaovien", SqlDbType.NVarChar).Value = ddlgv.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Lop", SqlDbType.NVarChar).Value = ddllop.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@ID_Phong", SqlDbType.NVarChar).Value = ddlphong.SelectedItem.Text.Trim()
cmd.Parameters.AddWithValue("@Ca", SqlDbType.NVarChar).Value = Ca.Trim()
cmd.Parameters.AddWithValue("@Tu", SqlDbType.Date).Value = Convert.ToDateTime(aspxdetu.Value.ToString())
cmd.Parameters.AddWithValue("@Den", SqlDbType.Date).Value = Convert.ToDateTime(aspxdeden.Value.ToString())
cmd.Parameters.AddWithValue("@Thu2", SqlDbType.NVarChar).Value = Tietthu2.Trim()
cmd.Parameters.AddWithValue("@Thu3", SqlDbType.NVarChar).Value = Tietthu3.Trim()
cmd.Parameters.AddWithValue("@Thu4", SqlDbType.NVarChar).Value = Tietthu4.Trim()
cmd.Parameters.AddWithValue("@Thu5", SqlDbType.NVarChar).Value = Tietthu5.Trim()
cmd.Parameters.AddWithValue("@Thu6", SqlDbType.NVarChar).Value = Tietthu6.Trim()
cmd.Parameters.AddWithValue("@Thu7", SqlDbType.NVarChar).Value = Tietthu7.Trim()
cmd.Parameters.AddWithValue("@Chunhat", SqlDbType.NVarChar).Value = Tietchunhat.Trim()
cmd.ExecuteNonQuery()
Response.Write("Nhập thành công")
End If
End If
mình phải post ra 2 post vì dài quá