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

📄 edit.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<% option explicit%>
<!-- #include virtual="include/MyFunc.asp" -->
<!-- #include virtual="include/DataEnvi.asp" -->
<!-- #include virtual="Include/Page.asp" -->
<!-- #include virtual="include/ShowAttachs.asp" -->
<!-- #include virtual="Include/SelectValue.asp" -->

<%
	Dim ObjDB
	Dim C
	Dim IntID
	Dim ObjRS,rs,sql,ObjRSA,ObjRSE
	Dim AddTerm,FirTerm
	Dim ConCode,ConName,FirBegDate,FirEndDate,ConType,AddBegDate,AddEndDate,LastTerm,AddTerm1,ConDesc,ConContent,AddNum,ChangContent	
	Dim x,y,aa,bb
	dim FirstMenu,SecondMenu,Opertion,OTime,OName,OIP,ODesc,OChang
    Dim AddConNum,AddLastTerm,AddTotle,AddString,NowTerm
    NowTerm=0
	IntID = Request.QueryString("ID")
	
	Session("Table_id")=IntID
	Session("TableName")="T_Hrms_Employees_ConName"
	
	Set ObjDB = Server.CreateObject("ADODB.Connection")
	OpenDBH ObjDB

	Set C = Server.CreateObject ("CMS2003.DBhandle")
	C.Init(ObjDB)
    Set ObjRS = C.View("Select * From T_Hrms_Employees_ConName Where ID = " & IntID)
	
	 Set ObjRSA = Server.CreateObject("ADODB.Recordset")
     sql="select *  from T_Hrms_Employees_ConName Where ID="&IntID
	  
     ObjRSA.open "Select * From T_Hrms_Employees_AddContract Where ConCode ='" & ObjRS("ID")&"'",ObjDB,1,1
	
	 AddConNum=ObjRSA.recordcount'修改次数
	 AddTotle=0 '累计
	
	if  not ObjRSA.eof then
	 
	      Set ObjRSE = ObjDB.EXECUTE("Select TOP 1 AddEndDate From T_Hrms_Employees_AddContract Where ConCode = '" &ObjRS("ID")&"' order by AddEndDate  desc")
    	  AddLastTerm=ObjRSE (0)'最后到期时间
	      ObjRSE.close
	       set ObjRSE =nothing 
		  
		  do WHILE  NOT  ObjRSA.EOF 
         
		      AddString=CInt(DateDiff("yyyy", ObjRSA("AddBegDate"), ObjRSA("AddEndDate")))
              IF AddString=0 THEN
		      AddTotle=AddTotle+1
			  ELSE
			  AddTotle=AddTotle+AddString
		      END IF
             ObjRSA.movenext
		loop
		
	end if
     '  response.write AddTotle&"<br>"&"totle"
	   'response.write AddConNum&"<br>"&"num"

	   'response.write AddLastTerm&"<br>"&"last"

	 ' response.End()
	 
	 

	If Request.Form.Count > 0 Then
 ' ----------------------------------------判断开始'
    	 
	  ConCode=request("_ConCode")
	  ConName=request("_ConName")
	  ConType	=request("_ConType")
	
	  
	  FirBegDate=request("_FirBegDate")	
      FirEndDate=request("_FirEndDate")
	  
	   AddBegDate=request("_AddBegDate")	
       AddEndDate=request("_AddEndDate")
	  
	  FirTerm=ObjRS("_FirTerm")
	  LastTerm=request("_LastTerm")
	  AddTerm=ObjRS("_AddTerm")

      AddNum=request("_AddNum")
	  ConDesc=request("_ConDesc")
	  ConContent=request("_ConContent")
      ChangContent=request("_ChangContent")
  
 
  
  
 '----------首次合同判断开始

  
    if ConCode="" then
  call MsgBox("合同代号不能为空!","Back","none")
  response.end  
   else
		  if Len(ConCode)>10 then
		   call MsgBox("合同代号超出10个字符了!","Back","none")
          response.end  
		  end if
  end if
  
  if ConName="" then
  call MsgBox("名称不能为空!","Back","none")
  response.end 
  else
   if Len(ConName)>20 then
		   call MsgBox("合同名称超出20个字符了!","Back","none")
          response.end  
		  end if 
  end if
  
    
	if CInt(DateDiff("y", cdate(FirBegDate), cdate(FirEndDate)))<0 then
   call MsgBox("首次合同开始日期超过结束日期了!","Back","none")
    response.end 
   end if


if AddConNum<>0 then
if CInt(DateDiff("y", cdate(FirEndDate), cdate(AddLastTerm)))<0 then
   'call MsgBox("首次合同结束日期超过续签合同的结束日期了!","Back","none")
    'response.end 
end if
end if
   if  trim(cstr(ObjRS("FirBegDate")))<>trim(FirBegDate) or trim(cstr(ObjRS("FirEndDate")))<>trim(FirEndDate) then

if CInt(DateDiff("yyyy", cdate(FirBegDate), cdate(FirEndDate)))<>0 then
FirTerm=CInt(DateDiff("yyyy", cdate(FirBegDate), cdate(FirEndDate)))
else
FirTerm=1
end if

end if


 '-----------首次合同判断结束
  
'续签合同开始
if AddBegDate<>""  and AddEndDate<>"" then'if begin
	
 if CInt(DateDiff("y", cdate(AddBegDate), cdate(AddEndDate)))<0 then
   call MsgBox("续签合同开始日期超过结束日期了!","Back","none")
    response.end 
 end if	 
 


if CInt(DateDiff("y", cdate(FirEndDate), cdate(AddEndDate)))<0 then
   'call MsgBox("续签合同结束日期必须大于首次合同的结束日期!","Back","none")
   ' response.end 
end if

if AddConNum<>0 then
if CInt(DateDiff("y", cdate(AddLastTerm), cdate(AddEndDate)))<0 then
   'call MsgBox("续签合同结束日期必须大于前次合同的结束日期!","Back","none")
    'response.end 
end if
end if




if AddConNum<>0 then'三者比较
if CInt(DateDiff("y", cdate(AddLastTerm), cdate(AddEndDate)))<0 then

if CInt(DateDiff("y", cdate(AddLastTerm), cdate(FirEndDate)))<0 then
AddLastTerm=AddLastTerm
else
AddLastTerm=FirEndDate
end if

else

if CInt(DateDiff("y", cdate(AddEndDate), cdate(FirEndDate)))<0 then
AddLastTerm=AddEndDate
else
AddLastTerm=FirEndDate
end if

end if
else'三者比较else
if CInt(DateDiff("y", cdate(AddEndDate), cdate(FirEndDate)))<0 then
AddLastTerm=AddEndDate
else
AddLastTerm=FirEndDate
end if

end if'三者比较结束

 AddConNum=AddConNum+1'次数
 NowTerm=CInt(DateDiff("yyyy", cdate(AddBegDate), cdate(AddEndDate)))
IF  NowTerm=0 THEN
     NowTerm=1
END IF

end if'if end
'------------续签合同结束


   '公共
   if ConDesc<>"" then
 
   if Len(ConDesc)>200 then
		   call MsgBox("合同备注信息超出200个字符了!","Back","none")
          response.end  
		  end if 
  end if
  
'累计期限
FirTerm=CInt(DateDiff("yyyy", cdate(request("_FirBegDate")), cdate(request("_FirEndDate"))))
IF  FirTerm=0 THEN
     FirTerm=1
END IF
    
     AddTerm=AddTotle+FirTerm+NowTerm
 

'最后时间
if AddBegDate<>""  and AddEndDate<>"" then'if begin
   LastTerm=AddEndDate
else
   if AddConNum=0 then
   LastTerm=FirEndDate
   else
   LastTerm=AddLastTerm
    end if
end if'if begin

 ' -------------------------------------------判断结束'
'修改
     Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select *  from T_Hrms_Employees_ConName Where ID="&IntID
 rs.open sql,ObjDB,3,3
 
  Sql="select Count(*) from T_Hrms_Employees_ConName where ConCode='" & trim(request("_ConCode"))&"'"
Set ObjRS = ObjDB.Execute(Sql)
  

   if   trim(rs("ConCode"))<>trim(ConCode) then
               if ObjRS(0) = 0 Then
                rs("ConCode")=trim(ConCode)
              else
               call MsgBox("该名称已经存在了!","Back","none")
               response.end  
             end IF
      end if 
	  
rs("ConName")=ConName
rs("FirBegDate")=FirBegDate
rs("FirEndDate")=FirEndDate
rs("ConType")=ConType
rs("FirTerm")=FirTerm
'公共
rs("AddTerm")=AddTerm
rs("ConDesc")=ConDesc
rs("ConContent")=ConContent
rs("LastTerm")=LastTerm
rs("Attachs") = Request("_Attachs")
rs("AddNum")= AddConNum
rs.update
rs.close
set rs=nothing

'添加续签合同
if AddBegDate<>""  and AddEndDate<>"" then
ObjDB.Execute("insert into T_Hrms_employees_AddContract (ConCode,AddBegDate,AddEndDate) values ('"&request("ConCode")&"','"&AddBegDate&"','"&AddEndDate&"')")
end if

'添加合同变更	 
if ChangContent<>"" then
 ObjDB.Execute("insert into T_Hrms_Employees_ConChange (ConCode,ChangContent) values ('"&request("ConCode")&"','"&ChangContent&"')")
end if 
OIP=Request.ServerVariables("REMOTE_ADDR")
OName= Session("AccountName") 

if OName="administrator" then
OName="系统管理员"
end if

call AddLog("员工管理","合同信息","修改",now(),OName ,OIP,"",OChang,ObjDB)
 '添加日志结束
 

ObjDB.Close
Set ObjDB = Nothing

Response.Redirect "list.asp"   
End If
   


	

	
%>

<Script language=javascript>  
	function EditAttach()
	{
	   	var r =window.showModalDialog("../../Attach/Index.asp?IDs=" + document.forms[0]._Attachs.value + "&BasePath=ContractAttach&R=" + Math.random(),"AttachWin","dialogHeight=240px,dialogWidth=420px,resizable=No,status=1,scrollbars=1");
  	if(r!=null)
  	{
  		ReturnAttachs(r)
  	}
	}

	function ReturnAttachs(v)
	{
    	document.forms[0]._Attachs.value = v[1]
		}
	

	function AddIDs(IDs)
	{
		window.open("addcontract.asp?IDs="+IDs,"RoleWin","width=400,height=300,scrollbars=yes")
	}
	
	function ViewChange(IDs)
	{
		window.open("ViewChange.asp?IDs="+IDs,"ChangeWin","width=400,height=300,scrollbars=yes")
	}

	function FirSubmit()
	{
		document.form1.submit();
	}
	
	
</Script>

<%'==================================================================%>
<%Sub Main%>
<%'------------------------------------------------------------------%>

	
	<form action="" method="post"  id=form1 name=form1>
	<input type=hidden name=ID value="<%=Request.QueryString("ID")%>">
	<input type=hidden name=InputType value="">
    <input type=hidden name=ConID value="<%=ObjRS("ConCode")%>">
	<input type=hidden name=ConCode value="<%=ObjRS("ID")%>">
	<input type=hidden name=ID value="<%=ObjRS("ID")%>">
  <table class=Ltable cellspacing=1 cellpadding=3>
    <tr class=LHtr align="middle"> 
      <td width="15%">修改合同纪录</td>
      <td width="85%"> </td>
    </tr>
 
    <tr class=Ltr> 
      <td align="center">合同代号</td>
      <td><input type="text" class=Input Check=0  name="_ConCode" value="<%=ObjRS("ConCode")%>"></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">姓名</td>
      <td>
	  <select type="text" class=Input Check=0  name="_ConName"  style="width: 150;" >
	<%=SelectValueSingle(ObjDB,"Select ID,Name from t_Hrms_Employees_UsersBasic",CStr(ObjRS("ConName")))%>
	</SELECT>
	  </td>
    </tr>
    <tr class=Ltr> 
      <td align="center">首次合同开始日期</td>
      <td><input  name="_FirBegDate" type="text" class=Input id="_FirBegDate"   readonly="true"  onclick="InputDate(this)"  value="<%=FormatDate(ObjRS("FirBegDate"))%>" Check=0></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">首次合同结束日期</td>
      <td><input  name="_FirEndDate" type="text" class=Input id="_FirEndDate"  readonly="true"  onclick="InputDate(this)"   value="<%=FormatDate(ObjRS("FirEndDate"))%>" Check=0></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">合同类型</td>
      <td><select type="text" class=Input Check=0  name="_ConType"  style="width: 150;" >
          <%=SelectValueSingle(ObjDB,"Select ID,ConName from T_Hrms_Sys_Contract",CStr(ObjRS("ConType")))%> 
        </SELECT></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">首次合同期限</td>
      <td><input  name="_FirTerm" type="text" class=Input id="_FirTerm" value="<%=ObjRS("FirTerm")%>" Check=0>
        年 </td>
    </tr>
	  
    <tr class=Ltr> 
      <td align="center">最后合同到期时间</td>
      <td><input  name="_LastTerm" type="text" class=Input id="_LastTerm"  readonly="true"    value="<%=FormatDate(ObjRS("LastTerm"))%>" Check=0></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">累计合同期限</td>
      <td><input  name="_AddTerm" type="text" class=Input id="_AddTerm" value="<%=ObjRS("AddTerm")%>" Check=0 readonly="true">
        年</td>
    </tr>
    <tr class=Ltr> 
      <td align="center">续签次数</td>
      <td><input name="_AddNum" type="text" id="_AddNum" value="<%=ObjRS("AddNum")%>" readonly="true">
        次</td>
    </tr>
       <tr class=Ltr> 
      <td align="center">合同备注(包括合同的变更)</td>
      <td><textarea name="_ConDesc" cols="60" rows="10" class="Input" id="_ConDesc" check="0"><%=ObjRS("ConDesc")%></textarea></td>
    </tr>
    <tr class=Ltr> 
      <td align="center">合同内容</td>
      <td><textarea name="_ConContent" cols="60" rows="10" class="Input" id="textarea" check="0"><%=ObjRS("ConContent")%></textarea></td>
    </tr>
    <tr class=Ltr> 
	      <td align="center">编辑附件</td>

       <td><%=ShowAttachsH(ObjDB,ObjRS("Attachs"))%><input name=_Attachs type=hidden class=Input value="<%=ObjRS("Attachs")%>"><input type=button value="编辑附件" class=button onclick="EditAttach()" id=button3 name=button3>

    </tr></table>
  <table id=MoreInfo class=Ltable cellspacing=1 cellpadding=3>
  <tr class=LHtr align="middle"> 
      <td width="15%">续签合同</td>
      <td width="85%"> </td>
    </tr>
    <tr class=Ltr> 
      <td align="center">续签合同开始日期</td>
      <td><input  name="_AddBegDate" type="text"    class=Input id="_AddBegDate" Check=0  readonly="true" onclick="InputDate(this)" end if%>
      </td>
    </tr>
    <tr class=Ltr> 
      <td align="center">续签合同结束日期</td>
      <td><input  name="_AddEndDate" type="text" class=Input id="_AddEndDate"  readonly="true"   onclick="InputDate(this)" Check=0>
        &nbsp; &nbsp; 
        <input type="button"  name="Submit22" class=Button value="查看续签合同情况" onclick="AddIDs(ConCode.value)">
        (添加后请点击<font color="#FF0000">修改</font>按钮) </td>
    </tr>
	
	  </table>	  
  <table id=MoreInfo class=Ltable cellspacing=1 cellpadding=3>
  <tr class=LHtr align="middle"> 
      <td width="15%">合同变更</td>
      <td width="85%"> </td>
    </tr>
    <tr class=Ltr> 
      <td align="center">变更内容</td>
      <td><textarea name="_ChangContent" cols="60" rows="5" class="Input" id="_ChangContent"  check="0" ></textarea>
      </td>
    </tr>
    <tr class=Ltr> 
      <td align="center">&nbsp;</td>
      <td> &nbsp; &nbsp; 
        <input type="button"  name="Submit222" class=Button value="查看变更情况" onClick="ViewChange(ConCode.value)"></td>
    </tr>
	
	  </table>
	<table cellspacing=1 cellpadding=3>
	<tr>
		<td>
		<input type="submit"  name="Submit" class=Button value="修改" >
        <input type="button" class=Button value="取 消" onclick="doList()" id=button1 name=button1></td>
		<td></td>
	</tr>
	</table></FORM>




<%'------------------------------------------------------------------%>
<%End Sub%>
<%'==================================================================%>

<!-- #include virtual="templet\templet.asp" -->                      

⌨️ 快捷键说明

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