普通列表頁面指的是上一章那種有層次感列表以外的正常列表頁面,由于上一章已講解了正常添加頁面的相關操作了,所以部分相關的操作本章節就不再羅嗦重復一次了。大家可以試試先用本章內容中的一些簡單介紹,自己使用上一章下載的解決方案來實現一下,做做練習。
首先還是打開數據字典,創建廣告內容表
在這里要說明一下的是,大家在對數據字典進行操作后(增、改、刪),一定要在數據字典中的“版本”工作表中添加更新歷史,以方便后面的維護人員查看(一定要養成一種良好的開發習慣),如下圖
然后還是使用ExcelToSQLString2.91_sql.exe工具生成SQL語句,并在數據庫中創建數據表,下面是生成好的SQL語句,請在數據庫查詢分析表中執行
1 /****** Object: Table [dbo].[Advertisement] Script Date: 2014/7/9 17:07:11 ******/ 2 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Advertisement]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 3 drop table [dbo].[Advertisement] 4 GO 5 6 /****** Object: Table [dbo].[Advertisement] Script Date: 2014/7/9 17:07:11 ******/ 7 CREATE TABLE [dbo].[Advertisement] ( 8 [Id] [int] IDENTITY (1, 1) NOT NULL, 9 [Name] [nvarchar] (50) NOT NULL, 10 [Content] [nvarchar] (100) NOT NULL, 11 [Url] [nvarchar] (200) NOT NULL, 12 [KeyWord] [nvarchar] (50) NOT NULL, 13 [AdvertisingPosition_Id] [int] NOT NULL, 14 [AdvertisingPosition_Name] [nvarchar] (20) NOT NULL, 15 [AdImg] [nvarchar] (250) NOT NULL, 16 [ShowRate] [int] NOT NULL, 17 [StartTime] [datetime] NOT NULL, 18 [EndTime] [datetime] NOT NULL, 19 [IsDisplay] [tinyint] NOT NULL, 20 [HitCount] [int] NOT NULL, 21 [Sort] [int] NOT NULL, 22 [Manager_Id] [int] NOT NULL, 23 [Manager_CName] [nvarchar] (20) NOT NULL, 24 [UpdateDate] [datetime] NOT NULL 25 ) ON [PRIMARY] 26 GO 27 28 ALTER TABLE [dbo].[Advertisement] WITH NOCHECK ADD 29 CONSTRAINT [PK_Advertisement] PRIMARY KEY CLUSTERED 30 ( 31 [Id] 32 ) ON [PRIMARY] 33 GO 34 35 ALTER TABLE [dbo].[Advertisement] ADD 36 CONSTRAINT [DF_Advertisement_Name] DEFAULT ('') FOR [Name], 37 CONSTRAINT [DF_Advertisement_Content] DEFAULT ('') FOR [Content], 38 CONSTRAINT [DF_Advertisement_Url] DEFAULT ('') FOR [Url], 39 CONSTRAINT [DF_Advertisement_Keyword] DEFAULT ('') FOR [Keyword], 40 CONSTRAINT [DF_Advertisement_AdvertisingPosition_Id] DEFAULT (0) FOR [AdvertisingPosition_Id], 41 CONSTRAINT [DF_Advertisement_AdvertisingPosition_Name] DEFAULT ('') FOR [AdvertisingPosition_Name], 42 CONSTRAINT [DF_Advertisement_AdImg] DEFAULT ('') FOR [AdImg], 43 CONSTRAINT [DF_Advertisement_ShowRate] DEFAULT (0) FOR [ShowRate], 44 CONSTRAINT [DF_Advertisement_StartTime] DEFAULT (getdate()) FOR [StartTime], 45 CONSTRAINT [DF_Advertisement_EndTime] DEFAULT (getdate()) FOR [EndTime], 46 CONSTRAINT [DF_Advertisement_IsDisplay] DEFAULT (0) FOR [IsDisplay], 47 CONSTRAINT [DF_Advertisement_HitCount] DEFAULT (0) FOR [HitCount], 48 CONSTRAINT [DF_Advertisement_Sort] DEFAULT (0) FOR [Sort], 49 CONSTRAINT [DF_Advertisement_Manager_Id] DEFAULT (0) FOR [Manager_Id], 50 CONSTRAINT [DF_Advertisement_Manager_CName] DEFAULT ('') FOR [Manager_CName], 51 CONSTRAINT [DF_Advertisement_UpdateDate] DEFAULT (getdate()) FOR [UpdateDate] 52 GO 53 54 CREATE INDEX [IX_Advertisement__Name] ON [dbo].[Advertisement]([Name]) ON [PRIMARY] 55 GO 56 57 CREATE INDEX [IX_Advertisement__Keyword] ON [dbo].[Advertisement]([Keyword]) ON [PRIMARY] 58 GO 59 60 CREATE INDEX [IX_Advertisement__AdvertisingPosition_Id] ON [dbo].[Advertisement]([AdvertisingPosition_Id]) ON [PRIMARY] 61 GO 62 63 CREATE INDEX [IX_Advertisement__StartTime] ON [dbo].[Advertisement]([StartTime]) ON [PRIMARY] 64 GO 65 66 CREATE INDEX [IX_Advertisement__EndTime] ON [dbo].[Advertisement]([EndTime]) ON [PRIMARY] 67 GO 68 69 CREATE INDEX [IX_Advertisement__IsDisplay] ON [dbo].[Advertisement]([IsDisplay]) ON [PRIMARY] 70 GO 71 72 CREATE INDEX [IX_Advertisement__Sort] ON [dbo].[Advertisement]([Sort]) ON [PRIMARY] 73 GO 74 75 exec sp_addextendedproperty N'MS_Description', N'主鍵Id', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Id' 76 GO 77 78 exec sp_addextendedproperty N'MS_Description', N'標題', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Name' 79 GO 80 81 exec sp_addextendedproperty N'MS_Description', N'備注', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Content' 82 GO 83 84 exec sp_addextendedproperty N'MS_Description', N'鏈接Url', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Url' 85 GO 86 87 exec sp_addextendedproperty N'MS_Description', N'關鍵字,只能由字母數字組成,主要用于模板標簽 {%ad-InfoKey%}', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Keyword' 88 GO 89 90 exec sp_addextendedproperty N'MS_Description', N'廣告位置Id', N'user', N'dbo', N'table', N'Advertisement', N'column', N'AdvertisingPosition_Id' 91 GO 92 93 exec sp_addextendedproperty N'MS_Description', N'廣告位置名稱', N'user', N'dbo', N'table', N'Advertisement', N'column', N'AdvertisingPosition_Name' 94 GO 95 96 exec sp_addextendedproperty N'MS_Description', N'圖片', N'user', N'dbo', N'table', N'Advertisement', N'column', N'AdImg' 97 GO 98 99 exec sp_addextendedproperty N'MS_Description', N'顯示頻率(同一個位置有多個廣告時,這里用來計算它隨機出現的頻率)', N'user', N'dbo', N'table', N'Advertisement', N'column', N'ShowRate'100 GO101 102 exec sp_addextendedproperty N'MS_Description', N'開始時間', N'user', N'dbo', N'table', N'Advertisement', N'column', N'StartTime'103 GO104 105 exec sp_addextendedproperty N'MS_Description', N'結束時間', N'user', N'dbo', N'table', N'Advertisement', N'column', N'EndTime'106 GO107 108 exec sp_addextendedproperty N'MS_Description', N'審核, 0=False,1=True,', N'user', N'dbo', N'table', N'Advertisement', N'column', N'IsDisplay'109 GO110 111 exec sp_addextendedproperty N'MS_Description', N'點擊數', N'user', N'dbo', N'table', N'Advertisement', N'column', N'HitCount'112 GO113 114 exec sp_addextendedproperty N'MS_Description', N'排序', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Sort'115 GO116 117 exec sp_addextendedproperty N'MS_Description', N'修改人員id', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Manager_Id'118 GO119 120 exec sp_addextendedproperty N'MS_Description', N'修改人員姓名', N'user', N'dbo', N'table', N'Advertisement', N'column', N'Manager_CName'121 GO122 123 exec sp_addextendedproperty N'MS_Description', N'修改時間', N'user', N'dbo', N'table', N'Advertisement', N'column', N'UpdateDate'124 GOView Code
跟著打開VS,找到數據層與邏輯層的SubSonic文件夾,選擇模板并點擊右鍵,找到“運行自定義工具”,點擊重新運行生成相關的模板類
打開Informations文件夾,將InformationList.aspx與InformationEdit.aspx復制到Advertisements(上一章廣告文件夾命名錯了,我將AdvertisingPositions重新修改為Advertisements)文件夾中
將它們修改名稱為AdvertisementList.aspx與AdvertisementEdit.aspx
然后將頁面中的“Information”替換成“Advertisement”,“信息”替換為“廣告”。
下面是改好的AdvertisementList.aspx頁面代碼
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdvertisementList.aspx.cs" Inherits="Solution.Web.Managers.WebManage.Advertisements.AdvertisementList" %> 2 <%@ Import Namespace="DotNet.Utilities" %> 3 4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head id="Head1" runat="server"> 7 <title>廣告列表</title> 8 </head> 9 <body> 10 <form id="form1" runat="server
新聞熱點
疑難解答