====咨询在涉及大型项目开发过程中,对于一些页面常规操作的设计思路====

alj 2003-12-15 10:20:04
在涉及到大型企业项目开发过程中,涉及到一些常规操作,比如:
(1)权限管理
(2)日志管理
(3)排序
(4)分页
权限管理现在我设计思路是新建PageBase.cs类模块,所有WebPage都从这个类继承,在PageBase里面初始化各项权限参数,这样实现起来方便一些。

对于其他功能:比如日志管理:如何设计,才能很方面将数据库的各项记录更改记录到日志表中,包括相应的操作用户名、操作时间、各个字段修改前后的值的变化情况

排序和分页我一直没有好的思路,所以我的应用程序一直没有实现,原因当然是懒……那位有比较好的思路,交流交流,分可以再加。
...全文
60 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
commars 2004-03-03
  • 打赏
  • 举报
回复
UP!
hunterzhi 2004-03-03
  • 打赏
  • 举报
回复
对谢
Nako 2004-03-03
  • 打赏
  • 举报
回复
tuio
zhouqi66 2004-03-03
  • 打赏
  • 举报
回复
很经典,收藏!
LFreeX 2004-03-02
  • 打赏
  • 举报
回复
权限管理 可是使用基类
日志管理 使用日志操作类。
(3)排序
(4)分页 定义一个用户DAtaGrid
bluesx 2004-03-02
  • 打赏
  • 举报
回复
有一套叫Infragistics.NetAdvantage的控件,里面的Grid的功能很强,基本上你能想得到的都有。
skylineforever 2004-03-02
  • 打赏
  • 举报
回复
其实很多人已经做好和用得很好了
比如“吴旗娃”的分页控件
比如下面这个通用存储过程(转)
/*--用存储过程实现的分页程序

显示指定表、视图、查询结果的第X页
对于表中主键或标识列的情况,直接从原表取数查询,其它情况使用临时表的方法
如果视图或查询结果中有主键,不推荐此方法

--邹建 2003.09--*/

/*--调用示例
exec p_show '地区资料'

exec p_show '地区资料',5,3,'地区编号,地区名称,助记码','地区编号'
--*/

/*
因为要顾及通用性,所以对带排序的查询语句有一定要求.如果先排序,再出结果.就是:

exec p_show 'select top 100 percent * from 地区资料 order by 地区名称',5,3,'地区编号,地区名称,助记码','地区名称'


--查询语句加上:top 100 percent //top时
*/

/*
----------------------修改自自定义存储过程分页-----------------------------------------
---------------------多种条件搜索-----------------------------------------------------------------
*/
CREATE procedure GetList
@QueryStr nvarchar(4000), --表名、视图名、查询语句
@PageSize int=10, --每页的大小(行数)
@PageCurrent int=1, --要显示的页
@FdShow nvarchar (4000)='', --要显示的字段列表,如果查询结果有标识字段,需要指定此值,且不包含标识字段
@FdOrder nvarchar (1000)='' --排序字段列表
as
declare
@FdName nvarchar(250) --表中的主键或表、临时表中的标识列名
,@Id1 varchar(20),@Id2 varchar(20) --开始和结束的记录号
,@Obj_ID int --对象ID
--表中有复合主键的处理
declare @strfd nvarchar(2000) --复合主键列表
,@strjoin nvarchar(4000) --连接字段
,@strwhere nvarchar(2000) --查询条件

select @Obj_ID=object_id(@QueryStr)
,@FdShow=case isnull(@FdShow,'') when '' then ' *' else ' '+@FdShow end
,@FdOrder=case isnull(@FdOrder,'') when '' then '' else ' order by '+@FdOrder end
,@QueryStr=case when @Obj_ID is not null then ' '+@QueryStr else ' ('+@QueryStr+') a' end

--如果显示第一页,可以直接用top来完成
/*if @PageCurrent=1
begin
select @Id1=cast(@PageSize as varchar(20))
exec('select top '+@Id1+@FdShow+' from '+@QueryStr+@FdOrder)
return
end
*/

--如果是表,则检查表中是否有标识更或主键
if @Obj_ID is not null and objectproperty(@Obj_ID,'IsTable')=1
begin
select @Id1=cast(@PageSize as varchar(20))
,@Id2=cast((@PageCurrent-1)*@PageSize as varchar(20))

select @FdName=name from syscolumns where id=@Obj_ID and status=0x80
if @@rowcount=0 --如果表中无标识列,则检查表中是否有主键
begin
if not exists(select 1 from sysobjects where parent_obj=@Obj_ID and xtype='PK')
goto lbusetemp --如果表中无主键,则用临时表处理

select @FdName=name from syscolumns where id=@Obj_ID and colid in(
select colid from sysindexkeys where @Obj_ID=id and indid in(
select indid from sysindexes where @Obj_ID=id and name in(
select name from sysobjects where xtype='PK' and parent_obj=@Obj_ID
)))
if @@rowcount>1 --检查表中的主键是否为复合主键
begin
select @strfd='',@strjoin='',@strwhere=''
select @strfd=@strfd+',['+name+']'
,@strjoin=@strjoin+' and a.['+name+']=b.['+name+']'
,@strwhere=@strwhere+' and b.['+name+'] is null'
from syscolumns where id=@Obj_ID and colid in(
select colid from sysindexkeys where @Obj_ID=id and indid in(
select indid from sysindexes where @Obj_ID=id and name in(
select name from sysobjects where xtype='PK' and parent_obj=@Obj_ID
)))
select @strfd=substring(@strfd,2,2000)
,@strjoin=substring(@strjoin,5,4000)
,@strwhere=substring(@strwhere,5,4000)
goto lbusepk
end
end
end
else

goto lbusetemp

/*--使用标识列或主键为单一字段的处理方法--*/
lbuseidentity:
exec('select top '+@Id1+@FdShow+' from '+@QueryStr
+' where '+@FdName+' not in(select top '
+@Id2+' '+@FdName+' from '+@QueryStr+@FdOrder
+')'+@FdOrder
)
return

/*--表中有复合主键的处理方法--*/
lbusepk:
exec('select '+@FdShow+' from(select top '+@Id1+' a.* from
(select top 100 percent * from '+@QueryStr+@FdOrder+') a
left join (select top '+@Id2+' '+@strfd+'
from '+@QueryStr+@FdOrder+') b on '+@strjoin+'
where '+@strwhere+') a'
)
return

/*--用临时表处理的方法--*/
lbusetemp:
select @FdName='[ID_'+cast(newid() as varchar(40))+']'
,@Id1=cast(@PageSize*(@PageCurrent-1) as varchar(20))
,@Id2=cast(@PageSize*@PageCurrent-1 as varchar(20))

exec('select '+@FdName+'=identity(int,0,1),'+@FdShow+'
into #tb from'+@QueryStr+@FdOrder+'
select '+@FdShow+' from #tb where '+@FdName+' between '
+@Id1+' and '+@Id2
)
GO
alj 2004-03-02
  • 打赏
  • 举报
回复
很久没有人回答这个问题,自己Up一下
brightview 2004-03-02
  • 打赏
  • 举报
回复
权限管理不太懂,估计还是要通过登录后的权限标识来确定以后的数据库查询所能列出的记录吧。日志是不是应该在每一个数据更新、删除操作后添加一条记录到专门的日志表来实现?
对于大量数据的显示与其他操作可以用这样一个免费控件来实现:http://dtable.2smm.com/
alj 2003-12-15
  • 打赏
  • 举报
回复
我知道其实并不难,但是在大型项目开发里面,这样需要分页、排序的DataGrid可能有很多。如果使用数据库排序,就要对每个表写一个存储过程,比较麻烦。

不知道列位有没有什么比较好的做法可供参考?
Programmersheaven 2003-12-15
  • 打赏
  • 举报
回复
排序和分页并非什么难题,datagrid如果设计成通用,性能会下降

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧