Chương trình nguồn
Trang 1' 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 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.
' 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, ' 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.
Trang 2' 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,
' 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
' 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.
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
Trang 3' 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
<title>Asp Computer Menu</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0"> <meta name="Microsoft Border" content="none">
<td width="100%" height="30"><a href="Gioithieu.html" target="rbottom"><img src=" /Quangcao/gthcuahang.gif" width="161" height="24" alt="gthcuahang.gif (302
Trang 4src=" /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>
<td width="100%" height="26"><a href=" /Quanly/Report.asp" target="_top"><img src=" /Quangcao/Qlkhachhang.gif" alt="Qlkhachhang.gif (315 bytes)" width="161"
Trang 5<meta name="GENERATOR" content="Microsoft FrontPage 3.0"> <meta name="Microsoft Border" content="none">
<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"
height="75" alt="H2_smb~2.gif (5941 bytes)"></td>
<td width="50%"><p align="center"><img src=" /Quangcao/H_pros~1.gif"
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>
Trang 6<table border="0" width="100%" cellspacing="0" cellpadding="0">
<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
<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"><%
Trang 7If 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>
Trang 8<td width="50%" height="26"><p align="center"><a
Trang 9target="_top"><img src=" /LoaiThietbi/Hdd.gif" width="126" height="22"
Trang 10SQL = 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
Trang 11SELECT CASE Request("Action") CASE "Tiep Tuc Mua"
Trang 12CASE "Khong Mua" ICount = 0
Session("ItemCount") = ICount Response.Redirect "MainASP.asp" CASE "Thanh Toan"
Soluong = Request("Soluong" & CStr(i))
"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
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"
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"
<p><font color="#0000A0"><input type="text"
name="<% Response.Write "Soluong" & CStr(i) %>"
Trang 15ISubtotal = ISubtotal + (ARYshoppingcart(cartUnitGIABANLE,i) *
<td width="14%" align="center" colspan="2"><% if ICount > 0 then %> <p><input type="Submit" value="Thanh Toan"
Trang 16SQL = 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
Trang 17SELECT CASE Request("Action") CASE "Tiep Tuc Mua"
Trang 18CASE "Thanh Toan"
Soluong = Request("Soluong" & CStr(i))
Session("Masokhachhang") = -1 ' Khach hang da ton tai trong database, nhung hien tai thi khong ton tai
Trang 19height="62" alt="Bieutuong.gif (890 bytes)"></td>
<td width="79%"><p align="center"><img src="Quangcao/Giomuahang1.gif"
Trang 20<p><font color="#0000A0"><input type="checkbox"
name="<%Response.Write "Confirm" & CStr(i) %>" Value="Confirmed"
<p><font color="#0000A0"><input type="text"
name="<% Response.Write "Soluong" & CStr(i) %>"
Trang 22<td width="14%" align="center" colspan="2"><% if ICount > 0 then %> <p><input type="Submit" value="Thanh Toan"
<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 23Vitri = Instr(Vitri + 2, chuoi,"'")
' Kiem tra mot so cong viec If Action = "GOI" Then
Trang 24'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)
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> <%
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>"
<td width="50%" align="center" height="45" bgcolor="#800000"><strong><font face="VNI-Times" color="#FFFFFF"><big>Thông tin khách
Trang 27<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,"'")
Trang 28DateErrorMsg = "<TT><B><I>Ngay thanh toan phai sau ngay hien tai</I></B></TT><BR>"
Action = Left(UCase(Request("Action")),3) If Action = "GOI" Then
' Kiem tra mot so cong viec truoc khi If 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
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) "
Trang 29sql = sql & Request("Cuocphivanchuyen") & ", " sql = sql & Request("Thue") & ")" sql = sql & ID_HDB & ","
sql = sql & ARYshoppingcart(cartID_TB,i) & "," sql = sql & RS2("SERIAL_NUMBER") & ","
sql = sql & ARYshoppingcart(cartUnitGIABANLE,i) & ")"
Trang 30Do 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) & ")"
' 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) &")"
Trang 31<! Begin table inserted into table data cell > <! Begin form with first roa of data >
<td width="22%" colspan="2" align="top"><form
name="Thue" value="<%=IMucthue%>"><input type="hidden" name="Tongtientra" value="<%=ITongcong%>"><! Begin columm header row >
color="#FFFFFF"><strong>Người Mua Hàng (Shipping)</strong></font></td> <td width="280" height="35" bgcolor="#800000" align="center"><font
Trang 32set RSCus = Conn.Execute("Select * from khachhang where Masokhachhang = " &
<select NAME="CreditCard" size="1"> <option value=" ">Tien mat</option> <option value=" -">The tin dung </option> <option value=" -">Thu chuyen tien </option> <option value=" -">Dien chuyen tien </option> <option value=" -">Trai phieu</option>
<option value=" -">Sec </option>
công tác :</font></small><br>
<input type="text" name="txtNoicongtac" value="<%=RSCus("Noicongtac")%>" size="20"
maxlength="20"></font></strong></td>
<td width="280" height="19" valign="top" rowspan="2"><font color="#000040"><strong><font
face="VNI-Times"><small>Số hiệu của hình thức thanh toán:</small><br> <small>( credit card # :)</small></font></strong><br>
<input type="text" name="Socreditcard" value="<%Request("Socreditcard")%>" size="20"></font></td>
</tr>
Trang 34type="text" name="txtMaquanhuyen" value="<%=RSCus("Maquanhuyen")%>"
Do while not rs.eof
Response.Write "< input type=radio name=PTgiaohang value=" & rs("ID_PTGiaohang") & Checked & rs("TENPTGHANG") & "<BR>"
soá Thieát bò</strong></font></td>
<td width="50%" align="center" bgcolor="#800000"><font face="VNI-Times"
Trang 35<td width="50%" align="center" bgcolor="#800000"><font face="VNI-Times"
Trang 36Tenngoaite = "USD"
Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Session ("ConnectionString")
SQl ="Select Tygiangoaite From TYGIA where Tenngoaite = '" & Tenngoaite &"'" set RSgia = Conn.Execute(SQl)
Trang 37<td width="45%" colspan="4" align="top"><div align="right"><p><strong><font face="VNI-Times" color="#000040">Toång soá tieàn
type="submit" value="Goi Hoa Don" name="Action"></td> <td width="50%" colspan="2" align="center"><div
Trang 38Conn.Open Session("ConnectionString")
Set RSCustomer = Conn.Execute("SELECT * FROM Khachhang") %>
<form Action="CustomerDel.asp%20Method=" POST"> <input type="hidden" name="Masokhachhang" value="<%=RSCustomer("Masokhachhang")%>"><table
border="0" width="100%" cellspacing="2" cellpadding="5"> <! BEGIN column header row >
<! BEGIN first row of inserted product data > <% Do While Not RSCustomer.EOF %>
<tr>
<td width="16%" height="111"><% =RSCustomer("Hovaten") %>
</td>
Trang 40<form action="admin.asp" method="post">
<td width="27%" height="145"><font face="VNI-Times" size="4" color="#000080">Mật khẩu
cũ :</font><p><font face="VNI-Times" size="4" color="#000080">Mật khẩu mới:</font></p>
<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"
width="100" height="25" alt="l_nhap.gif (1788 bytes)"></a><a href="trangchinh.htm"></a> <img
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0"> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;
<title>CAP NHAT HIEU</title> </head>