Imports System.Data
Imports AppCommon
Imports AppVariable
Imports AppVariable_student

Partial Class mobile_student_AttendStudentSP
    Inherits System.Web.UI.Page

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

    Private Const SESSION_DDL_SELECTED As String = "Attend_Search_GakuseiJyokyo_Jyugyo_Nendo" '選択中のドロップダウンリスト(履修年度)

#End Region

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

#End Region

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

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '---------------------------------------------------------------
        '検索条件をセット
        '---------------------------------------------------------------
        If Not IsPostBack Then
            If "".Equals(Session(SESSION_DDL_SELECTED)) _
                    Or Session(SESSION_DDL_SELECTED) Is Nothing Then
                Session(SESSION_DDL_SELECTED) = dd_検索_授業年度.Items(0).Value
            Else
                Try '※外すと落ちる

                    '2020/8/27 MOD START /Liu
                    'dd_検索_授業年度.Text = Session(SESSION_DDL_SELECTED)

                    dd_検索_授業年度.DataBind()
                    Dim str選択年度 As String = Session(SESSION_DDL_SELECTED)
                    If Not dd_検索_授業年度.Items.FindByValue(str選択年度) Is Nothing Then
                        dd_検索_授業年度.SelectedValue = str選択年度
                    Else
                        dd_検索_授業年度.Items.Add(New ListItem(str選択年度, str選択年度))
                        dd_検索_授業年度.SelectedValue = str選択年度
                    End If
                    '2020/8/27 MOD END /Liu

                Catch ex As Exception
                End Try
            End If
        End If
    End Sub

#End Region

#Region "***************** コントロールイベント *****************"
    Protected Sub sql_学生_Init(sender As Object, e As EventArgs) Handles sql_学生.Init
        sql_学生_select()
    End Sub

    Protected Sub sql_講座一覧_Init(sender As Object, e As EventArgs) Handles sql_講座一覧.Init
        sql_講座一覧_select()
    End Sub

    Protected Sub sql_dd_授業年度_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles sql_dd_授業年度.Init
        sql_dd_授業年度_select()
    End Sub

    Protected Sub dd_検索_授業年度_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dd_検索_授業年度.SelectedIndexChanged
        Session(SESSION_DDL_SELECTED) = dd_検索_授業年度.SelectedValue
        Response.Redirect(Request.RawUrl.ToString)
    End Sub

    Protected Sub lsv_講座_ItemCommand(sender As Object, e As ListViewCommandEventArgs) Handles lsv_講座.ItemCommand
        If e.CommandName = "授業選択" Then
            Dim str履修年度 As String = CType(e.Item.FindControl("lb_履修年度"), Label).Text
            Dim str成績年度 As String = CType(e.Item.FindControl("lb_成績年度"), Label).Text
            Dim str分野CD As String = CType(e.Item.FindControl("lb_分野CD"), Label).Text
            Dim str科目CD As String = CType(e.Item.FindControl("lb_科目CD"), Label).Text
            Dim str講座CD As String = CType(e.Item.FindControl("lb_講座CD"), Label).Text
            Dim str講座名 As String = CType(e.Item.FindControl("lb_授業名"), Label).Text
            Dim str期間 As String = CType(e.Item.FindControl("lb_期間"), Label).Text

            '選択した講座の情報をセッションに保存
            Session(S_Attend_Selected_Risyu_Nendo) = str履修年度
            Session(S_Attend_Selected_Seiseki_Nendo) = str成績年度
            Session(S_Attend_Selected_Bunya_CD) = str分野CD
            Session(S_Attend_Selected_Kamoku_CD) = str科目CD
            Session(S_Attend_Selected_Kouza_CD) = str講座CD
            Session(S_Attend_Selected_Kouza_Name) = str講座名
            Session(S_Attend_Selected_Kouza_Kikan) = str期間

            '詳細ページに遷移
            Response.Redirect(Com_Get_Content("menu_km_010_mb"))
        End If
    End Sub
#End Region

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

    Private Sub sql_学生_select()
        Dim sds As SqlDataSource = sql_学生
        WebControlsUtil.DeclareSP(sds, "共通_学生_個別_SELECT")
        With sds
            .SelectParameters.Add("学籍NO", Session(S_COM_UserCD))
        End With
    End Sub

    Private Sub sql_dd_授業年度_select()
        Dim sds As SqlDataSource = sql_dd_授業年度
        WebControlsUtil.DeclareSP(sds, "出欠_学生別_履修年度_DDL")
        With sds
            .SelectParameters.Add("USERCD", DbType.String, Session(S_COM_UserCD))
        End With
    End Sub

    Private Sub sql_講座一覧_select()
        '既定の授業年度をセッションにセット
        If Session(SESSION_DDL_SELECTED) Is Nothing Then
            Session(SESSION_DDL_SELECTED) = Com_Get_既定授業年度_学生(Session(S_COM_UserCD))
        End If

        Dim sds As SqlDataSource = sql_講座一覧
        WebControlsUtil.DeclareSP(sds, "出欠_モバイル_講座一覧_学生別_SELECT")
        With sds
            .SelectParameters.Add("学籍NO", DbType.String, Session(S_COM_UserCD))
            .SelectParameters.Add("履修年度", DbType.Int16, Session(SESSION_DDL_SELECTED))
        End With
    End Sub
#End Region

    
End Class
