版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创!
恰饭广告
前端:(stuSchedule.aspx)
<table class="table table-bordered"> <tr class="tdstyle"> <td class="auto-style2"></td> <td>星期一</td> <td>星期二</td> <td>星期三</td> <td>星期四</td> <td>星期五</td> <td>星期六</td> <td>星期日</td> </tr> <tr> <td class="auto-style2">第 1-2 节</td> <td><%=Schedule[0,0] %></td> <td><%=Schedule[0,1] %></td> <td><%=Schedule[0,2] %></td> <td><%=Schedule[0,3] %></td> <td><%=Schedule[0,4] %></td> <td><%=Schedule[0,5] %></td> <td><%=Schedule[0,6] %></td> </tr> <tr> <td class="auto-style2">第 3-4 节</td> <td><%=Schedule[1,0] %></td> <td><%=Schedule[1,1] %></td> <td><%=Schedule[1,2] %></td> <td><%=Schedule[1,3] %></td> <td><%=Schedule[1,4] %></td> <td><%=Schedule[1,5] %></td> <td><%=Schedule[1,6] %></td> </tr> <tr> <td class="auto-style2">第 5-6 节</td> <td><%=Schedule[2,0] %></td> <td><%=Schedule[2,1] %></td> <td><%=Schedule[2,2] %></td> <td><%=Schedule[2,3] %></td> <td><%=Schedule[2,4] %></td> <td><%=Schedule[2,5] %></td> <td><%=Schedule[2,6] %></td> </tr> <tr > <td class="auto-style2">第 7-8 节</td> <td><%=Schedule[3,0] %></td> <td><%=Schedule[3,1] %></td> <td><%=Schedule[3,2] %></td> <td><%=Schedule[3,3] %></td> <td><%=Schedule[3,4] %></td> <td><%=Schedule[3,5] %></td> <td><%=Schedule[3,6] %></td> </tr> <tr> <td class="auto-style2">第 9-10 节</td> <td><%=Schedule[4,0] %></td> <td><%=Schedule[4,1] %></td> <td><%=Schedule[4,2] %></td> <td><%=Schedule[4,3] %></td> <td><%=Schedule[4,4] %></td> <td><%=Schedule[4,5] %></td> <td><%=Schedule[4,6] %></td> </tr> <tr > <td class="auto-style2">第 11-12 节</td> <td><%=Schedule[5,0] %></td> <td><%=Schedule[5,1] %></td> <td><%=Schedule[5,2] %></td> <td><%=Schedule[5,3] %></td> <td><%=Schedule[5,4] %></td> <td><%=Schedule[5,5] %></td> <td><%=Schedule[5,6] %></td> </tr> </table>
后台:前端:(stuSchedule.aspx)
using SelectCourse.BLL; using SelectCourse.Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SelectCourse.student { public partial class stuSchedule : System.Web.UI.Page { public string[,] Schedule = new string[6, 7]; StudentBLL studentBLL = new StudentBLL(); StudentInfo student = new StudentInfo(); private void loadSchedule(StudentInfo stu) { string semester = ""; int year = Convert.ToInt32(DateTime.Now.ToString("yyyy")); int month = Convert.ToInt32(DateTime.Now.ToString("MM")); if (month >= 3 && month <= 8) { semester = year + "年下学期"; labSemester.Text = semester; } else { semester = year + "年上学期"; labSemester.Text = semester; } DataTable dt = studentBLL.Schedule(stu,semester); foreach (DataRow dr in dt.Rows) { int x = studentBLL.GetWeek(dr["ClassTime"].ToString()); int y = studentBLL.GetFestival(dr["Classfestival"].ToString()); string CourseInfo = String.Format("{0}<br>{1} {2}<br>{3}", dr["CName"].ToString(), dr["BuildingName"].ToString(), dr["RoomName"].ToString(), dr["TName"].ToString()); Schedule[y, x] += CourseInfo; } } protected void Page_Load(object sender, EventArgs e) { if (Session["id"] == null) { Response.Redirect("../login.aspx"); } else { student.id = Convert.ToInt32(Session["id"]); if (!IsPostBack) { loadSchedule(student); } } } } }
BLL层:
public int GetWeek(string ClassTime) { int week = 0; switch (ClassTime) { case "星期1": week = 0; break; case "星期2": week = 1; break; case "星期3": week = 2; break; case "星期4": week = 3; break; case "星期5": week = 4; break; case "星期6": week = 5; break; case "星期7": week = 6; break; } return week; } public int GetFestival(string Classfestival) { int Festival = 0; switch (Classfestival) { case "第1-2节": Festival = 0; break; case "第3-4节": Festival = 1; break; case "第5-6节": Festival = 2; break; case "第7-8节": Festival = 3; break; case "第9-10节": Festival = 4; break; case "第11-12节": Festival = 5; break; } return Festival; } public DataTable Schedule(StudentInfo stu, string semester) { return stuDAL.Schedule(stu, semester); }
DAL层:
#region 学生课程表 public DataTable Schedule(StudentInfo stu,string semester) { string sql = "SELECT Course.CName,Schedule.*,Building.BuildingName,Room.RoomName,Teacher.TName FROM SC,Student,Schedule,Course,Building,Room,Teacher WHERE SC.SId=@sid AND SC.SId=Student.SId AND SC.CId=Schedule.CId AND SC.CId=Course.CId AND Schedule.RoomId = Room.RoomId AND Room.BuildingId = Building.BuildingId AND Course.TId=Teacher.TId and Course.Semester=@semester and CisPass=1 and CisDeny=0"; return mySqlHelper.ExecuteSqlTable(sql, new MySqlParameter("@sid", stu.id), new MySqlParameter("@semester", semester)); } #endregion
原文链接:https://www.idaobin.com/archives/1316.html
让我恰个饭吧.ヘ( ̄ω ̄ヘ)
恰饭广告