📄 gggonggao.aspx.vb
字号:
Imports System.Data.SqlClient
Imports system.configuration
Imports System.Web.Configuration
Imports System.Data
Partial Class gggonggao
Inherits System.Web.UI.Page
Public pulic As New pulic1
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
Dim st1 = Mid(TextBox2.Text, 1, 4) + Mid(TextBox2.Text, 6, 2) + Mid(TextBox2.Text, 9, 2)
Dim sp1 = Mid(TextBox3.Text, 1, 4) + Mid(TextBox3.Text, 6, 2) + Mid(TextBox3.Text, 9, 2)
If (st1 > sp1) Or (TextBox2.Text.Trim.Length <> 10) Or (TextBox3.Text.Trim.Length <> 10) Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Trim = "" Then
' Response.Write("<script>alert('公告不能为空!')</script>")
'MsgBox("公告不能为空!", 0, "提示:")
Label1.Text = "提示:公告不能为空"
Label1.Visible = True
Exit Sub
End If
If IsValid Then
Dim strL As Integer = 0
Dim s As String
For i As Integer = 1 To TextBox1.Text.Length
s = Mid(TextBox1.Text, i, 1)
If Asc(s) < 0 Then
strL += 2
Else
strL += 1
End If
Next
If strL < 98 Then
Dim tp = Mid(TextBox3.Text, 1, 4) + Mid(TextBox3.Text, 6, 2) + Mid(TextBox3.Text, 9, 2)
Dim start = Mid(TextBox2.Text, 1, 4) + Mid(TextBox2.Text, 6, 2) + Mid(TextBox2.Text, 9, 2)
Dim del As New String("delete from gonggao_public where quyucode='001'")
pulic.noquery(del)
Dim strSQL1 As String = "INSERT INTO gonggao_public(quyucode,start,stop,info,flage) values ('001','" & Trim(start) & "','" & Trim(tp) & "','" & Trim(TextBox1.Text.Trim) & "','1')"
pulic.noquery(strSQL1)
If Label1.Text = "提示:公共公告发布成功" Then
Label1.Text = "提示:公共公告修改成功"
Label1.Visible = True
Else
Label1.Text = "提示:公共公告发布成功"
Label1.Visible = True
End If
Else
' MsgBox("发布的公告长度超出最大值!", 0, "提示:")
Label1.Text = "提示:发布的公告长度超出最大值"
Label1.Visible = True
End If
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not IsPostBack) Then
chushihua()
End If
End Sub
Protected Sub chushihua()
Dim cmd As New String("select count(*) from gonggao_public where quyucode='001'")
If Convert.ToInt32(pulic.Scalar(cmd)) <> 0 Then
Dim gonggong As New String("select * from gonggao_public where quyucode='001'")
Dim myReader As SqlDataReader = pulic.execute(gonggong)
While myReader.Read()
Dim start = myReader("start")
Dim tp = myReader("stop")
TextBox2.Text = Mid(start, 1, 4) + "-" + Mid(start, 5, 2) + "-" + Mid(start, 7, 2)
TextBox3.Text = Mid(tp, 1, 4) + "-" + Mid(tp, 5, 2) + "-" + Mid(tp, 7, 2)
TextBox1.Text = myReader("info").trim
End While
myReader.Close()
Button2.Enabled = True
Else
TextBox3.Text = Format(Now(), "yyyy-MM-dd")
TextBox2.Text = Format(Now(), "yyyy-MM-dd")
' MsgBox("暂无公共公告!", 0, "提示:")
Label1.Text = "提示:暂无公共公告"
Label1.Visible = True
End If
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
delete()
End Sub
Protected Sub delete()
Dim del As New String("delete from gonggao_public where quyucode='001'")
pulic.noquery(del)
' Response.Write("<script>alert('公共公告删除成功!')</script>")
Label1.Text = "提示:公共公告删除成功"
Label1.Visible = True
Button2.Enabled = False
TextBox1.Text = ""
TextBox3.Text = Format(Now(), "yyyy-MM-dd")
TextBox2.Text = Format(Now(), "yyyy-MM-dd")
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("index.aspx")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -