Imports System.Data
Imports AppCommon
Imports AppVariable

Partial Class training_applyregister
    Inherits System.Web.UI.Page

#Region "******************** メンバ変数 ********************"
    Private _search As TrainingSearch
    Private _param As TrainingParam
    Private _user As LoginUser
    Private trainingTel As String = Com_Get_変数("PT_COMMON_TRAINING_TEL")

    Private Class UserInfo
        Public Property PortalId As String
        Public Property UserCd As String
        Public Property UserName As String
        Public Property UserKbn As String
        Public Property PortalKbn As String
        Public Property Email As String
        Public Property Tel As String
        Public Property GakuenCd As String
        Public Property Department As String

        Public Sub New(userCd As String)
            Dim dt As DataTable = GetUserData(userCd, True)

            If dt.Rows.Count > 0 Then
                Me.UserCd = userCd
                Me.PortalId = dt.Rows(0)("PORTALID").ToString()
                Me.UserName = dt.Rows(0)("名前").ToString()
                Me.PortalKbn = dt.Rows(0)("PORTAL区分").ToString()
                Me.UserKbn = dt.Rows(0)("利用者区分").ToString()
                Me.Email = dt.Rows(0)("EMAIL").ToString()
                Me.Tel = dt.Rows(0)("電話番号").ToString()
                Me.GakuenCd = dt.Rows(0)("学園CD").ToString()
                Me.Department = dt.Rows(0)("所属部課").ToString()
            Else
                Me.UserCd = String.Empty
                Me.PortalId = String.Empty
                Me.UserName = String.Empty
                Me.PortalKbn = String.Empty
                Me.UserKbn = String.Empty
                Me.Email = String.Empty
                Me.Tel = String.Empty
                Me.GakuenCd = String.Empty
                Me.Department = String.Empty
            End If
        End Sub

    End Class

#End Region

#Region "******************** ページイベント ********************"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            _search = DirectCast(Session(S_Training_Search), TrainingSearch)
            _param = DirectCast(Session(S_Training_Seleted_Param), TrainingParam)
            _user = DirectCast(Session(S_COM_LoginUser), LoginUser)

            If Not IsPostBack() Then
                uc_TrainingInfo.Create研修詳細()
                CreateControls()
                AdjustControls()
                AdjustButtons()
                Bind申込()

                '注釈の追加 20240325 Add/S.Iguchi
                lb_未定表示.Text = uc_TrainingInfo.未定表示
            cb_未定.Enabled = uc_TrainingInfo.未定可 = "可"

            lb_履修年度.Text = _param.履修年度.ToString
            lb_成績年度.Text = _param.成績年度.ToString
            lb_分野CD.Text = _param.分野CD.ToString
            lb_科目CD.Text = _param.科目CD
            lb_講座CD.Text = _param.講座CD
            lb_連番.Text = _param.連番.ToString

            Dim msg As String = uc_TrainingInfo.新規申込NG
            If String.Empty.Equals(msg) Then
                btn_申込.Enabled = True
                div_error_mes_area.Visible = False
                'lb_新規申込NG.Visible = False
            Else
                btn_申込.Enabled = False
                div_error_mes_area.Visible = True
                'lb_新規申込NG.Visible = True
            End If
        End If
        End Sub
#End Region

#Region "***************** コントロールイベント *****************"
        Protected Sub btn_戻る_Click(ByVal sender As Object, ByVal e As EventArgs)
            If _param.Referer = FunctionCd.TrainingList Then
                _search.ForceSearch = True
                Session(S_Training_Search) = _search
            End If

            'ページ遷移
            Response.Redirect(Com_Get_Content(_param.Referer))
        End Sub

        Protected Sub btn_一時保存_Click(ByVal sender As Object, ByVal e As EventArgs)
            Regist申込("一時保存")

            Dim msg As String = ""
            msg &= "下書きを保存しました。"
            Session(S_Training_ClientMessage) = msg

            _search.ForceSearch = True
            Session(S_Training_Search) = _search

            'ページ遷移
            Response.Redirect(Com_Get_Content(FunctionCd.TrainingList))
        End Sub

        Protected Sub btn_申込_Click(ByVal sender As Object, ByVal e As EventArgs)

        If Regist申込("申込済み") Then

            '申込番号の取得
            Dim applyNo As String = Exec申込()
            Dim userCd As String = Session(S_COM_UserCD).ToString()

            If Not String.IsNullOrEmpty(applyNo) Then

                '研修申込完了メールの送信
                Dim sucFlg = AppMail.SendApplyRegisterMail(userCd, applyNo)

                Dim msg As String = ""
                msg &= "研修受講申込みを受け付けました。"
                msg &= "\r\n" & "後ほど受講申込み完了のメールが届きます。"
                msg &= "\r\n" & "完了メールが届かない場合は、研修部あてに電話"
                msg &= "\r\n" & "をしてください。(TEL："
                msg &= trainingTel
                msg &= ")"

                Session(S_Training_ClientMessage) = msg

                'ページ遷移
                Response.Redirect(Com_Get_Content(FunctionCd.TrainingApplyConfirm))

            Else
                Dim msg As String = ""
                msg &= "申込登録に失敗しました"
                msg &= "\r\n" & "管理者にお問い合わせください。"

                Session(S_Training_ClientMessage) = msg

                _search.ForceSearch = True
                Session(S_Training_Search) = _search

            End If

        End If
    End Sub

    Protected Sub btn_更新_Click(ByVal sender As Object, ByVal e As EventArgs)

        If Regist申込("申込済み") Then

            Dim applyNo As String = hf_ApplyNo.Value
            Dim userCd As String = Session(S_COM_UserCD).ToString()

            If Not String.IsNullOrEmpty(applyNo) Then

                '研修申込完了メールの送信
                Dim sucFlg = AppMail.SendApplyUpdateMail(userCd, applyNo)

                Dim msg As String = ""
                msg &= "申込内容更新を受け付けました。"
                msg &= "\r\n" & "後ほど更新完了のメールが届きます。"
                msg &= "\r\n" & "完了メールが届かない場合は、研修部あてに電話"
                msg &= "\r\n" & "をしてください。(TEL："
                msg &= trainingTel
                msg &= ")"

                Session(S_Training_ClientMessage) = msg

                'ページ遷移
                Response.Redirect(Com_Get_Content(FunctionCd.TrainingApplyConfirm))
            End If
        Else
            Dim msg As String = ""
            msg &= "申込更新に失敗しました"
            msg &= "\r\n" & "管理者にお問い合わせください。"

            Session(S_Training_ClientMessage) = msg

            _search.ForceSearch = True
            Session(S_Training_Search) = _search

        End If
    End Sub

#End Region


#Region "******************* Sub及びFunction ********************"
    Private Sub CreateControls()
            Create性別()
            Create選任区分()
            Create職層()
            Create職種()
            Create受講経験有無()
        'Create過去参加有無()
    End Sub

        Private Sub Create性別()
            Using spm As New StoredProcedureManager("共通_変数_DDL")
                spm.AddPrmIn("@変数", SqlDbType.VarChar, "性")
                spm.Fill()

                rbl_性別.DataSource = spm.ds.Tables(0)
            End Using

            rbl_性別.DataBind()
        End Sub

        Private Sub Create選任区分()
            Using spm As New StoredProcedureManager("共通_変数_DDL")
                spm.AddPrmIn("@変数", SqlDbType.VarChar, "研修申込_選任区分")
                spm.Fill()

                dd_選任区分.DataSource = spm.ds.Tables(0)
            End Using

            dd_選任区分.DataBind()
        End Sub

    Private Sub Create職層()

        Dim str研修区分 As String = uc_TrainingInfo.研修区分
        Dim str科目CD As String = _param.科目CD

        Using spm As New StoredProcedureManager("申込_職層_DDL")
            spm.AddPrmIn("@変数", SqlDbType.VarChar, "研修申込_職層")
            spm.AddPrmIn("@研修区分", SqlDbType.VarChar, str研修区分)
            spm.AddPrmIn("@科目CD", SqlDbType.VarChar, str科目CD)
            spm.Fill()

            dd_職層.DataSource = spm.ds.Tables(0)
        End Using

        dd_職層.DataBind()
    End Sub

    Private Sub Create職種()
            Using spm As New StoredProcedureManager("共通_変数_DDL")
                spm.AddPrmIn("@変数", SqlDbType.VarChar, "研修申込_職種")
                spm.Fill()

                dd_職種.DataSource = spm.ds.Tables(0)
            End Using

            dd_職種.DataBind()
        End Sub

    Private Sub Create受講経験有無()
        Using spm As New StoredProcedureManager("共通_変数_DDL")
            spm.AddPrmIn("@変数", SqlDbType.VarChar, "研修申込_有無")
            spm.Fill()

            dd_受講経験有無.DataSource = spm.ds.Tables(0)
        End Using

        dd_受講経験有無.DataBind()
    End Sub

    Private Sub AdjustControls()
        Dim str研修区分 = uc_TrainingInfo.研修区分

        If str研修区分.Equals("一般研修") Then
            DisenabledControl({lb_選任区分}, {vdt_選任区分}, {dd_選任区分})
        End If

        If str研修区分.Equals("市町村長セミナー") Then
            DisenabledControl({lb_選任区分}, {vdt_選任区分}, {dd_選任区分})
            DisenabledControl({lb_所属部課}, {vdt_所属部課}, {txt_所属部課})
            DisenabledControl({lb_職種}, {vdt_職種, vdt_職種_その他}, {dd_職種, txt_職種})
            DisenabledControl({lb_通算経験年月数}, {vdt_通算経験年数, vdt_通算経験月数}, {txt_通算経験年数, txt_通算経験月数})
            DisenabledControl({lb_過去受講不可科目}, {vdt_過去受講不可科目_実施年, vdt_過去受講不可科目_実施月, cvd_過去受講不可科目_実施年月}, {txt_過去受講不可科目, txt_過去受講不可科目_実施年, txt_過去受講不可科目_実施月})
        End If

        If str研修区分.Equals("監査セミナー") Then　'選任区分は監査セミナーのみで使用。それ以外は無効化
            DisenabledControl({lb_職名}, {vdt_職名}, {txt_職名})
            DisenabledControl({lb_職層}, {vdt_職層}, {dd_職層})
            DisenabledControl({lb_所属部課}, {vdt_所属部課}, {txt_所属部課})
            DisenabledControl({lb_職種}, {vdt_職種, vdt_職種_その他}, {dd_職種, txt_職種})
            DisenabledControl({lb_通算経験年月数}, {vdt_通算経験年数, vdt_通算経験月数}, {txt_通算経験年数, txt_通算経験月数})
            DisenabledControl({lb_過去受講不可科目}, {vdt_過去受講不可科目_実施年, vdt_過去受講不可科目_実施月, cvd_過去受講不可科目_実施年月}, {txt_過去受講不可科目, txt_過去受講不可科目_実施年, txt_過去受講不可科目_実施月})
        End If

        If str研修区分.Equals("議員セミナー") Then
            DisenabledControl({lb_所属部課}, {vdt_所属部課}, {txt_所属部課})
            DisenabledControl({lb_選任区分}, {vdt_選任区分}, {dd_選任区分})
            DisenabledControl({lb_職種}, {vdt_職種, vdt_職種_その他}, {dd_職種, txt_職種})
            DisenabledControl({lb_通算経験年月数}, {vdt_通算経験年数, vdt_通算経験月数}, {txt_通算経験年数, txt_通算経験月数})
            DisenabledControl({lb_過去受講不可科目}, {vdt_過去受講不可科目_実施年, vdt_過去受講不可科目_実施月, cvd_過去受講不可科目_実施年月}, {txt_過去受講不可科目, txt_過去受講不可科目_実施年, txt_過去受講不可科目_実施月})
        End If

    End Sub

        Private Sub DisenabledControl(
                  Optional ByRef lbls As Label() = Nothing _
                , Optional ByRef vdts As BaseValidator() = Nothing _
                , Optional ByRef ipts As WebControl() = Nothing
        )
            If lbls.Length > 0 Then
                For Each lbl As Label In lbls
                    lbl.Attributes("data-required") = "false"
                Next
            End If

            If vdts.Length > 0 Then
                For Each vdt As WebControl In vdts
                    vdt.Enabled = False
                Next
            End If

            If ipts.Length > 0 Then
                For Each int As WebControl In ipts
                    int.Enabled = False
                Next
            End If
        End Sub

        Private Function Regist申込(ByVal prm申込状況 As String) As Boolean

        Dim str履修年度 As String = lb_履修年度.Text
        Dim str成績年度 As String = lb_成績年度.Text
        Dim str分野CD As String = lb_分野CD.Text
        Dim str科目CD As String = lb_科目CD.Text
        Dim str講座CD As String = lb_講座CD.Text
        Dim str連番 As String = lb_連番.Text

        Using spm As New StoredProcedureManager("申込_締切状態_OUTPUT")
            spm.AddPrmIn("@履修年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str履修年度), DBNull.Value, str履修年度))
            spm.AddPrmIn("@成績年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str成績年度), DBNull.Value, str成績年度))
            spm.AddPrmIn("@分野CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str分野CD), DBNull.Value, str分野CD))
            spm.AddPrmIn("@科目CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str科目CD), DBNull.Value, str科目CD))
            spm.AddPrmIn("@講座CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str講座CD), DBNull.Value, str講座CD))
            spm.AddPrmOut("@out締切状態", SqlDbType.TinyInt)

            spm.Exec()

            Dim int締切状態 As Int16 = 0

            int締切状態 = spm.GetValue("@out締切状態")

            '締切状態
            '0:締め切っていない
            '1:定員超過で締切
            '2:申込期限超過で締切
            '3:追加募集期限日超過で締切
            Select Case int締切状態
                Case 0
                    div_error_mes_area.Visible = False
                    '申込処理にすすむ
                Case 1
                    '締切済メッセージの表示
                    div_error_mes_area.Visible = True
                    lb_締切MES.Text = "定員に達した為、新規申込できません。"
                    Return False
                Case 2, 3
                    div_error_mes_area.Visible = True
                    lb_締切MES.Text = "申込期限を過ぎた為、新規申込できません。"
                    Return False
            End Select
        End Using


        Try

                Using spm As New StoredProcedureManager("申込_研修申込_REGIST")
                '    spm.AddPrmIn("@履修年度", SqlDbType.SmallInt, _param.履修年度)
                '    spm.AddPrmIn("@成績年度", SqlDbType.SmallInt, _param.成績年度)
                '    spm.AddPrmIn("@分野CD", SqlDbType.VarChar, _param.分野CD)
                '    spm.AddPrmIn("@科目CD", SqlDbType.VarChar, _param.科目CD)
                '   　spm.AddPrmIn("@講座CD", SqlDbType.VarChar, _param.講座CD)
                'セッション値ではなく、画面出力したキー値を利用
                spm.AddPrmIn("@履修年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str履修年度), DBNull.Value, str履修年度))
                spm.AddPrmIn("@成績年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str成績年度), DBNull.Value, str成績年度))
                spm.AddPrmIn("@分野CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str分野CD), DBNull.Value, str分野CD))
                spm.AddPrmIn("@科目CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str科目CD), DBNull.Value, str科目CD))
                spm.AddPrmIn("@講座CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str講座CD), DBNull.Value, str講座CD))
                If _param.Mode = ScreenMode.Additions Then
                        spm.AddPrmIn("@連番", SqlDbType.Int, DBNull.Value)
                    Else
                    'spm.AddPrmIn("@連番", SqlDbType.Int, _param.連番)
                    spm.AddPrmIn("@連番", Data.SqlDbType.Int, IIf(String.IsNullOrEmpty(str連番), DBNull.Value, str連番))
                End If

                    spm.AddPrmIn("@氏名", SqlDbType.VarChar, txt_氏名.Text)
                    spm.AddPrmIn("@未定", SqlDbType.Bit, cb_未定.Checked)
                    spm.AddPrmIn("@ふりがな", SqlDbType.VarChar, txt_ふりがな.Text)
                    spm.AddPrmIn("@年齢", SqlDbType.TinyInt, txt_年齢.Text)
                    spm.AddPrmIn("@性別", SqlDbType.VarChar, rbl_性別.SelectedValue)
                    spm.AddPrmIn("@所属部課", SqlDbType.VarChar, txt_所属部課.Text)
                spm.AddPrmIn("@職名", SqlDbType.VarChar, txt_職名.Text)
                spm.AddPrmIn("@補職名", SqlDbType.VarChar, "")
                spm.AddPrmIn("@選任区分", SqlDbType.VarChar, dd_選任区分.SelectedValue)
                spm.AddPrmIn("@通算経験年数", SqlDbType.TinyInt, txt_通算経験年数.Text)
                    spm.AddPrmIn("@通算経験月数", SqlDbType.TinyInt, txt_通算経験月数.Text)
                    spm.AddPrmIn("@過去受講不可科目", SqlDbType.VarChar, txt_過去受講不可科目.Text)
                    spm.AddPrmIn("@過去受講不可科目_実施年", SqlDbType.SmallInt, txt_過去受講不可科目_実施年.Text)
                    spm.AddPrmIn("@過去受講不可科目_実施月", SqlDbType.TinyInt, txt_過去受講不可科目_実施月.Text)
                    spm.AddPrmIn("@受講経験有無", SqlDbType.VarChar, dd_受講経験有無.SelectedValue)
                spm.AddPrmIn("@受講経験年度", SqlDbType.SmallInt, String.Empty)
                spm.AddPrmIn("@職層", SqlDbType.VarChar, dd_職層.SelectedValue)
                    Dim val職種 As String
                    If String.IsNullOrEmpty(txt_職種.Text) Then
                        val職種 = dd_職種.SelectedValue
                    Else
                        val職種 = txt_職種.Text
                    End If
                    spm.AddPrmIn("@職種", SqlDbType.VarChar, val職種)
                spm.AddPrmIn("@過去参加有無", SqlDbType.VarChar, String.Empty)
                spm.AddPrmIn("@過去参加回数", SqlDbType.TinyInt, txt_過去参加回数.Text)

                spm.AddPrmIn("@研修担当所属", SqlDbType.VarChar, lb_研修担当所属.Text)
                spm.AddPrmIn("@研修担当氏名", SqlDbType.VarChar, txt_研修担当氏名.Text)
                    spm.AddPrmIn("@研修担当TEL", SqlDbType.VarChar, txt_研修担当TEL.Text)
                spm.AddPrmIn("@研修担当EMAIL", SqlDbType.VarChar, lb_研修担当EMAIL.Text)
                spm.AddPrmIn("@備考", SqlDbType.VarChar, txt_備考.Text)
                    spm.AddPrmIn("@任命権者名", SqlDbType.VarChar, txt_任命権者名.Text)
                    spm.AddPrmIn("@PASSWORD", SqlDbType.VarChar, txt_PASSWORD.Text)

                    spm.AddPrmIn("@申込状況", SqlDbType.VarChar, prm申込状況)
                    spm.AddPrmIn("@USERCD", SqlDbType.VarChar, _user.USERCD)
                    spm.AddPrmIn("@学園CD", SqlDbType.VarChar, _user.学園CD)
                    spm.AddPrmIn("@市区町村CD", SqlDbType.VarChar, _user.市区町村CD)

                    spm.AddPrmOut("@out連番", SqlDbType.Int)

                    spm.Exec()

                _param.連番 = spm.GetValue("@out連番")

                'セッションの値を更新
                _param.履修年度 = lb_履修年度.Text
                _param.成績年度 = lb_成績年度.Text
                _param.分野CD = lb_分野CD.Text
                _param.科目CD = lb_科目CD.Text
                _param.講座CD = lb_講座CD.Text


                Session(S_Training_Seleted_Param) = _param
                lb_連番.Text = _param.連番
            End Using

                Return True

            Catch ex As Exception
                Return False
            End Try

        End Function

        Private Function Exec申込() As String

        Dim str履修年度 As String = lb_履修年度.Text
        Dim str成績年度 As String = lb_成績年度.Text
        Dim str分野CD As String = lb_分野CD.Text
        Dim str科目CD As String = lb_科目CD.Text
        Dim str講座CD As String = lb_講座CD.Text
        Dim str連番 As String = lb_連番.Text

        Try
                Dim applyNo As String = ""


            Using spm As New StoredProcedureManager("申込_研修申込_EXEC")
                'spm.AddPrmIn("@履修年度", SqlDbType.SmallInt, _param.履修年度)
                'spm.AddPrmIn("@成績年度", SqlDbType.SmallInt, _param.成績年度)
                'spm.AddPrmIn("@分野CD", SqlDbType.VarChar, _param.分野CD)
                'spm.AddPrmIn("@科目CD", SqlDbType.VarChar, _param.科目CD)
                'spm.AddPrmIn("@講座CD", SqlDbType.VarChar, _param.講座CD)
                'spm.AddPrmIn("@連番", SqlDbType.Int, _param.連番)

                'セッション値ではなく、画面出力したキー値を利用
                spm.AddPrmIn("@履修年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str履修年度), DBNull.Value, str履修年度))
                spm.AddPrmIn("@成績年度", Data.SqlDbType.SmallInt, IIf(String.IsNullOrEmpty(str成績年度), DBNull.Value, str成績年度))
                spm.AddPrmIn("@分野CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str分野CD), DBNull.Value, str分野CD))
                spm.AddPrmIn("@科目CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str科目CD), DBNull.Value, str科目CD))
                spm.AddPrmIn("@講座CD", Data.SqlDbType.VarChar, 20, IIf(String.IsNullOrEmpty(str講座CD), DBNull.Value, str講座CD))
                spm.AddPrmIn("@連番", Data.SqlDbType.Int, IIf(String.IsNullOrEmpty(str連番), DBNull.Value, str連番))

                spm.AddPrmIn("@USERCD", SqlDbType.VarChar, _user.USERCD)
                    spm.AddPrmIn("@学園CD", SqlDbType.VarChar, _user.学園CD)
                    spm.AddPrmIn("@市区町村CD", SqlDbType.VarChar, _user.市区町村CD)

                    spm.AddPrmOut("@out_申込番号", SqlDbType.VarChar, 20)

                    spm.Exec()

                    applyNo = spm.GetValue("@out_申込番号")

                End Using

                Return applyNo

            Catch ex As Exception
                Return ""
            End Try

        End Function

        Private Sub Bind申込()

        If _param.Mode = ScreenMode.Additions Then
            '研修担当関連項目の初期値の設定
            Dim userInfo As UserInfo = New UserInfo(_user.USERCD)
            lb_研修担当所属.Text = userInfo.Department
            txt_研修担当氏名.Text = userInfo.UserName
            txt_研修担当TEL.Text = userInfo.Tel
            lb_研修担当EMAIL.Text = userInfo.Email
            Exit Sub
        End If

        '初期値の設定
        Dim dt As DataTable
        Using spm As New StoredProcedureManager("申込_研修申込_SELECT")
            spm.AddPrmIn("@履修年度", SqlDbType.SmallInt, _param.履修年度)
            spm.AddPrmIn("@成績年度", SqlDbType.SmallInt, _param.成績年度)
            spm.AddPrmIn("@分野CD", SqlDbType.VarChar, _param.分野CD)
            spm.AddPrmIn("@科目CD", SqlDbType.VarChar, _param.科目CD)
            spm.AddPrmIn("@講座CD", SqlDbType.VarChar, _param.講座CD)
            spm.AddPrmIn("@連番", SqlDbType.Int, _param.連番)
            spm.Fill()

            dt = spm.ds.Tables(0)
        End Using

        cb_未定.Checked = ("True".Equals(dt.Rows(0)("未定").ToString()))
        txt_氏名.Text = dt.Rows(0)("氏名").ToString()
        txt_ふりがな.Text = dt.Rows(0)("ふりがな").ToString()
        txt_年齢.Text = dt.Rows(0)("年齢").ToString()
        rbl_性別.SelectedValue = dt.Rows(0)("性別").ToString()
        txt_所属部課.Text = dt.Rows(0)("所属部課").ToString()
        txt_職名.Text = dt.Rows(0)("職名").ToString()
        dd_選任区分.SelectedValue = dt.Rows(0)("選任区分").ToString()
        dd_職層.SelectedValue = dt.Rows(0)("職層").ToString()
        Dim val職種 As String = dt.Rows(0)("職種").ToString()
        If Not String.IsNullOrEmpty(val職種) Then
            For Each li As ListItem In dd_職種.Items
                If li.Value = val職種 Then
                    dd_職種.SelectedValue = val職種
                    Exit For
                End If
            Next
            If String.IsNullOrEmpty(dd_職種.SelectedValue) Then
                dd_職種.SelectedValue = "その他"
                txt_職種.Text = val職種
            End If
        End If
        txt_通算経験年数.Text = dt.Rows(0)("通算経験年数").ToString()
        txt_通算経験月数.Text = dt.Rows(0)("通算経験月数").ToString()
        txt_過去受講不可科目.Text = dt.Rows(0)("過去受講不可科目").ToString()
        txt_過去受講不可科目_実施年.Text = dt.Rows(0)("過去受講不可科目_実施年").ToString()
        txt_過去受講不可科目_実施月.Text = dt.Rows(0)("過去受講不可科目_実施月").ToString()
        dd_受講経験有無.SelectedValue = dt.Rows(0)("受講経験有無").ToString()
        txt_過去参加回数.Text = dt.Rows(0)("過去参加回数").ToString()

        If dt.Rows.Count > 0 Then
            lb_研修担当所属.Text = dt.Rows(0)("研修担当所属").ToString()
            txt_研修担当氏名.Text = dt.Rows(0)("研修担当氏名").ToString()
            txt_研修担当TEL.Text = dt.Rows(0)("研修担当TEL").ToString()
            lb_研修担当EMAIL.Text = dt.Rows(0)("研修担当EMAIL").ToString()

        Else '申込情報未登録時の初期値
            Dim userInfo As UserInfo = New UserInfo(_user.USERCD)
            lb_研修担当所属.Text = userInfo.Department
            txt_研修担当氏名.Text = userInfo.UserName
            txt_研修担当TEL.Text = userInfo.Tel
            lb_研修担当EMAIL.Text = userInfo.Email
        End If

        txt_備考.Text = dt.Rows(0)("備考").ToString()
        txt_任命権者名.Text = dt.Rows(0)("任命権者名").ToString()
        txt_PASSWORD.Text = dt.Rows(0)("PASSWORD").ToString()

        '申込番号を保持→更新処理時のパラメータ用
        hf_ApplyNo.Value = dt.Rows(0)("学籍NO").ToString

        '複数セッション開くことによるエラー防止のため、セッション内容をページに出力しておく　--20250527 S.Iguchi
        lb_履修年度.Text = dt.Rows(0)("履修年度").ToString
        lb_成績年度.Text = dt.Rows(0)("成績年度").ToString
        lb_分野CD.Text = dt.Rows(0)("分野CD").ToString
        lb_科目CD.Text = dt.Rows(0)("科目CD").ToString
        lb_講座CD.Text = dt.Rows(0)("講座CD").ToString
        lb_連番.Text = dt.Rows(0)("連番").ToString

    End Sub

        Private Sub AdjustButtons()
            If _param.Mode = ScreenMode.Edits Then
                div_button_add.Visible = False
            Else
                div_button_edit.Visible = False
            End If
        End Sub


#End Region

    End Class
