首页 新闻 搜索 专区 学院

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is n

0
悬赏园豆:100 [已关闭问题] 关闭于 2012-05-14 15:11

Button1_Click 提交,有个时候出现以下问题 ,有个时候又没有. sqlconnection 连接打开都关闭的 .不知道为什么还会超时过期.

 

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.(   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at GridSorting.FrmStatus.SavaJianchaDataBase(String YwType, String strGetHuiZhiHao, String strBanJieType) in C:\web\approve2\FrmStatus.aspx.vb:line 1275
   at GridSorting.FrmStatus.Button1_Click(Object sender, EventArgs e) in C:\web\approve2\FrmStatus.aspx.vb:line 902)


Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.(   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.SetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at taia.Components.Database.DataBase.Fill(String sql, IDataParameter[] param, DataTable& dt))


Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.(   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.SetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at taia.Components.Database.DataBase.Fill(String sql, IDataParameter[] param, DataTable& dt)
   at taia.Components.Database.DataBase.Fill(String sql, DataTable& dt)
   at taia.xzxk.Bussiness.Core.GetData(String sql)
   at GridSorting.FrmStatus.ShowGridDetail(String strWhere, String strFromTableName) in C:\web\approve2\FrmStatus.aspx.vb:line 457
   at GridSorting.FrmStatus.Button1_Click(Object sender, EventArgs e) in C:\web\approve2\FrmStatus.aspx.vb:line 906)

 


Imports taia.xzxk.Bussiness.Model
Imports taia.xzxk.Bussiness
Imports taia.Components.Util


Namespace GridSorting

 

    Partial Class FrmStatus
        Inherits System.Web.UI.Page


        Dim m_SQLCn As SqlClient.SqlConnection
        Dim m_CnXzxk As SqlClient.SqlConnection
        Dim spItem As taia.xzxk.Bussiness.Model.SpItem = Nothing
        Dim core As New taia.xzxk.Bussiness.Core

        Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
        Protected WithEvents Panel2 As System.Web.UI.WebControls.Panel
        Dim m_strConn As String


#Region " Web 窗体设计器生成的代码 "

        '该调用是 Web 窗体设计器所必需的。
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub

        '注意: 以下占位符声明是 Web 窗体设计器所必需的。
        '不要删除或移动它。

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
            '不要使用代码编辑器修改它。
            InitializeComponent()
        End Sub

#End Region

        Function CreateDataSource_TeBieChengxuZhongLei() As ICollection  ''特别程序种类
            Dim dt As New DataTable
            Dim dr As DataRow

            dt.Columns.Add(New DataColumn("SelectedText", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedValues", GetType(String)))

            dr = dt.NewRow()
            dr(0) = "A类(延长审批)"
            dr(1) = "A"
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "B类(特别程序)"
            dr(1) = "B"
            dt.Rows.Add(dr)

            Return dt.DefaultView

        End Function

        Function CreateDataSource_TeBieChengxuDays() As ICollection  ''特别程序延长的天数
            Dim dt As New DataTable
            Dim dr As DataRow
            Dim i As Integer

            dt.Columns.Add(New DataColumn("SelectedText", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedValues", GetType(Integer)))

            For i = 1 To 10
                dr = dt.NewRow()
                dr(0) = CStr(i) & "天"
                dr(1) = i
                dt.Rows.Add(dr)
            Next

            Return dt.DefaultView

        End Function
        Function CreateDataSource_TeBieChengxuZhongLeiMingCheng(ByVal strParent As String) As ICollection ''特别程序种类名称
            Dim dt As New DataTable
            Dim dr As DataRow
            Dim i As Integer

            Dim mingchengA() As String = {"行政机关负责人特批"}
            Dim mingchengB() As String = {"专家鉴定", "听证", "招标", "拍卖", "检验", "检测", "检疫"}

            dt.Columns.Add(New DataColumn("SelectedText", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedValues", GetType(String)))
            dt.Columns.Add(New DataColumn("Parent", GetType(String)))


            For i = 0 To mingchengA.Length - 1
                dr = dt.NewRow()
                dr(0) = mingchengA(i)
                dr(1) = mingchengA(i)
                dr(2) = "A"
                dt.Rows.Add(dr)
            Next

            For i = 0 To mingchengB.Length - 1
                dr = dt.NewRow()
                dr(0) = mingchengB(i)
                dr(1) = mingchengB(i)
                dr(2) = "B"
                dt.Rows.Add(dr)
            Next

            dt.DefaultView.RowFilter = "[Parent]='" & strParent & "'"

            Return dt.DefaultView

        End Function


        Function CreateDataSource_Status() As ICollection
            Dim dt As New DataTable
            Dim dr As DataRow


            dt.Columns.Add(New DataColumn("SelectedText", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedValues", GetType(Integer)))


            ''状态类型(10:已受理,11:待缴费,20:办理中,21:待补材料,22:暂停,30:办结,31:退回办结,
            ''32:转报呈批,33:办结取证)

            dr = dt.NewRow()
            dr(0) = "已受理"
            dr(1) = 10
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "待缴费"
            dr(1) = 11
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "办理中"
            dr(1) = 20
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "待补材料"
            dr(1) = 21
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "暂停"
            dr(1) = 22
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "办结"
            dr(1) = 30
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "退回办理"
            dr(1) = 31
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "转报呈批"
            dr(1) = 32
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "办结取证"
            dr(1) = 33
            dt.Rows.Add(dr)

            Dim dv As New DataView(dt)
            Return dv

        End Function

        Function CreateDataSource_BanLiType(ByVal strTypeList As String) As ICollection
            Dim dt As New DataTable
            Dim dr As DataRow


            dt.Columns.Add(New DataColumn("SelectedText", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedValues", GetType(String)))
            dt.Columns.Add(New DataColumn("SelectedType", GetType(Integer)))


            ''状态类型

            dr = dt.NewRow()
            dr(0) = "承办"
            dr(1) = "t_ChengBan"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "补交告知"
            dr(1) = "t_BuJiaoGaoZhi"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "补交受理"
            dr(1) = "t_BuJiaoShouLi"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "审核"
            dr(1) = "t_ShenHe"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "批准"
            dr(1) = "t_PiZhun"
            dr(2) = 1
            dt.Rows.Add(dr)

            '' A-出证办结  B-退回办结  C-作废办结 D-转报办结  E-办结

            dr = dt.NewRow()
            dr(0) = "出证办结"
            dr(1) = "t_BianJie|A"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "退回办结(申请人退回申请的)"
            dr(1) = "t_BianJie|B"
            dr(2) = 1
            dt.Rows.Add(dr)


            dr = dt.NewRow()
            dr(0) = "作废办结(无效的纪录,比如受理录入错误等)"
            dr(1) = "t_BianJie|C"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "转报办结"
            dr(1) = "t_BianJie|D"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "办结"
            dr(1) = "t_BianJie|E"
            dr(2) = 1
            dt.Rows.Add(dr)

            dr = dt.NewRow()
            dr(0) = "特别程序申请"
            dr(1) = "t_TeBieChengXuShenQing"
            dr(2) = 2
            dt.Rows.Add(dr)


            dr = dt.NewRow()
            dr(0) = "特别程序结果"
            dr(1) = "t_TeBieChengXuJieGuo"
            dr(2) = 2
            dt.Rows.Add(dr)

            If strTypeList <> "" Then ''''为""则默认输出所有类型,否则输出指定的类型
                dt.DefaultView.RowFilter = " SelectedType in (" & strTypeList & ") "
            End If

            Return dt.DefaultView

        End Function

        Private Sub BindToBanLiType(ByVal strTypeList As String)
            With Me.DropDownList_BanLiType
                .ClearSelection()
                .DataSource = CreateDataSource_BanLiType(strTypeList)
                .DataTextField = "SelectedText"
                .DataValueField = "SelectedValues"
                .DataBind()
            End With
        End Sub


        Private Sub BindToTeBieChengXuZhongLei()
            With Me.ddlTeBieChengXuLeiBie
                .ClearSelection()
                .DataSource = CreateDataSource_TeBieChengxuZhongLei()
                .DataTextField = "SelectedText"
                .DataValueField = "SelectedValues"
                .DataBind()
            End With
        End Sub
        Private Sub BindToTeBieChengXuMingCheng(ByVal strParent As String)
            With Me.ddlTeBieChengXuMingCheng
                .ClearSelection()
                .DataSource = CreateDataSource_TeBieChengxuZhongLeiMingCheng(strParent)
                .DataTextField = "SelectedText"
                .DataValueField = "SelectedValues"
                .DataBind()
            End With
        End Sub
        Private Sub BindToTeBieDays()
            With Me.ddlTeBieDays
                .ClearSelection()
                .DataSource = CreateDataSource_TeBieChengxuDays()
                .DataTextField = "SelectedText"
                .DataValueField = "SelectedValues"
                .DataBind()
            End With
        End Sub

        Private Sub BindZzType()
            '绑定到证照下拉框

            If (Not (UltraWebGrid1.DisplayLayout.ActiveRow Is Nothing)) And DropDownList_BanLiType.SelectedValue = "t_BianJie|A" Then
                'ddlzztype()
                '获得当前选定记录的审批事项,来获得相应的证书类别
                Dim dt As DataTable
                Dim item As ListItem

                spItem = core.GetItemBySlbh(UltraWebGrid1.DisplayLayout.ActiveRow.Cells(9).Text)
                If Not (spItem Is Nothing) Then
                    '如果审批事项编号发生更改那么对应更新证照的下拉列表
                    If (ViewState("shixiangbianma") Is Nothing) Or (CStr(ViewState("shixiangbianma")) <> spItem.shixiangbianma) Then
                        ddlzztype.Items.Clear()
                        dt = core.GetZhengZhaoBySPSX(spItem.shixiangbianma)
                        If (Not (dt Is Nothing)) Then
                            'For Each dr In dt.Rows
                            'item =  ListItem( dr[0],dr[1])
                            'ddlzztype.Items.Add ( ListItem (dr[0],dr[1]))
                            ' Next
                            ddlzztype.DataSource = dt
                            ddlzztype.DataTextField = "zzmc"
                            ddlzztype.DataValueField = "zzbh"
                            ddlzztype.DataBind()
                            item = New ListItem("请选择证明类别", "")
                            ddlzztype.Items.Insert(0, item)
                        End If

                        '将本次的审批事项编码存入页面状态
                        ViewState("shixiangbianma") = spItem.shixiangbianma
                    End If
                End If

            End If
        End Sub


        Private Function GetXMLContent(ByVal zzbh As String) As String
            '得到相应的XML
            '首先取得字段表中的对应审批的字段,取得字段对应的值,然后组合成XML
            Dim dt As DataTable
            Dim dr As DataRow
            Dim field, kj, nx, val As String
            Dim obj As Control
            Dim content As New System.Text.StringBuilder("")


            dt = core.GetZhengZhaoField(zzbh)

            For Each dr In dt.Rows
                field = CStr(dr("zdmc"))
                kj = CStr(dr("kjmc"))
                nx = CStr(dr("kjnx"))
                obj = Page.FindControl(kj)
                val = ""
                If Not (obj Is Nothing) Then

                    If obj.GetType.Name = "TextBox" Then
                        val = CType(obj, TextBox).Text
                    ElseIf obj.GetType.Name = "DropDownList" Then
                        val = CType(obj, DropDownList).SelectedValue

                    End If

                End If
                content.AppendFormat("<{0}>{1}</{0}>", field, val)
            Next

            Return content.ToString()

        End Function

        Private Sub ShowGridDetail(ByVal strWhere As String, Optional ByVal strFromTableName As String = "shoulixinxibak")
            Dim strSQL As String
            Dim dt As DataTable


            '''If TxtFindKey.Text <> "" Then strWhere = "  Where a.shoulibianhao Like '" & Trim(TxtFindKey.Text) & "%'"


            '表格
            '                Session("Login_UnitID") = CStr(Dr.Item("DanWeiDaiMa"))
            '               Session("Login_Status")
            ''状态类型(10:已受理,11:待缴费,20:办理中,21:待补材料,22:暂停,30:办结,31:退回办结,
            ''32:转报呈批,33:办结取证)

            ''DATEDIFF(day,getdate(),Dateadd(day,d.worddayT,a.shouliriqi)) as 所剩工作日,

            If Session("Login_Status") <> 9 Then

                strWhere = IIf(strWhere = "", " where c.shoulirenbianhao='" & Session("Login_Userid") & "' and a.dm='" & Session("Login_UnitID") & "' and a.status='3' and (isnull(a.JiancheType,'')<>'t_BianJie' or a.ZhuangTaiType<30)", strWhere & " and a.status='3' and (isnull(a.JiancheType,'')<>'t_BianJie' or a.ZhuangTaiType<30) and c.shoulirenbianhao='" & Session("Login_Userid") & "' and a.dm='" & Session("Login_UnitID") & "' ")

                strSQL = "Select a.shoulibianhao as 统一编号,a.shenqingshixiang as 申请事项," & _
                      "a.shenqingdanweimingcheng as 申请单位," & _
                      "a.shoulirenxingming as 受理人,a.shouliriqi as 受理日期," & _
                      " d.wordDayT as 所剩工作日," & _
                      "(Case a.ZhuangTaiType When '10' then '已受理' When '11' then '待缴费' " & _
                      " when '20' then '办理中' when '21' then '待补材料' when '22' then '暂停' when '30' then '办结' " & _
                      " when '31' then '退回办结' when '32' then '转报呈批' when '33' then '办结取证' End) as 状态类型," & _
                      "(case a.JiancheType When 't_ChengBan' Then '承办' when 't_BuJiaoGaoZhi' then '补交告知' " & _
                      " when 't_BuJiaoShouLi' then '补交受理' when 't_ShenHe' then '审核' " & _
                      " when 't_PiZhun' then '批准' when 't_BianJie' then '办结' else '已受理' end )as 办理状态, " & _
                      " ((case IsNull(a.TeBieShengQin,0) when 1 then '申请' when 2 then '结果' else '' end )  + a.TeBieShengQinType) as 特别程序,a.shoulibianhao as 受理编号 " & _
                      " from (select a.*,b.danweidaima as DM from " & strFromTableName & _
                       " a inner join shouliren b on a.shoulirenbianhao=b.shoulirenbianhao ) a " & _
                        " inner join Usershixiang c on a.shixiangbianma=c.shenqingshixiangbianma " & _
                        " inner join ShenQingShiXiang as d on a.shixiangbianma=d.shenqingshixiangbianma " & _
                      "  " & strWhere & _
                      " order by  a.shoulibianhao desc"
            Else
                strWhere = IIf(strWhere = "", " where  a.status='3' and (isnull(a.JiancheType,'')<>'t_BianJie' or  a.ZhuangTaiType<30) ", strWhere & " and a.status='3'and (isnull(a.JiancheType,'')<>'t_BianJie'  or a.ZhuangTaiType<30) ")
                'strSQL = "Select b.tongyibianhao as 统一编号,a.shenqingshixiang as 申请事项," & _
                '      "a.shenqingdanweimingcheng as 申请单位," & _
                '      "a.shoulirenxingming as 受理人,a.shouliriqi as 受理日期," & _
                '      "DATEDIFF(day,Dateadd(day,d.worddayT,a.shouliriqi),getdate()) as 所剩工作日,(case a.status When '0' Then '未上报' when '1' then '已上报' " & _
                '      " when '2' then '上报失败' when '3' then '收到正确回执' " & _
                '      " when '4' then '服务未接收' when '5' then '收到错误回执' else '其它错误' end )as 受理状态," & _
                '      "(Case b.huizhileixing When '01' then '正常' When '02' then '错误'  End) as 回执类型," & _
                '      " b.huizhishijian as 回执时间 " & _
                '     " from "& strFromTableName & " as a inner join ShenQingShiXiang as d on a.shixiangbianma=d.shenqingshixiangbianma " & _
                '      "Left Join huizhixinxi b On a.shoulibianhao=b.shoulibianhao " & strWhere & _
                '      " order by  a.shouliriqi desc"

                strSQL = "Select a.shoulibianhao as 统一编号,a.shenqingshixiang as 申请事项," & _
                      "a.shenqingdanweimingcheng as 申请单位," & _
                      "a.shoulirenxingming as 受理人,a.shouliriqi as 受理日期," & _
                      " d.wordDayT as 所剩工作日," & _
                      "(Case a.ZhuangTaiType When '10' then '已受理' When '11' then '待缴费' " & _
                      " when '20' then '办理中' when '21' then '待补材料' when '22' then '暂停' when '30' then '办结' " & _
                      " when '31' then '退回办结' when '32' then '转报呈批' when '33' then '办结取证' End) as 状态类型," & _
                      "(case a.JiancheType When 't_ChengBan' Then '承办' when 't_BuJiaoGaoZhi' then '补交告知' " & _
                      " when 't_BuJiaoShouLi' then '补交受理' when 't_ShenHe' then '审核' " & _
                      " when 't_PiZhun' then '批准' when 't_BianJie' then '办结' else '已受理' end )as 办理状态, " & _
                      " ((case IsNull(a.TeBieShengQin,0) when 1 then '申请' when 2 then '结果' else '' end )  + a.TeBieShengQinType) as 特别程序,a.shoulibianhao as 受理编号 " & _
                     " from " & strFromTableName & " as a inner join ShenQingShiXiang as d on a.shixiangbianma=d.shenqingshixiangbianma " & _
                      " " & strWhere & _
                      " order by  a.shoulibianhao desc"


            End If


            dt = core.GetData(strSQL)

            LblCount.Text = Str(dt.Rows.Count)

            Me.UltraWebGrid1.DataSource = dt
            Me.UltraWebGrid1.DataBind()
            dt.Clear()
        End Sub

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim strYwType As String
            Dim IsDebug As Boolean = False

            If IsDebug Then
                Session("Login_Userid") = "0200004"
                Session("Login_UserName") = "测试人"
                Session("Login_Status") = 9
                Session("Login_UnitID") = "0001"
            Else
                If Trim(Session("Login_Userid")) = "" Then Response.Redirect("FrmLogin.aspx")
            End If
            GetPostBackClientEvent(btnClick, "")

            '数据库联接

            m_strConn = System.Configuration.ConfigurationSettings.AppSettings("Conn").ToString()
            m_SQLCn = New SqlClient.SqlConnection(m_strConn)
            m_strConn = System.Configuration.ConfigurationSettings.AppSettings("ConnXZXK").ToString()
            m_CnXzxk = New SqlClient.SqlConnection(m_strConn)


            If Not Page.IsPostBack Then
                Dim strSQL As String
                strSQL = "Select * From DanWeiZhiLiao"
                Dim dt As DataTable
                dt = core.GetData(strSQL)

                With Me.Dropdownlist_lcate()
                    .DataSource = dt
                    .DataTextField = "DanWeiMinCheng"
                    '.DataValueField = "DanWeiMinCheng" '改为单位代码
                    .DataValueField = "DanWeiDaiMa"
                    .DataBind()
                    .SelectedValue = Trim(Session("Login_UnitID"))
                End With

                With Me.DropDownList_status
                    .DataSource = CreateDataSource_Status()
                    .DataTextField = "SelectedText"
                    .DataValueField = "SelectedValues"
                    .DataBind()
                End With

                With Me.DropDownList_BanLiType
                    .DataSource = CreateDataSource_BanLiType(1)
                    .DataTextField = "SelectedText"
                    .DataValueField = "SelectedValues"
                    .DataBind()
                End With
                strYwType = DropDownList_BanLiType.SelectedValue.ToString()
                If InStr(strYwType, "|") > 0 Then
                    strYwType = Left(strYwType, InStr(strYwType, "|") - 1)
                End If

                'ShowshixiangJiaose(strYwType)

                If dropRen.Items.Count = 0 Then
                    dropRen.Items.Add(Session("Login_UserName"))
                    dropRen.SelectedIndex = 0
                End If


                ShowGridDetail("")
                TxtRen.Text = Session("Login_UserName")
            End If

 

            TxtDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            TxtDate.Attributes.Add("ReadOnly", "ReadOnly")
        End Sub


        Private Sub UltraWebGrid1_Click(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.ClickEventArgs) Handles UltraWebGrid1.Click
            Dim strSql As String
            Dim sqlCmd As New SqlClient.SqlCommand
            Dim dt As DataTable
            Dim strYwType As String
            Dim TeBieChengXuState As Integer = 0
            Dim TeBieChengXuType As String = ""
            'Try
            BindZzType()

            TxtID.Text = CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(0).Text)
            txtQYMC.Text = UltraWebGrid1.DisplayLayout.ActiveRow.Cells(2).Text
            TxtFindKey.Text = TxtID.Text
            If Trim(TxtID.Text) <> "" Then
                'strSql = "Select shoulibianhao from huizhixinxi where tongyibianhao='" & Trim(TxtID.Text) & "' and rtrim(shoulibianhao)<>''"
                '-------
                ' update:20005-12-26
                ' 增加得到该信息的特别程序状态的字段
                '-------
                strSql = "Select shoulibianhao,TeBieShengQin,TeBieShengQinType from shoulixinxibak  where shoulibianhao='" & Trim(TxtID.Text) & "' and rtrim(shoulibianhao)<>''"
                dt = core.GetData(strSql)
                If dt.Rows.Count > 0 Then
                    Dim dr As DataRow
                    dr = dt.Rows(0)
                    lblShouliBianhao.Text = dr(0)
                    If Not IsDBNull(dr(1)) Then
                        TeBieChengXuState = Convert.ToInt32(dr(1))
                    End If
                    If Not IsDBNull(dr(2)) Then
                        TeBieChengXuType = dr(2)
                    End If
                End If


                If Me.UltraWebGrid1.DisplayLayout.ActiveRow Is Nothing Then
                Else
                    If CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(1).Text) = "林业植物及其产品调运检疫" Or CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(1).Text) = "从林区运出木材" Then
                        txtZJYXQX.Text = "当次"
                        txtSFJE.Text = 0
                    End If
                    If CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(1).Text) = "动物诊疗" Or CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(1).Text) = "兽药经营" Then
                        txtFZDW.Text = "深圳市农林渔业局"
                    Else
                        txtFZDW.Text = Session("Login_UnitName")
                    End If

                    '--------------
                    ' update:2005-12-22 by taia
                    ' 如果事项为特别程序,则办理类型中应增加"特别程序申请" 和 "特别程序结果" 两项
                    '--------------
                    If (e.Row.Cells(1).Text = "动物及动物产品检疫") Then
                        If TeBieChengXuState = 0 Then
                            showTeBieState(1)
                        ElseIf TeBieChengXuState = 1 Then
                            If TeBieChengXuType.Trim() = "B" Then
                                showTeBieState(2)
                            Else
                                showTeBieState(0)
                            End If
                        Else
                            showTeBieState(0)
                        End If

                    Else
                        showTeBieState(0)
                    End If
                End If


                strYwType = DropDownList_BanLiType.SelectedValue.ToString()
                If InStr(strYwType, "|") > 0 Then
                    strYwType = Left(strYwType, InStr(strYwType, "|") - 1)
                End If


            End If

        End Sub

        Private Sub ShowshixiangJiaose(ByVal strType As String)
            Dim strSql As String
            Dim i As Long
            Dim IsExists As Boolean

            IsExists = False

            If Trim(TxtID.Text) <> "" Then

                strSql = "Select distinct " & strType & " From shixiangquanxian where shenqingshixiang ='" & CStr(Me.UltraWebGrid1.Rows(UltraWebGrid1.DisplayLayout.ActiveRow.Index()).Cells(1).Text) & "'" & _
                " and " & strType & "<>''"


                Dim dt As DataTable
                dt = core.GetData(strSql)

                dropRen.Items.Clear()

                With Me.dropRen()
                    .DataSource = dt
                    .DataTextField = strType
                    .DataValueField = strType
                    .DataBind()
                End With

            End If

            If dropRen.Items.Count = 0 Then
                dropRen.Items.Clear()
                dropRen.Items.Add(Session("Login_UserName"))
                dropRen.SelectedIndex = 0
            Else
                IsExists = False
                For i = 0 To dropRen.Items.Count - 1
                    If Trim(dropRen.Items(i).Text) = Trim(Session("Login_UserName")) Then
                        dropRen.Items(i).Selected = True
                        IsExists = True
                        Exit For
                    End If
                Next
            End If

        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim IsShenQing As Boolean
            Dim IsTeBieShengQin, IsTeBieJieGuo As Boolean   ''是否为特别程序申请,和结果的操作

            Dim ShenQingLeiBie As String
            Dim tempArr As ArrayList
            Dim tempYwlsh As String

            If Trim(TxtID.Text) = "" Then
                ShowClientAlert("", "<script>alert('统一编号不能为空!');</script>")
                Exit Sub
            End If

            If Trim(TxtDate.Text) = "" Then
                ShowClientAlert("", "<script>alert('日期格式不正确,请重新输入 格式:yyyy-MM-dd" & LblDateTip.Text & "!');</script>")
                Exit Sub
            End If

            If Not IsDate(TxtDate.Text) Then
                ShowClientAlert("", "<script>alert('日期格式不正确,请重新输入 格式:yyyy-MM-dd" & LblDateTip.Text & "!');</script>")
                Exit Sub
            End If

            If Trim(dropRen.SelectedItem.Text) = "" Then
                ShowClientAlert("", "<script>alert('请录入办理人员姓名!');</script>")
                Exit Sub
            End If

            'If Trim(TxtRemark.Text) = "" Then
            'ShowClientAlert("", "<script>alert('请录入处理意见或描述内容!');</script>")
            'Exit Sub
            'End If

            Dim strSQL As String
            Dim sqlCmd As New SqlClient.SqlCommand
            Dim strZhuangtaileixing As String
            Dim strYwType As String
            Dim strBanJtype As String
            Dim Ds As SqlClient.SqlDataReader
            Dim dt As DataTable
            Dim strStaut As String

            strYwType = DropDownList_BanLiType.SelectedValue.ToString()
            tempArr = GetBMList(TxtID.Text)
            tempYwlsh = GetYwlsh(CStr(tempArr(1)), CStr(tempArr(2)), CStr(tempArr(0)))
            IsTeBieShengQin = (chkTeBieShenQing.Checked And chkTeBieShenQing.Visible)
            IsTeBieJieGuo = (chkTeBieJieGuo.Checked And chkTeBieJieGuo.Visible)


            If InStr(strYwType, "|") > 0 Then
                strYwType = Left(strYwType, InStr(strYwType, "|") - 1)
                strBanJtype = Right(DropDownList_BanLiType.SelectedValue.ToString(), Len(DropDownList_BanLiType.SelectedValue.ToString()) - Len(strYwType) - 1)
            Else
                strBanJtype = ""
            End If
            If Val(DropDownList_status.SelectedValue) >= 30 Then
                If Trim(strYwType) <> "t_BianJie" Then
                    ShowClientAlert("", "<script>alert('当状态类型也为办结或其它办结状态类型时,请选择办理类型为办结或其它办结类型!');</script>")
                    Exit Sub
                End If

            End If
            If Trim(strYwType) = "t_BianJie" Then
                If Val(DropDownList_status.SelectedValue) < 30 Then
                    ShowClientAlert("", "<script>alert('当办理类型为办结或其它办结类型时,请选择状态类型也为办结或其它办结状态类型!');</script>")
                    Exit Sub
                End If
                Select Case strBanJtype
                    Case "A"
                        If Trim(ddlzztype.SelectedValue) = "" Or Trim(txtZJBH.Text) = "" Or Trim(txtZJYXQX.Text) = "" Or Trim(txtFZDW.Text) = "" Then
                            ShowClientAlert("", "<script>alert('出证办结要有证照信息并且录入完全!');</script>")
                            Exit Sub
                        End If
                        ''''add: data:2007-4-19
                        '添加对证书的重复检测,如果重复,则不能继续进行下去
                        Dim zz As ZhengZhao = core.GetZhengZhao(ddlzztype.SelectedValue)

                        If zz Is Nothing Then
                            ShowClientAlert("ZZERROR", "<script>alert('你所选择的证照有误!');</script>")
                        ElseIf zz.IsRepeat = False Then
                            If core.IsZhengZhaoExist(ddlzztype.SelectedValue.Trim(), txtZJBH.Text.Trim()) Then
                                ShowClientAlert("", "<script>alert('您所录入的证照编号已经存在!');</script>")
                                Exit Sub
                            End If
                        End If

                    Case "B", "C"
                        If Trim(TxtRemark.Text) = "" Then
                            ShowClientAlert("", "<script>alert('作废或退回办结要写明原因!');</script>")
                            Exit Sub
                        End If
                End Select

            End If

            If IsTeBieShengQin Then
                '---------------------
                ' 为特别程序时对相应的内容进行验证
                ' 1.如果是A类申请,则一定要写明延长的时间
                ' 2.手机电话,必须填写一种
                ' 3.申请内容,特别程序启动理由或依据,特别程序批准人,特别程序开始日期,特别程序种类名称 都不能为空
                '---------------------
                If Me.ddlTeBieChengXuLeiBie.SelectedValue = "A" And Me.ddlTeBieDays.SelectedValue = "" Then
                    ShowClientAlert("", "<script>alert('A类延长审批必须写明延长的时间');</script>")
                    Exit Sub
                End If

                If Me.txtTeBieDianHua.Text.Trim() = "" And Me.txtTeBieSouJi.Text.Trim() = "" Then
                    ShowClientAlert("", "<script>alert('特别程序批准人电话,手机至少应填写一项');</script>")
                    Exit Sub
                End If

                If Me.TxtRemark.Text.Trim() = "" Or Me.TxtMemo.Text.Trim() = "" Or Me.dropRen.SelectedValue = "" Then
                    ShowClientAlert("", "<script>alert('申请内容,特别程序启动理由或依据,特别程序批准人不能为空');</script>")
                    Exit Sub
                End If


            ElseIf IsTeBieJieGuo Then
                '---------------------
                ' 为特别程序结果时对相应的内容进行验证
                ' 1.如果它没有特别程序申请的记录,则不能录入特别程序结果
                ' 2.如果是A类申请,则不用写程序结果,如果是B类申请,则需要填报结果
                ' 3.结果内容,收费金额 都不能为空
                ' 1,2 的验证步骤在保存代码中验证
                '---------------------

 

                sqlCmd = New SqlClient.SqlCommand("select TBCXZL from t_TeBieChengXuShenQing where YWLSH='" & tempYwlsh & "'", m_CnXzxk)
                If m_CnXzxk.State = ConnectionState.Closed Then m_CnXzxk.Open()
                Ds = sqlCmd.ExecuteReader(CommandBehavior.SingleRow)
                IsShenQing = False
                If Ds.Read() = True Then
                    IsShenQing = True
                    ShenQingLeiBie = Ds.GetString(0)
                End If
                Ds.Close()

                If IsShenQing = False Then
                    ShowClientAlert("", "<script>alert('此记录没有经过特别程序的申请,不能录入特别程序结果');</script>")
                    Exit Sub
                ElseIf ShenQingLeiBie = "A" Then
                    ShowClientAlert("", "<script>alert('A类特别程序的申请不需要填报特别程序结果');</script>")
                    Exit Sub
                End If


                If ddlTeBieChengXuJieGuo.SelectedValue.Trim() = "" Or Me.txtSFJE.Text.Trim() = "" Then
                    ShowClientAlert("", "<script>alert('结果内容,收费金额不能为空');</script>")
                    Exit Sub
                End If

            End If

            strSQL = "Select Top 1 tingqibiaoshi from banlikongzhixinxibak where tingqibiaoshi='0' and tongyibianhao='" & Trim(TxtID.Text) & "' order by tingqiriqi Desc"
            dt = core.GetData(strSQL)

            If dt.Rows.Count > 0 Then
                strStaut = dt.Rows(0)("tingqibiaoshi")
            Else
                strStaut = "1"
            End If

            If strStaut <> "1" Then
                If Val(DropDownList_status.SelectedValue) = 22 Then
                    ShowClientAlert("", "<script>alert('这个申请事项已经暂停了一次,不能再暂停!');</script>")
                    Exit Sub

                End If
            End If
            Try
                If strStaut <> "1" Then
                    If Val(DropDownList_status.SelectedValue) <> 22 Then

                        strSQL = "if not EXISTS(Select Top 1 tingqibiaoshi from banlikongzhixinxibak where tingqibiaoshi='1' and tongyibianhao='" & Trim(TxtID.Text) & "')" & vbCrLf & _
                                "BEGIN " & vbCrLf & _
                                "  Insert Into  banlikongzhixinxi(tongyibianhao,tingqiriqi,tingqiyuanyin," & _
                                 " tingqibiaoshi,beizhuxinxi,shangbaoshijian,danweidaima)  Values ('" & TxtID.Text & "','" & _
                                Format(Now, "yyyy-MM-dd HH:mm:ss") & "','" & TxtRemark.Text & "','1','','" & TxtDate.Text & "','" & _
                                Session("Login_UnitID") & "') " & vbCrLf & _
                                "End"

                        core.ExecuteNonQuery(strSQL)

                    End If
                End If

                If chkTeBieShenQing.Checked And chkTeBieShenQing.Visible Then
                    '''如果只是特别程序申请,要改变受理信息表中的记录的特别程序字段状态 和特别程序的类别
                    strSQL = "update shoulixinxibak set TeBieShengQin=1,TeBieShengQinType='" & Me.ddlTeBieChengXuLeiBie.SelectedValue & "' where shoulibianhao='" & tempArr(0) & "'"


                Else
                    '状态类型:10:已受理,11:待缴费,20:办理中,21:待补材料,22:暂停,30:办结,31:退回办结,32:转报呈批,33:办结取证
                    If Val(DropDownList_status.SelectedValue) < 30 Then  '没有办结
                        strSQL = " Insert Into  zhuangtaixinxi(tongyibianhao,dangqianweizhi,songdashijian," & _
                                 " zhuangtaimiaoshu, zhuangtaileixing,danweidaima) " & _
                                 " Values ('" & TxtID.Text & "','" & Dropdownlist_lcate.SelectedItem.Text & "','" & _
                                  TxtDate.Text & "','" & TxtRemark.Text & "','" & DropDownList_status.SelectedValue & "','" & Session("Login_UnitID") & "')"

                    Else   '已经办结
                        strSQL = " Insert Into  zhuangtaixinxi(tongyibianhao,dangqianweizhi," & _
                                 " banjieriqi,zhuangtaimiaoshu,Zhuangtaileixing,danweidaima,songdashijian) " & _
                                 " Values ('" & TxtID.Text & "','" & Dropdownlist_lcate.SelectedItem.Text & "','" & _
                                 TxtDate.Text & "','" & _
                                 TxtRemark.Text & "','" & DropDownList_status.SelectedValue & "','" & Session("Login_UnitID") & "','" & _
                                 TxtDate.Text & "')"

                    End If

                    If IsTeBieJieGuo Then '如果是特别程序结果,将改变受理信息中的特别程序字段状态
                        strSQL = strSQL & vbCrLf & " update shoulixinxibak set TeBieShengQin=2 where shoulibianhao='" & tempArr(0) & "'"
                    End If

                End If

                core.ExecuteNonQuery(strSQL)


                If Val(DropDownList_status.SelectedValue) = 22 Then
                    strSQL = " Insert Into  banlikongzhixinxi(tongyibianhao,tingqiriqi,tingqiyuanyin," & _
                             " tingqibiaoshi,beizhuxinxi,shangbaoshijian,danweidaima)  Values ('" & TxtID.Text & "','" & _
                            Format(Now, "yyyy-MM-dd HH:mm:ss") & "','" & TxtRemark.Text & "','0','','" & TxtDate.Text & "','" & _
                            Session("Login_UnitID") & "')"
                    core.ExecuteNonQuery(strSQL)

                End If

                ShowClientAlert("", "<script>alert('更新成功! 等待上报!');</script>")

                ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作成功,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text, m_SQLCn)

                If IsTeBieShengQin Then
                    SaveJianchaTeBieChenXuShenQing(tempYwlsh, CStr(tempArr(1)), CStr(tempArr(2)), CStr(tempArr(0))) '存储特别程序申请数据
                ElseIf IsTeBieJieGuo Then
                    SaveJianchaTeBieChenXuJieGuo(tempYwlsh, CStr(tempArr(1)), CStr(tempArr(2)), CStr(tempArr(0)))      '存储特别申请程序结果
                    SavaJianchaDataBase(strYwType, TxtID.Text, strBanJtype)
                Else
                    SavaJianchaDataBase(strYwType, TxtID.Text, strBanJtype)
                End If
                'SavaJianchaDataBase(strYwType, TxtID.Text, strBanJtype)
                'If Not Page.IsPostBack Then
                ShowGridDetail("")
                'End If


                sqlCmd = Nothing
                Ds = Nothing

            Catch ex As Exception When True
                taia.Components.Logger.GetInstance().WriteLog(ex)
                ShowClientAlert("err", "<script>alert('错误信息:" & ex.Message & "');</script>")
                ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作写到监察系统失败,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text & "{" & ex.Message.Replace("'", "''") & "}", m_SQLCn)

                Exit Sub
            End Try

        End Sub
        Private Sub SaveJianchaTeBieChenXuShenQing(ByVal strYWLSH As String, ByVal strXKSXBH As String, ByVal strXKSXZX As String, ByVal strYXTYWLSH As String)
            Dim strSql, tmp As String

            '---------------------
            '特别程序申请业务
            '---------------------
            '业务流水号
            '                    审批事项编号(审批事项子项)
            '                    原系统业务流水号()
            '特别程序种类(AB)    特别程序种类名称
            '                    特别程序开始日期()
            '                    特别程序批准人()
            '                    特别程序批准人电话()
            '                    特别程序批准人手机()
            '                    特别程序启动理由或依据()
            '                    申请内容(申请延长时限)
            '                    备用字段()

            If Me.ddlTeBieChengXuLeiBie.SelectedValue = "A" Then  '''当类型为A类时要保存延长天数,为B类时不用填写天数字段
                tmp = Me.ddlTeBieDays.SelectedValue
            Else
                tmp = "null"
            End If

            strSql = "insert into t_TeBieChengXuShenQing " & _
                    "(YWLSH,XKSXBH,XKSXZX,YXTYWLSH,TBCXZL,TBCXZLMC,TBCXKSRQ,TBCXPZR,TBCXPZRDH,TBCXPZRSJ,TBCXQDLYHYJ,SQNR,SQYCSX)" & _
                    " values (" & _
                    "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                    "'" & Me.ddlTeBieChengXuLeiBie.SelectedValue & "','" & Me.ddlTeBieChengXuMingCheng.SelectedValue & "','" & TxtDate.Text & "'," & _
                    "'" & Me.dropRen.SelectedItem.Text & "','" & Me.txtTeBieDianHua.Text & "','" & Me.txtTeBieSouJi.Text & "'," & _
                    "'" & Me.TxtRemark.Text & "','" & Me.TxtMemo.Text & "'," & tmp & ")"
            ExecuteJianChaSQL(strSql)
        End Sub

        Private Sub SaveJianchaTeBieChenXuJieGuo(ByVal strYWLSH As String, ByVal strXKSXBH As String, ByVal strXKSXZX As String, ByVal strYXTYWLSH As String)
            Dim strSql
            '---------------------
            '特别程序结果
            '---------------------
            '业务流水号()
            '审批事项编号(审批事项子项)
            '原系统业务流水号()
            '特别程序结果()
            '结果产生日期(特别程序结束日期(结果送达时间))
            '特别程序收费金额()
            '备用字段()

            strSql = "insert into t_TeBieChengXuJieGuo " & _
                    "(YWLSH,XKSXBH,XKSXZX,YXTYWLSH,TBCXJG,JGCSRQ,TBCXJSRQ,TBCXSFJE)" & _
                    " values (" & _
                    "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                    "'" & Me.ddlTeBieChengXuJieGuo.SelectedValue & "',getDate(),'" & TxtDate.Text & "','" & txtSFJE.Text & "')"

            ExecuteJianChaSQL(strSql)

        End Sub

        Private Sub ExecuteJianChaSQL(ByVal sql As String)
            Dim sqlCmd As New SqlClient.SqlCommand
            m_CnXzxk.Close()
            m_CnXzxk.Open()
            sqlCmd.CommandTimeout = 60
            sqlCmd = New SqlClient.SqlCommand(sql, m_CnXzxk)

            sqlCmd.ExecuteNonQuery()

        End Sub


        Private Sub SavaJianchaDataBase(ByVal YwType As String, ByVal strGetHuiZhiHao As String, ByVal strBanJieType As String)
            Dim strSql As String
            Dim strYWLSH As String  '业务流水号()
            Dim strYXTYWLSH As String '原系统业务流水号
            Dim strXKSXBH As String '许可事项编号
            Dim strXKSXZX As String '许可事项子项编号
            Dim strShixiangbianma '事项编号用来找许可事项编号的
            Dim sqlCmd As New SqlClient.SqlCommand
            Dim Ds As SqlClient.SqlDataReader
            Dim tmp As String '''临时变量
            Dim Memo As String ''备注信息,因为数据库中对应的字段长度为100,所以当有超过的,应截断


            Dim IsShenQing As Boolean
            Dim ShenQingLeiBie As String

            Dim tmpArr As ArrayList '''临时角色容器
            Dim ChengBanName, ShenHeName, PiZhunName As String  ''''承办,审核,批准三个角色姓名

            m_SQLCn.Close()
            m_SQLCn.Open()
            m_CnXzxk.Close()
            m_CnXzxk.Open()

            sqlCmd.CommandText = "Select Top 1 shoulibianhao,Shixiangbianma from [shoulixinxibak] where shoulibianhao='" & strGetHuiZhiHao & "' and rtrim(shoulibianhao)<>''"
            sqlCmd.CommandType = CommandType.Text
            sqlCmd.Connection = m_SQLCn
            Ds = sqlCmd.ExecuteReader()
            If Ds.Read = True Then
                strYXTYWLSH = Ds.GetString(0)
                strShixiangbianma = Ds.GetString(1)
            Else
                ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作写到监察系统失败,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text, m_SQLCn)
                Response.Write("<script>alert('没有找到相应业务流水号,不能保存!');</script>")
                Exit Sub
            End If


            Ds.Close()
            strSql = "Select  caizhihao,XKSXZX from ShenQingShiXiang where shenqingshixiangbianma='" & strShixiangbianma & "'"
            sqlCmd.Connection = m_SQLCn
            sqlCmd.CommandText = strSql
            sqlCmd.CommandType = CommandType.Text
            Ds = sqlCmd.ExecuteReader()

            If Ds.Read = True Then
                strXKSXBH = Ds.GetString(0)
                strXKSXZX = Ds.GetString(1)
            Else
                ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作写到监察系统失败,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text, m_SQLCn)
                ShowClientAlert("", "<script>alert('未能找到相应许可事项编号,不能将受理保存到监察系统!');</script>")
                Exit Sub
            End If
            Ds.Close()


            strYWLSH = core.GetJCYWLSH(strXKSXBH, strXKSXZX, strYXTYWLSH)

            If strYWLSH = "0" Then
                ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作写到监察系统失败,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text, m_SQLCn)
                ShowClientAlert("", "<script>alert('未能生成业务流水号,不能将受理保存到监察系统!');</script>")
                Exit Sub
            End If

            If strXKSXBH <> "0" Then
                Memo = TxtMemo.Text.Replace("'", "")
                If Memo.Length >= 40 Then
                    Memo = TxtMemo.Text.Substring(0, 40)
                End If


                Select Case YwType
                    Case "t_ChengBan"
                        '业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '承办人姓名()
                        '承办意见()
                        '承办时间()
                        '备注()
                        strSql = "insert into t_ChengBan (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,CBRXM,CBYJ,CBSJ,BZ) values (" & _
                                "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                "'" & dropRen.SelectedItem.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                "'" & Memo & "')"


                    Case "t_BuJiaoGaoZhi"
                        '业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '补交材料告知清单()
                        '补交告知时间()
                        '备注()
                        strSql = "insert into t_BuJiaoGaoZhi(YWLSH,XKSXBH,XKSXZX,YXTYWLSH,BJCLGZQD,BJGZSJ,BZ) values (" & _
                                "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                "'" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                "'" & Memo & "')"

                    Case "t_BuJiaoShouLi"
                        '业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '补交时间()
                        '补交材料清单()
                        '备注()

                        strSql = "insert into  t_BuJiaoShouLi(YWLSH,XKSXBH,XKSXZX,YXTYWLSH,BJSJ,BJCLQD,BZ) values (" & _
                                "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                "'" & TxtDate.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "'," & _
                                "'" & Memo & "')"

                    Case "t_ShenHe"
                        '业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '审核人姓名()
                        '审核意见()
                        '审核时间()
                        '备注()
                        strSql = "if not EXISTS(Select Top 1 YXTYWLSH from t_ChengBan where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                    "insert into t_ChengBan (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,CBRXM,CBYJ,CBSJ,BZ) values (" & _
                                        "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                        "'" & dropRen.SelectedItem.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                        "'" & Memo & "')" & vbCrLf & "end "

                        strSql = strSql & vbCrLf & "insert into  t_ShenHe (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,SHRXM,SHYJ,SHSJ,BZ) values (" & _
                                "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                "'" & dropRen.SelectedItem.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                "'" & Memo & "')"


                    Case "t_PiZhun"
                        ' 业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '批准意见()
                        '批准人姓名()
                        '批准时间()
                        '备注()
                        strSql = "if not EXISTS(Select Top 1 YXTYWLSH from t_ChengBan where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                    "insert into t_ChengBan (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,CBRXM,CBYJ,CBSJ,BZ) values (" & _
                                        "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                        "'" & dropRen.SelectedItem.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                        "'" & Memo & "')" & vbCrLf & "end "
                        strSql = strSql & vbCrLf & "if not EXISTS(Select Top 1 YXTYWLSH from t_ShenHe where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                    "insert into  t_ShenHe (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,SHRXM,SHYJ,SHSJ,BZ) values (" & _
                                    "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                    "'" & dropRen.SelectedItem.Text & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                     "'" & Memo & "')" & vbCrLf & " end "

                        strSql = strSql & vbCrLf & "insert into t_PiZhun (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,PZYJ,PZRXM,PZSJ,BZ) values (" & _
                                "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                "'" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & dropRen.SelectedItem.Text & "','" & TxtDate.Text & "'," & _
                                "'" & Memo & "')"

                    Case "t_BianJie"
                        '业务流水号()
                        '许可事项编号()
                        '许可事项子项()
                        '原系统业务流水号()
                        '办结结果()
                        '作废或退回原因()
                        '办结机关组织机构代码()  ?
                        '办结(打证)时间
                        '证件/盖章名称 ?
                        '证件编号()    ?
                        '证件有效期限()   ?
                        '发证/盖章单位    ?
                        ' 收费金额()     ?
                        '备注()

                        '' A-出证办结  B-退回办结  C-作废办结 D-转报办结  E-办结

                        Dim zzmc As String = ""
                        If Not (ddlzztype.SelectedItem Is Nothing) Then
                            zzmc = ddlzztype.SelectedItem.Text
                        End If

                        If strBanJieType = "A" Or strBanJieType = "D" Or strBanJieType = "E" Then


                            ''如果用户设定了事项角色, 则从事项角色里边取, 如是没有, 则按当前登录人为所有缺省值 2005/12/12

                            ''Session("Login_Userid")

                            If Trim(strShixiangbianma) <> "" Then
                                tmpArr = GetPersonList(strShixiangbianma, Trim(Session("Login_Userid")), Trim(Session("Login_UserName")))
                                ChengBanName = CStr(tmpArr(0))
                                ShenHeName = CStr(tmpArr(1))
                                PiZhunName = CStr(tmpArr(2))
                            Else
                                ChengBanName = dropRen.SelectedItem.Text
                                ShenHeName = dropRen.SelectedItem.Text
                                PiZhunName = dropRen.SelectedItem.Text
                            End If

                            '============================================================================================================
                            strSql = "if not EXISTS(Select Top 1 YXTYWLSH from t_ChengBan where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                        "insert into t_ChengBan (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,CBRXM,CBYJ,CBSJ,BZ) values (" & _
                                            "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                            "'" & _
                                            ChengBanName & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                            "'" & Memo & "')" & vbCrLf & "end "
                            strSql = strSql & vbCrLf & "if not EXISTS(Select Top 1 YXTYWLSH from t_ShenHe where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                        "insert into  t_ShenHe (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,SHRXM,SHYJ,SHSJ,BZ) values (" & _
                                        "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                        "'" & _
                                        ShenHeName & "','" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & TxtDate.Text & "'," & _
                                         "'" & Memo & "')" & vbCrLf & "end "

                            strSql = strSql & vbCrLf & "if not EXISTS(Select Top 1 YXTYWLSH from t_PiZhun where YXTYWLSH='" & strYXTYWLSH & "')" & vbCrLf & "begin" & vbCrLf & _
                                        "insert into t_PiZhun (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,PZYJ,PZRXM,PZSJ,BZ) values (" & _
                                        "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                        "'" & IIf(Trim(TxtRemark.Text) = "", "同意", Trim(TxtRemark.Text)) & "','" & _
                                        PiZhunName & "','" & TxtDate.Text & "'," & _
                                        "'" & Memo & "')" & vbCrLf & "end "
                            '============================================================================================================

                            strSql = strSql & vbCrLf & "insert into t_BianJie (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,BJJG,ZFTHYY,BJJGZZJGDM,BJSJ," & _
                                    "ZJMC,ZJBH,ZJYXQX,FZDW,SFJE,BZ) values (" & _
                                    "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                    "'" & strBanJieType & "','" & Trim(TxtRemark.Text) & "','007541651','" & TxtDate.Text & "'," & _
                                    "'" & Trim(zzmc) & "','" & Trim(txtZJBH.Text) & "','" & Trim(txtZJYXQX.Text) & "','" & _
                                    Trim(txtFZDW.Text) & "','" & IIf(Trim(txtSFJE.Text) = "", 0, Trim(txtSFJE.Text)) & "'," & _
                                    "'" & Memo & "')"

                        Else

                            strSql = "insert into t_BianJie (YWLSH,XKSXBH,XKSXZX,YXTYWLSH,BJJG,ZFTHYY,BJJGZZJGDM,BJSJ," & _
                                    "ZJMC,ZJBH,ZJYXQX,FZDW,SFJE,BZ) values (" & _
                                    "'" & strYWLSH & "','" & strXKSXBH & "','" & strXKSXZX & "','" & strYXTYWLSH & "'," & _
                                    "'" & strBanJieType & "','" & Trim(TxtRemark.Text) & "','007541651','" & TxtDate.Text & "'," & _
                                    "'" & Trim(zzmc) & "','" & Trim(txtZJBH.Text) & "','" & Trim(txtZJYXQX.Text) & "','" & _
                                    Trim(txtFZDW.Text) & "','" & IIf(Trim(txtSFJE.Text) = "", 0, Trim(txtSFJE.Text)) & "'," & _
                                    "'" & Memo & "')"

                        End If

                        '=======如果是出证办结,将证照信息写入到证照表中(zhengzhao)
                        If strBanJieType = "A" Then
                            Dim zzInfo As New ZhengZhaoInfo
                            If spItem Is Nothing Then
                                spItem = core.GetItemBySlbh(UltraWebGrid1.DisplayLayout.ActiveRow.Cells(9).Text)
                            End If


                            zzInfo.ProduceOrgan = txtFZDW.Text
                            zzInfo.DocName() = zzmc
                            zzInfo.DocId = ddlzztype.SelectedValue
                            zzInfo.DocInfoId = txtZJBH.Text
                            zzInfo.ValidityPeriod = txtZJYXQX.Text
                            zzInfo.ProduceDate = TxtDate.Text
                            zzInfo.DocStatus = "V"
                            zzInfo.Memo = IIf(txtzzMemo.Text = "", ddlzztype.SelectedItem.Text, txtzzMemo.Text)
                            zzInfo.Admindivision = "440300"
                            zzInfo.Content = GetXMLContent(ddlzztype.SelectedValue)
                            zzInfo.DocOwner = UltraWebGrid1.DisplayLayout.ActiveRow.Cells(2).Text
                            zzInfo.BusinessId = UltraWebGrid1.DisplayLayout.ActiveRow.Cells(9).Text
                            zzInfo.JcYwlsh = strYWLSH
                            zzInfo.IsExistattachment = "N"

                            '企业组织机构代码,如果是个人则为九个九
                            If spItem.zhengjianleibie = "00" Then
                                zzInfo.OrganCode = spItem.shenqingdanweidaima
                            Else
                                zzInfo.OrganCode = "999999999"
                            End If
                            zzInfo.Id = zzInfo.DocId + "_" + zzInfo.DocInfoId + "_" + zzInfo.BusinessId

                            core.AddZhengZhaoInfo(zzInfo)
                            core.SaveJcZhengZhaoInfo(zzInfo)

                        End If

                End Select
                sqlCmd = New SqlClient.SqlCommand
                sqlCmd.CommandText = strSql
                sqlCmd.CommandType = CommandType.Text
                sqlCmd.Connection = m_CnXzxk
                sqlCmd.ExecuteNonQuery()

            End If

            Dim adoRs As SqlClient.SqlDataReader
            strSql = "Select 0 from " & YwType & "  where YXTYWLSH='" & Trim(strYXTYWLSH) & "'"
            sqlCmd.CommandText = strSql
            sqlCmd.CommandType = CommandType.Text
            adoRs = sqlCmd.ExecuteReader

            If adoRs.Read = True Or strXKSXBH = "0" Then
                strSql = "Update shoulixinxibak set JiancheType='" & YwType & "',ZhuangTaiType='" & DropDownList_status.SelectedValue & "' where shoulibianhao='" & Trim(lblShouliBianhao.Text) & "'"
                core.ExecuteNonQuery(strSql)

            End If


            ClassApprove.Write_TO_Log(Session("Login_Userid"), Session("Login_Userid") & "更新统一回执操作成功写到监察系统中,操作状态是:" & DropDownList_BanLiType.SelectedItem.Text & ",统一回执编号:" & TxtID.Text, m_SQLCn)

            adoRs.Close()
            m_SQLCn.Close()
            m_CnXzxk.Close()
            adoRs = Nothing
            sqlCmd = Nothing
            Ds = Nothing

        End Sub

        Private Sub DropDownList_status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

            If DropDownList_status.SelectedValue >= 30 Then
                LblDateTip.Text = "办结时间"
                LblRemark.Text = "办结描述"
            Else
                LblDateTip.Text = "送达时间"
                LblRemark.Text = "状态描述"

            End If

        End Sub

 


        Private Sub CmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSearch.Click
            Dim strSQLWhere As String

            If Trim(TxtFindKey.Text) <> "" Then
                strSQLWhere = "  Where b.tongyibianhao Like '%" & Trim(TxtFindKey.Text) & "%'"
            Else
                strSQLWhere = ""
            End If

            ShowGridDetail(strSQLWhere)

        End Sub

        Private Sub DropDownList_BanLiType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList_BanLiType.SelectedIndexChanged
            Dim strYwType As String


            BindZzType()
            'Try
            If DropDownList_BanLiType.SelectedValue.StartsWith("t_BianJie", StringComparison.OrdinalIgnoreCase) Then
                txtZJBH.Enabled = True
                txtFZDW.Enabled = True
                txtZJYXQX.Enabled = True
                'txtSFJE.Text = ""
                txtSFJE.Enabled = True
                ddlzztype.Enabled = True
                txtZJBH.BackColor = Color.White
                txtFZDW.BackColor = Color.White
                txtZJYXQX.BackColor = Color.White
                txtSFJE.BackColor = Color.White
                txtSFJE.Text = 0
                txtFZDW.Text = Session("Login_UnitName")
                txtZJYXQX.Text = ""
                LblRemark.Text = "退回或作废原因"
                Label2.Text = "*办结人员:"
            Else
                txtZJBH.Enabled = False
                txtFZDW.Enabled = False
                txtZJYXQX.Enabled = False
                txtSFJE.Enabled = False
                ddlzztype.Enabled = False
                txtZJBH.BackColor = SystemColors.ActiveBorder
                txtFZDW.BackColor = SystemColors.ActiveBorder
                txtZJYXQX.BackColor = SystemColors.ActiveBorder
                txtSFJE.BackColor = SystemColors.ActiveBorder

                txtZJYXQX.Text = ""

                LblRemark.Text = "*" & DropDownList_BanLiType.SelectedItem.Text & "描述:"
                Label2.Text = "*" & DropDownList_BanLiType.SelectedItem.Text & "人员:"
            End If

            strYwType = DropDownList_BanLiType.SelectedValue.ToString()
            If InStr(strYwType, "|") > 0 Then
                strYwType = Left(strYwType, InStr(strYwType, "|") - 1)
            End If


            '---------------------------------
            'update 2005-12-22  by taia
            '当选择不同的办理状态,相应的描述也随之改变
            '---------------------------------           

            If UCase(strYwType) <> UCase("t_BianJie") Then
                ShowshixiangJiaose(strYwType)
            Else
                dropRen.Items.Clear()
                dropRen.Items.Add(Session("Login_UserName"))
                dropRen.SelectedItem.Text = Session("Login_UserName")
            End If

            ''ShowshixiangJiaose(strYwType)

            If dropRen.Items.Count = 0 Then
                dropRen.Items.Clear()
                dropRen.Items.Add(Session("Login_UserName"))
                dropRen.SelectedItem.Text = Session("Login_UserName")
            End If


            'Catch ex As Exception
            'ShowClientAlert(String.Format(" alert('处理事项角色权限时,发生错误!\n{0}'); ", ex.Message))
            'taia.Components.Logger.GetInstance().WriteLog(ex)
            'End Try

        End Sub
        Private Sub GetData(ByVal strID As String)
            Dim strSql As String
            Dim Sqlcmd As New SqlClient.SqlCommand
            Dim Dr As SqlClient.SqlDataReader
            m_SQLCn.Close()
            m_SQLCn.Open()

            strSql = "Select * From BanZhendanwei where id='" & strID & "'"
            Sqlcmd.CommandText = strSql
            Sqlcmd.Connection = m_SQLCn
            Dr = Sqlcmd.ExecuteReader()
            If Dr.Read = True Then
                txtFZDW.Text = Dr.Item("fzdw")
                txtZJBH.Text = Dr.Item("zjbh")
                txtZJYXQX.Text = Dr.Item("ZJYXQX")
                txtSFJE.Text = Dr.Item("SFJE")
            Else
                txtFZDW.Text = ""
                txtZJBH.Text = ""
                txtZJYXQX.Text = ""
                txtSFJE.Text = ""

            End If


        End Sub

        Private Sub btnClick_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClick.Click
            GetData(Trim(txtFindid.Text))

        End Sub

 

        Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
            If Not m_SQLCn Is Nothing Then
                If m_SQLCn.State = ConnectionState.Open Then
                    m_SQLCn.Close()

                End If
            End If

            If Not m_CnXzxk Is Nothing Then
                If m_CnXzxk.State = ConnectionState.Open Then
                    m_CnXzxk.Close()
                End If
            End If

        End Sub

 


        Private Function GetPersonList(ByVal sxbm As String, ByVal userid As String, ByVal username As String) As ArrayList
            Dim strSql As String
            Dim Sqlcmd As New SqlClient.SqlCommand
            Dim Dr As SqlClient.SqlDataReader
            Dim arr As New ArrayList

            Try

                m_SQLCn.Close()
                m_SQLCn.Open()

                strSql = "Select t_ChengBan,t_ShenHe,t_PiZhun From shixiangquanxian where" & _
                        " shenqingshixiangbianma='" & sxbm & "' and t_shouliren_userid='" & userid & "'"

                Sqlcmd.CommandText = strSql
                Sqlcmd.Connection = m_SQLCn
                Dr = Sqlcmd.ExecuteReader()

                If Dr.Read Then
                    arr.Add(Dr.Item("t_ChengBan"))
                    arr.Add(Dr.Item("t_ShenHe"))
                    arr.Add(Dr.Item("t_PiZhun"))
                Else
                    arr.Add(username)
                    arr.Add(username)
                    arr.Add(username)
                End If

                Dr.Close()
                Dr = Nothing
                Sqlcmd = Nothing

            Catch ex As Exception
                ShowClientAlert("", "<script>alert('取事项角色权限时,发生错误!');</script>")
            End Try

            Return arr

        End Function

        Private Sub OptNormal_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptNormal.CheckedChanged
            OptFault.Checked = False
            ShowGridDetail("", "shoulixinxibak")
        End Sub

        Private Sub OptFault_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptFault.CheckedChanged
            OptNormal.Checked = False
            ShowGridDetail("", "shoulixinxi")
        End Sub


        Private Sub ddlTeBieChengXuLeiBie_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlTeBieChengXuLeiBie.SelectedIndexChanged

            BindToTeBieChengXuMingCheng(ddlTeBieChengXuLeiBie.SelectedValue)
            If ddlTeBieChengXuLeiBie.SelectedValue = "A" Then
                Me.ddlTeBieDays.Visible = True
                Me.ddlTeBieDays.ClearSelection()
                'BindToTeBieDays()
            Else
                Me.ddlTeBieDays.Visible = False
            End If
        End Sub


        Private Function checkAddTeBieChengXuJieGuo() As Boolean  '''检查特别程序结果
            Dim IsShenQing As Boolean
            Dim ShenQingLeiBie As String = ""
            Dim dt As DataTable
            checkAddTeBieChengXuJieGuo = True

            dt = core.GetData("select TBCXZL from t_TeBieChengXuShenQing where YWLSH='" & TxtID.Text & "'")

            IsShenQing = False
            If dt.Rows.Count > 0 Then
                IsShenQing = True
                ShenQingLeiBie = dt.Rows(0)("TBCXZL")
            End If

            If IsShenQing = False Then
                ShowClientAlert("", "<script>alert('此记录没有经过特别程序的申请,不能录入特别程序结果');</script>")
                Return False
            ElseIf ShenQingLeiBie = "A" Then
                ShowClientAlert("", "<script>alert('A类特别程序的申请不需要填报特别程序结果');</script>")
                Return False
            End If
        End Function


        Function GetYwlsh(ByVal strXKSXBH As String, ByVal strXKSXZX As String, ByVal strYXTYWLSH As String) As String  ''得到业务流水号
            Dim lsh As String

            lsh = core.GetJCYWLSH(strXKSXBH, strXKSXZX, strYXTYWLSH)

            If lsh = "0" Then
                Throw New Exception("未能生成业务流水号")
            End If

            Return lsh
        End Function

        Function GetBMList(ByVal strGetHuiZhiHao As String) As ArrayList

            '0为原系统流水号,1许可事项编号,2许可事项子项
            Dim dt As DataTable
            Dim arr As New ArrayList
            Dim strSql, strShixiangbianma As String


            strSql = "Select Top 1 Shixiangbianma from [shoulixinxibak] where shoulibianhao='" & strGetHuiZhiHao & "' "
            dt = core.GetData(strSql)
            If dt.Rows.Count > 0 Then
                arr.Add(strGetHuiZhiHao)
                strShixiangbianma = dt.Rows(0)("Shixiangbianma")

            Else
                Throw New Exception("没有找到相应业务流水号")
            End If


            strSql = "Select  caizhihao,XKSXZX from ShenQingShiXiang where shenqingshixiangbianma='" & strShixiangbianma & "'"
            dt = core.GetData(strSql)

            If dt.Rows.Count > 0 Then
                arr.Add(dt.Rows(0)(0))
                arr.Add(dt.Rows(0)(1))
            Else

                Throw New Exception("未能找到相应许可事项编号")

            End If


            Return arr
        End Function

 

        Private Sub showTeBieState(ByVal state As Integer)
            '''显示特别程序状态的界面
            '''1 显示特别申请,
            '''2 显示特别结果
            '''其它隐藏
            chkTeBieShenQing.Checked = False
            chkTeBieJieGuo.Checked = False
            chkTeBieShenQing.Visible = False
            chkTeBieJieGuo.Visible = False
            palTeBie.Visible = False
            palTeBieJieGuo.Visible = False

            If state = 1 Then
                chkTeBieShenQing.Visible = True
                chkTeBieJieGuo.Visible = False
            ElseIf state = 2 Then
                chkTeBieShenQing.Visible = False
                chkTeBieJieGuo.Visible = True
            End If
        End Sub

 

        Private Sub showTeBieShenQingContent()
            palTeBie.Visible = True
            palTeBieJieGuo.Visible = False

            Call BindToTeBieChengXuZhongLei() '绑定特别程序种类
            Call BindToTeBieChengXuMingCheng(Me.ddlTeBieChengXuLeiBie.SelectedValue)  '绑定特别程序种类名称


            LblRemark.Text = "特别程序启动理由或依据"
            Label7.Text = "申请内容"
            Label2.Text = "特别程序批准人"
            fillContent(Session("Login_UnitID"), "007541651050", "ShengQin")

            If Me.ddlTeBieChengXuLeiBie.SelectedValue = "A" Then
                Me.ddlTeBieDays.Visible = True
            Else
                Me.ddlTeBieDays.Visible = False
            End If
        End Sub

        Private Sub hideTeBieShenQingContent()
            palTeBie.Visible = False

            LblRemark.Text = "描述"
            Label7.Text = "备注"
            Label2.Text = "办理人员"
        End Sub

        Private Sub showTeBieJieGuoContent()
            palTeBie.Visible = False
            palTeBieJieGuo.Visible = True
            fillContent(Session("Login_UnitID"), "007541651050", "JieGuo")
        End Sub

        Private Sub hideTeBieJieGuoContent()
            palTeBieJieGuo.Visible = False
        End Sub

        Private Sub chkTeBieJieGuo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkTeBieJieGuo.CheckedChanged
            If chkTeBieJieGuo.Checked Then
                showTeBieJieGuoContent()
            Else
                hideTeBieJieGuoContent()
            End If
        End Sub

 

        Private Sub chkTeBieShenQing_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkTeBieShenQing.CheckedChanged
            If chkTeBieShenQing.Checked Then
                showTeBieShenQingContent()
            Else
                hideTeBieShenQingContent()
            End If
        End Sub

        Private Sub fillContent(ByVal DanWeiDaiMa As String, ByVal ShenQingShiXiang As String, ByVal Content As String)
            ''根据单位代码,和申请事项把数据填充到表单中
            Dim Ds As DataSet
            Dim Dv As DataView
            Dim arr As String()

            Ds = GetData()
            Dv = Ds.Tables("TeBieChengXuData").DefaultView()
            Dv.RowFilter = "DanWeiDaiMa='" & DanWeiDaiMa & "' and ShiXiangBianHao='" & ShenQingShiXiang & "'"

            If Dv.Count > 0 Then
                If Content = "ShengQin" Then  '''''填充申请的数据
                    TxtRemark.Text = Dv(0).Item("LiYou")
                    txtTeBieDianHua.Text = Dv(0).Item("LianXiDainHua")
                    txtTeBieSouJi.Text = Dv(0).Item("LianXiShouJi")

                    Me.ddlTeBieChengXuLeiBie.SelectedValue = Dv(0).Item("LeiBie")
                    BindToTeBieChengXuMingCheng(Dv(0).Item("LeiBie"))

                    Me.ddlTeBieChengXuMingCheng.SelectedValue = Dv(0).Item("LeiBieMingCheng")

                    Me.ddlTeBieDays.SelectedIndex = Dv(0).Item("YanChangShiXian") - 1

                    If IsNothing(Me.dropRen.Items.FindByValue(Dv(0).Item("PiZhunRen"))) Then
                        Me.dropRen.Items.Add(New ListItem(Dv(0).Item("PiZhunRen"), Dv(0).Item("PiZhunRen")))  ''批准人填充数据
                    End If
                    Me.dropRen.SelectedValue = Dv(0).Item("PiZhunRen")
                Else
                    If (Not IsDBNull(Dv(0).Item("JieGuo"))) Then
                        txtSFJE.Text = Dv(0).Item("ShouFeiJinE")

                        arr = CStr(Dv(0).Item("JieGuo")).Split("|".ToCharArray)
                        Me.ddlTeBieChengXuJieGuo.DataSource = arr
                        Me.ddlTeBieChengXuJieGuo.DataBind()
                    End If
                End If
            End If
        End Sub

        Private Function GetData() As DataSet
            '''得到特别程序预先设置的数据

            Dim da As SqlClient.SqlDataAdapter
            Dim Ds As DataSet
            Dim strSql As String
            If Cache.Item("data") Is Nothing Then
                da = New SqlClient.SqlDataAdapter
                Ds = New DataSet
                strSql = "select * from TeBieChengXuData"
                da.SelectCommand = New SqlClient.SqlCommand(strSql, m_SQLCn)
                da.Fill(Ds, "TeBieChengXuData")
                Cache.Insert("Data", Ds)

            Else
                Ds = CType(Cache.Item("data"), DataSet)

            End If
            Return Ds
        End Function


        Private Sub UltraWebGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.InitializeRow
            Dim str As String
            Dim dt As DateTime
            Dim days As Integer, totalDays As Integer

            str = e.Row.Cells(4).Text.Trim()
            totalDays = IIf(IsNumeric(e.Row.Cells(5).Text.Trim()), CInt(e.Row.Cells(5).Text.Trim()), 0)
            If IsDate(str) Then
                dt = DateTime.Parse(str)
                days = com.agri.approve.Util.PassWorkDay(dt.Date, DateTime.Today)
                UltraWebGrid1.Rows(e.Row.Index).Cells(5).Text = CStr(totalDays - days)
            End If

        End Sub

        Private Sub UltraWebGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout

        End Sub

        Private Sub ddlzztype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlzztype.SelectedIndexChanged
            Dim zzbh As String
            Dim zz As taia.xzxk.Bussiness.Model.ZhengZhao
            zzbh = ddlzztype.SelectedValue

            If zzbh <> "" Then
                zz = core.GetZhengZhao(zzbh)
                If Not (zz Is Nothing) Then
                    txtSFJE.Text = zz.sfjr
                    txtZJYXQX.Text = zz.zzyxq
                    txtFZDW.Text = zz.qfdw
                    txtzzMemo.Text = "企业名称:" & txtQYMC.Text & vbCrLf & "<br />有效期:" & zz.sfjr & vbCrLf & " <br /> 发证单位:" & zz.qfdw & " <br /> "
                End If
            End If
        End Sub

 

        Private Sub ShowClientAlert(ByVal key As String, ByVal content As String)
            ClientScript.RegisterStartupScript(Me.GetType(), key, content)
        End Sub

        Private Sub ShowClientAlert(ByVal content As String)
            ClientScript.RegisterStartupScript(Me.GetType(), "", content, True)
        End Sub

    End Class

End Namespace

清一涩的主页 清一涩 | 初学一级 | 园豆:111
提问于:2012-05-11 21:56
< >
分享
所有回答(2)
0

请求超时或者服务器没有响应。

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.(   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

悟行 | 园豆:12422 (专家六级) | 2012-05-11 22:08
0

问题很难说。或者你的Sql连接关闭不及时,有个时间差也是一个可能。

另外,你的网络或SQL服务提供的服务不稳定也会导致这个情况发生。

最后,你的SQL连接是否还有别的应用在使用,假如你的这个应用连接到SQL服务器的时候,别的应用也在连接,此时如果连接资源被用完了的话,就会报告这个错误。但这个时候有个时间等待的(超时时间),假如在超时时间内别的应用都没有一个释放连接资源或释放连接资源后又被别的应用优先抢用或者是你的这个应用排队很靠后,那就没办法了。

无之无 | 园豆:5085 (大侠五级) | 2012-05-12 08:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册