⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 我的图书管理系统
💻
字号:

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

<%
CategoryID=Request("CategoryID")


%>
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="tjh" content="Microsoft FrontPage Express 2.0">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>基本资料项目设置</title>
</head>

<body background="B01.jpg">

<p><object id="RDS1"
classid="ClsID:BD96C556-65A3-11D0-983A-00C04FC29E33"
align="baseline" border="0" width="25" height="4"><param
name="AllowAddnew" value="true"><param name="AllowDelete"
value="true"><param name="AllowUpdate" value="true"><param
name="allowarrows" value="true"></object> <object id="RDS2"
classid="ClsID:BD96C556-65A3-11D0-983A-00C04FC29E33"
align="baseline" border="0" width="26" height="12"><param
name="AllowAddnew" value="true"><param name="AllowDelete"
value="true"><param name="AllowUpdate" value="true"><param
name="allowarrows" value="true"></object> <font size="5">档案项目设置
<script language="VBScript">
   public  text11
   
   'msgbox <%=categoryid%>

    RDS1.Server = "http://127.0.0.1"

    RDS1.Connect = "database=school;uid=sa;pwd=;dsn=school"

    RDS1.SQL = "select * from <%=categoryid%>_p"

    RDS1.Refresh

    RDS2.Server = "http://127.0.0.1"

    RDS2.Connect = "database=school;uid=sa;pwd=;dsn=school"

</script></font></p>

<hr>
<div align="left">

<table border="1" width="100%">
    <tr>
        <td valign="top" width="65%"><object id="grid1"
        name="grid1"
        classid="clsid:00028CD1-0000-0000-0000-000000000046"
        align="baseline" border="0" width="510" height="329"
        datasrc="#rds1"></object> </td>
        <td valign="top" width="35%"><h5>&nbsp;<font
        color="#0000FF">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
        color="#0000FF" face="宋体"> </font><font
        color="#0000FF" size="2">使用说明</font></h5>
        <h5><font color="#0000FF">(1)项目名称:字段名称&nbsp;&nbsp;
        类型:字段数据类型&nbsp; 宽度:字段数据宽度&nbsp;
        小数:字段小数位</font></h5>
        <h5><font color="#0000FF">(2)项目名称严格按照字段名要求定义,不得重复</font></h5>
        <h5><font color="#0000FF">(3)类型必须为字符型(char)位型(bit)、整数型(int)、日期时间型(datetime)、和精确数值型(decimal)</font></h5>
        <h5><font color="#0000FF">(4)bit、int、datetime类型的宽度和小数为空,char型的宽度大于零、decimal型的宽度大于1、小数必须小于宽度</font></h5>
        <h5><font color="#0000FF">(5)基本项目不能删改</font></h5>
        </td>
    </tr>
</table>
</div>

<script language="vbscript">
 
  grid1.AllowAddnew = true

  grid1.AllowDelete = true

  grid1.AllowUpdate = true

</script>


<p><script language="vbscript">

 PUBLIC  x(20,3)
 
 public  y(40,3)

 public  z(40,3)
  
 PUBLIC l_button

 l_button="1"
   
 PUBLIC row_1

 public l_count

 public l_delete

 l_delete=0

 public l_tag

 l_tag="1"
   
sub grid1_BeforeColEdit()

   grid1.editactive = true

end sub

sub recordadd()

  
  
   row_1=0
  
 
   

   grid1.editactive=true
   
   rds1.recordset.addnew
 
   rds1.recordset.movelast
 
   
   
end sub

'sub grid1_click()

'msgbox grid1.row



'end sub


SUB GRID1_BeforeColUpdate(colindex,oldvalue,cancle)
	new_value = grid1.columns.item(colindex)
	select case colindex
	case 0
		if len(trim(new_value)) =0 then
		    msgbox "序号不能为空!请重新输入"
		    cancle = true
		    exit sub
		end if	
		rds2.sql = "select 序号  from   <%=categoryid%>_p where rtrim(序号) ='" & trim(new_value) & "'"
		rds2.ExecuteOptions = 1	
		rds2.refresh
		if rds2.recordset.recordCount>0 then
		    msgbox "序号重复!请重新输入"
		    cancle = true
			exit sub
		end if
	case 1				
		if len(trim(new_value)) =0 then
		    msgbox "项目名称不能为空!请重新输入"
		    cancle = true
			exit sub
		end if
		
		rds2.sql = "select *  from <%=categoryid%>_p where rtrim(项目名称) ='" & trim(oldvalue) & "'"
		rds2.ExecuteOptions = 1	
		rds2.refresh
		if rds2.recordset.recordCount>0 then
		    msgbox "此项目名称已存在表中!不得修改!"
		    cancle = true
			exit sub
		end if	

	case 2

	  if rtrim(new_value)="bit" then
        
		 if len(trim(grid1.columns.item(3)))>0 then

		    msgbox "宽度和小数只能为空!"
			 
		 end if

          cancle=false
		  exit sub
	     
	    elseif  rtrim(new_value)="int" then
		 
		 if len(trim(grid1.columns.item(3)))>0 then

		    msgbox "宽度和小数只能为空!"
			 
		 end if
		 cancle=false

		  exit sub

		   elseif rtrim(new_value)="datetime" then
		   
		   if len(trim(grid1.columns.item(3)))>0 then

		      msgbox "宽度和小数只能为空!"
			 
    	   end if

           cancle=false
		   exit sub

		     elseif rtrim(new_value)="char"  then
			 
		    	if len(trim(grid1.columns.item(4)))>0 then

		           msgbox "小数只能为空!"
			 
    		     end if
             cancle=false
			 exit sub

			 elseif rtrim(new_value)="decimal" then
              

			 
			 exit sub

          else

	        msgbox "数据类型输入错误,请重新输入!"
     
	     cancle=true
		 exit sub   

	  end if

     
     case 3

	 if rtrim(grid1.columns.item(2))="int" or rtrim(grid1.columns.item(2))="bit" or rtrim(grid1.columns.item(2))="datetime" then
	   
	   if len(trim(new_value))>0 then
	      

	    msgbox "因为此记录的类型是int、bit和datetime其中的一个,所以宽度不需要录入!"
        
        cancle=true
        exit sub
	   end if

	 end if
    
	 if rtrim(grid1.columns.item(2))="char" or rtrim(grid1.columns.item(2))="decimal" then
   
       if len(trim(new_value))=0 or rtrim(new_value)="0"   then

         msgbox "因为此记录的类型是char和decimal中的一个,所以宽度不能为空,必须大于0 !"
         
		 cancle=true
         
		 exit sub

	   end if

     end if
    
	 case 4

	 if rtrim(grid1.columns.item(2))="decimal" and len(trim(new_value))=0 then
     
	    'if len(trim(new_value))=0 then

         msgbox "小数不能为空!"
         
		 cancle=true
		 
		 exit sub          

       ' end if    
			
		elseif  rtrim(grid1.columns.item(2))="decimal" and rtrim(grid1.columns.item(3))="1" then

	      if rtrim(new_value)>"1" then
		 
		    msgbox "或者小数列只能为0 !"

          end if

		elseif rtrim(grid1.columns.item(2))="decimal" and rtrim(grid1.columns.item(3))>"1" then

          if rtrim(new_value)>rtrim(grid1.columns.item(3)) or rtrim(new_value)=rtrim(grid1.columns.item(3)) then  
          
		   msgbox "小数不能等于宽度或不能大于宽度!"
          
		  end if
   
     end if
	
	end select
END sub
    
	 


sub recorddelete()

     l_ok = msgbox("你真的要删除此项目吗!",1,"提示")
   
    
 
   if l_ok  = 1 then
    
      if ltrim(rtrim(grid1.columns.item(1)))="学号" or ltrim(rtrim(grid1.columns.item(1)))="班号" or ltrim(rtrim(grid1.columns.item(1)))="姓名" then

	     msgbox "对不起! 基本项目不能删除!"

		 exit sub
       end if

      if l_tag="1" then
	  
	    

      else
           l_tag="1"
        
		   l_delete=0

	  end if	        
	     

	    z(l_delete,0)=grid1.columns.item(1)
	   
'	    msgbox z(0,0)

		 
	    l_delete=l_delete+1

'		msgbox z(1,0)
       

	    rds1.recordset.delete

        grid1.rebind
       
'	   msgbox z(l_delete,0)

	    'RDS1.SubmitChanges
     
   end if
 
end sub

Sub CancleUpdate()
   On Error Resume Next
     RDS1.CancelUpdate
   Grid1.Rebind
End Sub



Sub MoveFirst()
  RDS1.Recordset.MoveFirst
'  msgbox text1.value
'  msgbox rtrim(text2.value)+"("&rtrim(text3.value)&+")"
End Sub

Sub MovePrevious()
   If Not RDS1.Recordset.BOF Then
      RDS1.Recordset.MovePrevious
   End If
End Sub

Sub MoveNext()
   If Not RDS1.Recordset.EOF Then
      RDS1.Recordset.MoveNext
   End If
End Sub

Sub MoveLast()
   RDS1.Recordset.MoveLast
End Sub

Sub SubmitChanges()
   
 ' 修改中取值与 原来的比较
  grid1.row=0
   
  for row_2=1 to rds1.recordset.recordcount
       'msgbox rds1.recordset.recordcount
     

 	 for col_2=1 to 4
      
         y(row_2-1,col_2-1)=grid1.columns.item(col_2)

    	'	msgbox y(row_2-1,col_2-1)
   
     next

     if row_2=rds1.recordset.recordcount then

      
     else
      
	    grid1.row = grid1.row+1     
 
     end if

  next

   for row_2=0 to grid1.row
     
      '找出原来已存在数据被修改的字段
    
	'msgbox "ok"
	'msgbox  ltrim(rtrim(y(row_2,2)))
	'msgbox  ltrim(rtrim(y(row_2,1)))

	
	if ltrim(rtrim(y(row_2,1)))="char" or ltrim(rtrim(y(row_2,1)))="decimal" then

         if len(rtrim(y(row_2,2)))=0 or ltrim(rtrim(y(row_2,1)))="0" then

	       msgbox "CHAR和DECIMAL类型的数据字段宽度必页大于0或不为空值!"
         
		   exit sub
         end if

     
	 end if
      
   
      rds2.sql = "select *  from  <%=categoryid%>_p  where (ltrim(rtrim(项目名称))='" & _
         	ltrim(rtrim(y(row_2,0)))&"'  and  ltrim(rtrim(宽度))<>'"&ltrim(rtrim(y(row_2,2)))&"') or (ltrim(rtrim(项目名称))='" & _
       	    ltrim(rtrim(y(row_2,0)))&"' and ltrim(rtrim(类型))<>'"&ltrim(rtrim(y(row_2,1)))&"') or (ltrim(rtrim(项目名称))='" & _
       	    ltrim(rtrim(y(row_2,0)))&"' and ltrim(rtrim(小数))<>'"&ltrim(rtrim(y(row_2,3)))&"')"
  

		     rds2.ExecuteOptions = 1	

		     rds2.refresh
         
        
	         '   msgbox rds2.recordset.recordcount

      if rds2.recordset.recordCount>0 then
      
	  
	      text_c=rtrim(y(row_2,1))+"("&rtrim(y(row_2,2))&+")"
	
 
        if rtrim(y(row_2,3))<>" " then
   
           text_c1=rtrim(y(row_2,1))+"("&rtrim(y(row_2,2))&+","&rtrim(y(row_2,3))&")"
      
         end if

         ' 改变表BASEINFO的表结构

         if rtrim(y(row_2,0))=" "  then
     
	         msgbox "项目名称不能为空"

             elseif rtrim(y(row_2,1))="int" or rtrim(y(row_2,1))="datetime" or rtrim(y(row_2,1))="bit"   then

             rds2.sql = "alter table <%=categoryid%> alter column "&rtrim(y(row_2,0))&" "&rtrim(y(row_2,1))&" null"
  
             RDS2.ExecuteOptions = 1	

             rds2.refresh

           elseif rtrim(y(row_2,1))="char" then
            
              rds2.sql = "alter table <%=categoryid%> alter column "&rtrim(y(row_2,0))&" "&text_c&"  null"
  
              RDS2.ExecuteOptions = 1	

               rds2.refresh
        else
         
		  rds2.sql = "alter table <%=categoryid%> alter column "&rtrim(y(row_2,0))&" "&text_c1&"  null"
  
          RDS2.ExecuteOptions = 1	

          rds2.refresh
   
   
     end if    
    end if
  next 
 
'找出被删除的数据

  for  row_3=1 to l_delete
     
	 

      rds2.sql = "select *  from  <%=categoryid%>_p  where ltrim(rtrim(项目名称))='"&ltrim(rtrim(z(row_3-1,0)))&"'"       	    

		     rds2.ExecuteOptions = 1	

		     rds2.refresh
       
	if rds2.recordset.recordCount>0 then

	    
       rds2.sql="alter table <%=categoryid%>  drop  column  "&ltrim(rtrim(z(row_3-1,0)))&"" 
	   
'	   msgbox rds2.sql   
       
       	     rds2.ExecuteOptions = 1	

		     rds2.refresh
     end if 

  next

' 找出新增的数据

  for row_2=0 to grid1.row

        rds2.sql = "select *  from  <%=categoryid%>_p  where ltrim(rtrim(项目名称))='"&ltrim(rtrim(y(row_2,0)))&"'"
		  
 '   msgbox rds2.sql
	
	    rds2.ExecuteOptions = 1	

		rds2.refresh
         
        
	 
   if rds2.recordset.recordCount>0 then
      
	  else

	    text_c=rtrim(y(row_2,1))+"("&rtrim(y(row_2,2))&+")"
	
 
   if rtrim(y(row_2,3))<>" " then
   
      text_c1=rtrim(y(row_2,1))+"("&rtrim(y(row_2,2))&+","&rtrim(y(row_2,3))&")"
      
   end if

' 改变表BASEINFO的表结构

   if rtrim(y(row_2,0))=" "  then
     
	  msgbox "项目名称不能为空"

     elseif rtrim(y(row_2,1))="int" or rtrim(y(row_2,1))="datetime" or rtrim(y(row_2,1))="bit"   then


         rds2.sql = "alter table <%=categoryid%> add "&rtrim(y(row_2,0))&" "&rtrim(y(row_2,1))&" null"
  
         RDS2.ExecuteOptions = 1	

         rds2.refresh

       elseif rtrim(y(row_2,1))="char" then
  '         msgbox y(row_2,0) 
          rds2.sql = "alter table <%=categoryid%>   add "&rtrim(y(row_2,0))&" "&text_c&"  null"
  
             RDS2.ExecuteOptions = 1	

             rds2.refresh
    else
         
		 rds2.sql = "alter table <%=categoryid%> add "&rtrim(y(row_2,0))&" "&text_c1&"  null"
  
         RDS2.ExecuteOptions = 1	

         rds2.refresh
   
   
    end if    
    end if
 next

 	   

   ' row_1=0

    moveflag = true
	if grid1.row > 0 then
      grid1.row = grid1.row -1
	else
		grid1.row =grid1.row +1
		moveflag = false
	end if

	grid1.Editactive = False
   
   On Error resume next

   RDS1.SubmitChanges
 
   
 If Err.Number <> 0 Then
     'RDS1.CancelUpdate
      MsgBox "无法更新数据!"
 else

 l_tag="0"

 End If

 
 if  moveflag then
      grid1.row = grid1.row +1
 else
      grid1.row = grid1.row -1
 end if
   

  


 '  l_button="1"

end sub

</script> <input type="button"
value="第一条" onclick="movefirst()"> <input type="button"
value="上一条" onclick="MovePrevious()"> <input type="button"
value="下一条" onclick="MoveNext()"> <input type="button"
value="最后一条" onclick="MoveLast()"> <input type="button"
value="添  加" onclick="recordadd()"> <input type="button"
value="删  除" onclick="recorddelete()"> <input type="button"
value="保  存" onclick="SubmitChanges()"> <input type="button"
value="取  消" onclick="cancleupdate()"></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -