Imports System.Data
Imports System.IO
Imports AppCommon
Imports AppInfo
Imports AppVariable

Partial Class _TopSP
    Inherits System.Web.UI.Page

#Region "************************* 定数 *************************"

#End Region


#Region "********************** メンバ変数 **********************"

    Private Read_Command As String '既読処理 OR 未読処理の判別フラグ

#End Region

#Region "******************** ページイベント ********************"

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        '---------------------------------------------------------------
        'HTMLタグを追加
        '---------------------------------------------------------------
        Dim ctl As Control = Page.Master.FindControl("msp_header")
        'CSS
        SetTagCss(ctl, "mobile_info.css")


    End Sub

#End Region

#Region "***************** コントロールイベント *****************"
    Protected Sub sql_info_midoku_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles sql_info_midoku.Init
        sql_info_midoku_select()
    End Sub

    Protected Sub sql_info_public_midoku_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles sql_info_public_midoku.Init
        sql_info_public_midoku_select()
    End Sub

    Protected Sub sql_info_class_midoku_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles sql_info_class_midoku.Init
        sql_info_class_midoku_select()
    End Sub

    Protected Sub gv_未読のお知らせ_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_未読のお知らせ.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            If CType(e.Row.FindControl("lb_添付"), Label).Text = "添付" Then
                CType(e.Row.FindControl("img_添付"), Image).Visible = True
            Else
                CType(e.Row.FindControl("img_添付"), Image).Visible = False
            End If

            If CType(e.Row.FindControl("lb_new"), Label).Text = "新着" Then
                CType(e.Row.FindControl("img_new"), Image).Visible = True
            Else
                CType(e.Row.FindControl("img_new"), Image).Visible = False
            End If

            If CType(e.Row.FindControl("lb_未読"), Label).Text = "既読" Then
                CType(e.Row.FindControl("img_未読"), Image).Visible = False
            Else
                CType(e.Row.FindControl("img_未読"), Image).Visible = True
            End If
			
			Dim lb_レベル as Label = CType(e.Row.FindControl("lb_レベル"), Label)
			Dim lb_レベル_重要 as Label = CType(e.Row.FindControl("lb_レベル_重要"), Label)
			Dim lb_レベル_緊急 as Label = CType(e.Row.FindControl("lb_レベル_緊急"), Label)
			
            If lb_レベル.Text = "通常" Then
                lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = False
            ElseIf lb_レベル.Text = "重要" Then
                lb_レベル_重要.Visible = true
                lb_レベル_緊急.Visible = False 
            ElseIf lb_レベル.Text = "緊急" Then
                lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = true
            Else
            	lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = False
            End If
           
        End If
    End Sub

    Protected Sub gv_未読のお知らせ_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv_未読のお知らせ.RowCommand
        Read_Command = e.CommandArgument
    End Sub

    Protected Sub gv_未読のお知らせ_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_未読のお知らせ.SelectedIndexChanged

        Dim str掲示NO As String = gv_未読のお知らせ.SelectedDataKey.Item(0).ToString

        '未読既読処理
        If Read_Command = "read" Then
            Info_既読処理(gv_未読のお知らせ.SelectedDataKey.Item(0).ToString, Session(S_COM_PortalID))

            'ページ遷移
            Session(S_Info_Selected_No) = str掲示NO
            Session(S_Info_遷移元) = "トップページ"
            Com_Change_UC1("menu_kj_001_mb")
            Response.Redirect("~/mobile/info/DetailSP.aspx")
        End If

    End Sub

    Protected Sub gv_未読の連絡事項_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_未読の連絡事項.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            If CType(e.Row.FindControl("lb_添付"), Label).Text = "添付" Then
                CType(e.Row.FindControl("img_添付"), Image).Visible = True
            Else
                CType(e.Row.FindControl("img_添付"), Image).Visible = False
            End If

            If CType(e.Row.FindControl("lb_new"), Label).Text = "新着" Then
                CType(e.Row.FindControl("img_new"), Image).Visible = True
            Else
                CType(e.Row.FindControl("img_new"), Image).Visible = False
            End If

            If CType(e.Row.FindControl("lb_未読"), Label).Text = "既読" Then
                CType(e.Row.FindControl("img_未読"), Image).Visible = False
            Else
                CType(e.Row.FindControl("img_未読"), Image).Visible = True
            End If


            Dim lb_レベル as Label = CType(e.Row.FindControl("lb_レベル"), Label)
			Dim lb_レベル_重要 as Label = CType(e.Row.FindControl("lb_レベル_重要"), Label)
			Dim lb_レベル_緊急 as Label = CType(e.Row.FindControl("lb_レベル_緊急"), Label)
			
            If lb_レベル.Text = "通常" Then
                lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = False
            ElseIf lb_レベル.Text = "重要" Then
                lb_レベル_重要.Visible = true
                lb_レベル_緊急.Visible = False 
            ElseIf lb_レベル.Text = "緊急" Then
                lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = true
            Else
            	lb_レベル_重要.Visible = False
                lb_レベル_緊急.Visible = False
            End If
        End If
    End Sub

    Protected Sub gv_未読の連絡事項_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv_未読の連絡事項.RowCommand
        Read_Command = e.CommandArgument
    End Sub

    Protected Sub gv_未読の連絡事項_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_未読の連絡事項.SelectedIndexChanged
        '未読既読処理
        If Read_Command = "read" Then
            Info_既読処理(gv_未読の連絡事項.SelectedDataKey.Item(0).ToString, Session(S_COM_PortalID))
        Else
            Info_未読処理(gv_未読の連絡事項.SelectedDataKey.Item(0).ToString, Session(S_COM_PortalID))
        End If

        'ページ遷移
        Session(S_Info_遷移元) = "トップページ"
        Com_Change_UC1("menu_kj_002_mb")

        Session(S_Info_Selected_No) = gv_未読の連絡事項.SelectedDataKey.Item(0).ToString

        Response.Redirect("~/mobile/info/DetailSP.aspx")
    End Sub

    Protected Sub gv_未読の授業関連_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_未読の授業関連.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then

            If CType(e.Row.FindControl("lb_new"), Label).Text = "新着" Then
                CType(e.Row.FindControl("img_new"), Image).Visible = True
            Else
                CType(e.Row.FindControl("img_new"), Image).Visible = False
            End If

            If CType(e.Row.FindControl("lb_未読"), Label).Text = "既読" Then
                CType(e.Row.FindControl("img_未読"), Image).Visible = False
            Else
                CType(e.Row.FindControl("img_未読"), Image).Visible = True
            End If

        End If
    End Sub

    Protected Sub gv_未読の授業関連_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv_未読の授業関連.RowCommand
        Read_Command = e.CommandArgument
    End Sub

    Protected Sub gv_未読の授業関連_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_未読の授業関連.SelectedIndexChanged
        '未読既読処理
        If Read_Command = "read" Then
            Info_既読処理(gv_未読の授業関連.SelectedDataKey.Item(0).ToString, Session(S_COM_PortalID))
        Else
            Info_未読処理(gv_未読の授業関連.SelectedDataKey.Item(0).ToString, Session(S_COM_PortalID))
        End If

        'ユーザコントロールを開く
        Session(S_Info_遷移元) = "トップページ"
        If CType(gv_未読の授業関連.Rows.Item(gv_未読の授業関連.SelectedIndex).FindControl("lb_対象予定区分"), Label).Text = "変更" Then
            '授業変更用UC呼び出し
            Com_Change_UC1("menu_kj_004_mb")
        Else
            '授業変更以外のUC呼び出し
            Com_Change_UC1("menu_kj_003_mb")
        End If

        Session(S_Info_Selected_No) = gv_未読の授業関連.SelectedDataKey.Item(0).ToString

        Response.Redirect("~/mobile/info/DetailSP.aspx")
    End Sub
#End Region

#Region "******************* Sub及びFunction ********************"

    '未読の個人のお知らせ
    Private Sub sql_info_midoku_select()
        Dim n As String

        If Request.QueryString("n") Is Nothing Then
            n = ""
        Else
            n = Request.QueryString("n").ToString
        End If

        Dim sds As SqlDataSource = sql_info_midoku
        WebControlsUtil.DeclareSP(sds, "掲示_掲示一覧_個人_SELECT")
        With sds
            .SelectParameters.Add("PORTALID", DbType.String, Session(S_COM_PortalID))
            .SelectParameters.Add("新着", DbType.Int32, n.ToString)
            .SelectParameters.Add("未読のみ", DbType.Boolean, "True")
        End With
    End Sub

    '未読の連絡事項
    Private Sub sql_info_public_midoku_select()
        Dim m As String
        Dim w As String
        Dim n As String
        Dim t As String

        '2020/6/22 MOD START モバイル版は自分宛てのみ /Liu
        'If Request.QueryString("m") Is Nothing Then
        '    m = ""
        'Else
        '    m = Request.QueryString("m").ToString
        'End If
        m = "1" '自分宛て
        '2020/6/22 MOD END /Liu

        If Request.QueryString("w") Is Nothing Then
            w = ""
        Else
            w = Request.QueryString("w").ToString
        End If

        If Request.QueryString("n") Is Nothing Then
            n = ""
        Else
            n = Request.QueryString("n").ToString
        End If

        If Request.QueryString("t") Is Nothing Then
            t = ""
        Else
            t = Request.QueryString("t").ToString
        End If

        Dim sds As SqlDataSource = sql_info_public_midoku
        WebControlsUtil.DeclareSP(sds, "掲示_掲示一覧_連絡_SELECT")
        With sds
            .SelectParameters.Add("PORTALID", DbType.String, Session(S_COM_PortalID))
            .SelectParameters.Add("自分宛て", DbType.String, m.ToString)
            .SelectParameters.Add("WORD", DbType.String, w.ToString)
            .SelectParameters.Add("掲示対象CD", DbType.String, t.ToString)
            .SelectParameters.Add("新着", DbType.Int32, n.ToString)
            .SelectParameters.Add("未読のみ", DbType.Boolean, "True")
        End With
    End Sub

    '未読の授業関連
    Private Sub sql_info_class_midoku_select()
        Dim m As String
        Dim w As String
        Dim n As String

        '2020/6/22 MOD START モバイル版は自分宛てのみ /Liu
        'If Request.QueryString("m") Is Nothing Then
        '    m = ""
        'Else
        '    m = Request.QueryString("m").ToString
        'End If
        m = "1" '自分宛て
        '2020/6/22 MOD END /Liu

        If Request.QueryString("w") Is Nothing Then
            w = ""
        Else
            w = Request.QueryString("w").ToString
        End If

        If Request.QueryString("n") Is Nothing Then
            n = ""
        Else
            n = Request.QueryString("n").ToString
        End If

        Dim sds As SqlDataSource = sql_info_class_midoku
        WebControlsUtil.DeclareSP(sds, "掲示_掲示一覧_授業_SELECT")
        With sds
            .SelectParameters.Add("PORTALID", DbType.String, Session(S_COM_PortalID))
            .SelectParameters.Add("自分宛て", DbType.String, m.ToString)
            .SelectParameters.Add("WORD", DbType.String, w.ToString)
            .SelectParameters.Add("新着", DbType.Int32, n.ToString)
            .SelectParameters.Add("未読のみ", DbType.Boolean, "True")
        End With
    End Sub

#End Region



End Class
