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
Customers.txt.</pre>
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 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' 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)
' 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
<title>Asp Computer Menu</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Border" content="none">
</tr>
<tr>
<td width="100%" height="26"><a href="Thongtin/Huongdan.asp"
target="_top"><img
Trang 4src=" /Quangcao/Hdmuahang.gif" alt="Hdmuahang.gif (316 bytes)" width="161"height="24"></a></td>
<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>
Trang 5<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"
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><%
RandomizeSotieude= 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>
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
</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> </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>
Trang 9target="_top"><img src=" /LoaiThietbi/Hdd.gif" width="126" height="22"alt="Hdd.gif "></a></td>
Trang 10Session("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 = 0For i=1 to iCount
If ARYshoppingcart(cartID_TB,i) = RSProduct("ID_TB") Then
flag = 1End 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) = 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 If
End If
Trang 11SELECT 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
ARYshoppingcart(cartItemSoluong,i) = 1End If
ARYshoppingcart(x,i) = ""
Next
n = iwhile 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") = ARYshoppingcart
Session("ItemCount") = ICount
Trang 12CASE "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) = 1End If
"select Noicongtac FROM Khachhang where Masokhachhang = "
& Masokhachhang & _
" and Hovaten = '" & Session("Hovaten") & "'")URL = "ShippingCus.asp"
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>
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) %>"
ARYshoppingcart(cartUnitGIABANSI,i) = 0Else
ThanhTien = (ARYshoppingcart(cartUnitGIABANSI,i) *ARYshoppingcart(cartItemSOLUONG,i))
ARYshoppingcart(cartUnitGIABANLE,i) = 0End if
Trang 15ISubtotal = 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 ifEnd if
<td width="14%" align="center" colspan="2"><% if ICount > 0 then %>
<p><input type="Submit" value="Thanh Toan"
Trang 16SQL = 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 = 1End If
Trang 17ARYshoppingcart(cartItemSOLUONG,ICount) = 1
ARYshoppingcart(cartUnitGIABANSI,ICount) = RSProduct("GIABANSI")ARYshoppingcart(cartUnitGIABANLE,ICount) = RSProduct("GIABANLE")ARYshoppingcart(cartID_TB,ICount) = RSProduct("ID_TB")
SELECT CASE Request("Action")
CASE "Tiep Tuc Mua"
Trang 18n = n + 1wend
CASE "Thanh Toan"
Soluong = Request("Soluong" & CStr(i))
Trang 19height="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>
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
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 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") & ")"
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
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) & ")"
Conn.Execute(sql)RS2.EditModeRS2.Onsale = FalseRS2.update
k = k + 1Loop
' 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)
'136
' 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
Trang 32set RSCus = Conn.Execute("Select * from khachhang where Masokhachhang = " &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"
Trang 34type="text" name="txtMaquanhuyen" value="<%=RSCus("Maquanhuyen")%>"size="5"
Do while not rs.eof
Response.Write "< input type=radio name=PTgiaohang value=" &
rs("ID_PTGiaohang") & Checked & rs("TENPTGHANG") & "<BR>"
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á
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 37type="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 >
<td width="17%" height="19" align="center"
<! 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">
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;
CHARSET=ISO-8859-1">
<title>CAP NHAT HIEU</title>
</head>