/// <summary> /// Method updates labels on start1.aspx with relevant values. /// Uses method GetLoggedInUserInfo to retrieve said information, /// </summary> private void UpdateWebsiteGUI() { DatabaseConnection dc = new DatabaseConnection(); DataTable dt = new DataTable(); DataTable dtAllInfo = new DataTable(); dt = dc.GetPersonInfo(userId); string userName = dt.Rows[0]["username"].ToString(); lblUserName.Text = userName; dtAllInfo = dc.GetPersonAndTestInfo(userName); if (dtAllInfo.Rows.Count <= 0) { lblresult.Text = "Inget test hittat"; lbldate.Text = "Inget datum"; lbltestToDo.Text = "1"; lblTestType.Text = "LST"; DateTime today = DateTime.Now; lblNextTestDate.Text = today.ToString("yyyy-MM-dd"); btnGoToOldTest.Enabled = false; } else { string passTest = dtAllInfo.Rows[0]["passed"].ToString(); DateTime date = DateTime.Parse(dtAllInfo.Rows[0]["date"].ToString()); lblresult.Text = SetPassOrFail(passTest); lbltestToDo.Text = CheckDateOfLastTest(date, passTest); lbldate.Text = date.ToString("yyyy-MM-dd"); lblTestType.Text = SetTypeOfTest(); lblTestTypeDone.Text = dtAllInfo.Rows[0]["testtype"].ToString(); } }
/// <summary> /// Method evaluates what type of test user should do, either ÅKU or LST. /// </summary> /// <returns>Returns new string value.</returns> private string SetTypeOfTest() { DatabaseConnection dc = new DatabaseConnection(); string userName = lblUserName.Text; DataTable dt = dc.GetPersonAndTestInfo(userName); string typeOfTest = string.Empty; string passTest = string.Empty; if (dt.Rows.Count <= 0) { typeOfTest = "LST"; return typeOfTest; } else { typeOfTest = dt.Rows[0]["testtype"].ToString(); passTest = dt.Rows[0]["passed"].ToString(); if (typeOfTest == "LST" && passTest == "False") { typeOfTest = "LST"; return typeOfTest; } else { typeOfTest = "ÅKU"; return typeOfTest; } } }