2014年7月29日 星期二

javascript:window.showModalDialog 需配合 gvCheckRec_RowCommand 才可以實現子視窗關閉後重新綁訂GridView

Protected Sub gvCheckRec_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvCheckRec.RowCommand
        Try
            bindGv()
        Catch ex As Exception
            MyBase.showAlertMsg(Utility.handlePageException(ex, MyBase.tracker))
        End Try
    End Sub


====================================================================
  Protected Sub gvCheckRec_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCheckRec.RowDataBound

        Dim js As String = ""
        Dim js_Register As String = ""
        Dim ProcessName As String = ""
        Dim RespArea As String = ""
        Dim dllclass As String = ""
        Dim UniqueContent As String = ""
        Dim button As New Button
        Dim rank As Integer = 1

        Try
            If e.Row.RowType = DataControlRowType.Pager Then
                e.Row.Style.Add("text-align", "center")
                e.Row.Style.Add("height", "40px")
                e.Row.Style.Add("background-image", "")
            End If
            'GV項次
            If (e.Row.RowIndex >= 0 And e.Row.RowType = DataControlRowType.DataRow) Then

                js = "javascript:window.open('RptDcsAlm_AnaTool_Detail.aspx?"
                js &= "&rptid=RptDcsAlm_BasMgt_SumQuery.aspx"
                js &= "&start=" & Me.txtDate_OccStart.Text
                js &= "&end=" & Me.txtDate_OccEnd.Text
                js &= "&class=" & dllclass
                js &= "&TagNo=" & e.Row.Cells(1).Text
                js &= "&process=" & ProcessName
                js &= "&RespArea=" & RespArea
                'js &= "&UniqueContent=" & e.Row.Cells(3).Text

                If e.Row.Cells(3).Text <> "" Then
                    Dim source As String = e.Row.Cells(3).Text
                    Dim str As String() = New String() {","}
                    Dim UniqueContentSplit As String() = source.Split(str, StringSplitOptions.RemoveEmptyEntries)
                    Dim Uniq As String
                    Uniq = UniqueContentSplit(0)

                    If Uniq = "上下限管制異常:H " Then
                        js &= "&UniqueContent=上下限管制異常: H"
                    ElseIf Uniq = "上下限管制異常:HH " Then
                        js &= "&UniqueContent=上下限管制異常: HH"
                    ElseIf Uniq = "上下限管制異常:L " Then
                        js &= "&UniqueContent=上下限管制異常: L"
                    ElseIf Uniq = "上下限管制異常:LL " Then
                        js &= "&UniqueContent=上下限管制異常: LL"
                    End If
                End If

                If Me.ddlLevelType.SelectedIndex = 1 Then
                    js &= "&ddlLevel=Level1"
                ElseIf Me.ddlLevelType.SelectedIndex = 2 Then
                    js &= "&ddlLevel=Level2"
                ElseIf Me.ddlLevelType.SelectedIndex = 3 Then
                    js &= "&ddlLevel=Level3"
                Else
                    js &= "&ddlLevel="
                End If

                js &= "','_blank', 'status=yes,left=350,top=200,width=1100,height=500');"

                CType(e.Row.Cells(5).Controls(0), ImageButton).OnClientClick = js


                js_Register = "javascript:window.showModalDialog('MntDcsAlm_BasMgt_AlmSumRegister.aspx?"
                'js_Register = "javascript:window.open('MntDcsAlm_BasMgt_AlmSumRegister.aspx?"
                js_Register &= "&rptid=RptDcsAlm_BasMgt_SumQuery.aspx"
                js_Register &= "&start=" & Me.txtDate_OccStart.Text
                js_Register &= "&end=" & Me.txtDate_OccEnd.Text
                js_Register &= "&class=" & dllclass
                js_Register &= "&TagNo=" & e.Row.Cells(1).Text
                js_Register &= "&process=" & ProcessName
                js_Register &= "&RespArea=" & Me.ddlRespArea.SelectedValue.ToString
                js_Register &= "&RankNo=" & e.Row.Cells(0).Text
                js_Register &= "&AlarmRank=" & Me.txt_AlarmRank.Text
                js_Register &= "&UniqueContent=" & e.Row.Cells(3).Text
                js_Register &= "&AlmCnt=" & e.Row.Cells(4).Text
                If e.Row.Cells(3).Text <> "" Then
                    Dim source As String = e.Row.Cells(3).Text
                    Dim str As String() = New String() {","}
                    Dim UniqueContentSplit As String() = source.Split(str, StringSplitOptions.RemoveEmptyEntries)
                    Dim Uniq As String

                    Uniq = UniqueContentSplit(0)

                    If Uniq = "上下限管制異常:H " Then
                        js_Register &= "&UniqueContent=上下限管制異常: H"
                    ElseIf Uniq = "上下限管制異常:HH " Then
                        js_Register &= "&UniqueContent=上下限管制異常: HH"
                    ElseIf Uniq = "上下限管制異常:L " Then
                        js_Register &= "&UniqueContent=上下限管制異常: L"
                    ElseIf Uniq = "上下限管制異常:LL " Then
                        js_Register &= "&UniqueContent=上下限管制異常: LL"
                    End If
                End If



                If e.Row.Cells(2).Text = "輕故障" Then
                    js_Register &= "&ddlLevel=Level3"
                ElseIf e.Row.Cells(2).Text = "中故障" Then
                    js_Register &= "&ddlLevel=Level2"
                ElseIf e.Row.Cells(2).Text = "重故障" Then
                    js_Register &= "&ddlLevel=Level1"
                Else
                    js_Register &= "&ddlLevel="
                End If

                js_Register &= "','','dialogWidth=850px,dialogHeight=300px');window.close();"


                Dim YorN As Boolean
                If myenumber = e.Row.RowIndex Then

                    YorN = Comparison(dtCheckRecRank, myenumber)
                    myenumber += 1

                    If YorN = True Then
                        CType(e.Row.Cells(6).Controls(0), ImageButton).Visible = False
                    Else
                        CType(e.Row.Cells(6).Controls(0), ImageButton).OnClientClick = js_Register
                    End If

                End If
                Dim u As Integer = myenumber - 10
                If u = e.Row.RowIndex Then

                    YorN = Comparison(dtCheckRecRank, u)
                    myenumber += 1

                    If YorN = True Then
                        CType(e.Row.Cells(6).Controls(0), ImageButton).Visible = False
                    Else
                        CType(e.Row.Cells(6).Controls(0), ImageButton).OnClientClick = js_Register
                    End If

                End If


                'Dim YorN As Boolean
                'If myenumber <= dtCheckRecRank.Rows.Count - 1 Then
                '    'If myenumber = dtCheckRec.Rows.Count - 1 Then
                '    '    myenumber = myenumber
                '    '    YorN = Comparison(dtCheckRec, myenumber)
                '    'Else
                '    YorN = Comparison(dtCheckRecRank, myenumber)
                '    myenumber += 1
                '    'End If


                '    If YorN = True Then
                '        CType(e.Row.Cells(6).Controls(0), ImageButton).Visible = False
                '    Else
                '        CType(e.Row.Cells(6).Controls(0), ImageButton).OnClientClick = js_Register
                '    End If
                'Else
                '    myenumber = 0
                '    'If myenumber = dtCheckRec.Rows.Count - 1 Then
                '    '    myenumber = myenumber
                '    '    YorN = Comparison(dtCheckRec, myenumber)
                '    'Else
                '    YorN = Comparison(dtCheckRecRank, myenumber)
                '    myenumber += 1
                '    'End If

                '    If YorN = True Then
                '        CType(e.Row.Cells(6).Controls(0), ImageButton).Visible = False
                '    Else
                '        CType(e.Row.Cells(6).Controls(0), ImageButton).OnClientClick = js_Register
                '    End If
                'End If


            End If

        Catch ex As Exception
            MyBase.showAlertMsg(Utility.handlePageException(ex, MyBase.tracker))
        End Try

    End Sub

沒有留言:

張貼留言