protected void LoginBtn_Click(object sender, EventArgs e) { if (IsValid) { try { CamperDAO camperDAO = new CamperDAO(txtUserName.Text.ToUpper(), txtPassword.Text); Camper camperInfo = camperDAO.ValidateCamper(); if (camperInfo != null) { Session.Add("login", camperInfo); Response.Redirect("~/CamperActivities.aspx"); } else { lblInvalid.Visible = true; } } catch (Exception) { lblInvalid.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { NotRegisteredLBL.Visible = false; Camper camperinfo = (Camper)(Session["login"]); CamperNameLBL.Text = camperinfo.FirstName + " " + camperinfo.LastName; ActivityDAO activityInfo = new ActivityDAO(camperinfo.UserName, camperinfo.Password); lblRegActivities.Text = activityInfo.GetNumberOfActivities().ToString(); if (!IsPostBack) { GetNumberOfActivities(); } }
private void GetNumberOfActivities() { Camper login = (Camper)Session["login"]; RegisterDAO registerDAO = new RegisterDAO(login.UserName, login.Password); List <RegisteredActivity> registerActivity = new List <RegisteredActivity>(); registerActivity = registerDAO.GetRegisteredActivities(); if (!registerActivity.Any()) { NotRegisteredLBL.Visible = true; } GridView1.DataSource = registerDAO.GetRegisteredActivities(); GridView1.DataBind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { Camper login = (Camper)Session["login"]; CamperDAO activity = new CamperDAO(login.UserName, login.Password); int index = Convert.ToInt32(e.CommandArgument); int ActivityID = Convert.ToInt32(GridView1.Rows[index].Cells[0].Text); if (e.CommandName == "DELETE") { try { activity.UnregisterActivity(ActivityID); GetNumberOfActivities(); } catch (Exception ex) { lblError.Text = ex.Message; } } }