਍ഀ ਍ഀ View ASP Source code਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ
ASP Source Code਍ഀ

ASP File: ਍ഀ vbscript/ado/webaccess/opentb.asp

 ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ ਍ഀ
   ASP ਍ഀ Script ਍ഀ
   Comments ਍ഀ or Client-side Script
   HTML and ਍ഀ Text ਍ഀ
਍ഀ
਍ഀ <%@ ਍ഀ Language=VBScript ਍ഀ %>
<HTML>
<HEAD>
</HEAD>
<BODY ਍ഀ bgcolor=Lavender>
<%
bErr = false
mvNext = ਍ഀ false
mvPrev = false

If Request.Form("ticker").count > 0 ਍ഀ then
      set Session("webRd") = ਍ഀ Server.CreateObject("ADODB.RECORDSET")
      ਍ഀ Session("webRd").ActiveConnection = ਍ഀ Session("webConn")
      ਍ഀ Session("webRd").CursorLocation = 3
      ਍ഀ Session("webRd").CursorType = 2
      ਍ഀ Session("webRd").LockType = 2
      ਍ഀ Session("webRd").Source = "SELECT * FROM " & ਍ഀ Request.Form("ticker")
      ਍ഀ Session("webRd").Open
End If

set RS = Session("webRd")

mode = ਍ഀ CInt( Request.QueryString("mode") )
If mode = 1 ਍ഀ then
      direction = CInt( ਍ഀ Request.QueryString("direction") )

      select ਍ഀ case direction
      case ਍ഀ 1:
           If not RS.Eof ਍ഀ or not RS.Bof ਍ഀ then
                ਍ഀ RS.MoveFirst
           End ਍ഀ If
      case 2:
      ਍ഀ If not RS.BOF ਍ഀ Then
                ਍ഀ RS.MovePrevious
                ਍ഀ mvPrev = true
      End ਍ഀ If
      case ਍ഀ 3:
           If not RS.EOF ਍ഀ Then
                ਍ഀ RS.MoveNext
                ਍ഀ mvNext = true
           ਍ഀ End If
      case ਍ഀ 4:
           If not RS.Eof ਍ഀ or not RS.Bof ਍ഀ then
                ਍ഀ RS.MoveLast
           End ਍ഀ If
      end ਍ഀ select

      'Error Handling ਍ഀ
      If not RS.BOF or not RS.EOF ਍ഀ then
           If RS.EOF ਍ഀ and mvNext Then
           ਍ഀ RS.MoveLast
           ਍ഀ elseif RS.EOF ਍ഀ then
                ਍ഀ RS.Requery
           End ਍ഀ If

           If RS.BOF ਍ഀ and mvPrev Then
           ਍ഀ RS.MoveFirst
           ਍ഀ elseif RS.BOF ਍ഀ then
                ਍ഀ RS.Requery
           End ਍ഀ If
      End If
elseif mode = 2 ਍ഀ then
      'get edit information : ਍ഀ Insert,Update,Delete or Cancel
      operate = CInt( ਍ഀ Request.QueryString("operate") )

      select ਍ഀ case operate
      case 2: ਍ഀ 'Delete
           If ਍ഀ RS.RecordCount > 0 ਍ഀ then
                ਍ഀ RS.Delete
                ਍ഀ 'RS.MoveNext
                ਍ഀ RS.MovePrevious
                ਍ഀ if RS.RecordCount > 0 and RS.BOF ਍ഀ then
                     ਍ഀ RS.MoveFirst
                ਍ഀ end if
           End ਍ഀ If
      case 3: ਍ഀ 'Update
           if not ਍ഀ RS.EOF and not RS.EOF ਍ഀ then
                ਍ഀ for i = 0 to RS.Fields.Count - 1
      on error ਍ഀ resume ਍ഀ next

                     ਍ഀ fdType = ਍ഀ RS(i).type
                     ਍ഀ if IsNull(RS(i).value) ਍ഀ then
                          ਍ഀ fdValue = ਍ഀ ""
                     ਍ഀ else
                          ਍ഀ fdValue = ਍ഀ RS(i).value
                     ਍ഀ end ਍ഀ if

                     ਍ഀ name = "S" & ਍ഀ CStr(i)
                     ਍ഀ txtVal = ਍ഀ Request.Form(name)
                     ਍ഀ if IsNull(txtVal) or IsEmpty(txtVal) ਍ഀ then
                          ਍ഀ txtVal = ਍ഀ ""
                     ਍ഀ end ਍ഀ if

                     ਍ഀ if Server.URLEnCode(txtVal) <> Server.URLEnCode(fdValue) ਍ഀ then
                          ਍ഀ if Len(txtVal) = 0 ਍ഀ then
                               ਍ഀ RS(i) = ਍ഀ null
                          ਍ഀ else
                               ਍ഀ select case ਍ഀ fdType
                               ਍ഀ case 16, 2, 3, 20, 17, 18, 19, 21, 4, 5, 6, 14, 131, ਍ഀ 11
                                    ਍ഀ if IsNumeric(txtVal) ਍ഀ then
                                         ਍ഀ RS(i) = ਍ഀ txtVal
                                    ਍ഀ else
                                         ਍ഀ bErr = ਍ഀ true
                                         ਍ഀ msgErr = fdName & " must be a numeric data. Please go ਍ഀ back."
                                    ਍ഀ end ਍ഀ if
                               ਍ഀ case ਍ഀ else
                                    ਍ഀ RS(i) = ਍ഀ txtVal
                               ਍ഀ end ਍ഀ select
                          ਍ഀ end ਍ഀ if
                     ਍ഀ end ਍ഀ if
                ਍ഀ next
                ਍ഀ if bErr = false ਍ഀ then
                     ਍ഀ RS.Update
                ਍ഀ end ਍ഀ if
             ਍ഀ on error goto 0
           ਍ഀ end if
      case 5: 'Update for ਍ഀ addnew
         on error resume ਍ഀ next

           ਍ഀ RS.AddNew
           for i ਍ഀ = 0 to RS.Fields.Count - ਍ഀ 1
                ਍ഀ fdType = ਍ഀ RS(i).type

                ਍ഀ name = "S" & ਍ഀ CStr(i)
                ਍ഀ txtVal = ਍ഀ Request.Form(name)
                ਍ഀ if IsNull(txtVal) or IsEmpty(txtVal) ਍ഀ then
                     ਍ഀ txtVal = ਍ഀ ""
                ਍ഀ end ਍ഀ if

                ਍ഀ if Len(txtVal) <> 0 ਍ഀ then
                     ਍ഀ select case ਍ഀ fdType
                     ਍ഀ case 16, 2, 3, 20, 17, 18, 19, 21, 4, 5, 6, 14, 131, ਍ഀ 11
                          ਍ഀ if IsNumeric(txtVal) ਍ഀ then
                               ਍ഀ RS(i) = ਍ഀ txtVal
                          ਍ഀ else
                               ਍ഀ bErr = ਍ഀ true
                               ਍ഀ msgErr = fdName & " must be a numeric data. Please go ਍ഀ back."
                          ਍ഀ end ਍ഀ if
                     ਍ഀ case ਍ഀ else
                          ਍ഀ RS(i) = ਍ഀ txtVal
                     ਍ഀ end ਍ഀ select
                ਍ഀ end if
           ਍ഀ next
           if bErr = ਍ഀ false ਍ഀ then
                ਍ഀ RS.Update
                ਍ഀ RS.MoveLast
           ਍ഀ else
                ਍ഀ RS.CancelUpdate
           ਍ഀ end if
         on error goto ਍ഀ 0
      end select
End ਍ഀ If
%>


<%if bErr then ਍ഀ
      Response.write ਍ഀ msgErr
else%>


<form name=form1 Method=Post ਍ഀ Action="opentb.asp">
      ਍ഀ <CENTER><TABLE><TR>
<%      if mode = 1 ਍ഀ then%>
           ਍ഀ <TD>
                ਍ഀ <input type=button name=Browsebt value="Browse Mode" ਍ഀ disabled>
                ਍ഀ <input type=button name=Editbt value="Edit Mode" ਍ഀ onClick="ModeClick(2);">
           ਍ഀ </TD>
           ਍ഀ <TD ਍ഀ width=10> </TD>
           ਍ഀ <TD>
                ਍ഀ <input type=button name=MoveFirst value=" |<    " ਍ഀ onClick="MoveClick(1);">
                ਍ഀ <input type=button name=MovePrevious value=" <    " ਍ഀ onClick="MoveClick(2);">
                ਍ഀ <input type=button name=MoveNext value=" > " ਍ഀ onClick="MoveClick(3);">
                ਍ഀ <input type=button name=MoveLast value=" >| " ਍ഀ onClick="MoveClick(4);">
           ਍ഀ </TD>
           ਍ഀ </TR>
<%      elseif ਍ഀ mode = 2 ਍ഀ then%>
           ਍ഀ <TD>
                ਍ഀ <input type=button name=Browsebt value="Browse Mode" ਍ഀ onClick="ModeClick(1);">
                ਍ഀ <input type=button name=Editbt value="Edit Mode" ਍ഀ disabled>
           ਍ഀ </TD>
           ਍ഀ <TD ਍ഀ width=10> </TD>
           ਍ഀ <TD>
<%           ਍ഀ if operate = 1 ਍ഀ then%>
                ਍ഀ <input type=button name=Insertbt value="Insert" ਍ഀ disabled>
                ਍ഀ <input type=button name=Deletebt value="Delete" disabled>
<%           ਍ഀ else%>
                ਍ഀ <input type=button name=Insertbt value="Insert" ਍ഀ onClick="OperateClick(1);">
                ਍ഀ <input type=button name=Deletebt value="Delete" ਍ഀ onClick="OperateClick(2);">
<%           ਍ഀ end if
           if ਍ഀ operate = 1 ਍ഀ then%>

                ਍ഀ <input type=button name=Updatebt value="Update" ਍ഀ onClick="OperateClick(5);">
<%           ਍ഀ else%>
                ਍ഀ <input type=button name=Updatebt value="Update" ਍ഀ onClick="OperateClick(3);">
<%           ਍ഀ end ਍ഀ if%>
                ਍ഀ <input type=button name=Cancelbt value="Cancel" ਍ഀ onClick="OperateClick(4);">
           ਍ഀ </TD>
           ਍ഀ </TR>
<%      end ਍ഀ if%>
      ਍ഀ </TABLE>

      <TABLE border=0 ਍ഀ width=100%>
     
<%      for i = 0 to RS.Fields.Count - ਍ഀ 1
           set fd = ਍ഀ RS.Fields.Item(i)
           ਍ഀ if i mod 2 = 0 ਍ഀ then%>

           ਍ഀ <TR>
<%           ਍ഀ end ਍ഀ if%>
                ਍ഀ <TD width=20% align=center><strong><%=fd.Name%>:</strong></TD>
                ਍ഀ <TD width=30%>

<%           ਍ഀ if mode = 1 ਍ഀ then
                ਍ഀ if RS.EOF or RS.EOF ਍ഀ then
                     ਍ഀ if fd.type = 201 or fd.type = 203 ਍ഀ then%>

                          ਍ഀ <TEXTAREA name=S<%=i%>  disabled ਍ഀ cols=22 rows=4 width=200 style="width:200"></TEXTAREA>
<%                     ਍ഀ else%>
                          ਍ഀ <INPUT name=S<%=i%>  disabled ਍ഀ size=26>
<%                     ਍ഀ end ਍ഀ if
                ਍ഀ else
                     ਍ഀ if fd.type = 201 or fd.type = 203 ਍ഀ then%>

                          ਍ഀ <TEXTAREA name=S<%=i%>  disabled ਍ഀ cols=22 rows=4 width=200 style="width:200"><%=fd.value%></TEXTAREA>
<%                     ਍ഀ else
                          ਍ഀ if isNull(fd.value) or isEmpty(fd.value) ਍ഀ then%>

                          ਍ഀ <INPUT name=S<%=i%>  disabled size=26 ਍ഀ value="">
<%                          ਍ഀ elseif fd.type = 129 or fd.type = 200 or fd.type = 130 or fd.type = 202 ਍ഀ then%>
                          ਍ഀ <INPUT name=S<%=i%>  disabled size=26 ਍ഀ value="<%=Replace(fd.value, """", ਍ഀ """)%>">
<%                          ਍ഀ else%>
                          ਍ഀ <INPUT name=S<%=i%>  disabled size=26 ਍ഀ value="<%=fd.value%>">
<%                          ਍ഀ end ਍ഀ if
                     ਍ഀ end ਍ഀ if
                ਍ഀ end if
           elseif ਍ഀ mode = 2 ਍ഀ then
                ਍ഀ if RS.BOF or RS.EOF or operate = 1 ਍ഀ then
                     ਍ഀ if fd.type = 201 or fd.type = 203 ਍ഀ then%>

                     ਍ഀ <TEXTAREA name=S<%=i%>  cols=22 rows=4 ਍ഀ width=200 style="width:200"></TEXTAREA>
<%                     ਍ഀ else%>
                     ਍ഀ <INPUT name=S<%=i%>  size=26 ਍ഀ value="">
<%                     ਍ഀ end ਍ഀ if
                ਍ഀ else
                     ਍ഀ if fd.type = 201 or fd.type = 203 ਍ഀ then%>

                     ਍ഀ <TEXTAREA name=S<%=i%>  cols=22 rows=4 ਍ഀ width=200 style="width:200"><%=fd.value%></TEXTAREA>
<%                     ਍ഀ else
                          ਍ഀ if isNull(fd.value) or isEmpty(fd.value) ਍ഀ then%>

                          ਍ഀ <INPUT name=S<%=i%>  size=26 ਍ഀ value="">
<%                          ਍ഀ elseif fd.type = 129 or fd.type = 200 or fd.type = 130 or fd.type = 202 ਍ഀ then%>
                          ਍ഀ <INPUT name=S<%=i%>  size=26 ਍ഀ value="<%=Replace(fd.value, """", ਍ഀ """)%>">
<%                          ਍ഀ else%>
                          ਍ഀ <INPUT name=S<%=i%>  size=26 ਍ഀ value="<%=fd.value%>">
<%                          ਍ഀ end ਍ഀ if
                     ਍ഀ end ਍ഀ if
                ਍ഀ end if
           end ਍ഀ if%>

                ਍ഀ </TD>
<%           ਍ഀ if i mod 2 = 1 ਍ഀ then%>
                ਍ഀ </TR>
<%           ਍ഀ end if
      next%>


<%      if i mod 2 = 1 ਍ഀ then%>
      <TD ਍ഀ width=20%> </TD><TD ਍ഀ width=30%> </TD></TR>
<%      end if%>  ਍ഀ
      </TABLE>

<%end if%>

<input type=hidden ਍ഀ name=InsertInf size=4 value="<%=InsertInfo%>">
      ਍ഀ

</CENTER>
</FORM>

<SCRIPT  Language = "JavaScript">
function ਍ഀ MoveClick(option){
      document.form1.action = ਍ഀ "opentb.asp?mode=1&direction=" + option;
      ਍ഀ document.form1.submit();
}

function ModeClick(option) ਍ഀ {
      if ( option == 1 ਍ഀ )
           ਍ഀ document.form1.action = ਍ഀ "opentb.asp?mode=1&direction=0";
      ਍ഀ else
           ਍ഀ document.form1.action = ਍ഀ "opentb.asp?mode=2&operate=0";
      ਍ഀ document.form1.submit();
}

function OperateClick(option) ਍ഀ {
      document.form1.action = ਍ഀ "opentb.asp?mode=2&operate=" + option;
      ਍ഀ document.form1.submit();
}
</SCRIPT>


</BODY>
</HTML>
਍ഀ
਍ഀ ਍ഀ

 

਍ഀ