Imports System.Data
Imports AppCommon
Imports AppVariable

Partial Class AttendStudent
    Inherits System.Web.UI.Page

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

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

#End Region

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

    Private ColmunCnt As Integer = 1
    Private ColmunMax As Integer = 15

#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_dd_授業年度_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles sql_dd_授業年度.Init
        sql_dd_授業年度_select()
    End Sub

    Protected Sub gv_出席状況_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_出席状況.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim ColmunCnt As Integer = 1

            While (ColmunCnt <= ColmunMax)
                If CType(e.Row.FindControl("lb_色" & ColmunCnt), Label).Text <> "" Then
                    e.Row.Cells(4 + ColmunCnt).BackColor = Drawing.Color.FromName(CType(e.Row.FindControl("lb_色" & ColmunCnt), Label).Text)
                ElseIf CType(e.Row.FindControl("lb_出" & ColmunCnt), Label).Text = "" Then
                    e.Row.Cells(4 + ColmunCnt).BackColor = Drawing.Color.FromName("#F0F0F0")
                End If

                ColmunCnt = ColmunCnt + 1
            End While
        End If
    End Sub

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

#End Region

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

    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
            '2017/03/31 M.Okabe MOD Start
            'Session(SESSION_DDL_SELECTED) = Com_Get_既定授業年度()
            Session(SESSION_DDL_SELECTED) = Com_Get_既定授業年度_学生(Session(S_COM_UserCD))
            '2017/03/31 M.Okabe MOD End
        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
