View Single Post
  #5 (permalink)  
Old July 13th, 2004, 08:39 AM
Stephan Stephan is offline
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the code

<%@ language = JavaScript%>
<html>
<head>
</head>
<body>
<%
    var month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    var nowDate = new Date();
    var nowDate = nowDate.getDate() + " " + month[nowDate.getMonth()] + " " + nowDate.getFullYear();
    var orderNo;

    var adoConnection = Server.CreateObject("ADODB.Connection");
    adoConnection.Open("DSN=ComBitsCoDB");
    var adoRecordset;

    var mySQL = "INSERT INTO CustomerOrder " + "(CustomerName, CustomerAddress, TelNumber, OrderDate)";
    mySQL = mySQL + " VALUES ('" + Request.Form("txtCustomerName") + "','";
    mySQL = mySQL + Request.Form("txtCustomerAddress") + "','";
    mySQL = mySQL + Request.Form("txtTelNumber") + "','";
    mySQL = mySQL + nowDate + "')";

    adoConnection.Execute(mySQL);

    mySQL = "SELECT Max(OrderNo) AS MaxOrderNo FROM CustomerOrder WHERE ";
    mySQL = mySQL + " OrderDate = #" + nowDate + "# AND ";
    mySQL = mySQL + " CustomerName = '" + Request.Form("txtCustomerName") + "'";

    adoRecordset = adoConnection.Execute(mySQL);

    orderNo = adoRecordset("MaxOrderNo").Value;

    adoRecordset.Close();
    adoRecordset = null;

    var mySQL = "INSERT INTO OrderItem (OrderNo, StockId, QtyOrdered)";
    mySQL = mySQL + " VALUES (" + orderNo + ",";
    mySQL = mySQL + Request.Form("txtStockId") + ",";
    mySQL = mySQL + "1)";

    adoConnection.Execute(mySQL);

    adoConnection.Close();
    adoConnection = null;

    Response.Write("<h2><center>Your order was completed successfully" + "</center></h2>");
    %>
</body>
</html>

Reply With Quote