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

📄 sendmessage.asp

📁 物业管理和办公自动化系统
💻 ASP
字号:
<%
'
'    Filename: SendMessage.asp
'    Generated with CodeCharge 2.0.3
'    ASP 2.0 & Templates.ccp build 10/17/2001
'

'-------------------------------
' SendMessage CustomIncludes begin
%>

<!-- #INCLUDE FILE="Common.asp" -->

<%
' SendMessage CustomIncludes end
'-------------------------------

'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "SendMessage.asp"
sTemplateFileName = "SendMessage.html"
'===============================


'===============================
' SendMessage PageSecurity begin
' SendMessage PageSecurity end
'===============================

'===============================
' SendMessage Open Event begin
' SendMessage Open Event end
'===============================

'===============================
' SendMessage OpenAnyPage Event begin
' SendMessage OpenAnyPage Event end
'===============================

'===============================
'Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================

' SendMessage Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sSendMessageErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "SendMessage"
    SendMessageAction(sAction)
end select
'===============================

'===============================
' Display page
'-------------------------------
' Load HTML template for this page
'-------------------------------
LoadTemplate sAppPath & sTemplateFileName, "main"
'-------------------------------
' Load HTML template of Header and Footer
'-------------------------------
'-------------------------------
SetVar "FileName", sFileName


'-------------------------------
' Step through each form
'-------------------------------
SendMessage_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' SendMessage Show end

'-------------------------------
' Destroy all object variables
'-------------------------------

' SendMessage Close Event begin
' SendMessage Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub SendMessageAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKSerial : pPKSerial = ""
  Dim fldMessage_Type : fldMessage_Type = ""
  Dim fldSubject : fldSubject = ""
  Dim fldContent : fldContent = ""
  Dim fldSender : fldSender = ""
  Dim fldReceiver : fldReceiver = ""
'-------------------------------

'-------------------------------
' SendMessage Action begin
'-------------------------------
  sActionFileName = "MessageList.asp"

'-------------------------------
' CANCEL action
'-------------------------------
  if sAction = "cancel" then

'-------------------------------
' SendMessage BeforeCancel Event begin
' SendMessage BeforeCancel Event end
'-------------------------------
    cn.Close
    Set cn = Nothing
    response.redirect sActionFileName
  end if
'-------------------------------

'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldMessage_Type = GetParam("Message_Type")
  fldSubject = GetParam("Subject")
  fldContent = GetParam("Content")
  fldSender = GetParam("Sender")
  fldReceiver = GetParam("Receiver")

'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' SendMessage Insert Event begin
' SendMessage Insert Event end
'-------------------------------
      sSQL = "insert into T_Message (" & _
          "Message_Type," & _
          "Subject," & _
          "Content," & _
          "Sender," & _
          "Receiver)" & _
          " values (" & _
          ToSQL(fldMessage_Type, "Number") & "," & _
          ToSQL(fldSubject, "Text") & "," & _
          ToSQL(fldContent, "Text") & "," & _
          ToSQL(fldSender, "Text") & "," & _
          ToSQL(fldReceiver, "Text") & _
          ")"
  end select
'-------------------------------
'-------------------------------
' SendMessage BeforeExecute Event begin
sSQL = "proc_NewMessage 0," & ToSQL(fldSubject,"Text") & "," & ToSQL(fldContent,"Text") & "," & ToSQL(fldSender,"Text") & "," & ToSQL(fldReceiver,"Text")
' SendMessage BeforeExecute Event end
'-------------------------------

'-------------------------------
' Execute SQL statement
'-------------------------------
if len(sSendMessageErr) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  sSendMessageErr = ProcessError
  on error goto 0
  if len(sSendMessageErr) > 0 then Exit Sub
  cn.Close
  Set cn = Nothing
  response.redirect sActionFileName
'-------------------------------
' SendMessage Action end
'-------------------------------
end sub
'===============================

'===============================
' Display Record Form
'-------------------------------
Sub SendMessage_Show()
'-------------------------------
' SendMessage Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = ""
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sSendMessageErr = "" then
    pSerial = GetParam("Serial")
    SetVar "SendMessageError", ""
  else
    fldSerial = GetParam("Serial")
    fldMessage_Type = GetParam("Message_Type")
    fldSubject = GetParam("Subject")
    fldContent = GetParam("Content")
    fldSender = GetParam("Sender")
    fldReceiver = GetParam("Receiver")
    pSerial = GetParam("PK_Serial")
    SetVar "sSendMessageErr", sSendMessageErr
    SetVar "FormTitle", sFormTitle
    Parse "SendMessageError", False
  end if
'-------------------------------

'-------------------------------
' Load all form fields

  fldEmployee = GetParam("Employee")
  fldSelect = GetParam("Select")
  fldUnselect = GetParam("Unselect")
  fldAssociate = GetParam("Associate")
'-------------------------------

'-------------------------------
' Build WHERE statement

  if IsEmpty(pSerial) then bPK = False
  
  sWhere = sWhere & "Serial=" & ToSQL(pSerial, "Number")
  SetVar "PK_Serial", pSerial
'-------------------------------
'-------------------------------
' SendMessage Open Event begin
' SendMessage Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from T_Message where " & sWhere
  openrs rs, sSQL
  bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "SendMessage") and not rs.eof)
'-------------------------------

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldMessage_Type = GetValue(rs, "Message_Type")
    fldReceiver = GetValue(rs, "Receiver")
    fldSender = GetValue(rs, "Sender")
    fldSerial = GetValue(rs, "Serial")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sSendMessageErr = "" then
      fldSubject = GetValue(rs, "Subject")
      fldContent = GetValue(rs, "Content")
    end if
    SetVar "SendMessageDelete", ""
    SetVar "SendMessageUpdate", ""
    SetVar "SendMessageInsert", ""
'-------------------------------
' SendMessage ShowEdit Event begin
' SendMessage ShowEdit Event end
'-------------------------------
  else
    if sSendMessageErr = "" then
      fldMessage_Type= "1"
      fldSender= "Session(""UserID"")"
      fldReceiver=fldAssociate
    end if
    SetVar "SendMessageEdit", ""
    Parse "SendMessageInsert", False
'-------------------------------
' SendMessage ShowInsert Event begin
' SendMessage ShowInsert Event end
'-------------------------------
  end if
  Parse "SendMessageCancel", false
  if sSendMessageErr = "" then
'-------------------------------
' SendMessage Show Event begin
'=======================================================================================================
' 备选人员:从数据库T_Employee表中选取人员
'=======================================================================================================
openrs RS, "select Emp_id, Name from T_Employee where Emp_id <> " & ToSQL(Session("UserID"),"Text") & " order by Emp_id"
optSuffix = "</OPTION>" & vbNewLine 
valPrefix = "<OPTION Value='" 
valSuffix = "'>" 
opts = RS.GetString( , , valSuffix, optSuffix & valPrefix, "--error--" ) 
opts = Left( opts, Len(opts)-Len(valPrefix) )  'This line is the key to it! 
fldEmployee = "<select name=employee multiple size=6 style='width:70px'>" & vbNewLine & valPrefix & opts & "</select>"

'=======================================================================================================
' 选择按钮>>
'=======================================================================================================
fldSelect = "<table border=0 cellspacing=0 cellpadding=0><tr><td class=""slct"" onclick=""JavaScript:_addloc(document.all.SendMessage.employee,document.all.SendMessage.receiver)"">&nbsp;>>&nbsp;</td></tr></table>"

'=======================================================================================================
' 删除按钮<<
'=======================================================================================================
fldUnselect = "<table border=0 cellspacing=0 cellpadding=0><tr><td class=""slct"" onclick=""JavaScript:_addloc(document.all.SendMessage.receiver,document.all.SendMessage.employee)"">&nbsp;<<&nbsp;</td></tr></table>"

'=======================================================================================================
'消息接收者
'=======================================================================================================
fldAssociate = "<select name=receiver multiple size=6 style='width:70px'></select>"
' SendMessage Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "Serial", ToHTML(fldSerial)
      SetVar "Message_Type", ToHTML(fldMessage_Type)
      SetVar "Subject", ToHTML(fldSubject)
      SetVar "Content", ToHTML(fldContent)
      SetVar "Sender", ToHTML(fldSender)
      SetVar "Employee", fldEmployee
      SetVar "Select", fldSelect
      SetVar "Unselect", fldUnselect
      SetVar "Associate", fldAssociate
      SetVar "Receiver", ToHTML(fldReceiver)
  Parse "FormSendMessage", False

'-------------------------------
' SendMessage Close Event begin
' SendMessage Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' SendMessage Show end
'-------------------------------
End Sub
'===============================
%>

⌨️ 快捷键说明

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