页面中添加某模块

添加模块

在Module.cs中

 

 private bool Create()
  {
   bool created = false;
   int newID = -1;
            this.guid = Guid.NewGuid();

   newID = DBModule.AddModule(
    this.pageID,
                this.siteID,
                this.siteGuid,
    this.moduleDefID,
    this.moduleOrder,
    this.paneName,
    this.moduleTitle,
    this.authorizedEditRoles,
    this.cacheTime,
    this.showTitle,
                this.availableForMyPage,
                this.allowMultipleInstancesOnMyPage,
                this.icon,
                this.createdByUserID,
                DateTime.UtcNow,
                this.guid,
                this.featureGuid,
                this.hideFromAuthenticated,
                this.hideFromUnauthenticated);
   
   this.moduleID = newID;
   created = (newID > -1);
   if(created)
   {
    ModuleSettings.CreateDefaultModuleSettings(this.moduleID);
   }
     
   return created;

  }

 

dbModule.cs中

 

 public static int AddModule(
            int pageId,
            int siteId,
            Guid siteGuid,
            int moduleDefId,
            int moduleOrder,
            string paneName,
            string moduleTitle,
            string authorizedEditRoles,
            int cacheTime,
            bool showTitle,
            bool availableForMyPage,
            bool allowMultipleInstancesOnMyPage,
            String icon,
            int createdByUserId,
            DateTime createdDate,
            Guid guid,
            Guid featureGuid,
            bool hideFromAuthenticated,
            bool hideFromUnauthenticated)
        {
            SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "mp_Modules_Insert", 19);
            sph.DefineSqlParameter("@PageID", SqlDbType.Int, ParameterDirection.Input, pageId);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@ModuleDefID", SqlDbType.Int, ParameterDirection.Input, moduleDefId);
            sph.DefineSqlParameter("@ModuleOrder", SqlDbType.Int, ParameterDirection.Input, moduleOrder);
            sph.DefineSqlParameter("@PaneName", SqlDbType.NVarChar, 50, ParameterDirection.Input, paneName);
            sph.DefineSqlParameter("@ModuleTitle", SqlDbType.NVarChar, 255, ParameterDirection.Input, moduleTitle);
            sph.DefineSqlParameter("@AuthorizedEditRoles", SqlDbType.NText, ParameterDirection.Input, authorizedEditRoles);
            sph.DefineSqlParameter("@CacheTime", SqlDbType.Int, ParameterDirection.Input, cacheTime);
            sph.DefineSqlParameter("@ShowTitle", SqlDbType.Bit, ParameterDirection.Input, showTitle);
            sph.DefineSqlParameter("@AvailableForMyPage", SqlDbType.Bit, ParameterDirection.Input, availableForMyPage);
            sph.DefineSqlParameter("@CreatedByUserID", SqlDbType.Int, ParameterDirection.Input, createdByUserId);
            sph.DefineSqlParameter("@CreatedDate", SqlDbType.DateTime, ParameterDirection.Input, createdDate);
            sph.DefineSqlParameter("@AllowMultipleInstancesOnMyPage", SqlDbType.Bit, ParameterDirection.Input, allowMultipleInstancesOnMyPage);
            sph.DefineSqlParameter("@Icon", SqlDbType.NVarChar, 255, ParameterDirection.Input, icon);
            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@FeatureGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, featureGuid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@HideFromAuth", SqlDbType.Bit, ParameterDirection.Input, hideFromAuthenticated);
            sph.DefineSqlParameter("@HideFromUnAuth", SqlDbType.Bit, ParameterDirection.Input, hideFromUnauthenticated);

           
           
            int newID = Convert.ToInt32(sph.ExecuteScalar());
            return newID;
        }

 

存储过程

 

 

Text                                                                                                                                                                                                                                                           
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[mp_Modules_Insert]

/*
Author:      Joe Audette
Created:    2004-12-26
Last Modified:   2008-07-24

*/

@PageID int,
@SiteID  int,
@ModuleDefID int,
@ModuleOrder int,
@PaneName nvarchar(50),
@ModuleTitle nvarchar(255),
@AuthorizedEditRoles ntext,
@CacheTime int,
@ShowTitle bit,
@AvailableForMyPage bit,
@CreatedByUserID int,
@CreatedDate  datetime,
@AllowMultipleInstancesOnMyPage bit,
@Icon nvarchar(255),
@Guid uniqueidentifier,
@FeatureGuid uniqueidentifier,
@SiteGuid uniqueidentifier,
@HideFromAuth bit,
@HideFromUnAuth bit

 
AS
DECLARE @ModuleID int

INSERT INTO  [dbo].[mp_Modules]
(
    SiteID,
    SiteGuid,
    [ModuleDefID],
    [ModuleTitle],
    [AuthorizedEditRoles],
    [CacheTime],
    [ShowTitle],
    AvailableForMyPage,
    AllowMultipleInstancesOnMyPage,
    Icon,
    CreatedByUserID,
    CreatedDate,
    [Guid],
    FeatureGuid,
    HideFromAuth,
    HideFromUnAuth
)

VALUES
(
    @SiteID,
    @SiteGuid,
    @ModuleDefID,
    @ModuleTitle,
    @AuthorizedEditRoles,
    @CacheTime,
    @ShowTitle,
    @AvailableForMyPage,
    @AllowMultipleInstancesOnMyPage,
    @Icon,
    @CreatedByUserID,
    @CreatedDate,
    @Guid,
    @FeatureGuid,
    @HideFromAuth,
    @HideFromUnAuth
    
)
SELECT @ModuleID =  @@IDENTITY                      //mp_Modules是Identity类型的,ModuleID取得上表中新纪录的@@Identity的值

IF @PageID > -1
BEGIN

DECLARE @PageGuid uniqueidentifier
SET @PageGuid = (SELECT TOP 1 PageGuid FROM mp_Pages WHERE PageID = @PageID) 

INSERT INTO  [dbo].[mp_PageModules]          //把moduleID与PageID相关联
(
    [PageID],
    [ModuleID],
    [ModuleOrder],
    [PaneName],
    [PublishBeginDate],
    PageGuid,
    ModuleGuid
    
)

VALUES
(
    @PageID,
    @ModuleID,
    @ModuleOrder,
    @PaneName,
    @CreatedDate,
    @PageGuid,
    @Guid
    
    
)
END


SELECT @ModuleID   //返回ModuleID

 

posted on   蓝蓝的天2016  阅读(329)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理
< 2009年4月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 1 2
3 4 5 6 7 8 9

点击右上角即可分享
微信分享提示