1. Trang chủ
  2. » Luận Văn - Báo Cáo

Chương 7:Chương trình nguồn

81 326 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 81
Dung lượng 105,63 KB

Nội dung

Chương trình nguồn

Trang 1

<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 khac h hang truy cap WEB siteCustomersCount = 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

Set FileObject = Server.CreateObject("Scripting.FileSystemObject")

Set Out= FileObject.CreateTextFile (Application("CustomersCountFN"), TRUE,FALSE)

Out.WriteLine(application("Customers"))END SUB

<SCRIPT LANGUAGE=VBScript RUNAT=Server>SUB Session_OnStart

const MaxShoppingCartItems = 10const 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 trongSession object

' 4) Khi co su thay doi dot ngot qua trinh di chuyen trong web site cua khach hangthi tra ve trang chinh.

Trang 2

'

-' Tang so ID cua Customers khi co truy cap web site.Application.lock

Application("Customers")= application("Customers") + 1I_Customers = application("Customers")

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)

Session("Masokhachhang") = Masokhachhang ' Dat "Masokhachhang vao session de sudung 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

Trang 3

' Kiem tra su truy cap cua khach hang co dung trinh tu lien kethay khongTrangdautien = "/MainASP.asp"

<SCRIPT LANGUAGE=VBScript RUNAT=Server> SUB Session_OnEnd

END SUB</SCRIPT>

File Mainasp.asp

<title>Asp Computer Menu</title>

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"><meta name="Microsoft Border" content="none">

<base target="rtop"></head>

</tr> <tr>

<td width="100%" height="26"><a href="Thongtin/Huongdan.asp"target="_top"><img

Trang 4

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>

<title>Asp Computer Main</title>

Trang 5

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"><meta name="Microsoft Border" content="none">

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>

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>

AdverOfDay= Instream.Readline%><div align="center"><center>

Trang 6

<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àngThứ:</font><%=FormatNumber(Session("CustomersID"),0)%></td> </tr>

File Category.asp

</tr> <tr>

<td width="10"><%

Trang 7

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>

<td width="50%" height="26"><p align="center"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="ProductGet.asp?ID_LOAI=SOU"

target="_top"><img src=" /LoaiThietbi/Soundcard.gif" width="98" height="24" alt="Soundcard.gif "></a></td>

</tr> <tr>

Trang 8

<td width="50%" height="26"><p align="center"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="ProductGet.asp?ID_LOAI=HDD"

Trang 9

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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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"><ahref="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>

File ProductGet.asp

<! #include virtual="/ASPComputer/Cart.inc" ><%

Trang 10

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) Thenflag = 0

For i=1 to iCount

If ARYshoppingcart(cartID_TB,i) = RSProduct("ID_TB") Thenflag = 1

End IfNext

If Flag = 0 Then

ARYshoppingcart(cartCHECKED,ICount) = "CHECKED"ARYshoppingcart(cartTEN_TB,ICount) = RSProduct("TEN_TB")ARYshoppingcart(cartMOTADACTINH,ICount) =

ARYshoppingcart(cartItemSOLUONG,ICount) = 1ARYshoppingcart(cartUnitGIABANSI,ICount) =RSProduct("GIABANSI")

ARYshoppingcart(cartUnitGIABANLE,ICount) =RSProduct("GIABANLE")

ARYshoppingcart(cartID_TB,ICount) = RSProduct("ID_TB")Session("MyShoppingCart") = ARYshoppingcart

RSProduct.CloseConn.CloseEnd If

End IfEnd If

Trang 11

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) = 1End If

Session("MyShoppingCart") = ARYshoppingcartResponse.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) = 1End If

Response.write(ARYshoppingcart(cartItemSoluong,i))For i = 1 to iCount

If Request("Confirm" & CStr(i)) = "" TheniCount = iCount - 1

For x = 1 to UBound(ARYshoppingcart,1)ARYshoppingcart(x,i) = ""

Nextn = 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 + 1wend

End If Next

Session("MyShoppingCart") = ARYshoppingcartSession("ItemCount") = ICount

Trang 12

CASE "Khong Mua"ICount = 0

Session("ItemCount") = ICountResponse.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) = 1End If

Session("MyShoppingCart") = ARYshoppingcart' Kiem tra Neu la khach hang moi

Masokhachhang = Session("Masokhachhang")if Masokhachhang = 0 then ' khach hang moiResponse.Redirect "SetCustomer.asp"else

' kiem tra user da ton tai trong trang web (co trung voi)& o DatabaseFirstConn.Open Session("ConnectionString")

End Ifrs.CloseConn.Close

Response.Redirect URLEnd If

END SELECT%>

<title>Buy Equipment</title>

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"></head>

<body background="Quangcao/Image16.jpg">

Trang 13

<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>

<! Begin first row of inserted product data ><%

ThanhTien = 0ISubtotal = 0For i = 1 to ICount%>

<tr>

Trang 14

<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 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 width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANLE,i)%>

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) = 0Else

ThanhTien = (ARYshoppingcart(cartUnitGIABANSI,i) *ARYshoppingcart(cartItemSOLUONG,i))

ARYshoppingcart(cartUnitGIABANLE,i) = 0End if

<td width="15%" align="center"><%= FormatCurrency(ThanhTien) %></td>

<%End if%><%

if ((ARYshoppingcart(cartUnitGIABANSI,i))= 0) and((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then

Trang 15

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *ARYshoppingcart(cartItemSOLUONG,i))

if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and((ARYshoppingcart(cartUnitGIABANLE,i))= 0) then

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANSI,i)* ARYshoppingcart(cartItemSOLUONG,i))

End ifEnd if

Next%> </tr>

<! Begin IsubTotal > <tr>

<td width="14%" align="center" colspan="3"><divalign="right"><p><small><font

face="VNI-Times" color="#000040"><strong>Tổngcộng(</strong>USD<strong>) :</strong></font></small></td>

<td width="14%" align="center"><%=FormatCurrency(ISubtotal)%></td>

<td width="14%" align="center"><%=FormatCurrency(ISubtotal * Tygia) %></td>

</table>

Trang 16

</form> </td> </tr></table>

<! #include virtual="/ASPComputer/aspform.inc" ></body>

File Productbuy.asp

<! #include virtual="/ASPComputer/Cart.inc" ><%

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) Thenflag = 0

For i=1 to iCount

If ARYshoppingcart(cartID_TB,i) = RSProduct("ID_TB") Thenflag = 1

End IfNext

If Flag = 0 Then

ARYshoppingcart(cartCHECKED,ICount) = "CHECKED"ARYshoppingcart(cartTEN_TB,ICount) = RSProduct("TEN_TB")ARYshoppingcart(cartMOTADACTINH,ICount) =

RSProduct("MOTADACTINH")

Trang 17

ARYshoppingcart(cartItemSOLUONG,ICount) = 1

ARYshoppingcart(cartUnitGIABANSI,ICount) = RSProduct("GIABANSI")ARYshoppingcart(cartUnitGIABANLE,ICount) = RSProduct("GIABANLE")ARYshoppingcart(cartID_TB,ICount) = RSProduct("ID_TB")

Session("MyShoppingCart") = ARYshoppingcartRSProduct.Close

Conn.CloseEnd If

End IfEnd 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) = 1End If

Session("MyShoppingCart") = ARYshoppingcartResponse.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) = 1End If

Nextn = i

while n < UBound(ARYshoppingcart,2)For x = 1 to UBound(ARYshoppingcart,1)

ARYshoppingcart(x,n) = ARYshoppingcart(x,n + 1)ARYshoppingcart(x,n + 1) = ""

Trang 18

Nextn = n + 1wend

End If Next

Session("MyShoppingCart") = ARYshoppingcartSession("ItemCount") = ICount

CASE "Khong Mua"ICount = 0

Session("ItemCount") = ICountResponse.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) = 1End 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 DatabaseFirstConn.Open Session("ConnectionString")

End Ifrs.CloseConn.Close

Response.Redirect URLEnd If

END SELECT%>

Trang 19

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>

Trang 20

</tr>

<! Begin first row of inserted product data ><%

ThanhTien = 0ISubtotal = 0For 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 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 width="15%" align="center"><% =ARYshoppingcart(cartUnitGIABANLE,i)%>

if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then

if (ARYshoppingcart(cartItemSOLUONG,i)) <= 2 thenThanhTien = (ARYshoppingcart(cartUnitGIABANLE,i) *ARYshoppingcart(cartItemSOLUONG,i))

ARYshoppingcart(cartUnitGIABANSI,i) = 0Else

ThanhTien = (ARYshoppingcart(cartUnitGIABANSI,i) *ARYshoppingcart(cartItemSOLUONG,i))

ARYshoppingcart(cartUnitGIABANLE,i) = 0End if

<td width="15%" align="center"><%= FormatCurrency(ThanhTien) %>

Trang 21

</td><%End if%><%

if ((ARYshoppingcart(cartUnitGIABANSI,i))= 0) and((ARYshoppingcart(cartUnitGIABANLE,i)) <> 0) then

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *ARYshoppingcart(cartItemSOLUONG,i))

if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> 0) and((ARYshoppingcart(cartUnitGIABANLE,i))= 0) then

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANSI,i) *ARYshoppingcart(cartItemSOLUONG,i))

End ifEnd if

Next%> </tr><%'99

Tygia = RSgia("Tygiangoaite")RSgia.Close

<! Begin IsubTotal >

<td width="14%" align="center" colspan="3"><divalign="right"><p><small><font

face="VNI-Times" color="#000040"><strong>Tổngcộng(</strong>USD<strong>) :</strong></font></small></td>

<td width="14%" align="center"><%=FormatCurrency(ISubtotal)%>

Trang 22

</td> </tr>

<tr align="center">

<td width="14%" align="center" colspan="7"><divalign="right"><p><small><font

face="VNI-Times" color="#000040"><strong>Tổngcộng(</strong>VND<strong>) :</strong></font></small></td>

<td width="14%" align="center"><%=FormatCurrency(ISubtotal * Tygia) %></td>

</table> </form> </td> </tr></table>

<! #include virtual="/ASPComputer/aspform.inc" ></body>

' 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)

Trang 23

Vitri = Instr(Vitri + 2, chuoi,"'")Wend

Kiemtrachuoi="'" & chuoi & "'" & kytucuoiEnd Function

Action = Left(UCase(Request("Action")),3)'14

' Kiem tra mot so cong viecIf 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

"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(Re quest("txtFax"),",")

sql = sql & Kiemtrachuoi(Request("txtQuanhuyen"),",")sql = sql & Kiemtrachuoi(Request("txtMaquanhuyen"),",")sql = sql & Kiemtrachuoi(Request("txtThanhpho"),",")

Trang 24

sql = sql & Kiemtrachuoi(Request("txtQuocgia"),",")sql = sql & Kiemtrachuoi(Request("txtEmail"),")")Set Conn = Server.CreateObject("ADODB.Connection")Conn.Open Session("ConnectionString")

'Su dung gia tri max vua moi them, de chuyen thong tin khach hangsql = "select max(Masokhachhang) from Khachhang"set RSCus = Conn.Execute(sql)

Masokhachhang = RSCus(0)RSCus.Close

Session("Masokhachhang")= MasokhachhangSession("Hovaten") = Request("Hovaten").Item

Response.Cookies("Noicongtac") = Request("Noicongtac")Response.Cookies("Noicongtac").Expires = Date+365

Response.Cookies("Noicongtac").Path = "/ASPComputer"Response.Cookies("Masokhachhang") = MasokhachhangResponse.Cookies("Masokhachhang").Expires = Date+365Response.Cookies("Masokhachhang").Path = "/ASPComputer"Response.Redirect "ShippingCus.asp"

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>

Trang 25

</tr><%

%> <tr>

<td width="20%" colspan="2" align="top"><formAction="/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"

</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")%>"

Trang 26

</tr> <tr>

<td width="50%" height="42"><strong><font face="VNI-Times">Nơi côngtác:</font><br>

<input type="text" name="txtNoicongtac"value="<%=Request("txtNoicongtac")%>" size="21" maxlength="30"></strong></td>

<td width="50%" height="42"><strong><font face="VNI-Times">Thànhphố:</font><br>

<input type="text" name="txtThanhpho"value="<%=Request("txtThanhpho")%>" size="8" maxlength="15"></strong></td>

</tr> <tr>

<td width="50%" height="42"><strong><font face="VNI-Times">Điệnthoại:</font><br>

<input type="text" name="txtSodienthoai"value="<%=Request("txtSodienthoai")%>" size="10" maxlength="15"></strong></td>

<td width="50%" height="42"><strong><font face="VNI-Times">Quốcgia:</font><br>

<input type="text" name="txtQuocgia" value="<%=Request("txtQuocgia")%>"size="8"

maxlength="15"></strong></td> </tr>

Trang 27

</table> </td> </tr> <tr>

<td width="50%" height="38"><div align="center"><center><p><inputtype="submit"

value="Goi thong tin" name="Action"></td> </tr>

</table> </form> </td> </tr></table>

<! #include virtual="/ASPComputer/aspform.inc" ></body>

File ShippingCus.asp

Masokhachhang = Session("Masokhachhang")if Masokhachhang = 0 then ' Khach hang moi

Response.Redirect "SetCustomer.asp"End If

<! #include virtual="/ASPComputer/Cart.inc" ><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,"'")

Kiemtrachuoi="'" & chuoi & "'" & kytucuoiEnd Function

'20 Lay gia tri trong session

ARYshoppingcart = Session("MyShoppingCart")ICount = Session("ItemCount")

Set Conn = Server.CreateObject("ADODB.Connection")msg=""

Trang 28

DateErrorMsg = "<TT><B><I>Ngay thanh toan phai sau ngay hientai</I></B></TT><BR>"

Action = Left(UCase(Request("Action")),3)If Action = "GOI" Then

' Kiem tra mot so cong viec truoc khiIf Len(Request("SoCreditcard")) < 8 Then

msg="<TT><B><I>So Credict card nen co it nhat 8 so</I></B></TT><BR>"elseif NOT IsDate(Request("Ngaythanhtoan")) then

Request("txtQuanhuyen") = "" OR _Request("txtMaquanhuyen") = "" OR _Request("txtThanhpho") = "" OR _Request("txtQuocgia") = "" Then

msg ="<TT><B><I>Xin khach hang nhap du thong tin</I></B></TT><BR>"End If

If msg = "" Then 'Them vao co so du lieu

sql = "INSERT INTO HOADONBAN(Masokhachhang, Ngaybanhang,Hotennguoimua, "

sql = sql & "Noicongtac, Diachinguoimua, Sodienthoai, Fax, "sql = sql & "Quanhuyen, Maquanhuyen, Thanhpho, Quocgia, "

sql = sql & "Ngaygiaohang, ID_PTGiaohang, Cuocphivanchuyen, Thue) "sql = sql & "VALUES( "

sql = sql & Request("Masokhachhang")sql = sql & "{fn now()},"

sql = sql & Kiemtrachuoi(Request("txtHovaten"),",")sql = sql & Kiemtrachuoi(Request("txtNoicongtac"),",")sql = sql & Kiemtrachuoi(Request("txtDiachinguoimua"),",")sql = sql & Kiemtrachuoi(Request("txtSodienthoai"), ",")sql = sql & Kiemtrachuoi(Request("txtFax"), ",")

sql = sql & Kiemtrachuoi(Request("txtQuanhuyen"), ",")sql = sql & Kiemtrachuoi(Request("txtMaquanhuyen"), ",")sql = s ql & Kiemtrachuoi(Request("txtThanhpho"), ",")sql = sql & Kiemtrachuoi(Request("txtQuocgia"), ",")sql = sql & "{fn now()}, "

sql = sql & Request("ID_PTGiaohang") & ", "

Trang 29

sql = sql & Request("Cuocphivanchuyen") & ", "sql = sql & Request("Thue") & ")"

Conn.Open Session("ConnectionString")Conn.Execute(sql)

sql = "select max(ID_HDB) from HOADONBAN"set rs = Conn.Execute(sql)

ID_HDB = rs(0)rs.Close

' Ghi cac tung thiet bi vao chi tiet hoa don banFor i = 1 to ICount

If ARYshoppingcart(cartUnitGIABANLE,i) <> 0 andARYshoppingcart(cartUnitGIABANSI,i)= 0 then

sql="Select Chitiethoadonnhap.SERIAL_NUMBER FromChitiethoadonnhap "

sql = sql & "Where ID_TB= ARYshoppingcart(CartID_TB,i)and OnSale= True"

set RS2 = Conn.Execute(sql)k=1

Do While not(RS2.eof) and k <=ARYshoppingcart(cartItemSOLUONG,i)

sql = "INSERT INTO CHITIETHOADONBAN(ID_HDB, ID_TB,SERIAL_NUMBER, GIABAN) "

sql = sql & "VALUES( " sql = sql & ID_HDB & ","

sql = sql & ARYshoppingcart(cartID_TB,i) & ","sql = sql & RS2("SERIAL_NUMBER") & ","

sql = sql & ARYshoppingcart(cartUnitGIABANLE,i) & ")"Conn.Execute(sql)

RS2.EditModeRS2.Onsale = FalseRS2.update

k = k + 1Loop

else'101

If ARYshoppingcart(cartUnitGIABANSI,i) <> 0 andARYshoppingcart(cartUnitGIABANLE,i)= 0 then

sql="Select Chitiethoadonnhap.SERIAL_NUMBER FromChitiethoadonnhap "

sql = sql & "Where ID_TB= ARYshoppingcart(CartID_TB,i)and OnSale= True"

set RS2 = Conn.Execute(sql)k=1

Trang 30

Do While not(RS2.eof) and k <=ARYshoppingcart(cartItemSOLUONG,i)

sql = "INSERT INTO CHITIETHOADONBAN(ID_HDB, ID_TB,SERIAL_NUMBER, GIABAN) "

sql = sql & "VALUES( " sql = sql & ID_HDB & ","

sql = sql & ARYshoppingcart(cartID_TB,i) & ","sql = sql & RS2("SERIAL_NUMBER") & ","

sql = sql & ARYshoppingcart(cartUnitGIABANSI,i) & ")"Conn.Execute(sql)

RS2.EditModeRS2.Onsale = FalseRS2.update

k = k + 1Loop

End ifEnd ifNextRS2.Close

Set RS2 = Nothing

' Hinh thuc va thoi han thanh toan

sql = "INSERT INTO THANHTOAN(ID_HDB, Tongtientra, Ngaytra,Socreditcard, Ngaythanhtoan) "

sql = sql & "VALUES( "sql = sql & ID_HDB & ","

sql = sql & Request("Tongtientra") & ","sql = sql & "{fn now()},"

sql = sql & "'" & Request("SoCreditCard") & "',"

sql = sql & "'" & CDate(Request("Ngaythanhtoan")) & "')"Conn.Execute(sql)

' Ghi thiet bi vao bang xuat nhap ton

sql = "INSERT INTO NHAPXUATTON(ID_TB,XUAT)"sql = sql & "VALUE( "

sql = sql & ARYshoppingcart(cartID_TB,i) & ","

sql = sql & ARYshoppingcart(cartItemSOLUONG,i) &")"Conn.Execute(sql)

Session("ItemCount") = 0Conn.Close

Response.Redirect "CongratulationCus.asp"End If 'msg = ""

Else if Action = "CANCE" ThenSession("ItemCount") = 0

Trang 31

Response.Redirect "MainASP.asp"End If

<title>Shipping Customer</title>

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"></head>

<body background=" /Quangcao/Image16.jpg"><table border="0" cellspacing="1" cellpadding="0"> <tr>

<td width="22%"><img src=" /Quangcao/Bieutuong.gif" width="163" height="62" alt="Bieutuong.gif (890 bytes)"></td>

<td width="78%"><p align="center"><img src=" /Quangcao/Thanhtoanthue1.gif"width="364"

height="42" alt="Thanhtoanthue1.gif (8428 bytes)"></td> </tr>

Conn.Open Session("ConnectionString")

Trang 32

set RSCus = Conn.Execute("Select * from khachhang where Masokhachhang = " &Masokhachhang)

%> <tr>

<td width="289" height="17"><font color="#000040"><small><strong><fontface="VNI-Times">HọvàTên

<option value=" -">Sec </option> </select></font></td>

</tr> <tr>

<td width="289" height="19"><strong><font color="#000040"><small><fontface="VNI-Times">Địa

chỉ liên lạc:</font></small><br>

<input type="text" name="txtDiachilienlac"value="<%=RSCus("Diachilienlac")%>" size="20" maxlength="50"></font></strong></td> </tr>

<tr>

<td width="289" height="19"><strong><font color="#000040"><small><fontface="VNI-Times">Nơi

công tác :</font></small><br>

<input type="text" name="txtNoicongtac" value="<%=RSCus("Noicongtac")%>"size="20"

Trang 34

type="text" name="txtMaquanhuyen" value="<%=RSCus("Maquanhuyen")%>"size="5"

maxlength="10"></td> </tr>

</table> </td>

<td width="280" height="19" valign="top" rowspan="3" align="center"><divalign="left"><p><small><strong><font

face="VNI-Times" color="#000040">Hình thức vậnchuyển:</font></strong></small></td>

Set rs = Conn.Execute("Select * from PTGIAOHANG")Checked = " checked>"

Do while not rs.eof

Response.Write "< input type=radio name=PTgiaohang value=" &rs("ID_PTGiaohang") & Checked & rs("TENPTGHANG") & "<BR>"

Checked = ">"rs.MovetextLoop

<div align="center"><center><table border="0" cellpadding="5"> <tr>

<td width="45%" align="center" bgcolor="#800000"><font face="VNI-Times"color="#FFFFFF"><strong>Mã

số Thiết bị</strong></font></td>

<td width="50%" align="center" bgcolor="#800000"><font face="VNI-Times"color="#FFFFFF"><strong>Tên

Thiết bị</strong></font></td>

<td width="55%" align="center" bgcolor="#800000"><font face="VNI-Times"color="#FFFFFF"><strong>Mô

tả</strong></font></td>

Trang 35

<td width="50%" align="center" bgcolor="#800000"><font face="VNI-Times"color="#FFFFFF"><strong>Soá

<tr>

<td width="50%"><font

size="2"><%=ARYshoppingcart(cartID_TB,i)%></font></td> <td width="50%"><font

size="2"><%=ARYshoppingcart(cartTEN_TB,i)%></font></td> <td width="55%"><font

size="2"><%=ARYshoppingcart(cartMOTADACTINH,i)%></font></td> <td width="50%"><font

size="2"><%=ARYshoppingcart(cartItemSOLUONG,i)%></font></td><%If ARYshoppingcart(cartGIABANLE,i) <> "" then %>

<td width="50%"><font

size="2"><%=ARYshoppingcart(cartGIABANLE,i)%></font></td><%Else %>

<td width="50%"><font

size="2"><%=ARYshoppingcart(cartGIABANSI,i)%></font></td><%End if %>

</tr> <tr><%

if ((ARYshoppingcart(cartUnitGIABANSI,i)) = "") and((ARYshoppingcart(cartUnitGIABANLE,i)) <> "") then

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *ARYshoppingcart(cartItemSoluong,i))

if ((ARYshoppingcart(cartUnitGIABANSI,i)) <> "") and((ARYshoppingcart(cartUnitGIABANLE,i)) = "") then

ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANSI,i) *ARYshoppingcart(cartItemSoluong,i))

End ifEnd if

<! Begin Subtotal ><%

Trang 36

Tygia = RSgia("Tygiangoaite")RSgia.Close

<td width="55%" colspan="2" align="top"><div align="right"><p><fontface="VNI-Times"

color="#000040"><strong>Tổng

cộng(USD):</strong></font><%=FormatCurrency(ISubtotal)%></td> <td width="50%"></td>

</tr> <tr>

<td width="45%" colspan="4" align="top"><div align="right"><p><fontface="VNI-Times"

color="#000040"><strong>Tổng cộng(VND):</strong></font><%=FormatCurrency(ISubtotal * Tygia)%> </td>

<td width="50%"></td> </tr>

Trang 37

color="#000040"><strong>Chi phí vận

chuyển:</strong></font><%=FormatCurrency(ICuocphi)%></td> <td width="50%"></td>

</td> </tr></table>

<! #include virtual ="/ASPComputer/aspform.inc" ></body>

File Customerlist.asp

<title>Customer List</title>

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"></head>

<body background=" /Quangcao/Image16.jpg"><%

Set Conn = Server.CreateObject("ADODB.Connection")

Trang 38

border="0" width="100%" cellspacing="2" cellpadding="5"><! BEGIN column header row >

<td width="17%" height="19" align="center"bgcolor="#800000"><strong><small><font

face="VNI-Times" color="#FFFF00">Thànhphố</font></small></strong></td>

<td width="17%" height="19" align="center"bgcolor="#800000"><strong><small><font

face="VNI-Times" color="#FFFF00">Quậnhuyện</font></small></strong></td>

<td width="17%" height="19" align="center"bgcolor="#800000"><strong><small><font

face="VNI-Times" color="#FFFF00">Quốcgia</font></small></strong></td>

</td>

Trang 39

<td width="16%" height="111"><%=RSCustomer("Noicongtac") %>

<td width="16%" height="111"><%=RSCustomer("Diachilienlac") %>

<td width="17%" height="111"><%=RSCustomer("Quanhuyen") %>

<td width="17%" height="111"><%=RSCustomer("Quocgia") %>

<td width="16%" height="111"><a

</tr><%

Set RSCustomer = Nothing%>

</table></form></body></html>

‘File form truy cap he thong

<meta name="GENERATOR" content="Microsoft FrontPage 3.0"></head>

<body background="image271.jpg">

Trang 40

<form action="admin.asp" method="post"> <p>&nbsp;</p>

<p>&nbsp;</p> <p>&nbsp;</p>

<table border="0" width="100%" height="149"> <tr>

<p><font face="VNI-Times" size="4"

color="#000080">Nhập lại mật khẩu mới:</font></td> <td width="51%" height="145"><input type="text"name="txtusername" size="20"><p><input

type="password" name="txtpasswd" size="20"></p> <p><input type="password" name="txtrepasswd"size="20"></td>

</tr> </table>

<a href="admin.asp"><div align="right"><p><imgsrc="luanvan/anh/l_nhap.gif"

width="100" height="25" alt="l_nhap.gif (1788bytes)"></a><a href="trangchinh.htm"></a> <img src=" / /luanvan/anh/l_thoat.gif" width="100"height="25" alt="l_thoat.gif (309 bytes)">

</p> </div></form></body></html>

‘File load danh sach hieu thiet bi trinh bay len trang web**************************************************************

<%@ LANGUAGE="VBSCRIPT" %><html>

Ngày đăng: 31/10/2012, 15:03

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w