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

📄 activitiesadd.asp

📁 this is the main file
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%@ CodePage=65001 LCID=1040 %>
<%
Const EW_PAGE_ID = "add"
Const EW_TABLE_NAME = "Activities"
%>
<!--#include file="ewcfg61.asp"-->
<!--#include file="Activitiesinfo.asp"-->
<!--#include file="Ordersinfo.asp"-->
<!--#include file="Authorsinfo.asp"-->
<!--#include file="aspfn61.asp"-->
<!--#include file="userfn61.asp"-->
<% Session.Timeout = 120 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Open connection to the database
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open EW_DB_CONNECTION_STRING
%>
<%
Dim Security
Set Security = New cAdvancedSecurity
%>
<%
If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
If Not Security.IsLoggedIn() Then
	Call Security.SaveLastUrl()
	Call Page_Terminate("login.asp")
End If
Call Security.LoadCurrentUserLevel("Activities")
If Not Security.CanAdd Then
	Call Security.SaveLastUrl()
	Call Page_Terminate("Activitieslist.asp")
End If
%>
<%

' Common page loading event (in userfn60.asp)
Call Page_Loading()
%>
<%

' Page load event, used in current page
Call Page_Load()
%>
<%
Response.Buffer = True

' Load key values from QueryString
Dim bCopy
bCopy = True
If Request.QueryString("Id").Count > 0 Then
	Activities.Id.QueryStringValue = Request.QueryString("Id")
Else
	bCopy = False
End If

' Create form object
Dim objForm
Set objForm = New cFormObj

' Process form if post back
If objForm.GetValue("a_add")&"" <> "" Then
	Activities.CurrentAction = objForm.GetValue("a_add") ' Get form action
	Call LoadFormValues() ' Load form values

' Not post back
Else
	If bCopy Then
		Activities.CurrentAction = "C" ' Copy Record
	Else
		Activities.CurrentAction = "I" ' Display Blank Record
		Call LoadDefaultValues() ' Load default values
	End If
End If

' Close form object
Set objForm = Nothing

' Perform action based on action code
Select Case Activities.CurrentAction
	Case "I" ' Blank record, no action required
	Case "C" ' Copy an existing record
		If Not LoadRow() Then ' Load record based on key
			Session(EW_SESSION_MESSAGE) = "No records found" ' No record found
			Call Page_Terminate(Activities.ReturnUrl) ' Clean up and return
		End If
	Case "A" ' Add new record
		Activities.SendEmail = True ' Send email on add success
		If AddRow() Then ' Add successful
			Session(EW_SESSION_MESSAGE) = "Add New Record Successful" ' Set up success message
			Call Page_Terminate(Activities.KeyUrl(Activities.ReturnUrl, "")) ' Clean up and return
		Else
			Call RestoreFormValues() ' Add failed, restore form values
		End If
End Select

' Render row based on row type
Activities.RowType = EW_ROWTYPE_ADD ' add ' Render add type
Call RenderRow()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
var EW_PAGE_ID = "add"; // Page id
//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_Order_Id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Order"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_zDate"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Date"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_zDate"];
		if (elm && !ew_CheckEuroDate(elm.value)) {
			if (!ew_OnError(elm, "Incorrect date, format = dd/mm/yyyy - Date"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_Activity_Type_Id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Activity Type"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_Hours"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - Hours"))
				return false;
		}
	}
	return true;
}
//-->
</script>
<script type="text/javascript">
<!--
// js for DHtml Editor
//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<p><span class="aspmaker">Add to TABLE: Activities<br><br><a href="<%= Activities.ReturnUrl %>">Go Back</a></span></p>
<%
If Session(EW_SESSION_MESSAGE) <> "" Then ' Mesasge in Session, display
%>
<p><span class="ewmsg"><%= Session(EW_SESSION_MESSAGE) %></span></p>
<%
	Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
End If
%>
<form name="fActivitiesadd" id="fActivitiesadd" action="Activitiesadd.asp" method="post" onSubmit="return ew_ValidateForm(this);">
<p>
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewTable">
	<tr class="ewTableRow">
		<td class="ewTableHeader">Order<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= Activities.Order_Id.CellAttributes %>><span id="cb_x_Order_Id">
<% If Activities.Order_Id.SessionValue <> "" Then %>
<div<%= Activities.Order_Id.ViewAttributes %>><%= Activities.Order_Id.ViewValue %></div>
<input type="hidden" id="x_Order_Id" name="x_Order_Id" value="<%= ew_HtmlEncode(Activities.Order_Id.CurrentValue) %>">
<% Else %>
<select id='x_Order_Id' name='x_Order_Id' title=''<%= Activities.Order_Id.EditAttributes %>>
<%
If IsArray(Activities.Order_Id.EditValue) Then
	arwrk = Activities.Order_Id.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = Activities.Order_Id.CurrentValue&"" Then
			selwrk = " selected"
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<% End If %>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Date<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= Activities.zDate.CellAttributes %>><span id="cb_x_zDate">
<input type="text" name="x_zDate" id="x_zDate" title="" value="<%= Activities.zDate.EditValue %>"<%= Activities.zDate.EditAttributes %>>
&nbsp;<img src="images/ew_calendar.gif" id="cx_zDate" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup(
{
inputField : "x_zDate", // ID of the input field
ifFormat : "%d/%m/%Y", // the date format
button : "cx_zDate" // ID of the button
}
);
</script>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Activity Type<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= Activities.Activity_Type_Id.CellAttributes %>><span id="cb_x_Activity_Type_Id">
<select id='x_Activity_Type_Id' name='x_Activity_Type_Id' title=''<%= Activities.Activity_Type_Id.EditAttributes %>>
<%
If IsArray(Activities.Activity_Type_Id.EditValue) Then
	arwrk = Activities.Activity_Type_Id.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = Activities.Activity_Type_Id.CurrentValue&"" Then
			selwrk = " selected"
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Hours</td>
		<td<%= Activities.Hours.CellAttributes %>><span id="cb_x_Hours">
<input type="text" name="x_Hours" id="x_Hours" title="" size="30" value="<%= Activities.Hours.EditValue %>"<%= Activities.Hours.EditAttributes %>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Notes</td>
		<td<%= Activities.Notes.CellAttributes %>><span id="cb_x_Notes">
<textarea name="x_Notes" id="x_Notes" title="" cols="35" rows="4"<%= Activities.Notes.EditAttributes %>><%= Activities.Notes.EditValue %></textarea>
</span></td>
	</tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="    Add    ">
</form>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<!--#include file="footer.asp"-->
<%

' If control is passed here, simply terminate the page without redirect
Call Page_Terminate("")

' -----------------------------------------------------------------
'  Subroutine Page_Terminate
'  - called when exit page
'  - clean up ADO connection and objects
'  - if url specified, redirect to url, otherwise end response
'
Sub Page_Terminate(url)

	' Page unload event, used in current page
	Call Page_Unload()

	' Global page unloaded event (in userfn60.asp)
	Call Page_Unloaded()
	conn.Close ' Close Connection
	Set conn = Nothing
	Set Security = Nothing
	Set Activities = Nothing

	' Go to url if specified
	If url <> "" Then
		Response.Clear
		Response.Redirect url
	End If

	' Terminate response
	Response.End
End Sub

'
'  Subroutine Page_Terminate (End)
' ----------------------------------------

%>
<%

' Load default values
Function LoadDefaultValues()
	Activities.Order_Id.CurrentValue = 0
	Activities.zDate.CurrentValue = date()
	Activities.Activity_Type_Id.CurrentValue = 0
	Activities.Hours.CurrentValue = 0
	Activities.Author_Id.CurrentValue = 0
End Function
%>
<%

' Load form values
Function LoadFormValues()

	' Load from form
	Activities.Order_Id.FormValue = objForm.GetValue("x_Order_Id")
	Activities.zDate.FormValue = objForm.GetValue("x_zDate")
	Activities.zDate.CurrentValue = ew_UnFormatDateTime(Activities.zDate.CurrentValue, 7)
	Activities.Activity_Type_Id.FormValue = objForm.GetValue("x_Activity_Type_Id")
	Activities.Hours.FormValue = objForm.GetValue("x_Hours")
	Activities.Notes.FormValue = objForm.GetValue("x_Notes")
	Activities.Author_Id.FormValue = objForm.GetValue("x_Author_Id")
	Activities.Creation_Date.FormValue = objForm.GetValue("x_Creation_Date")
	Activities.Creation_Date.CurrentValue = ew_UnFormatDateTime(Activities.Creation_Date.CurrentValue, 7)
End Function

' Restore form values
Function RestoreFormValues()
	Activities.Order_Id.CurrentValue = Activities.Order_Id.FormValue
	Activities.zDate.CurrentValue = Activities.zDate.FormValue
	Activities.zDate.CurrentValue = ew_UnFormatDateTime(Activities.zDate.CurrentValue, 7)
	Activities.Activity_Type_Id.CurrentValue = Activities.Activity_Type_Id.FormValue
	Activities.Hours.CurrentValue = Activities.Hours.FormValue
	Activities.Notes.CurrentValue = Activities.Notes.FormValue
	Activities.Author_Id.CurrentValue = Activities.Author_Id.FormValue
	Activities.Creation_Date.CurrentValue = Activities.Creation_Date.FormValue
	Activities.Creation_Date.CurrentValue = ew_UnFormatDateTime(Activities.Creation_Date.CurrentValue, 7)
End Function
%>
<%

' Load row based on key values

⌨️ 快捷键说明

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