Imports RGBC_ScoreCard.SystemFunctions Imports RGBC_ScoreCard.ProjectFunctions Imports System.Threading Imports System.Globalization '20180530 - added user level checks on load - maanie '20180604 - show/hide new link in overview based on Season - maanie '20180717 - changed onload queries to read from scrSurvey - maanie '20180719 - added catch to reinitialize Session if not set - maanie Partial Public Class Home Inherits System.Web.UI.Page Dim surveyCheck As Boolean Dim dr As DataRow Public db As New db Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit Dim p As Page = Me.Context.Handler Page.MasterPageFile = setMasterPage(Request) End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'ini Dim dtLastSurveyManager As String = " - No previous Manager Performance Review done - " Dim dtLastSurveySelf As String = " - No previous Self Performance Review done - " Dim strUserGroup As String = "User" Dim refQuestionnaireID As String = "0" Dim strLastSurveyStatus As String = "" Dim intSurveyID As Integer = 0 '20180719 - added catch to reinitialize Session if not set - maanie If Session.Item("User") Is Nothing Then 'lame LogginUser(Request, Session) End If If Request.QueryString("surveyCheck") = "True" Then lblSurveyComplete.Text = "
Survey has been completed successfully..." Else lblSurveyComplete.Text = "
Welcome " & Session.Item("USER")!strUserName '20180717 - changed onload queries to read from scrSurvey - maanie 'get survey stats 'dr = db.getRow("SELECT UserID, QuestionnaireID, RepID, LEFT(CONVERT(VARCHAR, MAX(dtDate), 120), 10) AS dtLastSurveyManager FROM dwfscorecard WHERE QuestionnaireID <> 3 AND RepID = " & Session.Item("USERID") & " AND UserID <> RepID GROUP BY UserID, QuestionnaireID, RepID") dr = db.getRow("SELECT ISNULL(LEFT(CONVERT(VARCHAR, MAX(dtDate), 120), 10),'') AS dtLastSurveyManager FROM scrSurvey WHERE QuestionnaireID <> 3 AND RepID = " & Session.Item("USER")!UserID & " AND UserID <> RepID") If dr IsNot Nothing Then If dr!dtLastSurveyManager <> "" Then dtLastSurveyManager = dr!dtLastSurveyManager End If End If 'dr = db.getRow("SELECT UserID, QuestionnaireID, RepID, LEFT(CONVERT(VARCHAR, MAX(dtDate), 120), 10) AS dtLastSurveySelf FROM dwfscorecard WHERE QuestionnaireID <> 3 AND RepID = " & Session.Item("USERID") & " AND UserID = RepID GROUP BY UserID, QuestionnaireID, RepID") dr = db.getRow("SELECT LEFT(CONVERT(VARCHAR, MAX(dtDate), 120), 10) AS dtLastSurveySelf, strStatus, SurveyID FROM scrSurvey WHERE QuestionnaireID <> 3 AND RepID = " & Session.Item("USER")!UserID & " AND UserID = RepID GROUP BY strStatus, SurveyID") If dr IsNot Nothing Then dtLastSurveySelf = dr!dtLastSurveySelf strLastSurveyStatus = dr!strStatus intSurveyID = dr!SurveyID End If dr = db.getRow("SELECT refQuestionnaireID FROM scrUser WHERE UserID = " & Session.Item("USER")!UserID) If dr IsNot Nothing Then refQuestionnaireID = dr!refQuestionnaireID End If 'set survey stats lblLastSurveyManager.Text = "Date of last Performance Review (Manager): " & dtLastSurveyManager lblLastSurveySelf.Text = "Date of last Performance Review (Self): " & dtLastSurveySelf If dtLastSurveySelf = " - No previous Self Performance Review done - " Then 'START NEW REVIEW If refQuestionnaireID <> 0 Then lblStartSelfPerformanceReview.Text = "To Start a new Self Performance Review, please click here" Else lblStartSelfPerformanceReview.Text = "Please ask HR to assign a Job Role to your User Account in order to start a new Self Performance Review" End If Else 'EDIT EXISTING REVIEW IF DRAFT OR START NEW REVIEW IF LAST SURVEY DONE BEFORE APRIL Dim dtLastSelfSurvey As DateTime = DateTime.Parse(dtLastSurveySelf) If dtLastSelfSurvey.Month < 4 Then lblStartSelfPerformanceReview.Text = "To Start a new Self Performance Review, please click here" ElseIf strLastSurveyStatus = "Draft" Then lblStartSelfPerformanceReview.Text = "To Edit your existing Self Performance Review, please click here" End If End If dr = db.getRow("SELECT strUserGroup FROM mstUserGroupScoreCard INNER JOIN mstUser ON mstUserGroupScoreCard.UserGroupID = mstUser.refUserGroupScoreCardID WHERE mstUser.UserID = " & Session.Item("USER")!UserID) If dr IsNot Nothing Then strUserGroup = dr!strUserGroup End If 'if Admin: Show All minions 'elseif manager: Show only his minions 'else: Dont show minions Select Case strUserGroup 'Session.Item("USER")!strUserGroup 'DONT USE SESSION AS IT'S UNRELIABLE AND THROWS AN ERROR Case "RSM" 'sdsUser.SelectParameters("refUserID").DefaultValue = Session.Item("USERID") 'self sdsUser.SelectParameters("refManagerID").DefaultValue = Session.Item("USER")!UserID ' only load Manager's users Case "User" div1.Style.Add("display", "none") divReport.Style.Add("display", "none") Case "Admin" Case "Dev" End Select End If End Sub Private Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete Dim imgLoading As WebControls.Image imgLoading = Page.Master.FindControl("imgLoading") imgLoading.CssClass = "invisible" End Sub Protected Sub LoadSurvey(ByVal sender As Object, ByVal e As System.EventArgs) Dim btnNewSurvey As Button = sender 'get UserID, refQuestionnaireID (i.e Job Role) from parameter string Dim params As String() = btnNewSurvey.CommandArgument.ToString().Split(New Char() {","}) Dim userID As String = params(0) Dim refQuestionnaireID As String = params(1) Response.Redirect("PeopleBalanceSheetNew.aspx?UserID=" & userID & "&QuestionnaireID=" & refQuestionnaireID) End Sub Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click sdsUser.FilterExpression = "1=1" If ddlJobRole.SelectedIndex > 0 Then sdsUser.FilterExpression &= " AND QuestionnaireID = " & ddlJobRole.SelectedValue End If End Sub '20180604 - show/hide new link in overview based on Season - maanie Protected Sub gvUsers_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvUsers.RowDataBound Dim strCurrentYear, strLastManagerReview, strLastPotentialReview As String 'Dim intQuestionnaireID As Integer Dim dtLastManagerReview, dtLastPotentialReview, dtSeasonStart, dtSeasonEnd As DateTime Dim hyperNewPerformanceReview As HyperLink Dim hyperNewPotentialReview As HyperLink If e.Row.RowType = DataControlRowType.DataRow Then 'SET DATE VARIABLES strCurrentYear = Now.Year.ToString() dtSeasonStart = DateTime.Parse(strCurrentYear & "-" & My.Settings.dtSeasonStart.ToString()) 'YYYY-MM-DD dtSeasonEnd = DateTime.Parse(strCurrentYear & "-" & My.Settings.dtSeasonEnd.ToString() & "-" & strCurrentYear) 'YYYY-MM-DD 'SHOW/HIDE PERFORMANCE NEW If e.Row.Cells(4).Text <> "-" Then dtLastManagerReview = DateTime.Parse(e.Row.Cells(4).Text.Substring(0, e.Row.Cells(4).Text.IndexOf(" "))) 'YYYY-MM-DD If (dtLastManagerReview >= dtSeasonStart And dtLastManagerReview <= dtSeasonEnd) Then hyperNewPerformanceReview = e.Row.Cells(5).Controls(0) hyperNewPerformanceReview.CssClass = "hideLink" End If End If 'SHOW/HIDE POTENTIAL NEW If e.Row.Cells(6).Text <> "-" Then dtLastPotentialReview = DateTime.Parse(e.Row.Cells(6).Text.Substring(0, e.Row.Cells(6).Text.IndexOf(" "))) 'YYYY-MM-DD If (dtLastPotentialReview >= dtSeasonStart And dtLastPotentialReview <= dtSeasonEnd) Then hyperNewPotentialReview = e.Row.Cells(7).Controls(0) hyperNewPotentialReview.CssClass = "hideLink" End If End If Dim dr As DataRowView = CType(e.Row.DataItem, DataRowView) Dim strStatus As String = dr("strStatus").ToString() Dim strStatusPotential As String = dr("strStatusPotential").ToString() 'PERFORMANCE If strStatus <> "Submitted" And (dtLastManagerReview >= dtSeasonStart And dtLastManagerReview <= dtSeasonEnd) Then strLastManagerReview = e.Row.Cells(4).Text Dim the_url As HyperLink = New HyperLink() the_url.NavigateUrl = "PeopleBalanceSheetNew.aspx?SurveyID=" & dr("SurveyID").ToString() the_url.Text = strLastManagerReview e.Row.Cells(4).Controls.Add(the_url) End If 'POTENTIAL If strStatusPotential <> "Submitted" And (dtLastPotentialReview >= dtSeasonStart And dtLastPotentialReview <= dtSeasonEnd) Then strLastPotentialReview = e.Row.Cells(6).Text Dim the_url As HyperLink = New HyperLink() the_url.NavigateUrl = "PeopleBalanceSheetNew.aspx?SurveyID=" & dr("PotentialSurveyID").ToString() the_url.Text = strLastPotentialReview e.Row.Cells(6).Controls.Add(the_url) End If End If End Sub End Class