using System; using System.Data; using System.Web.Security; using WebLib; namespace Education.MobileSurvey { public partial class SurveyList : System.Web.UI.Page { private DAC_課程報名 Dao課程報名; protected void Page_Load(object sender, EventArgs e) { if (Session[PublicVariable.UserId] == null || string.IsNullOrEmpty(Session[PublicVariable.UserId].ToString())) { Response.Redirect("Login.aspx"); return; } Dao課程報名 = new DAC_課程報名(DAC.NewConnection()); if (!IsPostBack) { string 學員ID = Session[PublicVariable.UserId].ToString(); string 學員姓名 = DAC.GetString(Session[PublicVariable.UserName]); ltUserInfo.Text = "學員:" + 學員ID + " " + 學員姓名; LoadSurveyList(); } } private void LoadSurveyList() { string 學員ID = Session[PublicVariable.UserId].ToString(); DataTable dt = Dao課程報名.Select選課紀錄(學員ID, false, false, true, true); if (dt != null) { DataView dv = dt.DefaultView; dv.RowFilter = "填寫數 = 0"; DataTable dtFiltered = dv.ToTable(); rptSurveyList.DataSource = dtFiltered; rptSurveyList.DataBind(); pnlEmpty.Visible = (dtFiltered.Rows.Count == 0); } } protected void rptSurveyList_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName == "Fill") { string[] args = e.CommandArgument.ToString().Split('|'); string courseId = args[0]; string studentId = args[1]; Response.Redirect("SurveyForm.aspx?course=" + courseId + "&student=" + studentId); } } protected void btnLogout_Click(object sender, EventArgs e) { Session.Clear(); FormsAuthentication.SignOut(); Response.Redirect("Login.aspx"); } protected void btnRefresh_Click(object sender, EventArgs e) { LoadSurveyList(); } } }