📄 newworkrep.aspx.vb
字号:
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Partial Class GZHB_newWorkRep
Inherits System.Web.UI.Page
Dim ctrl As Controls = New Controls()
Dim workProces As WorkProces = New WorkProces
Dim sqldb As SqlDataBase = New SqlDataBase
Dim senderID As String
Shared reciverID As String = ""
Shared reciver(50)() As Char
Shared ireciver As Int32
Dim mtitle As String
Dim Sort As String
Dim place As String
Dim Contents As String
Dim SendTime As DateTime = Date.Now
Dim scheduledFinishingTime As DateTime = SendTime
Dim scheduledFinishingTimestr As String
Dim status As String
Shared upfile(10) As FileUpload
Dim fileup As New FileUpload
Shared ifile As Int32
Dim mfile As Boolean = False
Dim path As String
Dim url As String = "ViewWorkRep.aspx?WorkRepID="
Dim idurl As Integer
Dim i As Int32
Dim mFileName As String = ""
Dim mFileAdd As String = ""
Dim users As users = New users
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If Not (Page.IsPostBack) Then
ifile = 0
upfile(10) = FileUpload_file
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As DataTable
'users.ValidateUser(Profile.user.id, "../cons_main.aspx")
If Not (Page.IsPostBack) Then
dt = sqldb.TSelect("T_role", "RoleID,RoleName", "RoleName!='系统管理员' and RoleName!='普通用户'")
ctrl.BindDropDownList(DropDownList1, dt.DefaultView, "RoleName", "RoleID", "所有用户")
ifile = 0
For i = 0 To 10
upfile(i) = FileUpload_file
Next
'清空已选择对象表
ListBox_UserSelect.Items.Clear()
ireciver = 0
reciverID = "everyone"
If Session.Item("FileStatus") = "workrepdraft" Then
If Session.Item("WorkRepID") <> Nothing Then
idurl = CInt(Session.Item("WorkRepID"))
ClientScript.RegisterStartupScript(Me.GetType(), "NoTitle", "<script>window.alert('注意:编辑草稿发送时需重新指定发送对象!');</script>")
dt = sqldb.GetTable("select * from T_workRep where WorkRepID ='" & idurl & "'")
textbox_title.Text = dt.Rows.Item(0).Item("Title")
TextBox_Sort.Text = dt.Rows.Item(0).Item("Sort")
TextBox_FinishTime.Text = CDate(dt.Rows.Item(0).Item("WorkTime")).ToShortDateString
TextBox_Where.Text = dt.Rows.Item(0).Item("Place")
ireciver = 0
reciverID = "everyone"
textbox_contents.Text = dt.Rows.Item(0).Item("contents")
If dt.Rows.Item(0).Item("mFile") = True Then
Dim dtfile As DataTable = sqldb.GetTable("select * from T_workRepFile where WorkRepID ='" & idurl & "'")
ifile = dtfile.Rows.Count
If ifile > 0 Then
For i = 0 To ifile - 1
ListBox_FileList.Items.Add(dtfile.Rows.Item(i).Item("FileName").ToString)
ListBox_FileList.Visible = True
Button_delFile.Visible = True
Next
End If
End If
End If
End If
If Request.QueryString("status") = "zhuanfa" Then
idurl = Request.QueryString("id")
dt = sqldb.GetTable("select * from T_workRep where WorkRepID ='" & idurl & "'")
textbox_title.Text = "[转发]" + dt.Rows.Item(0).Item("Title")
TextBox_Sort.Text = "文件转发"
TextBox_FinishTime.Text = CDate(dt.Rows.Item(0).Item("WorkTime")).ToShortDateString
TextBox_Where.Text = dt.Rows.Item(0).Item("Place")
ireciver = 0
reciverID = "everyone"
textbox_contents.Text = dt.Rows.Item(0).Item("contents")
If dt.Rows.Item(0).Item("mFile") = True Then
Dim dtfile As DataTable = sqldb.GetTable("select * from T_workRepFile where WorkRepID ='" & idurl & "'")
ifile = dtfile.Rows.Count
If ifile > 0 Then
For i = 0 To ifile - 1
ListBox_FileList.Items.Add(dtfile.Rows.Item(i).Item("FileName").ToString)
ListBox_FileList.Visible = True
Button_delFile.Visible = True
Next
ListBox_FileList.Enabled = False
FileUpload_file.Enabled = False
Button_addFile.Enabled = False
Button_delFile.Enabled = False
End If
End If
End If
End If
End Sub
Protected Sub Button_Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Submit.Click
getvalue()
If mtitle = "" Then
'MsgBox("标题不能为空!", MsgBoxStyle.Exclamation, "错误!")
ClientScript.RegisterStartupScript(Me.GetType(), "NoTitle", "<script>window.alert('标题不能为空!');</script>")
Return
End If
If Contents = "" Then
ClientScript.RegisterStartupScript(Me.GetType(), "NoContents", "<script>window.alert('内容不能为空!');</script>")
'MsgBox("内容不能为空!", MsgBoxStyle.Exclamation, "错误!")
Return
End If
If place = "" Then
ClientScript.RegisterStartupScript(Me.GetType(), "NoContents", "<script>window.alert('地点不能为空!');</script>")
'MsgBox("地点不能为空!", MsgBoxStyle.Exclamation, "错误!")
Return
End If
If ireciver = 0 Then
ClientScript.RegisterStartupScript(Me.GetType(), "NoContents", "<script>window.alert('请指定发送对象!');</script>")
'MsgBox("地点不能为空!", MsgBoxStyle.Exclamation, "错误!")
Return
End If
If scheduledFinishingTimestr = "" Then
ClientScript.RegisterStartupScript(Me.GetType(), "NoContents", "<script>window.alert('时间不能为空!');</script>")
'MsgBox("地点不能为空!", MsgBoxStyle.Exclamation, "错误!")
Return
End If
scheduledFinishingTime = CDate(scheduledFinishingTimestr)
If ifile > 0 Then
mfile = True
End If
Dim file_path As String
If Session.Item("FileStatus") = "workrepdraft" Then
If Session.Item("WorkRepID") <> Nothing Then
idurl = CInt(Session.Item("WorkRepID"))
file_path = senderID & idurl & Now.Year.ToString & Now.Month.ToString & Now.Day.ToString & Now.Hour.ToString & Now.Minute.ToString
If mfile Then
'sqldb.RunSql("delete from T_workRepFile where WorkRepID = '" & idurl & "'")
For i = 0 To (ifile - 1)
If upfile(i).HasFile Then
mFileName = upfile(i).FileName
path = Server.MapPath("~\UpLoad\HB\")
path = path & file_path
mFileAdd = ("~\UpLoad\HB\") & file_path & mFileName
upfile(i).PostedFile.SaveAs(path & upfile(i).FileName)
workProces.AddWorkRepFile(idurl.ToString, mFileName, mFileAdd)
Else
mFileName = ListBox_FileList.Items(i).Text
path = Server.MapPath("~\UpLoad\HB\")
path = path & file_path
mFileAdd = ("~\UpLoad\HB\") & file_path & mFileName
workProces.AddWorkRepFile(idurl.ToString, mFileName, mFileAdd)
End If
Next
End If
sqldb.RunSql("delete from T_WorkRepReturn where WorkRepID = '" & idurl & "'")
For i = 0 To ireciver - 1
workProces.AddWorkRepRe(idurl, senderID, reciver(i))
taskProc()
Next
sqldb.RunSql("update T_workRep set receiverID='" & reciverID & _
"' , Title ='" & mtitle & _
"' , Sort = '" & Sort & _
"' , Place = '" & place & _
"' , Contents = '" & Contents & _
"' , SendTime = '" & SendTime & _
"' , WorkTime ='" & scheduledFinishingTime & _
"' , mFile = '" & mfile & _
"' ,status = '" & status & _
"' where WorkRepID='" & idurl & "'")
Session.Remove("FileStatus")
Session.Remove("WorkRepID")
Page.Response.Redirect("WorkRepRe.aspx?check=true")
End If
Else
idurl = workProces.AddWorkRep(senderID, reciverID, mtitle, Sort, place, Contents, SendTime, scheduledFinishingTime, mfile, status, url)
file_path = senderID & idurl & Now.Year.ToString & Now.Month.ToString & Now.Day.ToString & Now.Hour.ToString & Now.Minute.ToString
If idurl <> 0 Then
If mfile And Request.QueryString("status") <> "zhuanfa" Then
For i = 0 To (ifile - 1)
mFileName = upfile(i).FileName
path = Server.MapPath("~\UpLoad\HB\")
path = path & file_path
mFileAdd = ("~\UpLoad\HB\") & file_path & mFileName
upfile(i).PostedFile.SaveAs(path & upfile(i).FileName)
workProces.AddWorkRepFile(idurl.ToString, mFileName, mFileAdd)
Next
End If
'添加发布对象表
For i = 0 To ireciver - 1
workProces.AddWorkRepRe(idurl, senderID, reciver(i))
'添加主界面信息表
If status <> "workrepdraft" Then
taskProc()
End If
Next
url += idurl.ToString
sqldb.RunSql("update T_workRep set URL='" & url & "' where WorkRepID='" & idurl & "'")
If Request.QueryString("status") = "zhuanfa" Then
Dim dt As DataTable
dt = sqldb.GetTable("select * from T_workRep where WorkRepID ='" & Request.QueryString("id") & "'")
If dt.Rows.Item(0).Item("mFile") = True Then
dt = sqldb.GetTable("select * from T_workRepFile where WorkRepID ='" & Request.QueryString("id") & "'")
For i = 0 To dt.Rows.Count - 1
sqldb.RunSql("insert into T_workRepFile(WorkRepID,FileName,FilePath)values('" & idurl & "','" & dt.Rows.Item(i).Item("FileName") & "','" & dt.Rows.Item(i).Item("FilePath") & "')")
Next
End If
ListBox_FileList.Enabled = True
FileUpload_file.Enabled = True
Button_addFile.Enabled = True
Button_delFile.Enabled = True
End If
Page.Response.Redirect("workRepRe.aspx?check=true")
Else
delWorkRep(idurl)
Page.Response.Redirect("workRepRe.aspx?check=false")
End If
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Reset.Click
Page.Response.Redirect("newWorkRep.aspx")
End Sub
Private Sub getvalue()
senderID = Profile.user.id
mtitle = ctrl.GetText(textbox_title)
Sort = ctrl.GetText(TextBox_Sort)
Contents = textbox_contents.Text
place = TextBox_Where.Text
If CheckBox_DraftOrNo.Checked = True Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -