大家帮我解释解释!
程序代码:
BaseClass bc = new BaseClass(); stringBuilder sb = new stringBuilder(); int[,] a = new int[8, 13]; protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session["stdUserName"]) == "") { Response.Write("<script language=javascript>location='../TS_login.aspx'</script>"); return; } if (!IsPostBack) { SqlConnection con1= new SqlConnection(ConfigurationManager.AppSettings["strcon"]); con1.Open(); SqlDataAdapter sda3 = new SqlDataAdapter("select studyYear from ts_xs_studyYear ", con1); DataSet ds3 = new DataSet(); sda3.Fill(ds3, "ts_xs_studyYear"); this.studyYear.DataSource = ds3.Tables["ts_xs_studyYear"]; this.studyYear.DataTextField = "studyYear"; this.studyYear.DataBind(); this.studyYear.Text = Session["currentlyStudyYear"].ToString(); con1.Close(); this.Label1.Text = Session["stdUserName"].ToString(); this.Label2.Text = Session["stdName"].ToString(); this.Label3.Text = Session["stdSpeciality"].ToString(); this.Label4.Text = Session["stdCollege"].ToString(); this.Label5.Text = Session["stdTeachedClass"].ToString(); this.Label6.Text = Session["stdAdminClass"].ToString(); this.stdGrade.Text = Session["stdGrade"].ToString(); for (int i = 1; i <= 7; i++) { for (int j = 1; j <= 12; j++) { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]); con.Open(); a[i, j] = i * 12 + j; string studyYear = Session["currentlyStudyYear"].ToString(); int semester = Convert.ToInt32(Session["currentlySemester"]); SqlCommand sd7 = new SqlCommand("select count(*) from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"].ToString() + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); int count = Convert.ToInt32(sd7.ExecuteScalar()); if (count > 0) { SqlCommand sd7_1 = new SqlCommand("select courseName from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"] + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); string courseName = Convert.ToString(sd7_1.ExecuteScalar()); SqlCommand sd7_2 = new SqlCommand("select weekPeriod from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"] + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); string weekPeriod = Convert.ToString(sd7_2.ExecuteScalar()); SqlCommand sd7_3 = new SqlCommand("select courseDatefrom from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"] + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); string courseDatefrom = Convert.ToString(sd7_3.ExecuteScalar()); SqlCommand sd7_4 = new SqlCommand("select teacherName from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"] + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); string teacherName = Convert.ToString(sd7_4.ExecuteScalar()); SqlCommand sd7_5 = new SqlCommand("select coursePlace from ts_xs_courseTable where courseTableName='" + Session["stdAdminClass"] + "'and weekday = '" + i + "'and daytime= '" + j + "' and studyYear = '" + studyYear + "' and semester ='"+semester+"'", con); string coursePlace = Convert.ToString(sd7_5.ExecuteScalar()); System.Text.StringBuilder std = new StringBuilder(); std.Append(courseName); std.Append("<br>"); std.Append(weekPeriod); std.Append(courseDatefrom); std.Append("<br>"); std.Append(teacherName); std.Append("<br>"); std.Append(coursePlace); sb.Add(new stringItem(std, a[i, j])); con.Close(); } else { System.Text.StringBuilder std1 = new StringBuilder(); stringItem si1 = new stringItem(std1, a[i, j]); con.Close(); } } } stringBuilder u = sb.getText(sb, 13); foreach (stringItem p in u) { this.Label7.Text = p.getText(); } stringBuilder u1 = sb.getText(sb, 14); foreach (stringItem p in u) { this.Label8.Text = p.getText(); } } }