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

📄 employeemaint.asp

📁 BugTrack is a basic, yet fully functional web based Bug Tracking system that you may use as a framew
💻 ASP
字号:
<!-- #INCLUDE FILE="Common.asp" -->

<%
'
'   Filename: EmployeeMaint.asp
'   Generated with CodeCharge 1.2.0
'   ASPTemplates.ccp build 5/9/2001
'


sFileName = "EmployeeMaint.asp"
sTemplateFileName = "EmployeeMaint.html"


' EmployeeMaint Open Event start
' EmployeeMaint Open Event end


' EmployeeMaint PageSecurity begin

' EmployeeMaint PageSecurity end

' EmployeeMaint OpenAnyPage Event start
' EmployeeMaint OpenAnyPage Event end


LoadTemplate sAppPath & sTemplateFileName, "main"

LoadTemplate sHeaderFileName, "Header"


SetVar "FileName", sFileName


sEmployeeErr = ""

sAction = GetParam("FormAction")
sForm = GetParam("FormName")
Select Case sForm
  Case "Employee"
    EmployeeAction(sAction)
end select

Menu_Show
Employee_Show
Parse "Header", False
Parse "main", False
Response.write PrintVar("main")

' EmployeeMaint Close Event start
' EmployeeMaint Close Event end


'--------------------------------------------------


Sub EmployeeAction(sAction)
  dim bExecSQL: bExecSQL = true
  
  ' Employee Action begin
  sActionFileName = "EmployeeList.asp"
  
  

  sWhere = ""
  bErr = False  


  ' Create WHERE statement
  if sAction = "update" or sAction = "delete" then
    pPKemployee_id = GetParam("PK_employee_id")
    if IsEmpty(pPKemployee_id) then exit sub
    sWhere = "employee_id=" & ToSQL(pPKemployee_id, "Number")
  end if


  ' Load all form fields into variables

  fldlogin = GetParam("login")
  fldpass = GetParam("pass")
  fldsecurity_level = GetParam("security_level")
  fldemployee_name = GetParam("employee_name")
  fldemail = GetParam("email")
  ' Validate fields
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldlogin) then
      sEmployeeErr = sEmployeeErr & "The value in field Login is required.<br>"
    end if
    if IsEmpty(fldpass) then
      sEmployeeErr = sEmployeeErr & "The value in field Password is required.<br>"
    end if
    if IsEmpty(fldsecurity_level) then
      sEmployeeErr = sEmployeeErr & "The value in field Security Level is required.<br>"
    end if
    if IsEmpty(fldemployee_name) then
      sEmployeeErr = sEmployeeErr & "The value in field Name is required.<br>"
    end if
    if not isNumeric(fldsecurity_level) then
      sEmployeeErr = sEmployeeErr & "The value in field Security Level is incorrect.<br>"
    end if
' Employee Check Event start
' Employee Check Event end

    If len(sEmployeeErr) > 0 then
      exit sub
    end if
  end if


  sSQL = ""
  ' Create SQL statement

  select case sAction
    case "insert"
      
' Employee Insert Event start
' Employee Insert Event end

      sSQL = "insert into employees (" & _
          "[login]," & _
          "[pass]," & _
          "[security_level]," & _
          "[employee_name]," & _
          "[email])" & _
          " values (" & _
          ToSQL(fldlogin, "Text") & "," & _
          ToSQL(fldpass, "Text") & "," & _
          ToSQL(fldsecurity_level, "Number") & "," & _
          ToSQL(fldemployee_name, "Text") & "," & _
          ToSQL(fldemail, "Text") & _
          ")"
    case "update"
      
' Employee Update Event start
' Employee Update Event end

      sSQL = "update employees set " & _
        "[login]=" & ToSQL(fldlogin, "Text") & _
        ",[pass]=" & ToSQL(fldpass, "Text") & _
        ",[security_level]=" & ToSQL(fldsecurity_level, "Number") & _
        ",[employee_name]=" & ToSQL(fldemployee_name, "Text") & _
        ",[email]=" & ToSQL(fldemail, "Text")
      sSQL = sSQL & " where " & sWhere
    case "delete"
' Employee Delete Event start
' Employee Delete Event end

      sSQL = "delete from employees where " & sWhere
  end select

  ' Execute SQL statement
  
' Employee BeforeExecute Event start
' Employee BeforeExecute Event end

  if len(sEmployeeErr) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  sEmployeeErr = ProceedError
  if len(sEmployeeErr) > 0 then Exit Sub
  on error goto 0
  response.redirect sActionFileName
  ' Employee Action end
end sub

Sub Employee_Show()

  ' Employee Show begin
  Dim sWhere, bPK
  sWhere = ""
  
  bPK = True

  if sEmployeeErr = "" then
    ' Load primary key and form parameters
    pemployee_id = GetParam("employee_id")
    SetVar "EmployeeError", ""
  else
    ' Load primary key, form parameters and form fields
    fldemployee_id = GetParam("employee_id")
    fldlogin = GetParam("login")
    fldpass = GetParam("pass")
    fldsecurity_level = GetParam("security_level")
    fldemployee_name = GetParam("employee_name")
    fldemail = GetParam("email")
    pemployee_id = GetParam("PK_employee_id")
    SetVar "sEmployeeErr", sEmployeeErr
    Parse "EmployeeError", False
  end if

  
  if IsEmpty(pemployee_id) then bPK = False
  
  sWhere = sWhere & "employee_id=" & ToSQL(pemployee_id, "Number")
  SetVar "PK_employee_id", pemployee_id
' Employee Open Event start
' Employee Open Event end


  sSQL = "select * from employees where " & sWhere

  openrs rs, sSQL
	

  if bPK and not(sAction = "insert" and sForm = "Employee") and not rs.eof then 
    
    fldemployee_id = GetValue(rs, "employee_id")
    if sEmployeeErr = "" then
      ' Load data from recordset when form displayed first time
      fldlogin = GetValue(rs, "login")
      fldpass = GetValue(rs, "pass")
      fldsecurity_level = GetValue(rs, "security_level")
      fldemployee_name = GetValue(rs, "employee_name")
      fldemail = GetValue(rs, "email")
    end if
    SetVar "EmployeeInsert", ""
    Parse "EmployeeEdit", False
' Employee ShowEdit Event start
' Employee ShowEdit Event end

  else
    SetVar "EmployeeEdit", ""
    Parse "EmployeeInsert", False
' Employee ShowInsert Event start
' Employee ShowInsert Event end

  end if
  SetVar "EmployeeCancel", ""
' Employee Show Event start
' Employee Show Event end

  ' Show form field
  
      SetVar "employee_id", ToHTML(fldemployee_id)
      SetVar "login", ToHTML(fldlogin)
      SetVar "pass", ToHTML(fldpass)
      SetVar "LBsecurity_level", ""
      LOV = Split("1;Developer;3;Administrator", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldsecurity_level) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "LBsecurity_level", True
        next
      end if
    
      SetVar "employee_name", ToHTML(fldemployee_name)
      SetVar "email", ToHTML(fldemail)
  Parse "FormEmployee", False
  
' Employee Close Event start
' Employee Close Event end

  ' Employee Show end
  
End Sub

%>

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

⌨️ 快捷键说明

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