protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (Int32.Parse(Page.RouteData.Values["userId"].ToString()) < 1) { //hids management buttons. btnUpdate.Visible = false; btnLock.Visible = false; //changes delete text to say add. btnDelete.Text = "Add User"; } //fills drop down from database. drpRole.Items.Clear(); drpRole.DataSource = SystemMethods.getDataTableFromStoredProcedure("stpGetRoles"); drpRole.DataTextField = "role"; drpRole.DataValueField = "roleId"; drpRole.DataBind(); } catch (Exception ex) { Response.Redirect("~/login.aspx"); } try { //gets ticket to make sure you are admin. FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies["mysite.ASPXAUTH"].Value); int userRole = Int32.Parse(ticket.UserData.ToString()); if (userRole != 1 && userRole != 4) { Response.Redirect("~/login.aspx"); } //fills in form with data from database. DataTable userInfo = SystemMethods.getDataTableFromStoredProcedureWithVars( "stpGetUserDataForAdmin", new string[1, 3] { { "@userId", Page.RouteData.Values["userId"].ToString(), "int" } } ); txtFirstName.Text = userInfo.Rows[0]["firstName"].ToString(); txtLastName.Text = userInfo.Rows[0]["lastName"].ToString(); txtEmail.Text = userInfo.Rows[0]["email"].ToString(); txtEmployeeId.Text = userInfo.Rows[0]["employeeId"].ToString(); //changes the lock/unlock text if (userInfo.Rows[0]["locked"].ToString() == "1") { btnLock.Text = "Unlock User"; } //displays last login. labLastLogin.Text = "Last Login: "******"lastLogin"].ToString(); //change dorpdown to display witch one is set. drpRole.Items.FindByValue(userInfo.Rows[0]["roleId"].ToString()).Selected = true; } catch (Exception ex) { } } }
public static string getDepartmentsForLeftMenu() { DataTable departments = SystemMethods.getDataTableFromStoredProcedure("stpGetDepartments"); string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int rows = departments.Rows.Count; string html = ""; List <CompanyDepartment> departmentList = new List <CompanyDepartment>(); for (int uth = 0; uth < rows; uth++) { departmentList.Add(new CompanyDepartment(Int32.Parse(departments.Rows[uth]["departmentId"].ToString()), departments.Rows[uth]["departmentName"].ToString())); } //this for loop sorts the departments and makes html ready to go. for (int uth = 0; uth < letters.Length; uth++) { //make header is the make the clickable letter. you only want it once int makeHeader = 1; //while true because there could be 0-9000 departments with the same letter while (true) { //this finds a department in the list. //letters is a string with A-Z. //we need to sort the dept list alphabetically first here i think? - SH CompanyDepartment foundDepartment = departmentList.Find(x => x.firstLetter == letters[uth]); //if foundDepartment is null that mena no match. if (foundDepartment == null) { //no match means no more in that letter. break; } //this should only happen once per found letter. if (makeHeader == 1) { //makes the clickable "link" html += "<div id='" + letters[uth] + "'>"; html += "<h2><a href='#" + letters[uth] + "'>" + letters[uth] + "</a></h2>"; //gets marked to 0 because this letter was just made. makeHeader = 0; } //removes the foundDepartment from the list. departmentList.Remove(foundDepartment); //finally this is the link inside a clickable letter. //change localhost when put on azure html += "<p><a href='/FunctionListing/" + foundDepartment.departmentId + "#" + letters[uth] + "'>" + foundDepartment.departmentName + "</a></p>"; } //this is in case a letter was not found it skips this. //it is to close the div made to be clicked. if (makeHeader == 0) { html += "</div>"; } } //returns this html back. return(html); }
public static string getStaffMembersForLeftMenu() { //this gets each staff member from database. DataTable staffMembers = SystemMethods.getDataTableFromStoredProcedure("stpGetStaffMembers"); //this is used for ABC order string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int rows = staffMembers.Rows.Count; //this will be the html code for the left menu. string html = ""; //this list is to store them in order List <CompanyStaffMember> staffMemberList = new List <CompanyStaffMember>(); for (int uth = 0; uth < rows; uth++) { staffMemberList.Add(new CompanyStaffMember(Int32.Parse(staffMembers.Rows[uth]["staffMemberId"].ToString()), staffMembers.Rows[uth]["lastName"].ToString() + ", " + staffMembers.Rows[uth]["firstName"].ToString())); } //this makes the html code for the left menu for (int uth = 0; uth < letters.Length; uth++) { int makeHeader = 1; while (true) { CompanyStaffMember foundMember = staffMemberList.Find(x => x.firstLetter == letters[uth]); if (foundMember == null) { break; } if (makeHeader == 1) { html += "<div id='" + letters[uth] + "'>"; html += "<h2><a href='#" + letters[uth] + "'>" + letters[uth] + "</a></h2>"; makeHeader = 0; } staffMemberList.Remove(foundMember); html += "<p><a href='/StaffMember/" + foundMember.staffMemberId + "#" + letters[uth] + "'>" + foundMember.staffMemberName + "</a></p>"; } if (makeHeader == 0) { html += "</div>"; } } return(html); }