+------------------------------------------------------------------------------------------------------+
ASP三层架构中的事件处理/表单提交(3) [2005-11-3] Xmercy 发表在 Develop
| 3.表单数据读取/校验 按上一步骤,表单将转交给下面的实例类处理: /Action/News.asp
<!--#include virtual="/Class/Package.asp"--> <!--#include virtual="/Class/Bll/News.asp"--> <!--#include virtual="/Class/Bll/Admin.asp"--> <% Class ActionNews
Private news private admin Private Session
Public Property Let NewsID(ByVal value) news.NewsID = value End Property Public Property Get NewsID() If IsEmpty(news.NewsID) Then news.NewsID = Request("NewsID") End If NewsID = news.NewsID End Property
Public Property Let ClassID(ByVal value) news.ClassID = value End Property Public Property Get ClassID() If IsEmpty(news.ClassID) Then news.ClassID = Request.Form("ClassID") End If ClassID = news.ClassID End Property
Public Property Let Title(ByVal value) news.Title = value End Property Public Property Get Title() If IsEmpty(news.Title) Then news.Title = Request.Form("Title") End If Title = news.Title End Property
Public Property Let Content(ByVal value) news.Content = value End Property Public Property Get Content() If IsEmpty(news.Content) Then news.Content = Request.Form("Content") End If Content = news.Content End Property Public Property Let Picture(ByVal value) news.Picture = value End Property Public Property Get Picture() If IsEmpty(news.Picture) Then news.Picture = Request.Form("Picture") End If Picture = news.Picture End Property Public Property Let IsCommend(ByVal value) news.IsCommend = value End Property Public Property Get IsCommend() If IsEmpty(news.IsCommend) Then news.IsCommend = (Request.Form("IsCommend") = "1") End If IsCommend = news.IsCommend End Property
Public Property Let Hits(ByVal value) news.Hits = value End Property Public Property Get Hits() If IsEmpty(news.Hits) Then news.Hits = Request.Form("Hits") End If Hits = Request.Form("Hits") End Property
Public Property Get NewsIDs() NewsIDs = Request.Form("NewsIDs") End Property
Public Property Get Action() Action = Request.QueryString("actionID") End Property
Public Function Execute() admin.CheckLogin() Select Case Action Case "insert" ClassID Title Content Picture IsCommend Hits news.Insert() Case "edit" NewsID ClassID Title Content Picture IsCommend Hits news.Update() Case "delete" If NewsIDs <> "" Then news.BatchDelete(NewsIDs) Else NewsID news.Throw() news.Delete() End If Case Else Response.Redirect "/" End Select news.Throw() End Function
Private Sub Class_initialize() Set news = New BllNews Set admin = New BllAdmin Set Session = New SessionState End Sub Private Sub Class_Terminate() Set news = Nothing Set admin = Nothing Set Session = Nothing End Sub
End Class %> <% Dim a : Set a = New ActionNews a.Execute() Set a = Nothing %> | |
+------------------------------------------------------------------------------------------------------+ |