Tải bản đầy đủ (.pdf) (81 trang)

CT_NGUON.pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (105.63 KB, 81 trang )

Global.asa
************************************************************************
*
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Application_OnStart
' Dac ta nay duoc mo ra khi co khach hang dau tien vao WEB site
' Dong thoi mo file va dem so luong khach hang truy cap WEB site
CustomersCount = Server.MapPath ("/ASPComputer") + "\Customers.txt"
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set Out= FileObject.OpenTextFile (CustomersCountFN, 1, FALSE, FALSE)
' Chan bi viec theo doi khach hang vao web site.
Application("Customers") = Out.ReadLine
' Luu ten file vat ly cua file chua tong so khach hang truy cap.
Application("CustomersCountFN") = CustomersCountFN
END SUB
</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Application_OnEnd
' Thuc thi khi Server bi shuts down hoac co su thay doi cua file global.
' Cap nhat lai so khach hang hien dang trong web site vao file
Customers.txt.</pre>
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set Out= FileObject.CreateTextFile (Application("CustomersCountFN"), TRUE,
FALSE)
Out.WriteLine(application("Customers"))
END SUB
</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Session_OnStart
const MaxShoppingCartItems = 10
const ShoppingCartAttributes = 7


' OnStart Event lam 4 viec sau:
' 1) Tang so luong khach hang vao web site.
' 2) Kiem tra so khach hang hien co trong web site va khach moi vao.
' 3) Tao lien ket den CSDL de truy xuat va noi luu tru so ID cua khach trong
Session object
' 4) Khi co su thay doi dot ngot qua trinh di chuyen trong web site cua khach hang
thi tra ve trang chinh.
' ----------------------------------
' Tang so ID cua Customers khi co truy cap web site.
Application.lock
Application("Customers")= application("Customers") + 1
I_Customers = application("Customers")
Application.unlock
Session("CustomersID") = I_Customers
' Luu so ID cua khach hang vao file Customers.txt theo thoi gian nhat dinh.
If I_Customers MOD 10 = 0 Then
SET FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set Out= FileObject.CreateTextFile (Application("CustomersCountFN"), TRUE,
FALSE)
Application.lock
Out.WriteLine(I_Customers)
Application.unlock
End If
' Kiem tra so khach hang moi truy cap va so khach hang da co trong web site.
' Doi voi khach hang da co trong web site truy cap lai thi se goi lai
"Masokhachhang"
' no chinh la so ID dau tien cua Khach hang duoc luu trong CSDL o bang "Khach
hang"
Masokhachhang = Request.Cookies("Masokhachhang")
If Masokhachhang = "" Then ' Khach hang moi -- Cap so ID de theo doi qua trinh di

chuyen va mua thiet bi.
Masokhachhang = 0
Else ' Neu da ton tai -- Lay ho ten nguoi do trong Cookies hien thi tren Trang chinh web
site.
Session("Hovaten") = Request.Cookies("Hovaten").Item
End If
Session("Masokhachhang") = Masokhachhang ' Dat "Masokhachhang vao session de su
dung cho viec mua hang.
' Thiet lap ADO Connection string -- Tao lien ket den CSDL dung de
' thuc thi " mo,ghi,doc,dong " tren moi trang
Session("ConnectionString") = "dsn=DATABASE;uid=DATABASE"
' Tao Shopping cart
ReDim ARYShoppingCart(ShoppingCartAttributes,MaxShoppingCartItems)
Session("MyShoppingCart") = ARYShoppingCart
Session("ItemCount") = 0
' Kiem tra su truy cap cua khach hang co dung trinh tu lien kethay khong
Trangdautien = "/MainASP.asp"
Tranghienhanh = Request.ServerVariables("SCRIPT_NAME")
' So sanh trang truy cap cua khach hang neu khong hop le thi tra su truy cap
' ve trang dau tien cua web site
If strcomp(Tranghienhanh,Trangdautien,1) Then
Response.Redirect("/ASPComputer" & Trangdautien)
End If
END SUB
</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
SUB Session_OnEnd
END SUB
</SCRIPT>
************************************************************************

*
File Mainasp.asp
************************************************************************
*
<html>
<head>
<title>Asp Computer Menu</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Border" content="none">
<base target="rtop">
</head>
<body background="../Quangcao/Image16.jpg">
<p><img src="../Quangcao/Bieutuong.gif" width="163" height="62"
alt="Bieutuong.gif (890 bytes)"></p>
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="190">
<tr>
<td width="100%" height="30"><a href="Gioithieu.html" target="rbottom"><img
src="../Quangcao/gthcuahang.gif" width="161" height="24" alt="gthcuahang.gif (302
bytes)"></a></td>
</tr>
<tr>
<td width="100%" height="26"><a href="Thongtin/Huongdan.asp"
target="_top"><img
src="../Quangcao/Hdmuahang.gif" alt="Hdmuahang.gif (316 bytes)" width="161"
height="24"></a></td>
</tr>
<tr>
<td width="100%" height="30"><a href="Category.asp" target="rbottom"><img
src="../Quangcao/Muahang.gif" alt="Muahang.gif (222 bytes)" width="161"
height="24"></a></td>

</tr>
<tr>
<td width="100%" height="26"><img src="../Quangcao/Thongtinmoi.gif"
alt="Thongtinmoi.gif (256 bytes)" width="161" height="24"></td>
</tr>
<tr>
<td width="100%" height="26"><img src="../Quangcao/Cachangmaytinh.gif"
alt="Cachangmaytinh.gif (288 bytes)" width="161" height="24"></td>
</tr>
<tr>
<td width="100%" height="26"><a href="../Dangky/Loginuser.asp"
target="_top"><img
src="../Quangcao/Dkkhachhang.gif" alt="Dkkhachhang.gif (320 bytes)" width="161"
height="24"></a></td>
</tr>
<tr>
<td width="100%" height="26"><a href="../Quanly/Report.asp" target="_top"><img
src="../Quangcao/Qlkhachhang.gif" alt="Qlkhachhang.gif (315 bytes)" width="161"
height="24"></a></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
************************************************************************
*

<html>
<head>
<title>Asp Computer Main</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Border" content="none">
</head>
<body background="../Quangcao/Image16.jpg" link="#FFFF00" vlink="#C0C0C0">
<form method="POST" action="../SearchPro.asp">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="54%"><div align="center"><center><p><font face="VNI-Times"
color="#000040"><strong><small>Tìm
kieám thieát bò :</small></strong></font></td>
<td width="50%" align="center"><div align="left"><p><input type="text"
name="txtTimkiem"
size="10" maxlength="15"></td>
<td width="26%" align="center"><div align="right"><p><input type="submit"
value="Tim Kiem"
name="Action"></td>
</tr>
</table>
</form>
<div align="center"><center>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="50%"><p align="center"><img src="../Quangcao/H2_smb~2.gif"
width="174"
height="75" alt="H2_smb~2.gif (5941 bytes)"></td>
<td width="50%"><p align="center"><img src="../Quangcao/H_pros~1.gif"
width="119"

height="162" alt="H_pros~1.gif (8528 bytes)"></td>
</tr>
</table>
</center></div><%
Randomize
Sotieude= Int(Rnd*5)
Set FileObject = Server.CreateObject("Scripting.FileSystemobject")
Set Instream = Fileobject.OpenTextFile (Server.Mappath
("/ASPComputer") & "\tieude.txt", 1 , false, false)
for i=1 to Sotieude -1
Instream.Skipline()
next
AdverOfDay= Instream.Readline%>
<div align="center"><center>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="center"><font face="VNI-TIMES" SIZE="8"
color="red"><%=AdverOfDay%></font> </td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="0" width="100%">
<tr>
<td width="100%"><% If IsEmpty(Session("Hovaten")) Then %>
<p><font face="VNI-Times" color="#000080">Chào Bạn</font> <% Else%><font
face="VNI-Times"><font color="#000080">Vui Mừng Gặp lai
</font><%=Session("Hovaten")%></font> <%End if%> <font
face="VNI-Times" color="#000080">Bạn Là Khách Hàng
Thứ:</font><%=FormatNumber(Session("CustomersID"),0)%></td>
</tr>

</table>
</center></div>
</body>
</html>
************************************************************************
*
File Category.asp
************************************************************************
*
<html>
<head>
<title>Category</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body link="#00FFFF" vlink="#0000FF" alink="#FF0000"
background="../Quangcao/Image16.jpg">
<table border="0" width="101%" bgcolor="#77FFFF" cellspacing="0" cellpadding="0"
height="349">
<tr>
<td width="50%" align="center" colspan="2" height="39" bgcolor="#800000"><font
face="VNI-Bodon" color="#FFFFFF"><strong><big>Các loại thiết
bò</big></strong></font></td>
</tr>
<tr>
<td width="10"><%
If Session("ItemCount") > 0 then %>
<p><a href="Productbuy.asp"><img src="../Quangcao/Productbuy.gif"
width="70" heigth="30" alt="Product buy" border="0"></a> <% End if %> </td>
</tr>
<tr>

<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=CAS"
target="_top"><img src="../LoaiThietbi/Case.gif" width="98" height="24"
alt="Case.gif "></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=NOT"
target="_top"><img src="../LoaiThietbi/Notebook.gif" width="100" height="22"
alt="Notebook.gif "></a></td>
</tr>
<tr>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=CDR"
target="_top"><img src="../LoaiThietbi/Cdrom.gif" width="98" height="24"
alt="Cdrom.gif "></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=PRI"
target="_top"><img src="../LoaiThietbi/Printer.gif" width="96" height="23"
alt="Printer.gif "></a></td>
</tr>
<tr>
<td width="50%" height="25"><p align="center"><a
href="ProductGet.asp?ID_LOAI=CPU"
target="_top"><img src="../LoaiThietbi/Cpu.gif" width="100" height="22"
alt="Cpu.gif "></a></td>
<td width="50%" height="25"><p align="center"><a
href="ProductGet.asp?ID_LOAI=SCA"
target="_top"><img src="../LoaiThietbi/Scanner.gif" width="96" height="23"
alt="Scanner.gif "></a></td>
</tr>
<tr>

<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=UPS"
target="_top"><img src="../LoaiThietbi/Ups.gif" width="96" height="23"
alt="Ups.gif"></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=SOU"
target="_top"><img src="../LoaiThietbi/Soundcard.gif" width="98" height="24"
alt="Soundcard.gif "></a></td>
</tr>
<tr>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=RAM"
target="_top"><img src="../LoaiThietbi/Ram.gif" width="100" height="22"
alt="Ram.gif "></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=FAX"
target="_top"><img src="../LoaiThietbi/Faxmodem.gif" width="98" height="24"
alt="Faxmodem.gif "></a></td>
</tr>
<tr>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=GLA"
target="_top"><img src="../LoaiThietbi/Glass.gif" width="98" height="24"
alt="Glass.gif "></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=VGA"
target="_top"><img src="../LoaiThietbi/Vgacard.gif" width="98" height="24"
alt="Vgacard.gif "></a></td>
</tr>
<tr>

<td width="50%" height="24"><p align="center"><a
href="ProductGet.asp?ID_LOAI=SER"
target="_top"><img src="../LoaiThietbi/Server.gif" width="100" height="22"
alt="Server.gif "></a></td>
<td width="50%" height="24"><p align="center"><a
href="ProductGet?ID_LOAI=MNB"
target="_top"><img src="../LoaiThietbi/Mainboard.gif" width="100" height="22"
alt="Mainboard.gif "></a></td>
</tr>
<tr>
<td width="50%" height="25"><p align="center"><a
href="ProductGet.asp?ID_LOAI=HUB"
target="_top"><img src="../LoaiThietbi/Hub.gif" width="100" height="22"
alt="Hub.gif "></a></td>
<td width="50%" height="25"><p align="center"><a
href="ProductGet.asp?ID_LOAI=DES"
target="_top"><img src="../LoaiThietbi/Desktop.gif" width="113" height="23"
alt="Desktop.gif "></a></td>
</tr>
<tr>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=KEY"
target="_top"><img src="../LoaiThietbi/Keyboard.gif" width="98" height="24"
alt="Keyboard.gif"></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=HDD"
target="_top"><img src="../LoaiThietbi/Hdd.gif" width="126" height="22"
alt="Hdd.gif "></a></td>
</tr>
<tr>

<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=SPE"
target="_top"><img src="../LoaiThietbi/Speaker.gif" width="98" height="24"
alt="Speaker.gif "></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=FDD"
target="_top"><img src="../LoaiThietbi/Fdd.gif" width="126" height="22"
alt="Fdd.gif "></a></td>
</tr>
<tr>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=MON"
target="_top"><img src="../LoaiThietbi/Monitor.gif" width="98" height="24"
alt="Monitor.gif"></a></td>
<td width="50%" height="26"><p align="center"><a
href="ProductGet.asp?ID_LOAI=TVM"
target="_top"><img src="../LoaiThietbi/Tvmovies.gif" width="131" height="24"
alt="Tvmovies.gif "></a></td>
</tr>
<tr>
<td width="50%" height="28"><p align="center"><a
href="ProductGet.asp?ID_LOAI=MOU"
target="_top"><img src="../LoaiThietbi/Mouse.gif" width="98" height="24"
alt="Mouse.gif "></a></td>
<td width="50%" height="28"><p align="center"><a
href="ProductGet.asp?ID_LOAI=NET"
target="_top"><img src="../LoaiThietbi/Netswitch.gif" width="152" height="26"
alt="Netswitch.gif "></a></td>
</tr>
</table>

<!-- #include virtual="/ASPComputer/aspform.inc" -->
</body>
</html>
************************************************************************
*
File ProductGet.asp
************************************************************************
*
<!--#include virtual="/ASPComputer/Cart.inc"-->
<%
ICount = Session("ItemCount")
ARYshoppingcart = Session("MyShoppingCart")
Set Conn = Server.CreateObject("ADODB.Connection")
If Request.QueryString("ID_TB") <> "" Then
If ICount < MaxShoppingCartItems Then
ICount = ICount + 1
End if
Session("ItemCount") = ICount
Conn.Open Session("ConnectionString")
SQL = "Select Thietbi.ID_TB,TEN_TB,MOTADACTINH,GIABANSI,GIABANLE"
SQL = SQL & " From THIETBI, BANGGIA"
SQL = SQL & " Where"
SQL = SQL & " BangGia.ID_TB = Thietbi.ID_TB and"
SQL = SQL & " Thietbi.ID_TB = '" & Request.QueryString("ID_TB") & "' and"
SQL = SQL & " Ngayban=(Select Max(Ngayban) from BangGia BG Where Ngayban <=
date() and BG.ID_TB = BANGGIA.ID_TB)"
Set RSProduct = Conn.Execute(SQL)
'21
If Not IsEmpty(RSProduct) Then
flag = 0

For i=1 to iCount
If ARYshoppingcart(cartID_TB,i) = RSProduct("ID_TB") Then
flag = 1
End If
Next
If Flag = 0 Then
ARYshoppingcart(cartCHECKED,ICount) = "CHECKED"
ARYshoppingcart(cartTEN_TB,ICount) = RSProduct("TEN_TB")
ARYshoppingcart(cartMOTADACTINH,ICount) =
RSProduct("MOTADACTINH")
ARYshoppingcart(cartItemSOLUONG,ICount) = 1
ARYshoppingcart(cartUnitGIABANSI,ICount) =
RSProduct("GIABANSI")
ARYshoppingcart(cartUnitGIABANLE,ICount) =
RSProduct("GIABANLE")
ARYshoppingcart(cartID_TB,ICount) = RSProduct("ID_TB")
Session("MyShoppingCart") = ARYshoppingcart
RSProduct.Close
Conn.Close
End If
End If
End If
SELECT CASE Request("Action")
CASE "Tiep Tuc Mua"
For i = 1 to ICount
Soluong = Request("Soluong" & CStr(i))
If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSOLUONG,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSOLUONG,i) = 1

End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Response.Redirect "Category.asp"
CASE "Tinh So Tien"
For i = 1 to iCount
Soluong = Request("Soluong" & CStr(i))
If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSoluong,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSoluong,i) = 1
End If
Next
Response.write(Soluong)
Response.write(ARYshoppingcart(cartItemSoluong,i))
For i = 1 to iCount
If Request("Confirm" & CStr(i)) = "" Then
iCount = iCount - 1
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,i) = ""
Next
n = i
while n < UBound(ARYshoppingcart,2)
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,n) = ARYshoppingcart(x,n +
1)
ARYshoppingcart(x,n + 1) = ""
Next
n = n + 1
wend

End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Session("ItemCount") = ICount
CASE "Khong Mua"
ICount = 0
Session("ItemCount") = ICount
Response.Redirect "MainASP.asp"
CASE "Thanh Toan"
Soluong = Request("Soluong" & CStr(i))
If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSOLUONG,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSOLUONG,i) = 1
End If
Session("MyShoppingCart") = ARYshoppingcart
' Kiem tra Neu la khach hang moi
Masokhachhang = Session("Masokhachhang")
if Masokhachhang = 0 then ' khach hang moi
Response.Redirect "SetCustomer.asp"
else
' kiem tra user da ton tai trong trang web (co trung voi)& o DatabaseFirst
Conn.Open Session("ConnectionString")
Set rs = Conn.Execute( _
"select Noicongtac FROM Khachhang where Masokhachhang = "
& Masokhachhang & _
" and Hovaten = '" & Session("Hovaten") & "'")
URL = "ShippingCus.asp"
If rs.EOF Then
Session("Masokhachhang") = -1 ' Khach hang da ton tai trong

database, nhung hien tai thi khong ton tai
URL ="SetCustomer.asp"
'105
End If
rs.Close
Conn.Close
Response.Redirect URL
End If
END SELECT
%>
<html>
<head>
<title>Buy Equipment</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body background="Quangcao/Image16.jpg">
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="21%"><p align="center"><img src="Quangcao/Bieutuong.gif"
width="163"
height="62" alt="Bieutuong.gif (890 bytes)"></td>
<td width="79%"><p align="center"><img src="Quangcao/Giomuahang1.gif"
width="250"
height="42" alt="Giomuahang1.gif (5413 bytes)"> </td>
</tr>
<tr>
<td width="21%" colspan="2" align="top"><form Action="Productbuy.asp"
method="POST">
<table border="0" width="100%" cellspacing="3" cellpadding="2">
<tr>

<td width="14%" align="center" Bgcolor="#800000"><font face=" VNI-Times"
color="#FFFFFF"><strong>Mua</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Ms
thiết bò</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Tên
thiết bò</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Mô
tả</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Số
lượng</strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Giá
sỉ </strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Giá
lẻ</strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Thành
tiền</strong></font></td>
</tr>
<!-- Begin first row of inserted product data -->
<%
ThanhTien = 0
ISubtotal = 0
For i = 1 to ICount
%>

<tr>
<td width="14%" align="center"><%If ARYshoppingcart(cartCHECKED,i) =
"CHECKED" Then%>
<p><font color="#0000A0"><input type="checkbox"
name="<%Response.Write "Confirm" & CStr(i) %>" Value="Confirmed"
CHECKED></font><%End if%></td>
<td width="14%" align="center"><%=ARYshoppingcart(cartID_TB,i) %>
</td>
<td width="14%" align="center"><%=ARYshoppingcart(cartTEN_TB,i)%>
</td>
<td width="14%" align="center"><%=ARYshoppingcart(cartMOTADACTINH,i)
%>
</td>
<td width="14%" align="center"><% if ARYshoppingcart(cartCHECKED,i) =
"CHECKED" Then%>
<p><font color="#0000A0"><input type="text"
name="<% Response.Write "Soluong" & CStr(i) %>"
Value="<%=ARYshoppingcart(cartItemSOLUONG,i)%>" size="2"
maxlendth="4"></font><% End if %></td>
<td width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANSI,i)
%>
</td>
<td width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANLE,i)
%>
</td>
<%
if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and
((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then
if (ARYshoppingcart(cartItemSOLUONG,i)) <= 2 then
ThanhTien = (ARYshoppingcart(cartUnitGIABANLE,i) *

ARYshoppingcart(cartItemSOLUONG,i))
ARYshoppingcart(cartUnitGIABANSI,i) = 0
Else
ThanhTien = (ARYshoppingcart(cartUnitGIABANSI,i) *
ARYshoppingcart(cartItemSOLUONG,i))
ARYshoppingcart(cartUnitGIABANLE,i) = 0
End if
%>
<td width="15%" align="center"><%= FormatCurrency(ThanhTien) %>
</td>
<%
End if
%>
<%
if ((ARYshoppingcart(cartUnitGIABANSI,i))= 0) and
((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then
ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *
ARYshoppingcart(cartItemSOLUONG,i))
Else
if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and
((ARYshoppingcart(cartUnitGIABANLE,i))= 0) then
ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANSI,i)
* ARYshoppingcart(cartItemSOLUONG,i))
End if
End if
Next
%>
</tr>
<!-- Begin IsubTotal -->
<tr>

<td width="14%" align="center" colspan="3"><div
align="right"><p><small><font
face="VNI-Times" color="#000040"><strong>Toång
coäng(</strong>USD<strong>) :</strong></font></small></td>
<td width="14%" align="center"><%=FormatCurrency(ISubtotal)%>
</td>
</tr>
<tr align="center">
<td width="14%" align="center" colspan="7"><div
align="right"><p><small><font
face="VNI-Times" color="#000040"><strong>Toång
coäng(</strong>VND<strong>) :</strong></font></small></td>
<td width="14%" align="center"><%=FormatCurrency(ISubtotal * Tygia) %>
</td>
</tr>
<tr align="center">
<td width="14%" align="center" colspan="2"><%if ICount <
MaxShoppingCartItems then %>
<p><input type="Submit" value="Tiep Tuc Mua"
name="Action"><%End if %></td>
<td width="14%" align="center" colspan="2"><% if ICount > 0 then %>
<p><input type="Submit" value="Thanh Toan"
name="Action"></td>
<td width="14%" align="center" colspan="2"><input type="Submit" value="Tinh
So Tien"
name="Action"><% End if %></td>
<td width="14%" align="center" colspan="2"><input type="Submit"
value="Khong Mua"
name="Action"></td>
<!-- End table inserted data -->

</tr>
</table>
</form>
</td>
</tr>
</table>
<!--#include virtual="/ASPComputer/aspform.inc" -->
</body>
</html>
************************************************************************
*
File Productbuy.asp
************************************************************************
*
<!--#include virtual="/ASPComputer/Cart.inc"-->
<%
ICount = Session("ItemCount")
ARYshoppingcart = Session("MyShoppingCart")
Set Conn = Server.CreateObject("ADODB.Connection")
If Request.QueryString("ID_TB") <> "" Then
If ICount < MaxShoppingCartItems Then
ICount = ICount + 1
End if
Session("ItemCount") = ICount
Conn.Open Session("ConnectionString")
SQL = "Select Thietbi.ID_TB,TEN_TB,MOTADACTINH,GIABANSI,GIABANLE"
SQL = SQL & " From THIETBI, BANGGIA"
SQL = SQL & " Where"
SQL = SQL & " BangGia.ID_TB = Thietbi.ID_TB and"
SQL = SQL & " Thietbi.ID_TB = '" & Request.QueryString("ID_TB") & "' and"

SQL = SQL & " Ngayban=(Select Max(Ngayban) from BangGia BG Where Ngayban <=
date() and BG.ID_TB = BANGGIA.ID_TB)"
Set RSProduct = Conn.Execute(SQL)
'21
If Not IsEmpty(RSProduct) Then
flag = 0
For i=1 to iCount
If ARYshoppingcart(cartID_TB,i) = RSProduct("ID_TB") Then
flag = 1
End If
Next
If Flag = 0 Then
ARYshoppingcart(cartCHECKED,ICount) = "CHECKED"
ARYshoppingcart(cartTEN_TB,ICount) = RSProduct("TEN_TB")
ARYshoppingcart(cartMOTADACTINH,ICount) =
RSProduct("MOTADACTINH")
ARYshoppingcart(cartItemSOLUONG,ICount) = 1
ARYshoppingcart(cartUnitGIABANSI,ICount) = RSProduct("GIABANSI")
ARYshoppingcart(cartUnitGIABANLE,ICount) = RSProduct("GIABANLE")
ARYshoppingcart(cartID_TB,ICount) = RSProduct("ID_TB")
Session("MyShoppingCart") = ARYshoppingcart
RSProduct.Close
Conn.Close
End If
End If
End If
SELECT CASE Request("Action")
CASE "Tiep Tuc Mua"
For i = 1 to ICount
Soluong = Request("Soluong" & CStr(i))

If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSOLUONG,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSOLUONG,i) = 1
End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Response.Redirect "Category.asp"
CASE "Tinh So Tien"
For i = 1 to iCount
Soluong = Request("Soluong" & CStr(i))
If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSoluong,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSoluong,i) = 1
End If
Next
For i = 1 to iCount
If Request("Confirm" & CStr(i)) = "" Then
iCount = iCount - 1
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,i) = ""
Next
n = i
while n < UBound(ARYshoppingcart,2)
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,n) = ARYshoppingcart(x,n + 1)
ARYshoppingcart(x,n + 1) = ""
Next
n = n + 1

wend
End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Session("ItemCount") = ICount
CASE "Khong Mua"
ICount = 0
Session("ItemCount") = ICount
Response.Redirect "MainASP.asp"
CASE "Thanh Toan"
Soluong = Request("Soluong" & CStr(i))
If IsNumeric(Soluong) Then
ARYshoppingcart(cartItemSOLUONG,i) = abs(CLng(Soluong))
Else
ARYshoppingcart(cartItemSOLUONG,i) = 1
End If
Session("MyShoppingCart") = ARYshoppingcart
' Kiem tra Neu la khach hang moi
Masokhachhang = Session("Masokhachhang")
if Masokhachhang = 0 then ' khach hang moi
Response.Redirect "SetCustomer.asp"
else
' kiem tra user da ton tai trong trang web (co trung voi)& o DatabaseFirst
Conn.Open Session("ConnectionString")
Set rs = Conn.Execute( _
"select Noicongtac FROM Khachhang where Masokhachhang = " &
Masokhachhang & _
" and Hovaten = '" & Session("Hovaten") & "'")
URL = "ShippingCus.asp"
If rs.EOF Then

Session("Masokhachhang") = -1 ' Khach hang da ton tai trong database, nhung
hien tai thi khong ton tai
URL ="SetCustomer.asp"
'105
End If
rs.Close
Conn.Close
Response.Redirect URL
End If
END SELECT
%>
<html>
<head>
<title>Buy Equipment</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body background="Quangcao/Image16.jpg">
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="21%"><p align="center"><img src="Quangcao/Bieutuong.gif"
width="163"
height="62" alt="Bieutuong.gif (890 bytes)"></td>
<td width="79%"><p align="center"><img src="Quangcao/Giomuahang1.gif"
width="250"
height="42" alt="Giomuahang1.gif (5413 bytes)"> </td>
</tr>
<tr>
<td width="21%" colspan="2" align="top"><form Action="Productbuy.asp"
method="POST">
<table border="0" width="100%" cellspacing="3" cellpadding="2">

<tr>
<td width="14%" align="center" Bgcolor="#800000"><font face=" VNI-Times"
color="#FFFFFF"><strong>Mua</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Ms
thiết bò</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Tên
thiết bò</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Mô
tả</strong></font></td>
<td width="14%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Số
lượng</strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Giá
sỉ </strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Giá
lẻ</strong></font></td>
<td width="15%" align="center" Bgcolor="#800000"><font face="VNI-Times"
color="#FFFFFF"><strong>Thành
tiền</strong></font></td>
</tr>
<!-- Begin first row of inserted product data -->
<%
ThanhTien = 0
ISubtotal = 0
For i = 1 to ICount

%>
<tr>
<td width="14%" align="center"><%If ARYshoppingcart(cartCHECKED,i) =
"CHECKED" Then%>
<p><font color="#0000A0"><input type="checkbox"
name="<%Response.Write "Confirm" & CStr(i) %>" Value="Confirmed"
CHECKED></font><%End if%></td>
<td width="14%" align="center"><%=ARYshoppingcart(cartID_TB,i) %>
</td>
<td width="14%" align="center"><%=ARYshoppingcart(cartTEN_TB,i)%>
</td>
<td width="14%" align="center"><%=ARYshoppingcart(cartMOTADACTINH,i)
%>
</td>
<td width="14%" align="center"><% if ARYshoppingcart(cartCHECKED,i) =
"CHECKED" Then%>
<p><font color="#0000A0"><input type="text"
name="<% Response.Write "Soluong" & CStr(i) %>"
Value="<%=ARYshoppingcart(cartItemSOLUONG,i)%>" size="2"
maxlendth="4"></font><% End if %></td>
<td width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANSI,i)
%>
</td>
<td width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANLE,i)
%>
</td>
<%
if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and
((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then
if (ARYshoppingcart(cartItemSOLUONG,i)) <= 2 then

ThanhTien = (ARYshoppingcart(cartUnitGIABANLE,i) *
ARYshoppingcart(cartItemSOLUONG,i))
ARYshoppingcart(cartUnitGIABANSI,i) = 0
Else
ThanhTien = (ARYshoppingcart(cartUnitGIABANSI,i) *
ARYshoppingcart(cartItemSOLUONG,i))
ARYshoppingcart(cartUnitGIABANLE,i) = 0
End if
%>
<td width="15%" align="center"><%= FormatCurrency(ThanhTien) %>
</td>
<%
End if
%>
<%
if ((ARYshoppingcart(cartUnitGIABANSI,i))= 0) and
((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then
ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *
ARYshoppingcart(cartItemSOLUONG,i))
Else
if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and
((ARYshoppingcart(cartUnitGIABANLE,i))= 0) then
ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANSI,i) *
ARYshoppingcart(cartItemSOLUONG,i))
End if
End if
Next
%>
</tr>
<%'99

Tenngoaite = "USD"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Session("ConnectionString")
SQL = "Select Tygiangoaite FROM TYGIA WHERE Tenngoaite = '" & Tenngoaite
&"'"
Set RSgia= Conn.Execute(SQL)
Tygiadola = RSgia("Tygiangoaite")
%>
<tr>
<td width="14%" align="center" colspan="3"><div align="left"><p><small><font
face="VNI-Times" color="#000040"><strong>Tyỷ
giaự(</strong>USD/VND<strong>) :
</strong></font></small><%=Formatcurrency(Tygiadola)%></td>
<td width="14%" align="center"></td>
<%
Tygia = RSgia("Tygiangoaite")
RSgia.Close
Conn.Close
%>
<!-- Begin IsubTotal -->
<td width="14%" align="center" colspan="3"><div
align="right"><p><small><font
face="VNI-Times" color="#000040"><strong>Toồng
coọng(</strong>USD<strong>) :</strong></font></small></td>
<td width="14%" align="center"><%=FormatCurrency(ISubtotal)%>
</td>
</tr>
<tr align="center">
<td width="14%" align="center" colspan="7"><div
align="right"><p><small><font

face="VNI-Times" color="#000040"><strong>Toång
coäng(</strong>VND<strong>) :</strong></font></small></td>
<td width="14%" align="center"><%=FormatCurrency(ISubtotal * Tygia) %>
</td>
</tr>
<tr align="center">
<td width="14%" align="center" colspan="2"><%if ICount <
MaxShoppingCartItems then %>
<p><input type="Submit" value="Tiep Tuc Mua"
name="Action"><%End if %></td>
<td width="14%" align="center" colspan="2"><% if ICount > 0 then %>
<p><input type="Submit" value="Thanh Toan"
name="Action"></td>
<td width="14%" align="center" colspan="2"><input type="Submit" value="Tinh
So Tien"
name="Action"><% End if %></td>
<td width="14%" align="center" colspan="2"><input type="Submit"
value="Khong Mua"
name="Action"></td>
<!-- End table inserted data -->
</tr>
</table>
</form>
</td>
</tr>
</table>
<!--#include virtual="/ASPComputer/aspform.inc" -->
</body>
</html>
************************************************************************

*
' File SetCustomer.asp
************************************************************************
*
<script Language="VBScript" Runat="Server">
Function Kiemtrachuoi (chuoi, kytucuoi)
Vitri= Instr(chuoi, "'")
While Vitri > 0
chuoi = Mid(chuoi, 1, Vitri) & "'" & Mid(chuoi, Vitri + 1)
Vitri = Instr(Vitri + 2, chuoi,"'")
Wend
Kiemtrachuoi="'" & chuoi & "'" & kytucuoi
End Function
</script>
<%
msg=""
Action = Left(UCase(Request("Action")),3)
'14
' Kiem tra mot so cong viec
If Action = "GOI" Then
If Request("txtHovaten") = "" OR _
Request("txtDiachilienlac") = "" OR _
Request("txtNoicongtac") = "" OR _
Request("txtSodienthoai") = "" OR _
Request("txtFax") = "" OR _
Request("txtQuanhuyen") = "" OR _
Request("txtMaquanhuyen") = "" OR _
Request("txtThanhpho") = "" OR _
Request("txtQuocgia") = "" OR _
Request("txtEmail") = "" then

msg="<B><I>Ban phai ghi du cac thong tin</font></I></B>"
End If
'29
'Sau khi cac field da day du cac gia tri can thiet thi insert vao Database
If msg = "" Then
sql = "Insert into Khachhang (" &_
"Hovaten, " &_
"Diachilienlac, " &_
"Noicongtac, " &_
"Sodienthoai, " &_
"Fax, " &_
"Quanhuyen, " &_
"Maquanhuyen, " &_
"Thanhpho, " &_
"Quocgia, " &_
"Email) " &_
"VALUES ( "
sql = sql & Kiemtrachuoi(Request("txtHovaten"),",")
sql = sql & Kiemtrachuoi(Request("txtDiachilienlac"),",")
sql = sql & Kiemtrachuoi(Request("txtNoicongtac"),",")
sql = sql & Kiemtrachuoi(Request("txtSodienthoai"),",")
sql = sql & Kiemtrachuoi(Request("txtFax"),",")
sql = sql & Kiemtrachuoi(Request("txtQuanhuyen"),",")
sql = sql & Kiemtrachuoi(Request("txtMaquanhuyen"),",")
sql = sql & Kiemtrachuoi(Request("txtThanhpho"),",")
sql = sql & Kiemtrachuoi(Request("txtQuocgia"),",")
sql = sql & Kiemtrachuoi(Request("txtEmail"),")")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Session("ConnectionString")
Conn.Execute(sql)

'Su dung gia tri max vua moi them, de chuyen thong tin khach hang
sql = "select max(Masokhachhang) from Khachhang"
set RSCus = Conn.Execute(sql)
Masokhachhang = RSCus(0)
RSCus.Close
Conn.Close
Session("Masokhachhang")= Masokhachhang
Session("Hovaten") = Request("Hovaten").Item
Response.Cookies("Noicongtac") = Request("Noicongtac")
Response.Cookies("Noicongtac").Expires = Date+365
Response.Cookies("Noicongtac").Path = "/ASPComputer"
Response.Cookies("Masokhachhang") = Masokhachhang
Response.Cookies("Masokhachhang").Expires = Date+365
Response.Cookies("Masokhachhang").Path = "/ASPComputer"
Response.Redirect "ShippingCus.asp"
'75
End If 'msg = ""
End If 'Action = "ENTER"
%>
<html>
<head>
<title>Set Customer</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body background="../Quangcao/Image16.jpg">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="1%"><p align="center"><img src="../Quangcao/Bieutuong.gif"
width="163"
height="62" alt="Bieutuong.gif (890 bytes)" align="left"></td>

<td width="115%"><p align="center"><img src="../Quangcao/Ghikhachhang1.gif"
width="133"
height="42" alt="Ghikhachhang1.gif (2893 bytes)"></td>
</tr>
<%
Hovaten = Request("txtHovaten")
' Kiem tra truong hop thong tin khach hang bi loai khoi database.
' Ho can dien lai thong tin
if Session("CustomerID") = -1 then
Response.Write "<I><B>" & Session("Hovaten") & "</B>, Chung toi can ghi thong tin
cua ban vao database</I><P>"
Hovaten = Session("Hovaten")
end if
%>
<tr>
<td width="20%" colspan="2" align="top"><form
Action="/ASPComputer/SetCustomer.asp"
method="POST">
<%=msg%>
<table border="0" width="100%" height="385" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="top" height="19"></td>
</tr>
<tr>
<td width="50%" align="center" height="45" bgcolor="#800000"><strong><font
face="VNI-Times" color="#FFFFFF"><big>Thông tin khách
hàng</big></font></strong></td>
</tr>
<tr>
<td width="50%" height="259"><table border="0" width="100%" height="255"

cellspacing="0"
cellpadding="0">
<tr>
<td width="50%" height="41"><strong><font face="VNI-Times">Họ và
tên:</font><br>
<input type="text" name="txtHovaten" value="<%=Request("txtHovaten")%>"
size="21"
maxlength="50"></strong></td>
<td width="50%" height="41"><strong><font face="VNI-Times">Quận
huyện:</font><br>
<input type="text" name="txtQuanhuyen"
value="<%=Request("txtQuanhuyen")%>" size="5"
maxlength="10"></strong></td>
</tr>
<tr>
<td width="50%" height="42"><strong><font face="VNI-Times">Đòa chỉ
liên lạc:</font><br>
<input type="text" name="txtDiachilienlac"
value="<%=Request("txtDiachilienlac")%>"

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×