Embed
Email

CSDL va code

Document Sample

Shared by: dandanhuanghuang
Categories
Tags
Stats
views:
1
posted:
12/1/2011
language:
English
pages:
49
ChannelRole

Column Name Data Type Allow Nulls

Cell ChannelID int

Column Name Data Type Allow Nulls Role nvarchar(150)

CellID int

Viewed bit

Name varchar(50)

Edited bit

Description nvarchar(50)

Approved bit

Administrated bit









Channel

Panel Column Name Data Type Allow Nulls

Column Name Data Type Allow Nulls

ChannelID int

PanelID int

Name nvarchar(128)

ControlID int

Link nvarchar(255)

ChannelID int

ParentID int

CellID int

Priority int

Priority int

Locked bit

Header nvarchar(255)

Language smallint

DisplayContainer bit

RequireApprove bit

DisplayInAllChannel bit

Field1 nvarchar(255)

Field2 nvarchar(255)









Article

Column Name Data Type Allow Nulls

ArticleID int

Control TypeImage nvarchar(64)

Column Name Data Type Allow Nulls

HeadImage image

ControlID int

Title nvarchar(1000)

Name nvarchar(50)

Head ntext

SourceFile nvarchar(50)

[Content] ntext

Author nvarchar(100)

Approver nvarchar(100)

CreatedTime smalldatetime

Image

ModifiedTime smalldatetime

Column Name Data Type Allow Nulls

PublishedTime smalldatetime

ImageID int

ExpiredTime smalldatetime

Created smalldatetime

Status int

Type varchar(64)

[Content] image







PanelList

Column Name Data Type Allow Nulls

PanelID int

ItemID int

USE [master]

GO

/****** Object: Database [Hopdt_CMS] Script Date: 12/10/2010 00:53:21

******/

CREATE DATABASE [Hopdt_CMS] ON PRIMARY

( NAME = N'Hopdt_CMS', FILENAME =

N'D:\Task\HPortal\HPortal\App_Data\Hopdt_CMS.mdf' , SIZE = 3072KB , MAXSIZE =

UNLIMITED, FILEGROWTH = 1024KB )

LOG ON

( NAME = N'Hopdt_CMS_log', FILENAME =

N'D:\Task\HPortal\HPortal\App_Data\Hopdt_CMS_log.ldf' , SIZE = 1536KB ,

MAXSIZE = 2048GB , FILEGROWTH = 10%)

COLLATE SQL_Latin1_General_CP1_CI_AS

GO

EXEC dbo.sp_dbcmptlevel @dbname=N'Hopdt_CMS', @new_cmptlevel=90

GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))

begin

EXEC [Hopdt_CMS].[dbo].[sp_fulltext_database] @action = 'enable'

end

GO

ALTER DATABASE [Hopdt_CMS] SET ANSI_NULL_DEFAULT OFF

GO

ALTER DATABASE [Hopdt_CMS] SET ANSI_NULLS OFF

GO

ALTER DATABASE [Hopdt_CMS] SET ANSI_PADDING OFF

GO

ALTER DATABASE [Hopdt_CMS] SET ANSI_WARNINGS OFF

GO

ALTER DATABASE [Hopdt_CMS] SET ARITHABORT OFF

GO

ALTER DATABASE [Hopdt_CMS] SET AUTO_CLOSE OFF

GO

ALTER DATABASE [Hopdt_CMS] SET AUTO_CREATE_STATISTICS ON

GO

ALTER DATABASE [Hopdt_CMS] SET AUTO_SHRINK OFF

GO

ALTER DATABASE [Hopdt_CMS] SET AUTO_UPDATE_STATISTICS ON

GO

ALTER DATABASE [Hopdt_CMS] SET CURSOR_CLOSE_ON_COMMIT OFF

GO

ALTER DATABASE [Hopdt_CMS] SET CURSOR_DEFAULT GLOBAL

GO

ALTER DATABASE [Hopdt_CMS] SET CONCAT_NULL_YIELDS_NULL OFF

GO

ALTER DATABASE [Hopdt_CMS] SET NUMERIC_ROUNDABORT OFF

GO

ALTER DATABASE [Hopdt_CMS] SET QUOTED_IDENTIFIER OFF

GO

ALTER DATABASE [Hopdt_CMS] SET RECURSIVE_TRIGGERS OFF

GO

ALTER DATABASE [Hopdt_CMS] SET DISABLE_BROKER

GO

ALTER DATABASE [Hopdt_CMS] SET AUTO_UPDATE_STATISTICS_ASYNC OFF

GO

ALTER DATABASE [Hopdt_CMS] SET DATE_CORRELATION_OPTIMIZATION OFF

GO

ALTER DATABASE [Hopdt_CMS] SET TRUSTWORTHY OFF

GO

ALTER DATABASE [Hopdt_CMS] SET ALLOW_SNAPSHOT_ISOLATION OFF

GO

ALTER DATABASE [Hopdt_CMS] SET PARAMETERIZATION SIMPLE

GO

ALTER DATABASE [Hopdt_CMS] SET READ_WRITE

GO

ALTER DATABASE [Hopdt_CMS] SET RECOVERY FULL

GO

ALTER DATABASE [Hopdt_CMS] SET MULTI_USER

GO

ALTER DATABASE [Hopdt_CMS] SET PAGE_VERIFY CHECKSUM

GO

ALTER DATABASE [Hopdt_CMS] SET DB_CHAINING OFF

USE [Hopdt_CMS]

GO

/****** Object: Table [dbo].[Article] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Article](

[ArticleID] [int] IDENTITY(1,1) NOT NULL,

[TypeImage] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[HeadImage] [image] NULL,

[Title] [nvarchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Head] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Author] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Approver] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[CreatedTime] [smalldatetime] NOT NULL CONSTRAINT

[DF_ArticleT_CreatedTime] DEFAULT (getdate()),

[ModifiedTime] [smalldatetime] NOT NULL CONSTRAINT

[DF_ArticleT_ModifiedTime] DEFAULT (getdate()),

[PublishedTime] [smalldatetime] NOT NULL CONSTRAINT

[DF_ArticleT_PublishTime] DEFAULT (getdate()),

[ExpiredTime] [smalldatetime] NOT NULL CONSTRAINT

[DF_ArticleT_ExpireTime] DEFAULT (getdate()),

[Status] [int] NULL CONSTRAINT [DF_ArticleT_Status] DEFAULT ((1)),

CONSTRAINT [PK_ArticleT] PRIMARY KEY CLUSTERED

(

[ArticleID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]



GO

/****** Object: Table [dbo].[Cell] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

SET ANSI_PADDING ON

GO

CREATE TABLE [dbo].[Cell](

[CellID] [int] IDENTITY(1,1) NOT NULL,

[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Description] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

CONSTRAINT [PK_Cell] PRIMARY KEY CLUSTERED

(

[CellID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]



GO

SET ANSI_PADDING OFF

GO

/****** Object: Table [dbo].[Channel] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Channel](

[ChannelID] [int] IDENTITY(1,1) NOT NULL,

[Name] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Link] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[ParentID] [int] NULL,

[Priority] [int] NOT NULL,

[Locked] [bit] NOT NULL,

[Language] [smallint] NULL CONSTRAINT [DF_Channel_Language] DEFAULT

((2)),

[RequireApprove] [bit] NULL,

CONSTRAINT [PK_Channel_1] PRIMARY KEY CLUSTERED

(

[ChannelID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]



GO

/****** Object: Table [dbo].[ChannelRole] Script Date: 12/10/2010

00:54:33 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[ChannelRole](

[ChannelID] [int] NOT NULL,

[Role] [nvarchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[Viewed] [bit] NULL CONSTRAINT [DF_CRR_Viewed] DEFAULT ((0)),

[Edited] [bit] NULL CONSTRAINT [DF_CRR_Edited] DEFAULT ((0)),

[Approved] [bit] NULL CONSTRAINT [DF_CRR_Approved] DEFAULT ((0)),

[Administrated] [bit] NULL,

CONSTRAINT [PK_CRR] PRIMARY KEY CLUSTERED

(

[ChannelID] ASC,

[Role] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]



GO

/****** Object: Table [dbo].[Control] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Control](

[ControlID] [int] IDENTITY(1,1) NOT NULL,

[Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[SourceFile] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL,

CONSTRAINT [PK_Control] PRIMARY KEY CLUSTERED

(

[ControlID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

/****** Object: Table [dbo].[Image] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

SET ANSI_PADDING ON

GO

CREATE TABLE [dbo].[Image](

[ImageID] [int] IDENTITY(1,1) NOT NULL,

[Created] [smalldatetime] NOT NULL,

[Type] [varchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Content] [image] NULL,

CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED

(

[ImageID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]



GO

SET ANSI_PADDING OFF

GO

/****** Object: Table [dbo].[Panel] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Panel](

[PanelID] [int] IDENTITY(1,1) NOT NULL,

[ControlID] [int] NOT NULL,

[ChannelID] [int] NOT NULL,

[CellID] [int] NOT NULL,

[Priority] [int] NOT NULL CONSTRAINT [DF_Panel_Priority] DEFAULT

((1)),

[Header] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

CONSTRAINT [DF_Panel_ENHeader] DEFAULT (N'ENHeader'),

[DisplayContainer] [bit] NOT NULL CONSTRAINT

[DF_Panel_DisplayContainer] DEFAULT ((1)),

[DisplayInAllChannel] [bit] NOT NULL CONSTRAINT

[DF_Panel_DisplayInAllChannel] DEFAULT ((0)),

[Field1] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Field2] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

CONSTRAINT [PK_Panel] PRIMARY KEY CLUSTERED

(

[PanelID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]



GO

/****** Object: Table [dbo].[PanelList] Script Date: 12/10/2010 00:54:33

******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[PanelList](

[PanelID] [int] NOT NULL,

[ItemID] [int] NOT NULL,

CONSTRAINT [PK_ArticlePanel] PRIMARY KEY CLUSTERED

(

[ItemID] ASC,

[PanelID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]



GO

USE [Hopdt_CMS]

GO

USE [Hopdt_CMS]

GO

ALTER TABLE [dbo].[ChannelRole] WITH CHECK ADD CONSTRAINT

[FK_ChannelRole_Channel] FOREIGN KEY([ChannelID])

REFERENCES [dbo].[Channel] ([ChannelID])

GO

ALTER TABLE [dbo].[Panel] WITH CHECK ADD CONSTRAINT [FK_Panel_Cell] FOREIGN

KEY([CellID])

REFERENCES [dbo].[Cell] ([CellID])

GO

ALTER TABLE [dbo].[Panel] WITH CHECK ADD CONSTRAINT [FK_Panel_Channel]

FOREIGN KEY([ChannelID])

REFERENCES [dbo].[Channel] ([ChannelID])

GO

ALTER TABLE [dbo].[Panel] WITH CHECK ADD CONSTRAINT [FK_Panel_Control]

FOREIGN KEY([ControlID])

REFERENCES [dbo].[Control] ([ControlID])

USE [Hopdt_CMS]

GO

/****** Object: StoredProcedure [dbo].[deleteChannel] Script Date:

12/10/2010 00:41:55 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[deleteChannel]

@ChannelID int

AS

BEGIN

IF (Not(Exists(SELECT * FROM Channel WHERE ParentID=@ChannelID)))

BEGIN

DELETE FROM [panel]

WHERE [channelID]=@ChannelID

DELETE [channel]

WHERE [channelID] = @ChannelID

END

END





GO

/****** Object: StoredProcedure [dbo].[editChannelRole] Script Date:

12/10/2010 00:41:55 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[editChannelRole]

@ChannelID int,

@Role nvarchar(150),

@Viewed bit,

@Edited bit,

@Approved bit,

@Administrated bit

AS

BEGIN

IF (SELECT Count(ChannelID) FROM [ChannelRole] WHERE [Role]=@Role AND

[ChannelID]=@ChannelID) = 0

INSERT INTO [ChannelRole] ([ChannelID],[Role]) VALUES

(@ChannelID,@Role)

IF (@Viewednull)

UPDATE [ChannelRole] SET [Viewed] = @Viewed WHERE Role=@Role AND

ChannelID = @ChannelID;

IF (@Editednull)

UPDATE [ChannelRole] SET [Edited] = @Edited WHERE Role=@Role AND

ChannelID = @ChannelID;

IF (@Approvednull)

UPDATE [ChannelRole] SET [Approved] = @Approved WHERE Role=@Role

AND ChannelID = @ChannelID;

IF (@Administratednull)

UPDATE [ChannelRole] SET [Administrated] = @Administrated WHERE

Role=@Role AND ChannelID = @ChannelID;

DELETE [ChannelRole] WHERE [Viewed]=0 AND [Edited]=0 AND [Approved]=0

AND [Administrated]=0

END



GO

/****** Object: StoredProcedure [dbo].[getArticleList] Script Date:

12/10/2010 00:41:56 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[getArticleList]

@PanelID int

AS

BEGIN

SELECT

ArticleID,TypeImage,HeadImage,Title,Head,PublishedTime,dbo.GetStatus(Status)

as Status FROM Article WHERE ArticleID IN (Select ItemID From PanelList WHERE

PanelID=@PanelID) order by PublishedTime

END







GO

/****** Object: StoredProcedure [dbo].[getPanel] Script Date: 12/10/2010

00:41:56 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO









-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[getPanel]

@panelID int

AS

BEGIN

SELECT p.*,cl.Name as Cell,c.SourceFile FROM Panel p INNER JOIN Control

c on p.ControlID=c.ControlID INNER JOIN Cell cl ON p.CellID=cl.CellID WHERE

PanelID=@panelID

END









GO

/****** Object: StoredProcedure [dbo].[getPanelList] Script Date:

12/10/2010 00:41:56 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[getPanelList]

@channelID int

AS

BEGIN

SELECT p.*,cl.Description as Cell,c.Name as Control FROM Panel p INNER JOIN

Control c on p.ControlID=c.ControlID INNER JOIN Cell cl ON p.CellID=cl.CellID

WHERE ChannelID=@ChannelID order by cell,priority

END







GO

/****** Object: StoredProcedure [dbo].[InsertChannel] Script Date:

12/10/2010 00:41:57 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE PROCEDURE [dbo].[InsertChannel]

@Name nvarchar(128),

@Link nvarchar(255),

@ParentID int,

@Priority int,

@Locked bit,

@Language int,

@RequireApprove bit

AS

BEGIN

INSERT INTO

Channel([Name],Link,ParentID,Priority,Locked,Language,RequireApprove)

Values(@Name,@Link,@ParentID,@Priority,@Locked,@Language,@RequireApprove)

END





GO

/****** Object: StoredProcedure [dbo].[UpdateChannel] Script Date:

12/10/2010 00:41:57 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

Create PROCEDURE [dbo].[UpdateChannel]

@Name nvarchar(128),

@Link nvarchar(255),

@ParentID int,

@Locked bit,

@Language int,

@RequireApprove bit,

@ChannelID int

AS

BEGIN

Update Channel Set

[Name]=@Name,Link=@Link,ParentID=@ParentID,Locked=@Locked,[Language]=@Languag

e,RequireApprove=@RequireApprove WHERE ChannelID=@ChannelID

END



USE [Hopdt_CMS]

GO

/****** Object: Trigger [Delete_ChannelRole] Script Date: 12/10/2010

00:42:28 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE TRIGGER [Delete_ChannelRole] ON [dbo].[Channel]

FOR DELETE

AS

BEGIN

declare @channelid int

set @channelid =(select channelid from deleted)

delete from channelrole where channelid=@channelid

END

GO

/****** Object: Trigger [insert_ChannelRole] Script Date: 12/10/2010

00:42:28 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



-- =============================================

-- Author: Dang Trong Hop

-- Create date: 3/12/2010

-- Description: Chen Channel

-- =============================================

CREATE TRIGGER [insert_ChannelRole] ON [dbo].[Channel]

FOR INSERT

AS

BEGIN

declare @channelid int

set @channelid =(select top 1 channelid from inserted)

declare @parentID int

set @parentID =(select top 1 @parentID from inserted)



insert into channelrole values(@channelid,'Administrator',1,1,1,1)

insert into channelrole Select @channelID as

ChannelID,[Role],Viewed,Edited,Approved,Administrated From ChannelRole Where

ChannelID=@parentID AND Role 'Administrator'

END













































































































Banner













































































Footer



























using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using HPortal.Lib;

using System.Data;

using System.Data.SqlClient;

using System.Web.Security;



namespace HPortal.Backend

{

public partial class ChannelList : System.Web.UI.Page

{

private DataTable channel;



protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

channel = getChannel();

LoadMenu(trvChannelList.Nodes, 0);

}

}





private DataTable getChannel()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

where = "WHERE ChannelID IN (SELECT DISTINCT ChannelID

FROM [ChannelRole] WHERE ([Role] IN (" + where + ") AND (Edited=1 OR

Approved=1 OR Administrated=1)))";

string query = "SELECT * FROM [Channel] " + where + "

ORDER BY Language,[ParentID],[Priority],[ChannelID]";

return DatabaseHelper.Select(query);

}

public void LoadMenu(TreeNodeCollection tnc, int ParentID)

{

int j = 0;

if (channel != null)

{

while (j









Cập nhật thông tin trang















Tên

trang:















Nguồn liên kết:





default.aspx









Trang cha:



















Tiếng

Việt

Tiếng Anh







   

















Di chuyển trang























  



















Phân quyền quản trị trang



























'>









'

OnCheckedChanged="CheckedView" />









'

OnCheckedChanged="CheckedEdit" />









'

OnCheckedChanged="CheckedApprove"/>









'

OnCheckedChanged="CheckedAdministrate"/>







a

b















Trở lại 

 

Cập nhật

  

Xóa chuyên

mục

















using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using HPortal.Lib;

using System.Data;

using System.Data.SqlClient;

using System.Web.Security;



namespace HPortal.Backend

{

public partial class EditChannel : System.Web.UI.Page

{

int channelID = 0;

protected void Page_Load(object sender, EventArgs e)

{



if (checkPermission() == false)

{

Response.Redirect("ChannelList.aspx");

}



channelID =

int.Parse(HtmlHelper.GetRequestString("ChannelID", "0"));

if (!IsPostBack)

{

BindgrvChannelRole(channelID);

BindcboParent();



if (channelID == 0)//Add New Channel

{

this.cboParent.SelectedValue = "0";

}

else // Edit Channel

{

int Priority = 0;

SqlDataReader dr =

DatabaseHelper.SelectReader(null, "Channel", "ChannelID=" +

channelID);

while (dr.Read())

{

txtChannelName.Text = dr["Name"].ToString();

txtUrl.Text = dr["Link"].ToString();

chkLock.Checked = (bool)dr["Locked"];

Priority = (int)dr["Priority"];

this.cboParent.SelectedValue =

dr["ParentID"].ToString();

this.chkLang.SelectedIndex =

int.Parse(dr["Language"].ToString());

this.chkApprove.Checked =

Boolean.Parse(dr["RequireApprove"].ToString());

}

dr.Close();



ViewState["Priority"] = Priority;

int PriorityMax =

DatabaseHelper.SelectScalarInt("Max(Priority)", "Channel", "ParentID="

+ cboParent.SelectedValue);

int PriorityMin =

DatabaseHelper.SelectScalarInt("Min(Priority)", "Channel", "ParentID="

+ cboParent.SelectedValue);

this.imgDownChannel.Visible = Priority !=

PriorityMax;

this.imgUpChannel.Visible = Priority !=

PriorityMin;

}

}

}

private DataTable getChannel()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

where = "WHERE ChannelID IN (SELECT DISTINCT ChannelID

FROM [ChannelRole] WHERE ([Role] IN (" + where + ") AND

Administrated=1))";

string query = "SELECT * FROM [Channel] " + where + "

ORDER BY [ParentID],[Priority],[ChannelID]";

return DatabaseHelper.Select(query);

}

private Boolean checkPermission()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

string query = "SELECT count(*) FROM [ChannelRole] WHERE

([Role] IN (" + where + ") AND Administrated=1)";

if

(int.Parse(DatabaseHelper.SelectScalar(query).ToString()) > 0)

return true;

else

return false;

}

protected void BindcboParent()

{

this.cboParent.DataSource = getChannel();

this.cboParent.DataValueField = "ChannelID";

this.cboParent.DataTextField = "Name";

this.cboParent.DataBind();

ListItem li = new ListItem("", "0");

this.cboParent.Items.Add(li);

this.cboParent.SelectedIndex = 0;

}



protected void BindgrvChannelRole(int channelID)

{

string[] arrRoles = Roles.GetAllRoles();

grvChannelRole.DataSource = arrRoles;

grvChannelRole.DataBind();



SqlDataReader dr = DatabaseHelper.SelectReader(null,

"ChannelRole", "ChannelID=" + channelID);

while (dr.Read())

{

for (int i = 0; i = 0)

{

int ChannelIDNew =

DatabaseHelper.SelectScalarInt("ChannelID", "Channel", "ParentID=" +

cboParent.SelectedValue + " AND [Priority]=" + PriorityMax);

DatabaseHelper.Update("UPDATE [Channel] SET

[Priority]=" + PriorityMax + " WHERE [ChannelID]=" + channelID);

DatabaseHelper.Update("UPDATE [Channel] SET

[Priority]=" + Priority + " WHERE [ChannelID]=" + ChannelIDNew);

}

Response.Redirect("ChannelList.aspx");

}

protected void imgDownChannel_Click(object sender,

ImageClickEventArgs e)

{

int Priority = (int)ViewState["Priority"];

int PriorityMin =

DatabaseHelper.SelectScalarInt("Min(Priority)", "Channel", "ParentID="

+ cboParent.SelectedValue + " AND [Priority]>" + Priority);

if (PriorityMin > 0)

{

int ChannelIDNew =

DatabaseHelper.SelectScalarInt("ChannelID", "Channel", "ParentID=" +

cboParent.SelectedValue + " AND [Priority]=" + PriorityMin);

DatabaseHelper.Update("UPDATE [Channel] SET

[Priority]=" + PriorityMin + " WHERE [ChannelID]=" + channelID);

DatabaseHelper.Update("UPDATE [Channel] SET

[Priority]=" + Priority + " WHERE [ChannelID]=" + ChannelIDNew);

}

Response.Redirect("ChannelList.aspx");

}

}

}











Chuyên mục:



















Danh sách các khối tin trên trang























' onclick="lnkChoose_Click">





















Thêm khối tin vào trang







Mã khối tin











Tên khối tin











Kiểu hiển thị tin













Vùng hiển thị















Thứ tự











Lưu 1











Lưu 2

































    



    











 







 























using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using HPortal.Lib;

using System.Data;

using System.Data.SqlClient;

using System.Web.Security;



namespace HPortal.Backend

{

public partial class PanelList : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

BindcboChannel();

BindPanelList();

BindcboControl();

BindcboCell();

}

string panelID = txtPanelID.Text;

if (panelID != "")

{

cmdSave.Enabled = true;

cmdDelete.Enabled = true;

}

else

{

cmdSave.Enabled = false;

cmdDelete.Enabled = false;

}



}

private DataTable getChannel()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

where = "WHERE ChannelID IN (SELECT DISTINCT ChannelID

FROM [ChannelRole] WHERE ([Role] IN (" + where + ") AND

Administrated=1))";

string query = "SELECT * FROM [Channel] " + where + "

ORDER BY [ParentID],[Priority],[ChannelID]";

return DatabaseHelper.Select(query);

}

protected void BindcboChannel()

{

this.cboChannelList.DataSource = getChannel();

this.cboChannelList.DataValueField = "ChannelID";

this.cboChannelList.DataTextField = "Name";

this.cboChannelList.DataBind();

this.cboChannelList.SelectedIndex = 0;

}

protected void BindPanelList()

{

grvPanelList.DataSource = DatabaseHelper.Select("exec

getPanelList " + cboChannelList.SelectedValue);

grvPanelList.DataBind();

}

protected void BindcboControl()

{

this.cboControl.DataSource = DatabaseHelper.Select("SELECT

ControlID,Name FROM Control");

this.cboControl.DataValueField = "ControlID";

this.cboControl.DataTextField = "Name";

this.cboControl.DataBind();

this.cboControl.SelectedIndex = 0;

}

protected void BindcboCell()

{

this.cboCell.DataSource = DatabaseHelper.Select("SELECT

CellID,Description FROM Cell");

this.cboCell.DataValueField = "CellID";

this.cboCell.DataTextField = "Description";

this.cboCell.DataBind();

this.cboCell.SelectedIndex = 0;

}

protected void cboChannelList_SelectedIndexChanged(object

sender, EventArgs e)

{

grvPanelList.DataSource = DatabaseHelper.Select("exec

getPanelList " + cboChannelList.SelectedValue);

grvPanelList.DataBind();

}



protected void cmdSave_Click(object sender, EventArgs e)

{

DatabaseHelper.Update(new string[] { "N@Header",

"@ControlID", "@CellID", "@Priority", "@DisplayContainer",

"@DisplayInAllChannel", "N@Field1", "N@Field2" },

new string[] { txtHeader.Text,

cboControl.SelectedValue, cboCell.SelectedValue, txtPriority.Text,

(chkDisplayContainer.Checked ? "1" : "0"),

(chkDisplayInAllChannel.Checked ? "1" : "0"),

txtField1.Text,txtField2.Text},

"Panel", "[PanelID]=" + txtPanelID.Text);

BindPanelList();

}



protected void cmdNew_Click(object sender, EventArgs e)

{

DatabaseHelper.Insert(new string[] { "N@Header",

"@ControlID", "@ChannelID", "@CellID", "@Priority",

"@DisplayContainer", "@DisplayInAllChannel", "N@Field1", "N@Field2" },

new string[] { txtHeader.Text,

cboControl.SelectedValue,cboChannelList.SelectedValue,

cboCell.SelectedValue, txtPriority.Text, (chkDisplayContainer.Checked

? "1" : "0"), (chkDisplayInAllChannel.Checked ? "1" : "0"),

txtField1.Text, txtField2.Text },"Panel");

BindPanelList();

}



protected void cmdDelete_Click(object sender, EventArgs e)

{

DatabaseHelper.Delete("Panel", "PanelID=" +

txtPanelID.Text);

BindPanelList();

}



protected void lnkChoose_Click(object sender, EventArgs e)

{

string panelID = ((LinkButton)sender).CommandArgument;

if (panelID != "")

{

DataTable p = DatabaseHelper.Select("SELECT * FROM

Panel WHERE PanelID=" + panelID);

if (p.Rows.Count > 0)

{

txtHeader.Text = p.Rows[0]["Header"].ToString();

txtPanelID.Text = p.Rows[0]["PanelID"].ToString();

txtPriority.Text =

p.Rows[0]["Priority"].ToString();

txtField1.Text = p.Rows[0]["Field1"].ToString();

txtField2.Text = p.Rows[0]["Field2"].ToString();

cboCell.SelectedValue =

p.Rows[0]["CellID"].ToString();

cboControl.SelectedValue =

p.Rows[0]["ControlID"].ToString();

}

cmdSave.Enabled = true;

cmdDelete.Enabled = true;

}

else

{

cmdSave.Enabled = false;

cmdDelete.Enabled = false;

}

}



}

}











Chuyên mục:

















Khối tin:



















Danh sách bài viết trên khối tin











































using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using HPortal.Lib;

using System.Data;

using System.Data.SqlClient;

using System.Web.Security;



namespace HPortal.Backend

{

public partial class ArticleList : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

BindcboChannel();

}

private DataTable getChannel()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

where = "WHERE ChannelID IN (SELECT DISTINCT ChannelID

FROM [ChannelRole] WHERE ([Role] IN (" + where + ") AND (Edited=1 OR

Approved=1 OR Administrated=1)))";

string query = "SELECT * FROM [Channel] " + where + "

ORDER BY [ParentID],[Priority],[ChannelID]";

return DatabaseHelper.Select(query);

}

protected void BindcboChannel()

{

this.cboChannelList.DataSource = getChannel();

this.cboChannelList.DataValueField = "ChannelID";

this.cboChannelList.DataTextField = "Name";

this.cboChannelList.DataBind();

this.cboChannelList.SelectedIndex = 0;

}

protected void BindPanelList()

{

cboPanelList.DataSource = DatabaseHelper.Select("exec

getPanelList " + cboChannelList.SelectedValue);

cboPanelList.DataValueField = "PanelID";

cboPanelList.DataTextField = "Header";

cboPanelList.DataBind();

}

protected void cboChannelList_SelectedIndexChanged(object

sender, EventArgs e)

{

BindPanelList();

}



protected void cboPanelList_SelectedIndexChanged(object

sender, EventArgs e)

{

BinhArticleList();

}

protected void BinhArticleList()

{

grvArticlelList.DataSource = DatabaseHelper.Select("exec

getArticleList " + cboPanelList.SelectedValue);

grvArticlelList.DataBind();

}

public string WriteArticleImage(object ImageType, int

ArticleID_, string Url, int width)

{



if (ImageType != System.DBNull.Value)

{

return "";

}

return string.Empty;

}

}

}









Soạn thảo bài viết



















Chuyên mục:





















Khối tin:



















Tiêu đề bài viết



















Tóm tắt nội dung















Ảnh minh họa 

















Ngày bắt đầu



















Ngày kết thúc











































   

 













using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using HPortal.Lib;

using System.Data;

using System.Data.SqlClient;

using System.Web.Security;



namespace HPortal.Backend

{

public partial class ArticleEdit : System.Web.UI.Page

{

public int ArticleID =

HtmlHelper.GetIdFromRequestString("ArticleID", -1);

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

BindcboChannel();



if (this.ArticleID != -1)

{

SqlDataReader dr =

DatabaseHelper.SelectReader(null, "Article", "ArticleID=" +

ArticleID);

while (dr.Read())

{

txtTitle.Text = dr["Title"].ToString();

txtHead.Text = dr["Head"].ToString();

txtContent.Value = dr["Content"].ToString();

txtPublishTime.Text =

StringHelper.ConvertDateTime((DateTime)dr["PublishedTime"]);

txtExpireTime.Text =

StringHelper.ConvertDateTime((DateTime)dr["ExpiredTime"]);



cmdAddArticle.Text = "Lưu bài";

}

dr.Close();

int PanelID =

DatabaseHelper.SelectScalarInt("PanelID", "PanelList", "ItemID=" +

ArticleID);

cboChannelList.SelectedValue =

DatabaseHelper.SelectScalarInt("ChannelID", "Panel", "PanelID=" +

PanelID).ToString();

cboPanelList.SelectedValue = PanelID.ToString();

cmdDelete.Visible = true;

}

else

{

//INSERT

txtPublishTime.Text =

StringHelper.ConvertDateTime(DateTime.Now.Date);

txtExpireTime.Text =

StringHelper.ConvertDateTime(DateTime.Now.AddMonths(3));

cmdDelete.Visible = false;

}

}

////bool requireApprove =

DatabaseHelper.SelectScalarBool("RequireApprove", "Panel", "PanelID="

+ cboChannelList.SelectedValue);

//if (requireApprove && !IsRoleOfPanel(PanelID,

"Approved"))

{

cmdPublic.Visible = false;

}

//else

cmdPublic.Visible = true;

}



private DataTable getChannel()

{

string where = string.Empty;

if (this.Context.User.Identity.IsAuthenticated)

{

string[] arrRoleName =

Roles.GetRolesForUser(this.Context.User.Identity.Name);

foreach (string roleName in arrRoleName)

{

where +=

DatabaseHelper.EscapeQuoteUnicode(roleName) + ",";

}



}

where = where.Remove(where.Length - 1);

where = "WHERE ChannelID IN (SELECT DISTINCT ChannelID

FROM [ChannelRole] WHERE ([Role] IN (" + where + ")AND (Edited=1 OR

Approved=1 OR Administrated=1)))";

string query = "SELECT * FROM [Channel] " + where + "

ORDER BY [ParentID],[Priority],[ChannelID]";

return DatabaseHelper.Select(query);

}

protected void BindcboChannel()

{

this.cboChannelList.DataSource = getChannel();

this.cboChannelList.DataValueField = "ChannelID";

this.cboChannelList.DataTextField = "Name";

this.cboChannelList.DataBind();

this.cboChannelList.Items.Insert(0, "Chọn chuyên mục");

this.cboChannelList.SelectedIndex = 0;

}

protected void BindPanelList()

{

cboPanelList.DataSource = DatabaseHelper.Select("exec

getPanelList " + cboChannelList.SelectedValue);

cboPanelList.DataValueField = "PanelID";

cboPanelList.DataTextField = "Header";

cboPanelList.DataBind();

}

protected void cboChannelList_SelectedIndexChanged(object

sender, EventArgs e)

{

BindPanelList();

}

public void SaveArticle(int status)

{

string ImageType = flImage.PostedFile.ContentType;

byte[] ImageContent = new

byte[flImage.PostedFile.ContentLength];

flImage.PostedFile.InputStream.Read(ImageContent, 0,

ImageContent.Length);

string Title = txtTitle.Text.Trim();

string Head = txtHead.Text.Trim();

string Content = txtContent.Value.Trim();

string AuthorName = this.Context.User.Identity.Name;

DateTime publishedTime =

DateTime.Parse(txtPublishTime.Text);

publishedTime = new DateTime(publishedTime.Year,

publishedTime.Month, publishedTime.Day, DateTime.Now.Hour,

DateTime.Now.Minute, DateTime.Now.Second);

DateTime expiredTime = DateTime.Parse(txtExpireTime.Text);

expiredTime = new DateTime(expiredTime.Year,

expiredTime.Month, expiredTime.Day, DateTime.Now.Hour,

DateTime.Now.Minute, DateTime.Now.Second);

if (ArticleID == -1)//INSERT

{

int ArticleID_Identity =

DatabaseHelper.InsertIdentity("TypeImage", "HeadImage", ImageContent,

ImageType,

new string[] { "N@Title", "N@Head", "N@Content",

"N@Author", "@ModifiedTime", "@PublishedTime", "@ExpiredTime",

"@Status" },

new string[]{ Title,

Head,

Content,

AuthorName,

DateTime.Now.ToString(),

publishedTime.ToString(),

expiredTime.ToString(),

status.ToString(),

}, "Article");

DatabaseHelper.Insert("INSERT INTO [PanelList]

([ItemID],[PanelID]) VALUES (" + ArticleID_Identity + ","

+cboPanelList.SelectedValue + ")");

}

else // UPDATE

{

DatabaseHelper.Update("TypeImage", "HeadImage",

ImageContent, ImageType,

new string[] { "N@Title", "N@Head", "N@Content",

"N@Approver", "@ModifiedTime", "@PublishedTime", "@ExpiredTime",

"@Status" },

new string[]{ Title,

Head,

Content,

AuthorName,

DateTime.Now.ToString(),

publishedTime.ToString(),

expiredTime.ToString(),

status.ToString(),

}, "Article", "ArticleID=" +

ArticleID);



}



Response.Redirect("~/default.aspx?ChannelID=" +

cboChannelList.SelectedValue);

}



protected void cmdAddArticle_Click(object sender, EventArgs e)

{

SaveArticle(1);

}



protected void cmdSubmit_Click(object sender, EventArgs e)

{

SaveArticle(2);

}



protected void cmdPublic_Click(object sender, EventArgs e)

{

if(chkTop.Checked ==true)

SaveArticle(4);

else

SaveArticle(3);

}



protected void cmdDelete_Click(object sender, EventArgs e)

{

if (ArticleID != -1)

{

DatabaseHelper.Delete("Article", "ArticleID=" +

ArticleID);

Response.Redirect("default.aspx?ChannelID=" +

cboChannelList.SelectedValue);

}

}

}

}



Related docs
Other docs by dandanhuanghua...
CSCE_Postgrad_Research_Students_Guidelines
Views: 0  |  Downloads: 0
F
Views: 6  |  Downloads: 0
SDS_User_Manual
Views: 3  |  Downloads: 0
systémy - FEL wiki
Views: 0  |  Downloads: 0
Alan Kalter - Bio 020812
Views: 0  |  Downloads: 0
Battery Balancer - Control Board
Views: 0  |  Downloads: 0
cocuk_1_erkekler
Views: 0  |  Downloads: 0
CARLSON.TESTIMONY
Views: 0  |  Downloads: 0
New_York_2011_info_letter_1_
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!