按日期而不是时间选择记录

时间:2017-08-08 14:48:36

标签: javascript html asp.net asp-classic

我有一个旧的遗留页面,我需要按日期和国家/客户(一个字段)选择记录。

我的日期格式包含日期和时间。似乎发生了什么,当它在查询时查找查找时间。

我真的不知道从哪里开始。

我确实需要选择日期和客户/国家/地区并显示记录。

我已附上以下页面的代码。



<%@ Language=VBScript %>
<%
Option Explicit
%>
<!--#include file="_sinclude/authentication.asp"-->
<!--#include file="_sinclude/fnc_general.asp"-->
<%
Dim strSQL, rsUser, strUpdated, strShowall
Dim strTxtCountry, strTxtDate, strCountryID, strCountryName, strHdnCountryID, strTxtDesc
Dim strStatusMessage, strDelID
Dim nRowCount 

nRowCount = 0

IF trim(Request.Querystring("showall")) <> "" THEN
	strShowall = Request.Querystring("showall")
ELSE
	strShowall = "false"
END IF

IF trim(Request.Querystring("CountryID")) <> "" THEN
	strCountryID = int(Request.Querystring("CountryID"))
ELSE
	strCountryID = ""
END IF

IF trim(Request.Querystring("update")) <> "" THEN
	strUpdated = Request.Querystring("update")
ELSE
	strUpdated = ""
END IF

IF trim(Request.Querystring("DelID")) <> "" THEN

	strDelID = chkString(Request.Querystring("DelID"))

Dim Conn, dbPath 

'dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb"
dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb" 
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

	strSQL ="delete * from TBL_EMBASSY where EmbID=" & strDelID 

	conn.Execute(strSQL)

	conn.Close
	Set rsUser = nothing

	Response.Redirect("add_date.asp?CountryID=" & strCountryID)
END IF


IF trim(Request.Form("txtCountry")) <> "" THEN

	strTxtDate = chkString(Request.Form("txtDate"))
	strTxtCountry = (Request.Form("txtCountry")) 
	strTxtDesc = Replace((Request.Form("txtDesc")), "'" , "&rsquo;")
		
				'dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb"
				dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb" 
				Set Conn = Server.CreateObject("ADODB.Connection")
				Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

	strSQL =	"INSERT INTO TBL_EMBASSY (EmbDate, EmbDesc, EmbCountryID)" & vbCRLF & _
				"VALUES (" & vbCRLF & _
				"'" & strTxtDate & "'," & vbCRLF & _
				"'" & strTxtDesc & "'," & vbCRLF & _
				"'" & strTxtCountry & "'" & vbCRLF & _
				")"

	conn.Execute(strSQL)

	conn.close
	
	Response.Redirect("add_date.asp?CountryID=" & strTxtCountry & "&update=True")
	
END IF
%>
<html>
<head>
<title>Flying Logistics Scanning</title>
<!-- calendar stylesheet -->
<link rel="stylesheet" type="text/css" media="all" href="_cinclude/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<script type="text/javascript" src="_cinclude/calendar.js"></script>
<!-- main calendar program -->
<script type="text/javascript" src="_cinclude/calendar-en.js"></script>
<!-- language for the calendar -->
<!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
<script type="text/javascript" src="_cinclude/calendar-setup.js"></script>
<script language="JavaScript">
<!--
function GoToURL() { //v3.0
  var i, args=GoToURL.arguments; document.ReturnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function showCountry(selection) {
var tempIndex, selectedURL;
tempIndex = selection.selectedIndex;
selectedURL = selection.options[tempIndex].value;
window.location.href = "add_date.asp?CountryID="+selectedURL;
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}

//-->
</script>
<style type="text/css">
<!--
td {  font-family: Arial, Helvetica, sans-serif; font-size: 12px;}
body {	background-color: #FFFFFF;}
.style10 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 14px;
}
.style11 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="document.getElementById('txtDesc').focus();">
<form action="add_date.asp" method="post">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0" background="../images/topCalendar_bg.gif">
          <tr>
            <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="center">
              <table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="225" height="20" align="center" valign="top" bgcolor="#9BCEEC"><select name="txtCountry" id="txtCountry" onChange="showCountry(this);">
                    <option value="" selected<% IF strCountryID = "" THEN %>selected<% END IF %>>Please select a Client</option>
                    <%
				'dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb"
				dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb" 
				Set Conn = Server.CreateObject("ADODB.Connection")
				Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

strSQL =	"SELECT CountryID, CountryName" & vbCRLF & _
			"FROM TBL_LKP_COUNTRY" & vbCRLF & _
			"Order by CountryName"

Set rsUser = conn.Execute(strSQL)

WHILE NOT rsUser.EOF

IF rsUser.Fields("CountryID") = strCountryID THEN strCountryName = rsUser.Fields("CountryName")
%>
                    <option value="<%= rsUser.Fields("CountryID") %>" <% IF rsUser.Fields("CountryID") = strCountryID THEN %>selected <% END IF %> name="country"><%= rsUser.Fields("CountryName")%></option>
                    <%
							rsUser.MoveNext
							WEND

conn.close
Set rsUser = nothing

%>
                  </select></td>
                  </tr>
                </table>
               </td>
                </tr>
              </table>

</td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td align="center" valign="top"></td>
    </tr>
    <tr>
      <td align="center" valign="top"><table cellpadding="4" cellspacing="0" border="0" width="100%" bgcolor="#9BCEEC" style="border:1px solid #000000">
          <tr>
            <td colspan="3"><img src="../images/clear1x1.gif" width="8" height="8"></td>
          </tr>
          <tr>
            <td width="95" align="right"><strong>Add a Date</strong>

            </td>
            <td width="335"><input name="txtDate" type="text" id="misc1" style="width:74px" value="<% =now %>" maxlength="20" />
             
            <script type="text/javascript">
    Calendar.setup({
        inputField     :    "misc1",     // id of the input field
        ifFormat       :    "dd/mm/y",      // format of the input field
        button         :    "misc1_trigger",  // trigger for the calendar (button ID)
        align          :    "Bl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
              </script></td>
            <td width="46" align="right">&nbsp;</td>
          </tr>
          <tr>
            <td><img src="../images/clear1x1.gif" width="8" height="8"><strong>Barcode</strong></td>
            <td><input name="txtDesc" type="text" id="txtDesc" style="width:240px" autofocus></td>
            <td><input type="submit" value=" Add " name="submit"></td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
      </table></td>
    </tr>
	<tr>
	<td align="right"><br>
	<% IF strShowall<> "true" Then %>
		<a href="add_date.asp?showall=true"><strong>Show All</strong></a> 
	<% ELSE %>
		<a href="add_date.asp"><strong>Hide All</strong></a>
	<% END IF %>
	</td></tr>
  </table>

<table width="100%" border="0" align="center" cellpadding="4" cellspacing="1" style="border:1px solid #000000">
  <tr bgcolor="#9BCEEC">
    <td width="200" height="28"><strong>Client  Name </strong></td>
    <td width="78"><strong>Date</strong></td>
    <td width="205"><strong>Barcode Reference</strong></td>
    <td width="34">&nbsp;</td>
  </tr>
  <% IF strCountryID <> "" OR strShowall = "true" THEN %>
  <%
				'dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb"
				dbPath = "C:\Inetpub\visaswift\barcode\Embassy.mdb" 
				Set Conn = Server.CreateObject("ADODB.Connection")
				Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
 %>  
 	<% IF strShowall <> "true" THEN
				strSQL ="SELECT TBL_LKP_COUNTRY.CountryName, TBL_LKP_COUNTRY.CountryURL, TBL_EMBASSY.EmbDate, TBL_EMBASSY.EmbDesc, TBL_EMBASSY.EmbCountryID, TBL_EMBASSY.EmbID" & vbCRLF & _ 
						"FROM TBL_EMBASSY INNER JOIN TBL_LKP_COUNTRY ON TBL_EMBASSY.EmbCountryID = TBL_LKP_COUNTRY.CountryID" & vbCRLF & _ 
						"WHERE (((TBL_EMBASSY.EmbCountryID)=" & strCountryID & "))" & vbCRLF & _
						"ORDER BY TBL_EMBASSY.EmbDate ASC"
	ELSE	
					strSQL ="SELECT TBL_LKP_COUNTRY.CountryName, TBL_LKP_COUNTRY.CountryURL, TBL_EMBASSY.EmbDate, TBL_EMBASSY.EmbDesc, TBL_EMBASSY.EmbCountryID, TBL_EMBASSY.EmbID" & vbCRLF & _ 
						"FROM TBL_EMBASSY INNER JOIN TBL_LKP_COUNTRY ON TBL_EMBASSY.EmbCountryID = TBL_LKP_COUNTRY.CountryID" & vbCRLF & _ 
						"ORDER BY TBL_LKP_COUNTRY.CountryName ASC"
	END IF %>
	<%
						Set rsUser = conn.Execute(strSQL)
						WHILE NOT rsUser.EOF
	%>


  <% If (nRowCount Mod 2) = 0 Then %>
  <tr bgcolor="#F0F2F4">
  <% END IF %>
    <td align="left"><b><%= rsUser.Fields("CountryName") %></b></td>
    <td align="left"><b><%= rsUser.Fields("EmbDate") %></b></td>
    <td align="left"><b><%= rsUser.Fields("EmbDesc") %></b>&nbsp;
    </td>
    <td align="left"><a href="add_date.asp?DelID=<%= rsUser.Fields("EmbID") %>&CountryID=<%= strCountryID %>"><b>Delete</b></a></td>
  </tr>
  <%
				rsUser.MoveNext
				nRowCount = nRowCount + 1
				WEND
				conn.Close
				Set rsUser = nothing
	%>
<%IF nRowCount = 0 THEN%><tr bgcolor="#E3EDF0">
  <td><b><%= strCountryName %></b></td>
  <td></td>
  <td>&nbsp;</td><td>&nbsp;</td></tr><% END IF %>
  <% ELSE %>
  <tr bgcolor="#E3EDF0">
    <td align="left"><b>Nothing Selected</b></td>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
  </tr>
  <% END IF %>
</table></form>
</body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案