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

📄 shezhi.aspx.vb

📁 一个报税管理系统AJAX第二版B-S.rar
💻 VB
字号:
Imports System.Data.SqlClient
Imports system.configuration
Imports System.Web.Configuration
Imports System.Data
Partial Class shezhi
    Inherits System.Web.UI.Page
    Public pulic As New pulic1
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        chushihua()
        Dim str = ""
        If Session("s") = "" Then
            str = "select distinct nsrinf.nsrname,nsrinf.nsrid from nsrinf,shezhi where  nsrinf.nsrid=shezhi.nsrid "
        Else
            str = "select distinct nsrinf.nsrname,nsrinf.nsrid from nsrinf,shezhi where  nsrinf.nsrid=shezhi.nsrid  and " & Session("s")
        End If
        Dim tiaojian = ""
        If TextBox1.Text <> "" Then
            tiaojian = tiaojian + " and nsrinf.nsrname like '%" + TextBox1.Text().Trim + "%'"
        End If
        If TextBox2.Text <> "" Then
            tiaojian = tiaojian + "and  nsrinf.nsrid like '%" + TextBox2.Text().Trim + "%'"
        End If
        Session("skj") = str + tiaojian

        If pulic.execute(Session("skj")).HasRows Then
            System.Threading.Thread.Sleep(800)
            ' pulic.selectcommand(GridView1, sql1, grid1)
            GridView1.DataSource = pulic.execute(Session("skj"))
            GridView1.AllowSorting = True
            '   GridView1.AllowPaging = True
            GridView1.DataBind()
        Else
            GridView1.DataSource = ""
            GridView1.DataBind()
            'MsgBox("无匹配信息!", 0, "提示 ")
            Label9.Text = "提示:无匹配信息"
            Label9.Visible = True
        End If

    End Sub
    Protected Sub chushihua()
        Label9.Visible = False
        GridView1.DataSource = ""
        GridView1.DataBind()
        GridView1.SelectedRowStyle.Reset()
        Session("skjname") = ""
        Session("shezhiid") = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        CheckBox1.Checked = False
        CheckBox2.Checked = False

    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("bz") = "" Then
            Response.Redirect("login.aspx")
        End If

        If (Not IsPostBack) Then
            setFields()
            chushihua()
        End If
    End Sub

    Protected Sub timeset(ByVal box1, ByVal str1, ByVal box2, ByVal str2)
        box1.text = Mid(str1, 1, 4) + "-" + Mid(str1, 5, 2) + "-" + Mid(str1, 7, 2)
        box2.text = Mid(str2, 1, 4) + "-" + Mid(str2, 5, 2) + "-" + Mid(str2, 7, 2)
    End Sub
    Protected Sub unset(ByVal box1, ByVal str1, ByVal box2, ByVal str2)
        box1 = Mid(str1, 1, 4) + Mid(str1, 6, 2) + Mid(str1, 9, 2)
        box2 = Mid(str2, 1, 4) + Mid(str2, 6, 2) + Mid(str2, 9, 2)
    End Sub
    Protected Sub setFields()
        '建立命令字段
        GridView1.AutoGenerateColumns = False
        Dim selectField As New CommandField()
        selectField.ButtonType = ButtonType.Link
        selectField.ShowSelectButton = True   '显示选择按钮
        selectField.SelectText = "选择"
        selectField.HeaderText = "操作"
        selectField.ItemStyle.Wrap = False

        '建立数据绑定字段
        Dim employeeidField As New BoundField()
        employeeidField.DataField = "nsrname" '指定数据来源字段
        employeeidField.HeaderText = "纳税人名称" '设置字段头名称
        GridView1.Columns.Add(selectField)
        GridView1.Columns.Add(employeeidField)
    End Sub
    Protected Sub gridview1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
        Session("skjname") = GridView1.Rows(e.NewSelectedIndex).Cells(1).Text
        chuli()
    End Sub
    Protected Sub chuli()
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        System.Threading.Thread.Sleep(800)
        Button2.Enabled = True
        Dim name As String = Session("skjname")
        Dim cmd2 As New String("select nsrid from nsrinf where nsrname='" & name.Trim & "'")
        Session("shezhiid") = Convert.ToString(pulic.Scalar(cmd2))
        Dim shezhi = Session("shezhiid")
        Dim cmd3 As New String("select rjy_bz,bs_time,fpxm_bz,bd_jg,rjy_start,rjy_end,fpxm_start,fpxm_end from shezhi where nsrid='" & Session("shezhiid") & "'")
        Dim myReader As SqlDataReader = pulic.execute(cmd3)
        While myReader.Read()
            Dim rjy_bz As String = (myReader.GetString(0).Trim)
            Dim bs_time As String = (myReader.GetString(1).Trim)
            Dim fpxm_bz As String = (myReader.GetString(2).Trim)
            TextBox6.Text = (myReader.GetString(3).Trim)
            Dim bz = Mid(bs_time, 1, 1)
            If bz = "0" Then
                TextBox3.Text = Mid(bs_time, 2, 1)
            Else
                TextBox3.Text = Mid(bs_time, 1, 2)
            End If
            TextBox4.Text = Mid(bs_time, 3, 2)
            TextBox5.Text = Mid(bs_time, 5, 2)

            If rjy_bz = "01" Then
                CheckBox1.Checked = True
                timeset(TextBox7, myReader.GetString(4), TextBox8, myReader.GetString(5))
            Else
                CheckBox1.Checked = False
                TextBox7.Text = Format(Now(), "yyyy-MM-dd")
                TextBox8.Text = Format(Now(), "yyyy-MM-dd")
            End If
            If fpxm_bz = "01" Then
                CheckBox2.Checked = True
                timeset(TextBox9, myReader.GetString(6), TextBox10, myReader.GetString(7))
            Else
                CheckBox2.Checked = False
                TextBox9.Text = Format(Now(), "yyyy-MM-dd")
                TextBox10.Text = Format(Now(), "yyyy-MM-dd")
            End If
        End While

    End Sub

    Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
        Dim strFiled As String = e.SortExpression.Trim.ToString
        If ViewState("SortDirction") = "" Then
            ViewState("SortDirction") = "desc"   '这个与填充gridview语句的排序相反   
        Else
            If ViewState("SortDirction").ToString = "asc" Then
                ViewState("SortDirction") = "desc"
            Else
                ViewState("SortDirction") = "asc"
            End If
        End If
        Dim cmd As New String(Session("skj") + "order   by   " + strFiled + "   " + ViewState("SortDirction").ToString)
        GridView1.DataSource = pulic.execute(cmd)
        GridView1.DataBind()
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Session("shezhiid") = "" Then
            ' Dim answer
            '  answer = MsgBox("无操作对象,保存失败!", 0, "提示:")
            Label9.Text = "无操作对象"
            Label9.Visible = True
            Exit Sub
        End If

        If IsValid Then
            Dim str As New String("select quyucode,deptcode,kecode,taxcode  from nsrinf where  nsrid='" & Session("shezhiid") & "'")
            Dim myReader As SqlDataReader = pulic.execute(str)
            Dim quyucode
            Dim deptcode
            Dim kecode
            Dim taxcode
            While myReader.Read()
                quyucode = (myReader.GetString(0).Trim)
                deptcode = (myReader.GetString(1).Trim)
                kecode = (myReader.GetString(2).Trim)
                taxcode = (myReader.GetString(3).Trim)
            End While
            myReader.Close()
            Dim bs_time = ""
            If TextBox3.Text.Trim.Length = 1 Then
                bs_time = "0" + TextBox3.Text.Trim
            Else
                bs_time = TextBox3.Text.Trim
            End If
            If TextBox4.Text.Trim.Length = 1 Then
                bs_time = bs_time + "0" + TextBox4.Text.Trim
            Else
                bs_time = bs_time + TextBox4.Text.Trim
            End If
            If TextBox5.Text.Trim.Length = 1 Then
                bs_time = bs_time + "0" + TextBox5.Text.Trim
            Else
                bs_time = bs_time + TextBox5.Text.Trim
            End If
            Dim bd_jg = TextBox6.Text.Trim.Trim
            Dim rjy_bz
            Dim fpxm_bz
            If CheckBox1.Checked Then
                rjy_bz = "01"
            Else
                rjy_bz = "00"
            End If
            If CheckBox2.Checked Then
                fpxm_bz = "01"
            Else
                fpxm_bz = "00"
            End If
            Dim rjy_start, rjy_end, fpxm_start, fpxm_end
            rjy_start = Mid(TextBox7.Text, 1, 4) + Mid(TextBox7.Text, 6, 2) + Mid(TextBox7.Text, 9, 2)
            rjy_end = Mid(TextBox8.Text, 1, 4) + Mid(TextBox8.Text, 6, 2) + Mid(TextBox8.Text, 9, 2)
            fpxm_start = Mid(TextBox9.Text, 1, 4) + Mid(TextBox9.Text, 6, 2) + Mid(TextBox9.Text, 9, 2)
            fpxm_end = Mid(TextBox10.Text, 1, 4) + Mid(TextBox10.Text, 6, 2) + Mid(TextBox10.Text, 9, 2)
            Dim strSQL As String = "update  shezhi set quyucode='" & quyucode & "',deptcode='" & deptcode & "',kecode='" & kecode & "',taxcode='" & taxcode & "',nsrid='" & Session("shezhiid") & "',bs_time='" & bs_time & "',bd_jg='" & bd_jg & "',rjy_bz='" & rjy_bz & "',rjy_start='" & rjy_start & "',rjy_end='" & rjy_end & "',fpxm_bz='" & fpxm_bz & "',fpxm_start='" & fpxm_start & "',fpxm_end='" & fpxm_end & "' where  nsrid='" & Session("shezhiid") & "'"
            pulic.noquery(strSQL)
            Label9.Text = "设置保存成功"
            Label9.Visible = True
        Else
            Exit Sub
        End If

    End Sub
    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
        Dim st1 = Mid(TextBox7.Text, 1, 4) + Mid(TextBox7.Text, 6, 2) + Mid(TextBox7.Text, 9, 2)
        Dim sp1 = Mid(TextBox8.Text, 1, 4) + Mid(TextBox8.Text, 6, 2) + Mid(TextBox8.Text, 9, 2)
        Dim sp2 = Mid(TextBox10.Text, 1, 4) + Mid(TextBox10.Text, 6, 2) + Mid(TextBox10.Text, 9, 2)
        Dim st2 = Mid(TextBox9.Text, 1, 4) + Mid(TextBox9.Text, 6, 2) + Mid(TextBox9.Text, 9, 2)
        If (st1 > sp1) Or (st2 > sp2) Or (TextBox7.Text.Trim.Length <> 10) Or (TextBox8.Text.Trim.Length <> 10) Or (TextBox9.Text.Trim.Length <> 10) Or (TextBox10.Text.Trim.Length <> 10) Then
            args.IsValid = False
        Else
            args.IsValid = True
        End If
    End Sub
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
    End Sub
    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Response.Redirect("index.aspx")
        ' ScriptManager1.RegisterAsyncPostBackControl(Button3)
    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
End Class

⌨️ 快捷键说明

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