Lập trình với ASP

Một phần của tài liệu Cty CPTM Và Phát Triển Công Nghệ Thành Phát (Trang 34)

II. Sơ đồ dòng dữ liệu nghiệp vụ:

1.4Lập trình với ASP

1.4.1 Khai báo biến.

- Không bắt buộc nhưng nên khai báo để kiểm soát và bắt lỗi. - Nên sử dụng <% Option Explicit %> ở ngay đầu mỗi tệp ASP. - Cú pháp: Dim biến 1, biến 2…

- Để khai báo mảng:

i. Dim a(10) : chỉ số chạy từ 0->10 do đó có 11 phần tử. ii. Khi khai báo nên sử dụng các tiền tố:

Dạng dữ liệu Tiền tố (prefix)

Boolean Bln Byte Byt Double Dbl Integer Int Long Lng Object Obj String Str ADO command Cmd ADO connection Cnn ………..

1.4.2 Khai báo hằng số.

CONST tên hằng= giá trị

1.4.3 Các đối tượng xây dựng sẵn trong ASP.

Trong ASP có 5 đối tượng phục vụ cho việc sử dụng toàn bộ. + Request: Lấy thông tin từ User

+ Response: Gửi thông tin từ Server tới User.

+ Server: Dùng để điều khiển IIS

+ Session: Dùng để lưu trữ các thông tin như các cài đặt, thay đổi cho một phiên làm việc hiện thời của User.

+ Application: Dùng để chia sẻ các thông tin cấp ứng dụng và điều khiển các thiết lập cho toàn bộ quá trình chạy ứng dụng

1.5 Cấu trúc điều khiển lệnh và Hàm.1.5.1 Các cấu trúc điều khiển. 1.5.1 Các cấu trúc điều khiển.

A. Cấu trúc điều kiện IF..THEN..ELSE..IF

Cú pháp: <%

If <Điều kiện 1> then <Các câu lệnh> Else

If <Điều kiện 2> then <Các câu lệnh> End if

End if %>

Ngoài ra có thể sử dụng cấu trúc IF.. THEN. . . . ELSEIF. . . END IF

<%

If <Điều kiện 1> then <Các câu lệnh 1>

ElseIf <Điều kiện 2> then <Các câu lệnh 2> Else

<Các câu lệnh 3> End if

%>

B. Cấu trúc lựa chọn select case…end select Cú pháp:

<%

Select Case <tenbien> Case <gia tri 1>

<Nhóm lệnh 1> Case <gia tri 2>

<Nhóm lệnh 2> Case <gia tri n> (adsbygoogle = window.adsbygoogle || []).push({});

<Nhóm lệnh n> Case Else

Ví dụ: Hiện ngày giờ trên máy chủ và cho biết hôm nay là thứ mấy?

C. Cấu trúc lặp tuần tự for…next.

Dùng để lặp với số lần đã biết, tuy nhiên ta có thể ngắt bằng lệnh EXIT FOR.

Cú pháp:

<%

FOR <tenbien>=<giatridau> TO <Giatribien> STEP <Buoc nhay> NEXT %> D. Các Cấu trúc lặp . D.1 DO WHILE….LOOP. Cú pháp: <% Do while <Dieukien> <Các cau lenh> Loop %> D.2 WHILE….wend. Cú pháp: <% While <Dieukien> <Các cau lenh> Wend %> D.3 DO….Loop until Cú pháp: <% DO <Các cau lenh> Loop until <Điều kiện> %>

1.6 Một số hàm hữu dụng trong ASP.1.6.1 Các Hàm xử lý văn bản 1.6.1 Các Hàm xử lý văn bản

i. TRIM(xâu as string): Bỏ khoảng trắng hai đầu kí tự

ii. LEFT(Xâu as string, n as interger): Lấy bên trái xâu n kí tự. iii. RIGHT(Xâu as string, n as interger): Lấy bên phải xâu n kí

tự.

iv. LCASE(Xâu as string) : Chuyển xâu về chữ thường v. UCASE(Xâu as string) : Chuyển xâu về chữ hoa

vi. MID(xâu as string, n1, n2): Lấy n2 kí tự trong xâu bắt đầu từ vị trí n1.

vii. CSTR(Biến): Hàm chuyển đổi biến thành kiểu string viii. Hàm JOIN/SPLIT(Xâu as string, kí tự ngăn cách): Sẽ

Nối/Cắt xâu thành một/nhiều đoạn bằng cách xác định kí tự ngăn cách ở trên và cho các đoạn đó lần lượt vào một mảng.

Ví dụ: <% x=”Hà nội;Hải phòng; TPHCM” y=split(x,”;”) Response.write y(0) ‘y(0)=”Hà nội” %>

ix. SQR(n): Căn bậc hai của n x. INT(n) : Lấy phần nguyên n xi. MOD : Phép đồng dư

xii. Toán tử \ : Chia nguyên

xiii. Round(số, n) : Làm tròn số với n chữ số thập phân xiv. RND(): Trả về số ngẫu nhiên bất kì trong khoảng [0,1]

1.6.3 Các hàm về ngày tháng thời gian.

i. now()

ii. date()

II. Thiết kế một số giao diện chính của hệ thống

Đối với một hệ thống hỗ trợ bán hàng qua mạng thì việc thiết kế giao diện đóng góp một phần rất quan trọng bởi vì ngoài việc thực chức năng chính là bán hàng nó còn đóng góp một phần rất lớn trong việc quảng bá sản phẩm, nâng cao chất lượng thương hiệu và uy tín trách nhiệm của Công ty đối với khách hàng… Vì vậy giao diện cần phải được thiết kế thân thiện, đẹp mắt dễ sử dụng. Thể hiện được tính chuyên nghiệp của công tác Thương mại điện tử.

Một số giao diện chính của hệ thống Website hỗ trợ bán hàng qua mạng:

Khi một khách hàng ghé thăm Website của Công ty . Hệ thống sẽ kết nối và hiển thị trang chủ của Website có giao diện như (Hình 4.1.1)

(Hình 4.1.1)

Tại đây một giao diện trực quan của hệ thống sẽ được hiển thị, bao chứa các liên kết và tất cả các chức năng của hệ thống đều có thể bắt đầu từ trang chủ này: Nếu là một khách hàng mới ghé thăm lần đầu tiên bạn có thể lướt các trang liên kết, và xem thông tin quảng cáo của các sản phẩm của công ty, những sản phẩm mới ra hay sản phẩm nào bán chạy nhất hiện nay. Để có thêm các chức năng , tiện ích khác của hệ thống khách có thể đăng ký là một thành viên, bằng cách điền các thông tin cá nhân vào Form của trang đăng ký như (Hình 4.1.2)

(Hình 4.1.2)

Khi đă có một tài khoản được chấp nhận , tức là việc đăng ký của khách đã thành công. Khách có thể dùng tài khoản này để đăng nhập vào hệ thống. (Hình 4.1.3) Tài khoản này có thể sử dụng được cho cả các lần ghé thăm sau. (adsbygoogle = window.adsbygoogle || []).push({});

(Hình 4.1.4)

Đăng nhập rồi hệ thống sẽ tự động liên kết đến trang chủ . Khách có thể xem danh mục của tất cả các loại sản phẩm của công ty (Hình 4.1.5) Ví dụ như: các loại Chip – CPU mà công ty có bán.

(Hình 4.1.5)

Khi khách không nhớ rõ tên của một sản phẩm nào đó , khách có thể nhập một vài ký tự liên quan vào Text tìm kiếm và thực hiện hiện Serach Danh sách các mặt hàng có chứa từ khóa tìm kiếm đó sẽ được hiển thị từ đó khách có thể lựa chọn ra sản phẩm mà mình quan tâm. Nếu việc xác định thông tin của sản phẩm cần còn khó khăn khách có thể vào liên kết Tìm kiếm chi tiết . Để tìm kiếm một cách cụ thể hơn (Hình 4.1.6).

(Hình 4.1.6) Kết quả tìm kiếm sẽ được hiển thị (Hình 4.1.7)

(Hình 4.1.7)

Có được thông tin của sản phẩm mong muốn khách có thể xem chi tiêt sản phẩm đó như trên (Hình 4.1.8)

(Hình 4.1.8)

Tại đây khách có thể thực hiện lựa chọn và mua hàng bằng việc đưa hàng vào giỏ hàng , khách hàng có thể mua thêm nhiều mặt hàng khác nhau, có thể xóa hay sửa số lượng mua một mặt hàng nào đó mà mình chưa yên tâm hay không có đủ kinh phí để mua tất cả . Giỏ hàng có giao diện như (Hình 4.1.9).

(Hình 4.1.9)

Nếu quyết định mua hàng khách có thể thực hiện việc lập phiếu mua. Ngoài ra khách có thể xem được thông tin cá nhân đã đăng ký của mình (Hình 4.1.10)

(Hình 4.1.10)

Khi thành viên là ADMIN (Người có quyền quản trị) thì sẽ được cấp các quyền có thể tác động đến Cơ Sở Dữ Liệu (CSDL) – Thêm, sửa , Xóa trên một CSDL nào đó, hay là việc xem thông tin của các thành viên khác …

III. Một số mudule chính trong hệ thống3.1 Function.asp 3.1 Function.asp <% filename = "..\data\data_tp.mdb" set conn=server.CreateObject("adodb.connection") conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & server.MapPath(filename) conn.CursorLocation=3 conn.Open sub SetRecord(sql,conn,rs) set rs=Server.CreateObject("ADODB.recordset") rs.CursorLocation=3 rs.Open sql,conn end sub sub ngatketnoi(rs,conn) rs.close

set rs=nothing set conn=nothing end sub

%>

3.2 Hienthi.asp

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/style.css" rel="stylesheet" type="text/css">

<!-- #include file = "Function.asp" -->

<table border="1" width="100%" cellspacing="1" cellpadding="0" id="table1" style="border-collapse: collapse">

<tr>

<td bgcolor="#92D3C7"><img src = "<%Response.Write Server.MapPath("../Images/icon_home.gif")%>"></td>

<td bgcolor="#92D3C7">

<p align="right"><%if session("MaThanhVien")=0 then%>Welcome, <b>Guest

&nbsp;&nbsp;&nbsp;</b><%else%>Welcome, <b>< %=session("strUserName")%>&nbsp;</b> <a href="Logout.asp">

[Thoát]</a><%end if%> </td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td colspan="2">

<table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#0099FF" id="table2" style="border-collapse: collapse">

<tr>

<td width="3%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>STT</b></font></td> (adsbygoogle = window.adsbygoogle || []).push({});

<td width="42%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Tên Sản Phẩm</b></font></td>

<td width="13%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Kho hàng</b></font></td> <td width="9%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Giá (USD)</b></font></td> <td width="13%" align="center" bgcolor="#D4D4D4"

<font color="#CC3300"><b>Giá (VNĐ)</b></font></td> <td width="11%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Bảo Hành</b></font></td> <td align="center" bgcolor="#D4D4D4" height="27" width="8%"><font color="#CC3300"><b>

Chọn Mua</b></font></td> </tr>

<%

maloai = Request.QueryString("maloai")

sql = "SELECT * FROM Loai WHERE Maloai = "& maloai call SetRecord(sql,conn,rs_loai)

Do While NOT rs_loai.EOF

sql_sp = "SELECT * FROM Hanghoa WHERE Maloai = "& rs_loai("MaLoai")

call SetRecord(sql_sp,conn,rs_sp) %>

<tr>

<td align="center"colspan="7"><b> <font color="Black" size = "3.5" face = "Arial">

Danh sách </font><font color = blue><% Response.Write rs_loai("Tenloai")%></font></b></td>

</tr> <%

stt = 0

Do While NOT rs_sp.EOF stt = stt + 1

%>

<tr onmouseover="this.style.backgroundColor='#FFFFCC';" onmouseout="this.style.backgroundColor='#FFFFFF'">

<td width="3%" height="32"align = center><% Response.Write stt %></td>

<td width="42%" height="32"><a href = "ChitietSanpham.asp?Mahang=<%=rs_sp("Mahang")%>"><%Response.Write

rs_sp("Tenhang")%></a></td>

<td width="13%" align = center height="32" ><%If rs_sp("Tonkho") > 0 THEN Response.Write "Còn hàng" ELSE Response.Write "H&#7871;t hàng"%></td>

<td width="9%" align =right height="32"><font color="Red"><b><%Response.Write "$ " & rs_sp("Dongia")%>&nbsp;</b></font></td>

<td width="13%" height="32" align = right><font color="Red"><%Response.Write rs_sp("Dongia")*tygia%></font></td>

<td width="11%" align =right height="32" >< %Response.Write rs_sp("Baohanh")%></td>

<img class = "giohang" src=<%Response.Write Server.MapPath("../Images/shoping.gif")%> border="0" align="absmiddle"></a></td> (adsbygoogle = window.adsbygoogle || []).push({});

</tr> <% rs_sp.MoveNext Loop rs_loai.MoveNext Loop rs_loai.Close

Set rs_loai = nothing rs_sp.Close Set rs_sp = nothing %> </table> </td> </tr> </table> 3.3 Xacnhandangky.asp

<!--#include file = "Function.asp"--> <head>

<meta http-equiv="Content-Language" content="en-us"> </head>

<%

Dim thongbao Sub LoiDangky() %>

<div align = center>

<table border="1" width="60%" cellspacing="0" cellpadding="0" style="border-collapse: collapse">

<tr>

<td height="32" bgcolor="#92D3C7" width="34%"> <p align="left">

<img src = "<%Response.Write Server.MapPath("../Images/icon_home.gif")%>" align="left"><b>&nbsp;

<a href="trangchu.asp">HOME</a></b></p></td> <td height="32" bgcolor="#92D3C7" width="65%"> <b>L&#7894;I &#272;&#258;NG KÝ</b></td> </tr>

<tr>

<td height="108" align = center valign = top colspan="2">< %Response.Write thongbao%></td>

<tr>

<td colspan="2"> <p align="center">

<img with = "40" height = "40" border="0" src="<%Response.Write Server.MapPath("../images/back.jpg")%>" style="cursor:hand" onclick="javascript:history.back()" align="center"></td> </tr> </table> </div> <% End Sub %> <% hodem = Trim(Request.Form("hodem")) ten = Trim(Request.Form("tenthanhvien")) tendangnhap = Trim(Request.Form("tendangnhap")) matkhau = Trim(Request.Form("matkhau")) matkhau1 = Trim(Request.Form("matkhau1")) gioitinh = Trim(Request.Form("goitinh"))

NgaySinh = Trim(Request.Form("Thang") + "/" + Request.Form("Ngay") + "/" + Request.Form("Nam")) diachi = Trim(Request.Form("diachi")) dienthoai = Trim(Request.Form("dienthoai")) email = Trim(Request.Form("email")) nghenghiep = Trim(Request.Form("nghenghiep")) hinhanh = Trim(Request.Form("hinhanh")) If hodem = "" Then

thongbao = "B&#7841;n ch&#432;a nh&#7853;p H&#7885; &#272;&#7879;m !" call LoiDangky()

Else

If ten = "" Then

Thongbao = "B&#7841;n ch&#432;a nh&#7841;p Tên thành viên !" call LoiDangky()

Else

If tendangnhap = "" Then

Thongbao = "B&#7841;n ch&#432;a nh&#7853;p Tên d&#259;ng nh&#7853;p !"

call LoiDangky() Else

If matkhau <> matkhau1 Then

Thongbao = "M&#7853;t kh&#7849;u và Xác nh&#7853;n m&#7853;t kh&#7849;u không gi&#7889;ng nhau !"

call LoiDangky() Else

if not rs.bof then (adsbygoogle = window.adsbygoogle || []).push({});

call ngatketnoi(rs,conn)

Response.Redirect("Thongbao.asp?Thongbao=3") end if

sql = "INSERT INTO thanhvien

(hodem,tenthanhvien,tendangnhap,matkhau,gioitinh,ngaysinh,diachi,dienthoai,email,nghen ghiep,hinhanh) VALUES ('"

sql = sql & hodem & "','" sql = sql & ten & "','"

sql = sql & tendangnhap & "','" sql = sql & matkhau & "','" sql = sql & gioitinh & "','"

sql = sql & ngaysinh & "','" sql = sql & diachi & "','"

sql = sql & dienthoai & "','" sql = sql & email & "','"

sql = sql & nghenghiep & "','" sql = sql & hinhanh & "')"

conn.Execute(sql) conn.close

Set conn = nothing End If End If End If End If %> 3.4 Loguot.asp <% session.abandon Session("User")="False" Session("ID")=0 Session("strUserName")="" Session("MaThanhVien")=0 Response.Redirect("Trangchu.asp") %> 3.5 Timkiem.asp

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/style.css" rel="stylesheet" type="text/css">

<% Dim tenhang Dim Maloai Dim dem tenloai = Request.Form("Tenloai") xuatxu = Request.Form("Xuatxu") if (Request.Form("tenhang") <> "") then tenhang = Request.Form("tenhang")

sql_loai = "SELECT * FROM Loai WHERE Tenloai = '" & Tenloai & "'" call SetRecord(sql_loai,conn,rs_loai)

If NOT rs_loai.EOF Then

maloai = rs_loai("Maloai") End If

%>

<div align = center >

<table border="1" width="100%" cellspacing="1" cellpadding="0" id="table1" style="border-collapse: collapse"> <tr> <td bgcolor="#92D3C7"><img src = "<%Response.Write Server.MapPath("../Images/icon_home.gif")%>"></td> </tr> <tr>

<td valign = "center" align="center" ><B>KẾT QUẢ TÌM KIẾM</B></td>

<tr>

<td valign = "center" align="left" >Tìm với từ khoá: Tên hàng - <font color = colpal><B><%Response.Write tenhang%></B>

</font>, Xuất xứ - <font color = colpal><B><%Response.Write xuatxu %></B></font>

</font>, Thuộc loại - <font color = colpal><B><%Response.Write tenloai %></B></font>

</td> </tr>

<tr>

<td>

<table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#0099FF" id="table2" style="border-collapse: collapse">

<tr>

<td width="3%" align="center" bgcolor="#D4D4D4" height="27"> (adsbygoogle = window.adsbygoogle || []).push({});

<font color="#CC3300"><b>STT</b></font></td> <td width="42%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Tên Sản Phẩm</b></font></td>

<td width="13%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Kho hàng</b></font></td> <td width="8%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Giá (USD)</b></font></td> <td width="13%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Giá (VNĐ)</b></font></td> <td width="11%" align="center" bgcolor="#D4D4D4" height="27">

<font color="#CC3300"><b>Bảo Hành</b></font></td> <td align="center" bgcolor="#D4D4D4" height="27" width="8%">

<font color="#CC3300"><b>Xuất xứ</b></font></td> </tr>

<%

sql = "SELECT * FROM Hanghoa WHERE "

sql = sql & " tenhang like " & "'%"& tenhang & "%' " sql = sql & "AND Xuatxu like " & "'%"& xuatxu & "%' " sql = sql & "AND Maloai = " & Maloai

call SetRecord(sql,conn,rs_tim) dem = 0

Do While NOT rs_tim.EOF dem = dem + 1

%>

</b></font></td>

<td align="center"colspan="7"><font color="Black" size = "3.5" ><b></td>

</tr>

<tr onmouseover="this.style.backgroundColor='#FFFFCC';" onmouseout="this.style.backgroundColor='#FFFFFF'">

<td width="3%" height="32"align = center>< %Response.Write dem%></td>

<td width="42%" height="32"><a href =

"ChitietSanpham.asp?Mahang=<%=rs_tim("Mahang")%>"><%Response.Write rs_tim("Tenhang")%></a></td>

<td width="13%" align = center height="32" ><%If rs_tim("Tonkho") > 0 THEN Response.Write "Còn hàng" ELSE Response.Write "H&#7871;t hàng"%></td>

<td width="8%" align =right height="32"><font

color="Red"><b><%Response.Write "$ " & rs_tim("Dongia")%>&nbsp;</b></font></td> <td width="13%" height="32"><%Response.Write "$ " & rs_tim("Dongia")*Tygia%></td>

<td width="11%" align =right height="32" >< %Response.Write rs_tim("Baohanh")%></td>

<td align="center" height="32" width="8%"> <%Response.Write rs_tim("Xuatxu")%></td> </tr> <% rs_tim.MoveNext Loop If dem = 0 Then

Response.Redirect("Thongbao.asp?Thongbao=8") End If

rs_tim.Close

Set rs_tim = nothing Else Response.Redirect("Thongbao.asp?Thongbao=4") End If %> </table> </td> </tr> </table> </div>

<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table3" height="56"> (adsbygoogle = window.adsbygoogle || []).push({});

<tr>

<td>&nbsp;</td> <td width="401">

<img border="0" src="<%Response.Write Server.MapPath("../images/back.gif") %>" style="cursor:hand" onclick="javascript:history.back()" align="center"></td>

</tr> </table>

3.6 Thuchiennhaphang.asp

<!--#include file = "Function.asp"--> <%

quycach = Trim(Request.Form("quycach")) loaihang = Trim(Request.Form("loaihang")) hangsanxuat = Trim(Request.Form("hangsanxuat")) xuatxu = Trim(Request.Form("xuatxu")) baohanh = Trim(Request.Form("baohanh")) ngaynhap = Trim(Request.Form("ngaynhap")) soluong = Request.Form("soluongnhap") dongia = Request.Form("dongia") hinhanh = Trim(Request.Form("hinhanh"))

sql_loai = "SELECT * FROM Loai WHERE Tenloai = '" & loaihang & "'" call SetRecord(sql_loai,conn,rs_loai)

If NOT rs_loai.BOF Then

maloai = rs_loai("Maloai") End If

sql_hsx = "SELECT * FROM HangSx WHERE Tenhangsx = '" & hangsanxuat & "'"

call SetRecord(sql_hsx,conn,rs_hsx) If NOT rs_hsx.BOF Then

mahangsx = rs_hsx("Mahangsx") End If

'If tenhang = "" Then %>

<%

Sub loinhap() %>

<div align = center>

<table border="1" width="60%" cellspacing="0" cellpadding="0" style="border-collapse: collapse">

<tr>

<td height="32" bgcolor="#92D3C7" width="34%"> <p align="left">

<img src = "<%Response.Write Server.MapPath("../Images/icon_home.gif")%>" align="left"><b>&nbsp;

<a href="trangchu.asp">HOME</a></b></p></td> <td height="32" bgcolor="#92D3C7" width="65%"> <b>L&#7894;I KHI NH&#7852;P HÀNG</b></td> </tr>

<tr>

<td height="108" align = center valign = top colspan="2"><% Response.Write "B&#7841;n Ph&#7843;i nh&#7853;p Tên cho s&#7843;n ph&#7849;m !"%></td>

</tr> <tr>

<p align="center">

<img with = "40" height = "40" border="0" src="<%Response.Write Server.MapPath("../images/back.jpg")%>" style="cursor:hand" onclick="javascript:history.back()" align="center"></td> </tr> </table> <% End Sub %><% ' Else

sql_nhapsp = "INSERT INTO Hanghoa

(tenhang,xuatxu,maloai,Mahangsx,quycach,Anh,Baohanh,Ngaynhap,Soluongnhap,dongia) VALUES ('"

sql_nhapsp = sql_nhapsp & tenhang & "','" sql_nhapsp = sql_nhapsp & xuatxu & "'," sql_nhapsp = sql_nhapsp & maloai & "," (adsbygoogle = window.adsbygoogle || []).push({});

sql_nhapsp = sql_nhapsp & mahangsx & ",'" sql_nhapsp = sql_nhapsp & quycach & "','" sql_nhapsp = sql_nhapsp & hinhanh & "','" sql_nhapsp = sql_nhapsp & Baohanh & "','" sql_nhapsp = sql_nhapsp & Ngaynhap & "'," sql_nhapsp = sql_nhapsp & soluong & "," sql_nhapsp = sql_nhapsp & Dongia& ")"

conn.Execute(sql_nhapsp) conn.close

Set conn = nothing 'End If

Response.Redirect("DanhsachSP.asp?maloai="&maloai) %>

3.7 Xoahang.asp

<% Session.CodePage=65001 %> <!-- #include file = "Function.asp" --> <!-- #include file = "admin.asp" --> <%

If isNull(Request.QueryString("ID")) = True Or isNumeric(Request.QueryString("ID")) = False Then

Response.redirect "Message.asp?message=2" Else

Mahang=Request.QueryString("ID") End If

conn.execute(sql) conn.close set conn=nothing Response.Redirect("Message.asp?message=16" ) %> 3.8 Thuchiensuahang.asp

<!--#include file = "Function.asp"--> <% Dim Maloai Dim MahangSX Mahang = Request.QueryString("Mahang") Tenhang = Request.Form("Tenhang") Tenloai = Request.Form("Tenloai") Quycach = Request.Form("Quycach") TenHangSX = Request.Form("HangSX") Xuatxu = Request.Form("Xuatxu") Baohanh = Request.Form("Baohanh") Dongia = Request.Form("Dongia") SoluongNhap = Request.Form("SoluongNhap") Tonkho = Request.Form("Tonkho")

sql_loai = "SELECT * FROM Loai WHERE Tenloai = '"& Tenloai & "'" call SetRecord(sql_loai,conn,rs_loai)

If NOT rs_loai.EOF Then

Maloai = rs_loai("Maloai") End If

rs_loai.Close

sql_hangsx = "SELECT * FROM HangSX WHERE TenHangSX = '"& TenHangSX & "'" call SetRecord(sql_hangsx,conn,rs_hangsx)

If NOT rs_hangsx.EOF Then

MaHangSX = rs_hangsx("MahangSX") End If

rs_HangSX.Close

sql = "UPDATE Hanghoa SET Tenhang = '" sql = sql & Tenhang & "', Maloai = '"

sql = sql & Maloai & "', Quycach = '" sql = sql & Quycach & "', MahangSX = '" sql = sql & MahangSX & "', Xuatxu = '" sql = sql & Xuatxu & "', Baohanh = '" sql = sql & Baohanh & "', Dongia = '" sql = sql & Dongia & "', SoluongNhap = '" sql = sql & Soluongnhap & "', Tonkho = '"

sql = sql & Tonkho & "' WHERE Mahang = " & Mahang conn.Execute(sql)

conn.Close

Set conn = nothing

Response.Redirect("Thongbao.asp?Thongbao=15") %>

3.9 ThuchienGiohang.asp

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/style.css" rel="stylesheet" type="text/css">

<% Session.CodePage=65001 %> <!-- #include file = "Function.asp" -->

<table width="100%" border="1" cellspacing="0" cellpadding="0" height="429" bordercolor="#C0C0C0" style="border-collapse: collapse; border-top-width:0"> <tr background="images/3.GIF">

<td width="75%" height="19" style="border-right-color: #000080; border-right-width: 0;" valign =baseline bgcolor="#92D3C7" > (adsbygoogle = window.adsbygoogle || []).push({});

<img src = "<%Response.Write Server.MapPath("../Images/icon_home.gif")%>"

Một phần của tài liệu Cty CPTM Và Phát Triển Công Nghệ Thành Phát (Trang 34)