⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contractanalyse.aspx.vb

📁 电子合同管理系统C#
💻 VB
字号:
Public Class ContractAnalyse
    Inherits System.Web.UI.Page
    Protected WithEvents StatBtn As System.Web.UI.WebControls.LinkButton
    Protected WithEvents CompareValidator3 As System.Web.UI.WebControls.CompareValidator
    Protected WithEvents txtTotalCharge As System.Web.UI.WebControls.TextBox
    Protected WithEvents DpListState As System.Web.UI.WebControls.DropDownList
    Protected WithEvents CompareValidator2 As System.Web.UI.WebControls.CompareValidator
    Protected WithEvents CompareValidator1 As System.Web.UI.WebControls.CompareValidator
    Protected WithEvents txtEndDate As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtStartDate As System.Web.UI.WebControls.TextBox
    Protected WithEvents DpListDept As System.Web.UI.WebControls.DropDownList
    Protected WithEvents txtSide_B As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtSide_A As System.Web.UI.WebControls.TextBox
    Protected WithEvents ExportToExcel As System.Web.UI.WebControls.LinkButton
    Protected WithEvents StatDGrd As System.Web.UI.WebControls.DataGrid

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

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

    End Sub

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

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If Not IsPostBack Then
            Dim obj As MemberInfo = CType(Session("UserInfo"), MemberInfo)
            'DpListDept
            If obj.Role <> 1 Then
                DpListDept.Items.Insert(0, obj.DepartmentName)
                DpListDept.Items(0).Value = obj.DepartmentId
            Else
                Dim objDB As DBController = New DBController()
                objDB.BindDrpDownList("DepartmentName", "DepartmentId", "select * from DepartmentInfo", DpListDept)
                objDB.Close()
                DpListDept.Items.Insert(0, "选择部门")
                DpListDept.Items(0).Value = "-1"
            End If

            BindData()
        End If
    End Sub
    Private Sub BindData()
        If viewstate("sortexp") Is Nothing Then
            viewstate("sortexp") = "ContractSn"
        End If
        Dim sqlstr As String
        sqlstr = " where 1=1 " '

        If (txtSide_A.Text.Trim() <> "") Then
            sqlstr = sqlstr & " and Side_A= '" & txtSide_A.Text.Trim() & "' "
        End If

        If (txtSide_B.Text.Trim <> "") Then
            sqlstr = sqlstr & " and Side_B='" & txtSide_B.Text.Trim() & "'"
        End If
        '
        If (DpListDept.Items(DpListDept.SelectedIndex).Text.ToString <> "选择部门") Then
            sqlstr = sqlstr & " and DepartmentId=" & DpListDept.Items(DpListDept.SelectedIndex).Value.ToString
        End If
        '
        Try
            Dim txtSTime As DateTime
            Dim txtETime As DateTime
            If (txtStartDate.Text.Trim() <> "") Then

                txtSTime = CType(txtStartDate.Text.Trim, DateTime)
                If (txtEndDate.Text.Trim() <> "") Then

                    txtETime = CType(txtStartDate.Text.Trim, DateTime)
                    sqlstr = sqlstr & " and ( SubscribeDate >= '" & txtSTime.ToString("yyyy-MM-dd") & " 0:0:0' " & " and " & " SubscribeDate >= '" & txtETime.ToString("yyyy-MM-dd") & " 0:0:0') "
                Else
                    sqlstr = sqlstr & " and SubscribeDate >= '" & txtSTime.ToString("yyyy-MM-dd") & " 0:0:0'"
                End If
            Else
                If (txtEndDate.Text.Trim() <> "") Then
                    txtETime = CType(txtStartDate.Text.Trim, DateTime)
                    sqlstr = sqlstr & " and SubscribeDate <= '" & txtETime.ToString("yyyy-MM-dd") & " 0:0:0'"
                End If
            End If
        Catch ex As Exception

        End Try

        If DpListState.SelectedIndex <> 0 Then
            sqlstr = sqlstr & " and ContractState='" & DpListState.Items(DpListState.SelectedIndex).Text.ToString & "'"
        End If

        If txtTotalCharge.Text.ToString <> "" Then
            sqlstr = sqlstr & " and TotalCharge>" & txtTotalCharge.Text.ToString & ""
        End If
        sqlstr = "select * from ContractInfo  " + sqlstr
        Dim obj As DBController = New DBController()
        obj.BindDBGrd(sqlstr, StatDGrd)
        obj.Close()
    End Sub
    Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExportToExcel.Click
        ToExcel(StatDGrd)
    End Sub
    '=============================================================
    ' 函 数 名:ToExcel
    ' 功能描述:将DataGrid写到Excel中,并提供保存下载
    ' 输入参数:DataGrid对象
    ' 返 回 值:无
    ' 创建日期:2004-8-12
    ' 修改日期:2004-8-12
    ' 作    者:
    ' 附加说明: 
    '==============================================================

    Public Sub ToExcel(ByVal Dg As DataGrid)
        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Data.xls")
        HttpContext.Current.Response.Charset = "GB-2312"
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default
        HttpContext.Current.Response.ContentType = "application/ms-excel"
        Dg.Page.EnableViewState = False
        Dim tw As New System.IO.StringWriter()
        Dim hw As New System.Web.UI.HtmlTextWriter(tw)
        Dg.RenderControl(hw)
        HttpContext.Current.Response.Write(tw.ToString())
        HttpContext.Current.Response.End()
    End Sub

    Private Sub StatBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatBtn.Click
        StatDGrd.CurrentPageIndex = 0
        BindData()
    End Sub

    Private Sub StatDGrd_PageIndexChanged(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles StatDGrd.PageIndexChanged
        StatDGrd.CurrentPageIndex = e.NewPageIndex
        BindData()
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -