Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Request.IsAuthenticated)
         {
             FormsAuthentication.RedirectToLoginPage();
         }
         else
         {
             FormsAuthenticationTicket ticket = (FormsAuthentication.Decrypt(Session["auth"].ToString()));
             string userId = ticket.UserData.Split(';')[0];
             string role   = ticket.UserData.Split(';')[1];
             if (Session["sessionId"] == null)
             {
                 SessionCL sessionCL = sessionBLL.addorCheckSession();
                 Session["sessionId"] = sessionCL.id;
             }
             else if (role.ToLower() == "teacher" || role.ToLower() == "attendanceo")
             {
                 Response.Redirect("../UnAuthorized.aspx");
             }
             else
             {
                 sessionId = Convert.ToInt32(Session["sessionId"]);
                 if (Request.QueryString["examinationId"] != null)
                 {
                     int examId = Convert.ToInt32(Request.QueryString["examinationId"]);
                     lblHeading.Text         = "Update Examination";
                     ddlClass.DataSource     = classBLL.viewClasses(sessionId);
                     ddlClass.DataValueField = "id";
                     ddlClass.DataTextField  = "classSection";
                     ddlClass.DataBind();
                     ExaminationCL examCL = examinationBLL.viewExaminationById(examId);
                     ddlClass.SelectedValue = examCL.classId.ToString();
                     txtExamination.Text    = examCL.name;
                     txtDateCreated.Text    = examCL.dateCreated.ToString("dd MMMM yyyy");
                     txtDateUpdated.Text    = examCL.dateModified.ToString("dd MMMM yyyy");
                     btnSubmit.Text         = "Update";
                     btnDelete.Visible      = true;
                 }
                 else
                 {
                     lblHeading.Text         = "Add Examination";
                     ddlClass.DataSource     = classBLL.viewClasses(sessionId);
                     ddlClass.DataValueField = "id";
                     ddlClass.DataTextField  = "classSection";
                     ddlClass.DataBind();
                     btnSubmit.Text    = "Submit";
                     btnDelete.Visible = false;
                 }
             }
         }
     }
 }