Imports System.Data
Imports AppVariable
Imports AppCommon

Partial Class uc_SearchClaim
    Inherits System.Web.UI.UserControl
    Dim _portalId As String
    Dim _searchParam As SearchClaimParam
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session(S_COM_PortalID) Is Nothing Then
            Return
        End If

        _portalId = Session(S_COM_PortalID)

        If Session(S_Claim_Search_Param) IsNot Nothing Then
            _searchParam = CType(Session(S_Claim_Search_Param), SearchClaimParam)
        End If
        If Not IsPostBack Then
            SetDropDown学園リスト(ddl学園, _portalId)
            SetDropDown出予年度(ddl出予年度)

            If Session(S_Claim_Search_Param) IsNot Nothing Then
                txt出身校名.Text = _searchParam.出身校名
                txt氏名.Text = _searchParam.氏名
                txtふりがな.Text = _searchParam.ふりがな
                ddl学園.SelectedValue = _searchParam.学園
                ddl出願.SelectedValue = _searchParam.出願
                ddl出予年度.SelectedValue = _searchParam.出予年度

                gv学生リスト.SelectedIndex = _searchParam.SelectedIndex
                gv学生リスト.PageIndex = _searchParam.PageIndex
            End If

            Set学生リスト()
        End If
    End Sub

    Private Sub Set学生リスト()
        WebControlsUtil.DeclareSP(sds学生リスト, "募集_請求一覧_学生検索_SELECT")
        With sds学生リスト
            .SelectParameters.Add("出身校名検索", DbType.String, txt出身校名.Text)
            .SelectParameters.Add("名前検索", DbType.String, txt氏名.Text)
            .SelectParameters.Add("ふり検索", DbType.String, txtふりがな.Text)
            .SelectParameters.Add("学園CD", DbType.String, ddl学園.SelectedValue)
            .SelectParameters.Add("出願FLG", DbType.String, ddl出願.SelectedValue)
            .SelectParameters.Add("出予年度検索", DbType.String, ddl出予年度.SelectedValue)
            .SelectParameters.Add("PORTALID", DbType.String, _portalId)
        End With
    End Sub
    Protected Sub btn_検索_Click(sender As Object, e As EventArgs)
        Session.Remove(S_Claim_Search_Param)

        Dim params As New SearchClaimParam
        '検索条件をセッションに保存
        params.出身校名 = txt出身校名.Text
        params.氏名 = txt氏名.Text
        params.ふりがな = txtふりがな.Text
        params.学園 = ddl学園.SelectedValue
        params.出願 = ddl出願.SelectedValue
        params.出予年度 = ddl出予年度.SelectedValue

        Session(S_Claim_Search_Param) = params

        gv学生リスト.SelectedIndex = -1
        gv学生リスト.PageIndex = 0
        Set学生リスト()

    End Sub
    Protected Sub btn_検索クリア_Click(sender As Object, e As EventArgs)
        Session.Remove(S_Claim_Search_Param)
        Response.Redirect(Request.RawUrl.ToString)
    End Sub
    Protected Sub gv学生リスト_SelectedIndexChanged(sender As Object, e As EventArgs)
        '検索リストから選択された授業情報を保持
        Dim params As New ClaimParam
        params.請求No = gv学生リスト.SelectedDataKey.Item(0)
        Session(S_Claim_Selected_Student) = params
        '選択行の位置を保持
        If _searchParam Is Nothing Then
            _searchParam = New SearchClaimParam
            '検索条件をセッションに保存
            _searchParam.出身校名 = txt出身校名.Text
            _searchParam.氏名 = txt氏名.Text
            _searchParam.ふりがな = txtふりがな.Text
            _searchParam.学園 = ddl学園.SelectedValue
            _searchParam.出願 = ddl出願.SelectedValue
            _searchParam.出予年度 = ddl出予年度.SelectedValue
        End If
        _searchParam.SelectedIndex = gv学生リスト.SelectedIndex
        _searchParam.PageIndex = gv学生リスト.PageIndex

        Session(S_Claim_Search_Param) = _searchParam
        Response.Redirect(Com_Get_Content(S_Claim_機能CD_Of_請求詳細), True)
    End Sub
    Protected Sub gv学生リスト_RowDataBound(sender As Object, e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            'リストクリック時選択状態にする
            Dim instance As ClientScriptManager = Page.ClientScript
            Dim button As LinkButton = CType(e.Row.FindControl("lbtn_選択"), LinkButton)
            e.Row.Attributes("onclick") = instance.GetPostBackClientHyperlink(button, "")
        End If
    End Sub

    Protected Sub gv学生リスト_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
        '選択行を解除
        gv学生リスト.SelectedIndex = -1
        'ページを移動
        gv学生リスト.PageIndex = e.NewPageIndex

        'ページの位置を保持
        '選択行の位置を保持
        If _searchParam Is Nothing Then
            _searchParam = New SearchClaimParam
            '検索条件をセッションに保存
            _searchParam.出身校名 = txt出身校名.Text
            _searchParam.氏名 = txt氏名.Text
            _searchParam.ふりがな = txtふりがな.Text
            _searchParam.学園 = ddl学園.SelectedValue
            _searchParam.出願 = ddl出願.SelectedValue
            _searchParam.出予年度 = ddl出予年度.SelectedValue
        End If
        _searchParam.SelectedIndex = -1
        _searchParam.PageIndex = gv学生リスト.PageIndex
        Session(S_Claim_Search_Param) = _searchParam
        Set学生リスト()
    End Sub
End Class
