protected void Page_Load(object sender, EventArgs e) { _user = this.LoggedInUserData(); if (this.IsPostBack) { return; } this.ddlGroup.Enabled = false; this.butApprove.Enabled = false; this.butSave.Enabled = false; this.butSubmit.Enabled = false; this.populateCenterDDL(); var repo = new DataRepo(); if (this.ClientQueryString.Contains("dg") && (this.dailyGroupId == 0)) //Manager coming from Approval Email { int dailyGroupId = int.Parse(cQCryptographyHelper.DecryptString(this.Request.QueryString["dg"])); _Session.SetVar("DAILY_GROUP_ID", dailyGroupId); } this.dailyGroupId = int.Parse(_Session.GetVar("DAILY_GROUP_ID", 0).ToString()); string role = _user.Role.ToLower(); if (this.dailyGroupId > 0) //Admin or Manager coming from Approval Email { DailyGroupDTO dailyGroup = repo.getDailyGroup(this.dailyGroupId); this.ddlCenter.SelectedValue = dailyGroup.CenterId.ToString(); this.populateGroupDDL(dailyGroup.CenterId); this.ddlGroup.SelectedValue = dailyGroup.GroupId.ToString(); this.bindData(); this.pnlCenter.Enabled = false; this.ddlGroup.Enabled = ((role == "admin" || role == "manager") && (!this.ClientQueryString.Contains("dg"))); } else { switch (role) { case "manager": var centerId = repo.getCentersByManagerIdLookup(_user.Id).FirstOrDefault().Key; this.ddlCenter.SelectedValue = centerId.ToString(); this.pnlCenter.Enabled = false; this.populateGroupDDL(centerId); this.ddlGroup.Enabled = true; break; } } }
protected void butLogin_Click(object sender, EventArgs e) { try { UserDTO user; var repo = new DataRepo(); if (this.pnlLogin.Visible) { _Session.RemoveVar("DAILY_GROUP_ID"); user = new UserDTO() { UserName = this.UserName.Text, Password = this.Password.Text }; user = repo.authenticateUser(user); this._Session.SetVar("User", user); if (user.Role.ToLower() == "teacher") { this.pnlLogin.Visible = false; this.pnlTeacherLogin.Visible = true; this.butLogin.Text = "Go"; this.populateCenterDDL(); this.ddlGroup.Enabled = false; return; } } else //Teacher Login so create or update DailyGroup record and redirect to menu { user = (UserDTO)_Session.GetVar("User", null); int dailyGroupId = int.Parse(_Session.GetVar("DAILY_GROUP_ID", 0).ToString()); DailyGroupDTO dailygroup = new DailyGroupDTO() { Id = dailyGroupId, CenterId = int.Parse(this.ddlCenter.SelectedValue), GroupId = int.Parse(this.ddlGroup.SelectedValue), TeacherId = user.Id }; dailyGroupId = repo.postDailyGroups(dailygroup); _Session.SetVar("DAILY_GROUP_ID", dailyGroupId); } FormsAuthentication.RedirectFromLoginPage(this.UserName.Text, this.RememberMe.Checked); } catch (CBSException ex) { this.writeMessage(ex); } catch (Exception ex) { this.writeMessage(ex); } }