CREATE PROCEDURE [hiweb_ExtabModi_tableName] 
@title nvarchar (250) =null,
@content ntext =null  ,
@saveUser nvarchar(50) =null  ,
@saveUserID nvarchar(50) =null  , 
@saveUserIP nvarchar(50) =null  ,
@IPaddress   nvarchar(200)=null, 
@CBS nvarchar(250) =null  ,
@Kind nvarchar(50) =null,
@TabKeys nvarchar(250) =null  ,
@TabImage nvarchar(250) =null  ,
@WebUrl nvarchar(250) =null  ,
@IsTop int =null  ,
@IsEssence int =null  ,
@Examine int =null  ,
@IsHidden int =null  ,
@IsRemark int =null,
@ArtID int =null  ,
@pID int =null  ,
@inquiry nvarchar(100) =null  ,
@Source nvarchar(50) =null  ,
@SourceUrl nvarchar(250) =null  ,
@signFor int =null  ,
@signForUser ntext =null  ,
@fid int =null,
@saveDate dateTime =null,
@menuid int =null,
@id int =null output 
 AS
/* 修改条记录的基本数据*/
Declare @menuName nvarchar(100)
select @menuName=mName from zydn_menu where mid =@menuid
if(@fid is null)   
    INSERT INTO [tableName] ([title],[content],[SaveUser],[SaveUserID],[SaveUserIP],[IPaddress],[SaveDate],[CBS],[Kind],[TabKeys],[TabImage],[WebUrl],[IsTop],[IsEssence],[Examine],[IsHidden],[Count_Click],[Count_Down],[Count_Revert],[Point_Good],[Point_Bad],[Art_View_Int_ID],[P_A_View_ID],[inquiry],[Source],[SourceUrl],[signFor],[signForUser],[signInUser],[isDel],IsRemark,[menuid],[menuName])  values(@title,@content,@saveUser,@saveUserID,@saveUserIP,@IPaddress,getdate(),@CBS,@Kind,@TabKeys,@TabImage,@WebUrl,@IsTop,@IsEssence,@Examine,@IsHidden,0,0,0,0,0,@ArtID,@pID,@inquiry,@Source,@SourceUrl,@signFor,@signForUser,'',0,@IsRemark,@menuid,@menuName) 
else  
  BEGIN  
	  if ( @saveDate is null)
		 BEGIN 
		  update [tableName] set   menuid=@menuid,menuName=@menuName,title=@title,content=@content,saveUserIP=@saveUserIP,saveDate=getDate(),cbs=@CBS,[Kind]=@Kind,[TabKeys]=@TabKeys,[TabImage]=@Tabimage,[WebUrl]=@WebUrl,[IsTop]=@isTop,[IsEssence]=@IsEssence,[Examine]=@Examine,[IsHidden]=@IsHidden,[P_A_View_ID]=@pID,[inquiry]=@inquiry,[Source]=@Source,[SourceUrl]=@SourceUrl,[signFor]=@signFor,[signForUser]=@signForUser,IsRemark=@IsRemark where id=@fid   
		 END
	 else 
		 BEGIN 
		  update [tableName] set   menuid=@menuid,menuName=@menuName,title=@title,content=@content,saveUserIP=@saveUserIP,saveDate=@saveDate,cbs=@CBS,[Kind]=@Kind,[TabKeys]=@TabKeys,[TabImage]=@Tabimage,[WebUrl]=@WebUrl,[IsTop]=@isTop,[IsEssence]=@IsEssence,[Examine]=@Examine,[IsHidden]=@IsHidden,[P_A_View_ID]=@pID,[inquiry]=@inquiry,[Source]=@Source,[SourceUrl]=@SourceUrl,[signFor]=@signFor,[signForUser]=@signForUser,IsRemark=@IsRemark where id=@fid   
		 END
                   


  END


if (@fid is null) 
	BEGIN
		 select top 1 @id=id from [tableName] order by id desc
		 update  zydn_User_Base set  Count_Comment=Count_Comment+1 where id=    @saveUserID
	END
else
	BEGIN
	 set @id=@fid
	END 
