📄 student_electchoosecourse.aspx.cs
字号:
if (totalcount <= 2)
{
if (checkedCount1 == 1)
{
int checkedNumber = 0;
int teachingMaterial = 0;
for (int i = 0; i <= 199; i++)
{
if (a[i] != 0)
{
checkedNumber = i;
}
}
for (int i = 0; i <= 199; i++)
{
if (b[checkedNumber] != 0)
{
teachingMaterial = 1;
}
}
int yuding = 0;
for (int i = 0; i <= 199; i++)
{
if (i != checkedNumber && b[i] != 0)
{
yuding++;
}
}
if (yuding != 0)
{
Response.Write("<script>alert('你选择了其他选修课科目预定教材,但你没有选择此选修课!');history.back()</script>");
}
else
{
string courseName = GridView1.Rows[checkedNumber].Cells[2].Text.ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]);
con.Open();
string capacity1 = GridView1.Rows[checkedNumber].Cells[9].Text.ToString();
int capacity = Math.Abs(Convert.ToInt32(capacity1));
string choosed1 = GridView1.Rows[checkedNumber].Cells[10].Text.ToString();
int choosed = Math.Abs(Convert.ToInt32(choosed1));
choosed++;
string remain1 = GridView1.Rows[checkedNumber].Cells[11].Text.ToString();
int remain = Math.Abs(Convert.ToInt32(remain1));
remain--;
SqlCommand sd = new SqlCommand("select count(*) from ts_xs_stdChooseCoursesInfo where courseName = '" + courseName + "' and studyNumber ='"+ Session["stdUserName"].ToString() +"'", con);
int sdSQL = Convert.ToInt32(sd.ExecuteScalar());
if (sdSQL <= 0)
{
SqlCommand sd1 = new SqlCommand("select courseCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string courseCode = Convert.ToString(sd1.ExecuteScalar());
SqlCommand sd2 = new SqlCommand("select teacherCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string teacherCode = Convert.ToString(sd2.ExecuteScalar());
SqlCommand sd3 = new SqlCommand("select teacherName from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string teacherName = Convert.ToString(sd3.ExecuteScalar());
SqlCommand sd4 = new SqlCommand("select courseTime from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string courseTime = Convert.ToString(sd4.ExecuteScalar());
SqlCommand sd5 = new SqlCommand("select coursePlace from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string coursePlace = Convert.ToString(sd5.ExecuteScalar());
SqlCommand sd6 = new SqlCommand("select creditHour from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
int creditHour = Convert.ToInt32(sd6.ExecuteScalar());
SqlCommand sd7 = new SqlCommand("select weekPeriod from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
int weekPeriod = Convert.ToInt32(sd7.ExecuteScalar());
SqlCommand sd8 = new SqlCommand("select weekDateFrom from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string weekDateFrom = Convert.ToString(sd8.ExecuteScalar());
SqlCommand sd9 = new SqlCommand("select remark from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string remark = Convert.ToString(sd9.ExecuteScalar());
SqlCommand sd10 = new SqlCommand("select courseProperty from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string courseProperty = Convert.ToString(sd10.ExecuteScalar());
SqlCommand sd11 = new SqlCommand("select schoolArea from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string schoolArea = Convert.ToString(sd11.ExecuteScalar());
SqlCommand sd12 = new SqlCommand("select courseCollege from ts_xs_chooseCoursesInfo where courseName = '" + courseName + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
string courseCollege = Convert.ToString(sd12.ExecuteScalar());
string SQL = "insert into ts_xs_stdChooseCoursesInfo (studyNumber,studentName,IDcardNumber,college,speciality,teachedClass,adminClass,courseCode,ifChoose,ifTeachingMaterial,courseName,teacherCode,teacherName,courseTime,coursePlace,creditHour,weekPeriod,weekDateFrom,remark,courseProperty,schoolArea,courseCollege,courseStudyYear,courseSemester,chooseDate) values('" + Session["stdUserName"].ToString() + "','" + Session["stdName"].ToString() + "','" + Session["stdIDcardNumber"].ToString() + "','"+ Session["stdCollege"].ToString() +"','" + Session["stdSpeciality"].ToString() + "','" + Session["stdTeachedClass"].ToString() + "','" + Session["stdAdminClass"] + "','" + courseCode + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','" + teachingMaterial + "','" + courseName + "','" + teacherCode + "','" + teacherName + "','" + courseTime + "','" + coursePlace + "','" + creditHour + "','" + weekPeriod + "','" + weekDateFrom + "','" + remark + "','" + courseProperty + "','" + schoolArea + "','" + courseCollege + "','" + Session["currentlyStudyYear"].ToString() + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','"+ System.DateTime.Now.ToString() +"')";
string SQL1 = "update ts_xs_chooseCoursesInfo set choosed= '" + choosed + "' where courseName='" + courseName + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
string SQL2 = "update ts_xs_chooseCoursesInfo set remain= '" + remain + "' where courseName='" + courseName + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
if (bc.ExecSQL(SQL) && bc.ExecSQL(SQL1) && bc.ExecSQL(SQL2))
{
con.Close();
this.bind1();
this.bind2();
this.bind3();
Response.Write("<script>alert('你已成功选择此门修课!')</script>");
}
else
{
con.Close();
Response.Write("<script>alert('数据提交不成功!系统忙!请稍后再试!');history.back()</script>");
}
}
else
{
Response.Write("<script>alert('你已经选择过此门选修课或你已经选修此们选修课!');history.back()</script>");
}
}
}
if (checkedCount1 == 2)
{
int p=0, q = 0;
System.Collections.ArrayList myList = new System.Collections.ArrayList();
for (int i = 0; i <= 199; i++)
{
if (a[i] != 0)
{
myList.Add(i);
}
}
int m = (int)myList[0];
int n = (int)myList[1];
for (int i = 0; i <= 199; i++)
{
if (a[m] != 0)
{
p = 1;
}
if (a[n] != 0)
{
q = 1;
}
}
int yuding = 0;
for (int i = 0; i < 199; i++)
{
if (i != m && i != n && b[i] != 0)
{
yuding++;
}
}
if (yuding != 0)
{
Response.Write("<script>alert('你选择了其他选修科目预定教材,但你没有选择次们此选修课!');history.back()</script>");
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -