|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。 By Kevin Perkins
Article
Article:
One thing I've learned over the last few years is to use techniques in my applications that make it easy to debug and maintain, especially if you leave the project and have to come back to it at a later time.
Besides error handling and commenting, I try to automate as much as possible to make maintenance a cake-walk. One area that can be tremendously automated is implementing date structures in your application.
For instance... if you're building an ecommerce application, you'll eventually have to deal with credit card expiry. The predominant technique for handling expiration dates is to use two drop-down boxes representing the month and the year. Having said that, it's very easy to hard-code those dates in each drop-down box.... 1-12 for month, but what to what for the year? Do you use the current year (2000) and the following two (2001,2002) ?
What happens when we're in year 2001? You'll have an older entry for the previous year (2000), and you'll be one short for the future (2002,?). This is bad practice because your application should be smart enough to remove previous years that are invalid to present-day transactions, as well as account for new credit cards that might have an expiration date farther in the future.
To work with drop-down dates dynamically, I determine the current month, current year, and how far into the future I want to account for expiration. My rule is 5 years, but each application is different:
<%@LANGUAGE=VBSCRIPT%>
<%
' ----------------------------------------------------------------------------------
' You could use similar looping techniques with JavaScript
' ----------------------------------------------------------------------------------
%>
<html>
<head></head>
<body>
<form>
<%
' ----------------------------------------------------------------------------------
' Build the MONTH drop-down box
' ----------------------------------------------------------------------------------
iMonth = Month(Now())
' This produces the current month's integer (ex. 7)
%>
<select name="drpMonth">
<% For i = 1 to 12 %>
<option <%
' This will select the current month in the list
If CInt(iMonth = i) Then
Response.Write "selected "
End if
%>value="<%= i %>"><%= i %></option>
<% Next %>
</select>
<!-- Drop-down separator -->
/
<!-- End separator -->
<%
' ----------------------------------------------------------------------------------
' Build the YEAR drop-down box
' ----------------------------------------------------------------------------------
iYear = Year(Now())
' This produces the current year's integer (ex. 2000)
%>
<select name="drpYear">
<% For i = iYear to ( CInt(iYear + 5) ) %>
<option <%
' This will select the current year in the list
If CInt(iYear = i) Then
Response.Write "selected "
End if
%>value="<%= i %>"><%= i %></option>
<% Next %>
</select>
</form>
</body>
</html>
Of course, if you have more complex date interactions, you can manipulate the If/Then statement inside of the loop to select the appropriate value. And, if you're working with dates in the past, you can reindex the starting value of (i) by subtracting how many years you want to go back...
Example:
"For i = iYear to ..." tells the application to do something "From 2000 to ..."
"For i = CInt(iYear - 2) to ..." tells the application to do something "From 1998 to ... "
-END-
</p> Access是一种桌面数据库,只适合数据量少的应用,在处理少量数据和单机访问的数据库时是很好的,效率也很高。但是它的同时访问客户端不能多于4个。access数据库有一定的极限,如果数据达到100M左右,很容易造成服务器iis假死,或者消耗掉服务器的内存导致服务器崩溃。 |
|