protected String Repostdata(String Attri, String Enti, String PrimKey) { String HTMLField = ""; System.Diagnostics.Debug.WriteLine(UserID); try { // Links application to database, opens SQL connection and establishs insert string System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand(); SQLisConnect.SQLConnection(); Statement = "SELECT " + Attri + " from dbo." + Enti + " WHERE " + PrimKey + "=" + UserID; HTMLField = SQLisConnect.DatabaseSelect(Statement); return(HTMLField); } catch (System.Data.SqlClient.SqlException sqlException) { // Throws any DB errors in a Message Box for user System.Diagnostics.Debug.WriteLine(sqlException.Message); } return(HTMLField = "Error Loading"); }
protected void Page_Load(object sender, EventArgs e) { Enti = (String)Session["username"]; String HTMLField = ""; if (!IsPostBack) { if (AppStatues.Equals("Started")) { try { System.Data.SqlClient.SqlConnection sc = new System.Data.SqlClient.SqlConnection(); sc.ConnectionString = @"Server=SILAS-PC\LOCALHOST; Database=WLS;Trusted_Connection=Yes;"; sc.Open(); System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand(); insert.Connection = sc; insert.CommandText = ""; insert.CommandText = "Select * from PROFILE where USERNAME = @USERNAME;"; using (SqlDataReader volReader = insert.ExecuteReader()) { while (volReader.Read()) { PhoneNumber.Text = volReader["PHONE"].ToString(); DOB.Text = volReader["DOB"].ToString(); Gender.Text = volReader["GENDER"].ToString(); Allergies.Text = volReader["ALLERGIESSPECIFY"].ToString(); limitations.Text = volReader["LIMITATIONSSPECIFY"].ToString(); MedicalConditions.Text = volReader["CONDITIONS"].ToString(); TeamType = volReader["TeamType"].ToString(); } } insert.CommandText = ""; insert.CommandText = "Select * from EMERGENCYCONTACT where USERNAME = @USERNAME;"; using (SqlDataReader volReader = insert.ExecuteReader()) { while (volReader.Read()) { EMName.Text = volReader["NAME"].ToString(); EMPhoneNumber.Text = volReader["PHONE"].ToString(); EMRelation.Text = volReader["RELATIONSHIP"].ToString(); EMAddress.Text = volReader["ADDRESSLINE1"].ToString(); EMAddress2.Text += volReader["ADDRESSLINE2"].ToString(); EMCity.Text += volReader["CITY"].ToString(); EMZipCode.Text += volReader["ZIPCODE"].ToString(); } } insert.CommandText = ""; insert.CommandText = "Select filepath from datafiles where lastupdated = @USERNAME and Filetype = profile pic;"; using (SqlDataReader volReader = insert.ExecuteReader()) { while (volReader.Read()) { ProfileImg.ImageUrl = volReader["filepath"].ToString(); } } } catch (System.Data.SqlClient.SqlException sqlException) { // Throws any DB errors in a Message Box for user System.Diagnostics.Debug.WriteLine(sqlException.Message); HTMLField = "Error Loading"; } System.Diagnostics.Debug.WriteLine(UserID); try { // Links application to database, opens SQL connection and establishs insert string System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand(); SQLisConnect.SQLConnection(); Statement = "SELECT filetype, filePath from dbo. datafiles WHERE LastUpdatedBy =" + UserID; HTMLField = SQLisConnect.DatabaseSelect(Statement); } catch (System.Data.SqlClient.SqlException sqlException) { // Throws any DB errors in a Message Box for user System.Diagnostics.Debug.WriteLine(sqlException.Message); HTMLField = "Error Loading"; } try { //UserID = (String)Session["Username"]; Enti = "Users"; PrimKey = "USERNAME"; UserFirstN = Repostdata(UserFirstN, Enti, PrimKey); UserLastN = Repostdata(UserLastN, Enti, PrimKey); UserEmail = Repostdata(UserEmail, Enti, PrimKey); NavUsername.Text = UserFirstN + " " + UserLastN; Position.Text = "IDK"; Email.Text = UserEmail; } catch (System.Data.SqlClient.SqlException sqlException) { // Throws database errors in a Message Box to alert the user System.Diagnostics.Debug.WriteLine(sqlException.Message); } if (ProfileImg.ImageUrl == "") { ProfileImg.ImageUrl = "http:/localhost:58532/WLS-CSHARP/images/" + "Default PP.jpg"; } } //if (TeamType.Contains("1")) //{ // Departmentlist.Text.Concat(" Animal Care"); // frmAnimalCare.Visible = true; //} //if (TeamType.Contains("2")) //{ // Departmentlist.Items.Add("Other"); // frmFrontDesk.Visible = true; //} //if (TeamType.Contains("3")) //{ // Departmentlist.Items.Add("Outreach"); // frmOutreach.Visible = true; //} //if (TeamType.Contains("4")) //{ // Departmentlist.Items.Add("Transport"); // frmTransport.Visible = true; //} //if (TeamType.Contains("5")) //{ // Departmentlist.Items.Add("Vet"); // frmVet.Visible = true; //} //if (TeamType.Contains("None")||(TeamType == "")) //{ // Departmentlist.Visible = false; //} this.Page.DataBind(); } }