Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 11 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
11
Dung lượng
162,98 KB
Nội dung
§Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn </tr> <tr> <td width="100%" bgcolor="#99CCCC" height="20"><div align="center"><center><table border="0" width="90%" cellspacing="0" cellpadding="0"> <tr> <td width="22%"> </td> <td width="78%"> </td> </tr> <tr> <td width="22%">Địa bàn</td> <td width="78%"> <% Call ListBox("DiaBan","MaVung","TenTinh","Select * From Tinh",0) %> </td> </tr> <tr> <td width="22%">Họ </td> <td width="78%"><input type="text" name="Ho" size="40"></td> </tr> <tr> <td width="22%">Tên</td> <td width="78%"><input type="text" name="Ten" size="40"></td> </tr> <tr> <td width="22%">Địa chỉ</td> §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn <td width="78%"><input type="text" name="DiaChi" size="40"></td> </tr> <tr> <td width="22%">Điện Thoại</td> <td width="78%"><input type="text" name="DienThoai" size="40"></td> </tr> <tr> <td width="22%"> </td> <td width="78%"> </td> </tr> </table> </center></div></td> </tr> <tr> <td width="100%" bgcolor="#99CCCC" height="21" align="center"><input type="submit" value="Tìm kiếm" name="MySubmit"> <input type="reset" value="Nhập Lại" name="B2"></td> </tr> </table> </td> </tr> </table> </center></div><p> </p> </form> <% End Sub '''''''''''''''''''''''''''''''''''''''''' Sub ListBox(Name,Ma,Ten,SQL,Cur) Cur=Cstr(Cur) §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn rs.Open SQL,Conn %><select name='<%=Name%>'><option value=''></option><% Do While not rs.Eof %><option value='<%=rs(Ma)%>'<% if rs(Ma)=Cur Then Response.write(" Selected") End if %>><%=rs(Ma)%>: <%=rs(Ten)%></option><% rs.MoveNext Loop Response.write("</select>") rs.close End Sub '''''''''''''''''''''''''''''''''''''''''' Sub ListBoxTrang(Name,num,cur,Submit) Dim i %><select name='<%=Name%>' style='font-family: .VnTime; font-size=12pt'<% If Submit Then Response.write(" onChange='submit()'>") Else Response.write(">") End if For i=1 to num %><option value='<%=i%>'<% If i=cur Then Response.write(" selected") End if %>><%=i%></option><% Next ResPonse.write("</select>") End Sub §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn '''''''''''''''''''''''''''''''''''''''''' Function MyFilter(vMaVung,vHo,vTen,vDiaChi,vSDT) Dim strTemp strTemp="" if vMaVung<>"" then strTemp=strTemp+" And MaVung='"+vMaVung+"'" end if if vHo<>"" then strTemp=strTemp+" And InStr(Ho,'"+vHo+"')" end if if vTen<>"" then strTemp=strTemp+" And Ten='"+vTen+"'" end if if vDiaChi<>"" then strTemp=strTemp+" And InStr(DiaChi,'"+vDiaChi+"')" end if if vSDT<>"" then strTemp=strTemp+" And SoDienThoai='"+vSDT+"'" end if MyFilter=strTemp end Function '''''''''''''''''''''''''''''''''''''''''' Function ShowData(Query,CurrentPage,Selected) Dim i set RsTemp= server.CreateObject("ADODB.recordset") 'RsTemp.CursorLocation=3 'RsTemp.PageSize=2 RsTemp.open Query,Conn 'i=0+CurrentPage 'CurrentPage=1 'CurrentPage=i 'RsTemp.AbsolutePage = CurrentPage §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn i=0 Do while Not RsTemp.Eof 'And RsTemp.AbsolutePage=CLng(CurrentPage) i=i+1 %><tr><td align=center><%=i%></td><% %><td align='center'><input type='checkbox' name='Cb(<%=RsTemp.Fields("Id")%>)' value='1'></td><% if Cint(Selected)=RsTemp.Fields("Id") then %><td align='center'><input type='radio' name='Rb' value='<%=RsTemp.Fields("Id")%>' onclick='submit()' checked></td><% else %><td align='center'><input type='radio' name='Rb' value='<%=RsTemp.Fields("Id")%>' onclick='submit()'></td><% end if %><td align='left'><%=RsTemp.Fields("Ho")+" "+ RsTemp.Fields("Ten")%></td> <td align='left'><%=RsTemp.Fields("SoDienThoai")%></td> <td align='left'><%=RsTemp.Fields("MaVung")%></td><% RsTemp.MoveNext Loop Response.write("</table>") ShowData=RsTemp.PageCount RsTemp.close Set RsClose=nothing End Function %> Mã nguồn trang tìm kiếm <! #include file=Connection.inc > §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn <% Header FormTimKiem() Footer %> <! #include file=Lib.asp > Mã nguồn trang in kết quả tìm kiếm <! #include file=Connection.inc > <% 'Dim CurrentPage DiaBan=Trim(Request("DiaBan")) Ho=Trim(Request("Ho")) Ten=Trim(Request("Ten")) DiaChi=Trim(Request("DiaChi")) DienThoai=Trim(Request("DienThoai")) Query="Select * from SoDanhBa Where True" Query=Query+MyFilter(DiaBan,Ho,Ten,Diachi,DienThoai) 'Response.write Query rs.CursorLocation=3 'rs.PageSize=2 rs.open Query, Conn 'NumPage= rs.PageCount Header() 'Response.write rs.RecordCount %> <blockquote> <p><font face=".VnArialH" size="5" color="#000080"><strong>Kết quả tìm kiếm</strong></font></p> §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn </blockquote> <% if rs.RecordCount>0 then %> <FORM METHOD=POST ACTION=""> <table border="0" width="100%" bgcolor="#008080" cellspacing="0" cellpadding="0" height="34"> <tr> <td width="80%" height="34"><font color="#FFFFFF"><strong> Tìm thấy <%=rs.RecordCount%> kết quả </strong></font></td> </tr> </table> <table border="0" width="100%" bgcolor="#008080" cellspacing="0" cellpadding="0"> <tr> <td width="100%"> <table border="0" width="100%" cellspacing="1"> <% rs.MoveFirst i=0 'rs.AbsolutePage=CLng(Page1) Do While not rs.Eof 'And rs.AbsolutePage=CLng("1") i=i+1 %> <tr> <td width="5%" bgcolor="#FFFFFF" align="center"><font color="#800000"><%=i%></font></td> <td width="75%" bgcolor="#FFFFFF"><font color="#0000FF"><strong> §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn <%=rs("Ho")%><%=" "%><%=rs("Ten")%></strong></font><br> <%=rs("DiaChi")%></td> <td width="21%" bgcolor="#FFFFFF" align="center"><font color="#FF0000"><strong>(<%=rs("MaVung")%>)<%=rs("SoDien Thoai")%></strong> </font></td> </tr> <% rs.MoveNext Loop %> </table> </td> </tr> </table> <table border="0" width="100%" bgcolor="#008080" cellspacing="0" cellpadding="0" height="34"> <tr> <td width="80%" height="34"><font color="#FFFFFF"><strong> Tìm thấy <%=rs.RecordCount%> kết quả </strong></font></td> </tr> </table> </FORM> <% else %> <br><br><center> §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn <b><font face="VnArial" size="5" color="#FF0000">Không tìm thấy kết quả</font></b> <center> <% end if Footer() rs.Close %> <! #include file=Lib.asp > Mã nguồn form thêm <! #include file=Connection.inc > <% SoDienThoai=Trim(Request("SoDienThoai")) MaVung=Request("MaVung") Ho=Trim(Request("Ho")) Ten=Trim(Request("Ten")) DiaChi=Trim(Request("DiaChi")) Page=Int(Request("Page")) NameButton="Nhập mới" ErrorStr="" if Trim(Request("MySubmit"))="Nhập mới" then if SoDienThoai<>"" and MaVung<>"" and Ho<>"" and Ten<>"" and DiaChi<>"" then Query="INSERT INTO SoDanhBa(SoDienThoai,Ho,Ten,DiaChi,MaVung) VALUES('" & _ +SoDienThoai+"','"+ Ho + "','"+ Ten +"','"+ DiaChi +"','"+ MaVung +"')" Conn.Execute Query 'Response.write(Query) §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn SoDienThoai="" MaVung="" Ho="" Ten="" DiaChi="" else ErrorStr="Bạn cha nhập đủ thông tin" end if end if if Trim(Request("MySubmit"))="Ghi Sửa" then if SoDienThoai<>"" and MaVung<>"" and Ho<>"" and Ten<>"" and DiaChi<>"" then Query="Update SoDanhBa Set SoDienThoai='"+SoDienThoai+"',Ho='"+Ho+ "',Ten='"+Ten+"',DiaChi='"+DiaChi+"',MaVung='"+MaVung+"' Where Id="+Request("Rb") Conn.Execute Query 'Response.write(Query) SoDienThoai="" MaVung="" Ho="" Ten="" DiaChi="" NameButton="Nhập Mới" else ErrorStr="Bạn cha nhập đủ thông tin" end if end if if Trim(Request("MySubmit"))="Xóa" then rs.Open "Select Id From SoDanhBa", Conn . width="78%"> <% Call ListBox("DiaBan","MaVung","TenTinh","Select * From Tinh",0) %> </td> </tr> <tr> <td width="22%">Họ. face=".VnArialH" size="5" color="#000080"><strong>Kết quả tìm kiếm</strong></font></p> §Ò ¸n M«n häc Sinh Viªn : TrÇn Trung ThuËn </blockquote>. height="34"><font color="#FFFFFF"><strong> Tìm thấy <%=rs.RecordCount%> kết quả </strong></font></td> </tr> </table>