Free 3 Months
|
| |
| AspTger | Asp.Net User |
| How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 6/12/2006 1:28:40 AM |
0/0 | |
|
To All experts,
Please help.
I am trying to add more variables to an Ad posting. For instance zip code, Date of availibility etc.
Can some one please list the Steps I need to follow to achieve this. Like what changes I should make to the DB and what files I should touch etc.
The Postad form uses Stored procedures, Is there an easy way to modify the stored procedures through the GUI ?
Thanks a lot in advance.
-AspTiger.
|
| marcgel | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 6/23/2006 10:26:58 PM |
0/0 | |
|
What you want to do can be done, but it will take some time to work through all the details. There are probably several ways to approach the additional fields. I think from the data structures (tables, stored procedures) out to the data layers and then to the UI. So with that bias here are some steps to get you oriented. (I'm sure some things are missing.)
Starting with the database:
1. Add extra fields to Ads table (You can create an auxiliary table that has AdID as key - but I won't consider that solution here.)
2. Modify ClassifiedsView_Ads view with new fields.
3. Modify the trigger on the Ads table "AdUpdated" to reflect the new fields added to the Ads table. Other triggers are okay.
4. The following stored procedures are affect/not affected (this is a first-pass estimate looking at the functionality quickly so check for yourself): GetAdByID() - modify to return new fields ExpireAd() - no change GeAdsByRandomOrder() - no change - uses ClassifiedView_Ads GetAdsByStatus() - no change - uses ClassifiedView_Ads GetAllAdsByQuery() - modify with any new input parameter that involve new fields GetExpiredAds() - no change - uses ClassifiedView_Ads GetSavedAds() - modify to return new fields InsertAd() - modify to insert new fields InsertSavedAd() - no change MoveAds() - no change RelistAd() - modify to account for new fields RemoveAd() - no change RemoveAdsByStatus() - no change RemoveSavedAd() - no change UpdateAd() - modify to account for new fields UpdateAdCategory() - no change UpdateAdLevel() - no change UpdateAdStats() - no change UpdateAdStatus() - no change
In the Web App:
5. Go into App_Code\DAL\Ads.xsd and add any new parameters that were created in the database stored procedures. You need to add the new columns to the Ads DataTable.
6. In the App_Code\BLL\Ads.cs you will have to make changes to the AdsDB class to account for all the input/output of the new fields. In particular, the UpdateAd method, GetAdsByQuery method, GetActiveAdsByQuery method, and InsertAd method.
7. Aspx files that do the data-related work.
EditAd.aspx - modify objectdatasource ID="AdDataSource" to have appropriate <asp:Parameters>
PostAd.aspx.cs - change code to reflect new parameters or inserting and relisting operations.
Admin/Ads.aspx - similar to EditAd.aspx need to modify ObjectDataSource parameters.
UI work:
8. Modify the UI to capture the new information. Include original ad creation , relisting, updating, and admin function (Admin/Ads.aspx).
[This posting is provided "AS IS" with no warranties, and confers no rights.] |
| yhhaw | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 6/27/2006 6:05:40 AM |
0/0 | |
|
Hi Marcgel,
I am trying to add "contact no" as one of the variables .....
I have got the problem to follow your step 3 & 8 (don't understand), and I skip. When I debug, I am getting the following error:
Please Help.
Server Error in '/PriceDB' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30311: Value of type 'System.Nullable(Of Date)' cannot be converted to 'Integer'.
Source Error:
|
Line 98: Dim ad As AdsDataComponent.AdsRow = Nothing
Line 99: Using db As New AdsDataAdapter()
Line 100: adId = CInt(db.InsertAd(memberId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, numViews, numResponses, CInt(adLevel), CInt(adStatus), CInt(adType)))
Line 101:
Line 102: If s.AdminNotification = AdminNotificationSetting.EachAd Then
| Source File: C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb Line: 100
Show Detailed Compiler Output:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.dll" /D:DEBUG=1 /debug+ /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.7.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.16.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.5.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.2.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.18.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.23.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.12.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.6.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.17.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.10.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.4.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.8.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.19.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.20.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.11.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.9.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.3.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.21.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.1.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.22.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.13.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.15.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\pricedb\be42e5e6\b6af51d3\App_Code.aazkudau.14.vb"
Microsoft (R) Visual Basic Compiler version 8.0.50727.42
for Microsoft (R) .NET Framework version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(100) : error BC30311: Value of type 'System.Nullable(Of Date)' cannot be converted to 'Integer'.
adId = CInt(db.InsertAd(memberId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, numViews, numResponses, CInt(adLevel), CInt(adStatus), CInt(adType)))
~~~~~~~~~~~~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(100) : error BC30057: Too many arguments to 'Public Overridable Overloads Function InsertAd(MemberId As Integer, CategoryId As Integer, Title As String, Description As String, URL As String, Price As Decimal, Location As String, ExpirationDate As System.Nullable(Of Date), DateCreated As Date, DateApproved As System.Nullable(Of Date), NumViews As Integer, NumResponses As Integer, AdLevel As Integer, AdStatus As Integer, AdType As Integer) As System.Nullable(Of Integer)'.
adId = CInt(db.InsertAd(memberId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, numViews, numResponses, CInt(adLevel), CInt(adStatus), CInt(adType)))
~~~~~~~~~~~~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(237) : error BC30237: Parameter already declared with name 'title'.
Public Shared Sub UpdateAd(ByVal original_Id As Integer, ByVal memberId As Integer, ByVal title As String, ByVal description As String, ByVal title As String,, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal isRelisting As Boolean)
~~~~~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(237) : error BC30203: Identifier expected.
Public Shared Sub UpdateAd(ByVal original_Id As Integer, ByVal memberId As Integer, ByVal title As String, ByVal description As String, ByVal title As String,, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal isRelisting As Boolean)
~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(246) : error BC30451: Name 'ContactNo' is not declared.
HttpUtility.HtmlEncode(ContactNo), _
~~~~~~~~~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(285) : error BC30311: Value of type 'System.Nullable(Of Date)' cannot be converted to 'System.Nullable(Of Integer)'.
db.RelistAd(adId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, CInt(adLevel), CInt(adStatus), CInt(adType))
~~~~~~~~~~~~
C:\Documents and Settings\Jerry\My Documents\Visual Studio 2005\WebSites\PriceDB\App_Code\BLL\Ads.vb(285) : error BC30057: Too many arguments to 'Public Overridable Overloads Function RelistAd(AdId As System.Nullable(Of Integer), CategoryId As System.Nullable(Of Integer), Title As String, Description As String, URL As String, Price As System.Nullable(Of Decimal), Location As String, ExpirationDate As System.Nullable(Of Date), DateCreated As System.Nullable(Of Date), DateApproved As System.Nullable(Of Date), AdLevel As System.Nullable(Of Integer), AdStatus As System.Nullable(Of Integer), AdType As System.Nullable(Of Integer)) As Integer'.
db.RelistAd(adId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, CInt(adLevel), CInt(adStatus), CInt(adType))
~~~~~~~~~~~~
|
Show Complete Compilation Source:
Line 1: Imports System
Line 2: Imports System.Web
Line 3: Imports System.Web.Security
Line 4: Imports System.Text
Line 5: Imports System.Net.Mail
Line 6: Imports System.Collections
Line 7: Imports System.Collections.Generic
Line 8: Imports AdsDataComponentTableAdapters
Line 9:
Line 10: Imports AspNet.StarterKits.Classifieds.Web
Line 11:
Line 12: Namespace AspNet.StarterKits.Classifieds.BusinessLogicLayer
Line 13:
Line 14: ''' <summary>
Line 15: ''' Describes the type of an ad: "For Sale" or "Wanted."
Line 16: ''' "Unspecified" is used to indicate a variable of this type has not yet been set.
Line 17: ''' </summary>
Line 18: Public Enum AdType
Line 19: Unspecified = 0
Line 20: ForSale = 1
Line 21: Wanted = 2
Line 22: End Enum
Line 23: ''' <summary>
Line 24: ''' Describes the level, or priority, of an ad.
Line 25: ''' This value is used when ordering results (highest to lowest)
Line 26: ''' on search queries and it can affect the display of rows.
Line 27: '''
Line 28: ''' "Featured" indicates that the ad will be selected by the "Featured Ad" control
Line 29: ''' that rotates ads to display on the site.
Line 30: ''' "Unspecified" is used to indicate a variable of this type has not yet been set.
Line 31: '''
Line 32: ''' Use this enumeration to differentiate ads with different priorities
Line 33: ''' or even price points.
Line 34: ''' </summary>
Line 35: Public Enum AdLevel
Line 36: Unspecified = 0
Line 37: Normal = 10
Line 38: Featured = 50
Line 39: End Enum
Line 40:
Line 41: ''' <summary>
Line 42: ''' Describes the status of an ad:
Line 43: ''' Only ads with positive AdStatus values will be displayed on the public site;
Line 44: ''' administrators will be able to see all.
Line 45: '''
Line 46: '''
Line 47: '''
Line 48: ''' "Unspecified" is used to indicate a variable of this type has not yet been set.
Line 49: ''' </summary>
Line 50: Public Enum AdStatus
Line 51: ActivationPending = -200
Line 52: Deleted = -100
Line 53: Inactive = -50
Line 54: Unspecified = 0
Line 55: Activated = 100
Line 56: End Enum
Line 57:
Line 58: Public NotInheritable Class AdsDB
Line 59:
Line 60:
Line 61: Private Sub New()
Line 62: End Sub
Line 63:
Line 64: #Region "InsertingAds"
Line 65:
Line 66: Public Shared Function InsertAd(ByVal memberId As Integer, ByVal categoryId As Integer, ByVal title As String, ByVal description As String, ByVal ContactNo As String, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal numDaysActive As Integer, ByVal adLevel As AdLevel, ByVal adStatus As AdStatus, ByVal adType As AdType) As Integer
Line 67:
Line 68: Dim s As SiteSettings = SiteSettings.GetSharedSettings()
Line 69:
Line 70: Dim numViews As Integer = 0
Line 71: Dim numResponses As Integer = 0
Line 72: Dim dateCreated As DateTime = DateTime.Now
Line 73: Dim dateApproved As System.Nullable(Of DateTime)
Line 74:
Line 75: If numDaysActive > s.MaxAdRunningDays Then
Line 76: numDaysActive = s.MaxAdRunningDays
Line 77: End If
Line 78:
Line 79: If numDaysActive < 1 Then
Line 80: numDaysActive = 1
Line 81: End If
Line 82:
Line 83: Dim expirationDate As DateTime = DateTime.Today.AddDays(numDaysActive)
Line 84:
Line 85: If s.AdActivationRequired Then
Line 86: adStatus = adStatus.ActivationPending
Line 87: dateApproved = Nothing
Line 88: Else
Line 89: adStatus = adStatus.Activated
Line 90: dateApproved = dateCreated
Line 91: End If
Line 92:
Line 93: If adLevel = adLevel.Unspecified Then
Line 94: adLevel = adLevel.Normal
Line 95: End If
Line 96:
Line 97: Dim adId As Integer = DefaultValues.IdNullValue
Line 98: Dim ad As AdsDataComponent.AdsRow = Nothing
Line 99: Using db As New AdsDataAdapter()
Line 100: adId = CInt(db.InsertAd(memberId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, numViews, numResponses, CInt(adLevel), CInt(adStatus), CInt(adType)))
Line 101:
Line 102: If s.AdminNotification = AdminNotificationSetting.EachAd Then
Line 103: ad = GetFirstRow(db.GetAdById(adId))
Line 104: End If
Line 105: End Using
Line 106: If Not (ad Is Nothing) Then
Line 107: Maintenance.SendAdNotification(ad)
Line 108: End If
Line 109: Return adId
Line 110: End Function
Line 111:
Line 112: Public Shared Sub InsertSavedAd(ByVal adId As Integer, ByVal memberId As Integer)
Line 113:
Line 114: Using db As New AdsDataAdapter()
Line 115: db.InsertSavedAd(adId, memberId)
Line 116: End Using
Line 117:
Line 118: End Sub
Line 119:
Line 120: Public Shared Sub InsertSavedAdList(ByVal adIds As List(Of Integer), ByVal memberId As Integer)
Line 121:
Line 122: Using db As New AdsDataAdapter()
Line 123: Dim i As Integer
Line 124: For i = 0 To adIds.Count - 1
Line 125: db.InsertSavedAd(adIds(i), memberId)
Line 126: Next i
Line 127: End Using
Line 128:
Line 129: End Sub
Line 130:
Line 131: #End Region
Line 132:
Line 133: #Region "GetAds..."
Line 134:
Line 135: Public Shared Function GetAdById(ByVal adId As Integer) As AdsDataComponent.AdsRow
Line 136:
Line 137: Using db As New AdsDataAdapter()
Line 138: Return GetFirstRow(db.GetAdById(adId))
Line 139: End Using
Line 140:
Line 141: End Function
Line 142:
Line 143:
Line 144: Public Shared Function GetActiveAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal location As String, ByVal adType As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable
Line 145:
Line 146: Dim escapedSearchTerm As String = AdsDB.EscapeWildcardCharacters(searchTerm)
Line 147: Dim escapedLocation As String = AdsDB.EscapeWildcardCharacters(location)
Line 148: Return GetAdsByQuery(recordLimit, _
Line 149: categoryId, memberId, maxPrice, _
Line 150: HttpUtility.HtmlEncode(escapedSearchTerm), _
Line 151: HttpUtility.HtmlEncode(escapedLocation), _
Line 152: adType, CInt(AdStatus.Activated), _
Line 153: adLevel, dayRange, mustHaveImage)
Line 154:
Line 155: End Function
Line 156:
Line 157:
Line 158:
Line 159: Public Shared Function GetAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal location As String, ByVal adType As Integer, ByVal adStatus As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable
Line 160: Dim minCreatedDate As System.Nullable(Of DateTime)
Line 161: If location Is Nothing Then
Line 162: location = ""
Line 163: End If
Line 164: If dayRange > 0 Then
Line 165: minCreatedDate = DateTime.Now.Subtract(TimeSpan.FromDays(dayRange))
Line 166: End If
Line 167: ' To return no results if the searchTerm is empty remove the following
Line 168: ' check on the searchTerm.
Line 169: If searchTerm Is Nothing Then
Line 170: searchTerm = ""
Line 171: End If
Line 172: Using db As New AdsDataAdapter()
Line 173: Dim aa As AdsDataComponent.AdsDataTable = Nothing
Line 174: aa = db.GetAllAdsByQuery(recordLimit, categoryId, memberId, maxPrice, searchTerm, location, adType, adStatus, adLevel, minCreatedDate, mustHaveImage)
Line 175: Return aa
Line 176: End Using
Line 177: End Function
Line 178:
Line 179:
Line 180: Public Shared Function GetPendingAds() As AdsDataComponent.AdsDataTable
Line 181: Return GetAdsByStatus(AdStatus.ActivationPending, DefaultValues.IdNullValue)
Line 182: End Function
Line 183:
Line 184:
Line 185: Public Shared Function GetPendingAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Line 186: Return GetAdsByStatus(AdStatus.ActivationPending, memberId)
Line 187: End Function
Line 188:
Line 189:
Line 190: Public Shared Function GetActiveAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Line 191: Return GetAdsByStatus(AdStatus.Activated, memberId)
Line 192: End Function
Line 193:
Line 194:
Line 195: Public Shared Function GetInactiveAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Line 196: Return GetAdsByStatus(AdStatus.Inactive, memberId)
Line 197: End Function 'GetInactiveAds
Line 198:
Line 199:
Line 200: Public Shared Function GetAdsByStatus(ByVal adStatus As AdStatus, ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Line 201:
Line 202: Using db As New AdsDataAdapter()
Line 203: Return db.GetAdsByStatus(CInt(adStatus), memberId)
Line 204: End Using
Line 205:
Line 206: End Function
Line 207:
Line 208:
Line 209: Public Shared Function GetAdsByStatus(ByVal adStatus As AdStatus) As AdsDataComponent.AdsDataTable
Line 210: Return GetAdsByStatus(adStatus, DefaultValues.IdNullValue)
Line 211: End Function
Line 212:
Line 213:
Line 214: Public Shared Function GetFeaturedAdsSelection(ByVal maxNumAds As Integer) As AdsDataComponent.AdsDataTable
Line 215:
Line 216: If maxNumAds < 1 Then
Line 217: Return Nothing
Line 218: End If
Line 219: Using db As New AdsDataAdapter()
Line 220: Return db.GetAdsByRandomOrder(maxNumAds, CInt(AdStatus.Activated), CInt(AdLevel.Featured))
Line 221: End Using
Line 222:
Line 223: End Function
Line 224:
Line 225:
Line 226: Public Shared Function GetSavedAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Line 227:
Line 228: Using db As New AdsDataAdapter()
Line 229: Return db.GetSavedAds(memberId)
Line 230: End Using
Line 231:
Line 232: End Function
Line 233: #End Region
Line 234:
Line 235: #Region "Update Ads"
Line 236:
Line 237: Public Shared Sub UpdateAd(ByVal original_Id As Integer, ByVal memberId As Integer, ByVal title As String, ByVal description As String, ByVal title As String,, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal isRelisting As Boolean)
Line 238:
Line 239: If (url Is Nothing) Then
Line 240: url = String.Empty
Line 241: End If
Line 242: Using db As New AdsDataAdapter()
Line 243: db.UpdateAd(original_Id, memberId, _
Line 244: HttpUtility.HtmlEncode(title), _
Line 245: HttpUtility.HtmlEncode(description), _
Line 246: HttpUtility.HtmlEncode(ContactNo), _
Line 247: HttpUtility.UrlEncode(url), _
Line 248: price, _
Line 249: HttpUtility.HtmlEncode(location))
Line 250: End Using
Line 251:
Line 252: End Sub
Line 253:
Line 254:
Line 255: Public Shared Sub RelistAd(ByVal adId As Integer, ByVal categoryId As Integer, ByVal title As String, ByVal description As String, ByVal ContactNo As String, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal numDaysActive As Integer, ByVal adLevel As AdLevel, ByVal adStatus As AdStatus, ByVal adType As AdType)
Line 256:
Line 257: Dim s As SiteSettings = SiteSettings.GetSharedSettings()
Line 258:
Line 259: Dim dateCreated As DateTime = DateTime.Now
Line 260: Dim dateApproved As System.Nullable(Of DateTime)
Line 261:
Line 262: If numDaysActive > s.MaxAdRunningDays Then
Line 263: numDaysActive = s.MaxAdRunningDays
Line 264: End If
Line 265: If numDaysActive < 1 Then
Line 266: numDaysActive = 1
Line 267: End If
Line 268: Dim expirationDate As DateTime = DateTime.Today.AddDays(numDaysActive)
Line 269:
Line 270: If s.AdActivationRequired Then
Line 271: adStatus = adStatus.ActivationPending
Line 272: dateApproved = Nothing
Line 273: Else
Line 274: adStatus = adStatus.Activated
Line 275: dateApproved = dateCreated
Line 276: End If
Line 277:
Line 278: If adLevel = adLevel.Unspecified Then
Line 279: adLevel = adLevel.Normal
Line 280: End If
Line 281: Dim ad As AdsDataComponent.AdsRow = Nothing
Line 282:
Line 283: Using db As New AdsDataAdapter()
Line 284:
Line 285: db.RelistAd(adId, categoryId, title, description, ContactNo, url, price, location, expirationDate, dateCreated, dateApproved, CInt(adLevel), CInt(adStatus), CInt(adType))
Line 286:
Line 287: If s.AdminNotification = AdminNotificationSetting.EachAd Then
Line 288: ad = GetFirstRow(db.GetAdById(adId))
Line 289: End If
Line 290: End Using
Line 291:
Line 292: If Not (ad Is Nothing) Then
Line 293: Maintenance.SendAdNotification(ad)
Line 294: End If
Line 295:
Line 296: End Sub
Line 297:
Line 298:
Line 299: Public Shared Sub IncrementViewCount(ByVal adId As Integer)
Line 300:
Line 301: Using db As New AdsDataAdapter()
Line 302: db.UpdateAdStats(adId, 1, 0)
Line 303: End Using
Line 304:
Line 305: End Sub
Line 306:
Line 307:
Line 308: Public Shared Sub IncrementResponseCount(ByVal adId As Integer)
Line 309:
Line 310: Using db As New AdsDataAdapter()
Line 311: db.UpdateAdStats(adId, 0, 1)
Line 312: End Using
Line 313:
Line 314: End Sub
Line 315:
Line 316:
Line 317: Public Shared Sub UpdateAdCategory(ByVal adId As Integer, ByVal categoryId As Integer)
Line 318:
Line 319: Using db As New AdsDataAdapter()
Line 320: db.UpdateAdCategory(adId, categoryId)
Line 321: End Using
Line 322:
Line 323: End Sub
Line 324:
Line 325:
Line 326:
Line 327: Public Shared Sub UpdateAdLevel(ByVal adId As Integer, ByVal adLevel As AdLevel)
Line 328:
Line 329: Using db As New AdsDataAdapter()
Line 330: db.UpdateAdLevel(adId, CInt(adLevel))
Line 331: End Using
Line 332:
Line 333: End Sub
Line 334:
Line 335:
Line 336: Public Shared Sub UpdateAdLevelList(ByVal adIds As List(Of Integer), ByVal adLevel As AdLevel)
Line 337:
Line 338: Using db As New AdsDataAdapter()
Line 339: Dim i As Integer
Line 340: For i = 0 To adIds.Count - 1
Line 341: db.UpdateAdLevel(adIds(i), CInt(adLevel))
Line 342: Next i
Line 343: End Using
Line 344:
Line 345: End Sub
Line 346:
Line 347:
Line 348: Public Shared Sub UpdateAdStatus(ByVal adId As Integer, ByVal adStatus As AdStatus)
Line 349:
Line 350: Using db As New AdsDataAdapter()
Line 351: db.UpdateAdStatus(adId, CInt(adStatus))
Line 352: End Using
Line 353:
Line 354: End Sub
Line 355:
Line 356:
Line 357: Public Shared Sub UpdateAdStatusList(ByVal adIds As List(Of Integer), ByVal adStatus As AdStatus)
Line 358:
Line 359: Using db As New AdsDataAdapter()
Line 360: Dim i As Integer
Line 361: For i = 0 To adIds.Count - 1
Line 362: db.UpdateAdStatus(adIds(i), CInt(adStatus))
Line 363: Next i
Line 364: End Using
Line 365:
Line 366: End Sub
Line 367:
Line 368: Public Shared Sub ExpireAd(ByVal adId As Integer, ByVal memberId As Integer)
Line 369:
Line 370: Using db As New AdsDataAdapter()
Line 371: db.ExpireAd(adId, memberId, CInt(AdStatus.Inactive))
Line 372: End Using
Line 373:
Line 374: End Sub
Line 375: #End Region
Line 376:
Line 377: #Region "Remove Ads"
Line 378:
Line 379: Public Shared Sub RemoveFromUserList(ByVal id As Integer)
Line 380:
Line 381: Dim s As SiteSettings = SiteSettings.GetSharedSettings()
Line 382: If s.AllowUsersToDeleteAdsInDB Then
Line 383: RemoveFromDatabase(id)
Line 384: Else
Line 385: UpdateAdStatus(id, AdStatus.Deleted)
Line 386: End If
Line 387:
Line 388: End Sub
Line 389:
Line 390: Public Shared Sub RemoveFromDatabase(ByVal adId As Integer)
Line 391:
Line 392: Using db As New AdsDataAdapter()
Line 393: PhotosDB.RemovePhotosByAdId(adId)
Line 394: db.RemoveAd(adId)
Line 395: End Using
Line 396:
Line 397: End Sub
Line 398:
Line 399: Public Shared Sub RemoveListFromDatabase(ByVal adIds As List(Of Integer))
Line 400:
Line 401: Using db As New AdsDataAdapter()
Line 402: Dim i As Integer
Line 403: For i = 0 To adIds.Count - 1
Line 404: PhotosDB.RemovePhotosByAdId(adIds(i))
Line 405: db.RemoveAd(adIds(i))
Line 406: Next i
Line 407: End Using
Line 408:
Line 409: End Sub
Line 410:
Line 411: Public Shared Sub RemoveFromDatabaseByStatus(ByVal adStatus As AdStatus)
Line 412:
Line 413: PhotosDB.RemovePhotosOfDeletedAds()
Line 414: Using db As New AdsDataAdapter()
Line 415: db.RemoveAdsByStatus(CInt(adStatus))
Line 416: End Using
Line 417:
Line 418: End Sub
Line 419:
Line 420:
Line 421: Public Shared Sub RemoveSavedAd(ByVal id As Integer, ByVal memberId As Integer)
Line 422:
Line 423: Using db As New AdsDataAdapter()
Line 424: db.RemoveSavedAd(id, memberId)
Line 425: End Using
Line 426:
Line 427: End Sub
Line 428: #End Region
Line 429:
Line 430: #Region "Various Helper and Maintenance Methods"
Line 431:
Line 432:
Line 433: Public Shared Sub MoveAdsToCategory(ByVal currentCategoryId As Integer, ByVal newCategoryId As Integer)
Line 434:
Line 435: Using db As New AdsDataAdapter()
Line 436: db.MoveAds(currentCategoryId, newCategoryId)
Line 437: End Using
Line 438:
Line 439: End Sub
Line 440:
Line 441:
Line 442: Public Shared Function SendAdInEmail(ByVal adId As Integer, ByVal senderName As String, ByVal senderAddress As String, ByVal recipientEmail As String, ByVal subject As String, ByVal message As String) As Boolean
Line 443: Dim sent As Boolean = False
Line 444: Dim from As String = String.Format("{0} <{1}>", senderName, senderAddress)
Line 445: Try
Line 446: Dim m As New MailMessage(from, recipientEmail)
Line 447: m.Subject = subject
Line 448: m.Body = message
Line 449: Dim client As New SmtpClient()
Line 450: client.Send(m)
Line 451: sent = True
Line 452: Catch ex As Exception
Line 453: ' Consider customizing the message for the EmailNotSentPanel in the ShowAds page.
Line 454: sent = False
Line 455: End Try
Line 456: Return sent
Line 457: End Function
Line 458:
Line 459:
Line 460: Public Shared Function SendResponse(ByVal adId As Integer, ByVal senderName As String, ByVal senderAddress As String, ByVal comments As String) As Boolean
Line 461: Dim sent As Boolean = False
Line 462: Dim s As SiteSettings = SiteSettings.GetSharedSettings()
Line 463: Dim ad As AdsDataComponent.AdsRow = GetAdById(adId)
Line 464: If Not (ad Is Nothing) Then
Line 465: Dim adUser As MembershipUser = Membership.GetUser(ad.MemberName)
Line 466: If Not (adUser Is Nothing) Then
Line 467:
Line 468: Dim sb As New StringBuilder()
Line 469: sb.AppendFormat("A user has sent a response to your Ad '{0}' at {1}", ad.Title, s.SiteName)
Line 470: sb.AppendLine()
Line 471:
Line 472: sb.AppendLine()
Line 473:
Line 474: sb.AppendLine("The contact information of the user is below:")
Line 475:
Line 476: sb.AppendLine()
Line 477:
Line 478: sb.AppendLine(("Name: " + senderName))
Line 479: sb.AppendLine(("Email: " + senderAddress))
Line 480:
Line 481: sb.AppendLine()
Line 482:
Line 483: sb.AppendLine("User comments/questions:")
Line 484: sb.AppendLine(comments)
Line 485:
Line 486: sb.AppendLine()
Line 487:
Line 488: sb.AppendLine("You can respond to the user by using the Reply feature of your email client.")
Line 489:
Line 490: sb.AppendLine()
Line 491: sb.AppendLine(s.SiteName)
Line 492: sb.AppendLine(ClassifiedsHttpApplication.SiteUrl)
Line 493:
Line 494:
Line 495: Dim from As String = String.Format("{0} <{1}>", senderName, senderAddress)
Line 496: Try
Line 497: Dim m As New MailMessage(from, adUser.Email)
Line 498: m.Subject = "Response for Ad: " + ad.Title
Line 499: m.Body = sb.ToString()
Line 500: Dim client As New SmtpClient()
Line 501: client.Send(m)
Line 502:
Line 503: IncrementResponseCount(adId)
Line 504: sent = True
Line 505: Catch ex As Exception
Line 506: ' Consider customizing the message for the EmailNotSentPanel in the ShowAds page.
Line 507: sent = False
Line 508: End Try
Line 509: End If
Line 510: End If
Line 511: Return sent
Line 512: End Function
Line 513:
Line 514:
Line 515: Private Shared Function GetFirstRow(ByVal table As AdsDataComponent.AdsDataTable) As AdsDataComponent.AdsRow
Line 516: If Not (table Is Nothing) AndAlso table.Rows.Count > 0 Then
Line 517: Dim row As AdsDataComponent.AdsRow = table.Rows(0)
Line 518: row.URL = System.Web.HttpUtility.UrlDecode(row.URL)
Line 519: row.Title = System.Web.HttpUtility.HtmlDecode(row.Title)
Line 520: row.Description = System.Web.HttpUtility.HtmlDecode(row.Description)
Line 521: row.ContactNo = System.Web.HttpUtility.HtmlDecode(row.ContactNo)
Line 522: row.Location = System.Web.HttpUtility.HtmlDecode(row.Location)
Line 523: Return row
Line 524: Else
Line 525: Return Nothing
Line 526: End If
Line 527:
Line 528: End Function
Line 529:
Line 530: Private Shared Function EscapeWildcardCharacters(ByVal input As String) As String
Line 531: Dim output As String = input
Line 532: If Not (String.IsNullOrEmpty(input)) Then
Line 533: output = output.Replace("%", "[%]")
Line 534: output = output.Replace("_", "[_]")
Line 535: output = output.Replace("[", "[[]")
Line 536: ' Could also remove common search terms.
Line 537: End If
Line 538: Return output
Line 539: End Function
Line 540: #End Region
Line 541:
Line 542: End Class
Line 543: End Namespace
Line 544:
|
function OnToggleTOCLevel1(level2ID)
{
var elemLevel2 = document.getElementById(level2ID);
if (elemLevel2.style.display == 'none')
{
elemLevel2.style.display = '';
}
else {
elemLevel2.style.display = 'none';
}
}
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
|
| marcgel | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 6/28/2006 5:29:20 PM |
0/0 | |
|
The steps above were meant to act as a guide. (Sorry for the confusion.) I meant to point out the types of tasks you would need to consider if you were adding extra fields to the Ads table. It's not trivial. Also, skipping some parts will probably lead to your changes not working.
To your specific problem. First, is "ContactNo" a property of the Ad or the User posting the Ad. If it is a property of the User, then see this thread for easily adding the information to the User posting the ad. http://forums.asp.net/thread/1266073.aspx (Basically, add an extra profile data item.)
From your error message above, it appears you just stuck in the new data item "ContactNo" and all your parameters to the InsertAd are offset leading to a mismatch in types.
[This posting is provided "AS IS" with no warranties, and confers no rights.] |
| yousaid | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 7/26/2006 1:22:06 PM |
0/0 | |
|
An easier way IMO to do what he is trying to do is to extend the profile properties.
Since a user is required to register and then login before posting an Add, you can then write a simple query that joins the Add table and the profile table.
The problem with doing this currently is that the profile table is serialized, so meaningful queries can not be written against the data. I have started extending the registeration module by creating a new table that holds the profile data. So when a user registers, I can capture all the info I need about them and then use basic queries to extract info from the data. The major problem with working with these Starter kits is the lack of documentation. Strangely, MS included documentation with samples that shipped with earlier versions of VS. DOTNET NUKE came out of ISpy portal.
yousaid |
| yousaid | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 7/26/2006 11:52:37 PM |
0/0 | |
|
You are right. If you user is looking to extend the Adds table, he has a lot of work as you sugested, but an item for sell has only so many properties that if he goes too far, it bacome more complex than it needs to be.
Yes I was refering to extending the user profile properties. The way Amazon.com handles "availability date" seems to be to use a static field that is manually updated. The default text seems to be "available on xxxxdate". Do you have any ideas on extending the profile table THAT DOES NOT USE the serialized table?
yousaid |
| marcgel | Asp.Net User |
| Re: How To ? :: Extend/ Add more Variables/properties to an Ad Posting. | 7/27/2006 12:39:54 AM |
0/0 | |
|
Here is an effort that makes it easier to query profile data:
http://www.asp.net/sandbox/samp_profiles.aspx?tabindex=0&tabid=1
Each profile property is stored in a different column.
[This posting is provided "AS IS" with no warranties, and confers no rights.] |
|
| |
Free Download:
Books: STACS 92: 9th Annual Symposium on Theoretical Aspects of Computer Science, Cachan, France, February 13-15, 1992, Proceedings Authors: A. Finkel, Matthias Jantzen, Pages: 620, Published: 1992 Proceedings: Proceedings, Villa Olmo, Como, Italy, September 8-12, 1997 Authors: IEEE Computer Society, Institute of Electrical and Electronics Engineers, Pages: 253, Published: 1997 Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005 Foundations of Software Science and Computation Structures: Second International Conference, FOSSACS'99 Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS'99, Amsterdam, The Netherlands, March 22-28, 1999 : Proceedings Authors: Wolfgang Thomas, Pages: 321, Published: 1999 Trustworthy Global Computing: Third Symposium, TGC 2007, Sophia-Antipolis, France, November 5-6, 2007, Revised Selected Papers Authors: Gilles Barthe, Cédric Fournet, Pages: 400, Published: 2008 Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006 Taxation in the Global Economy Authors: Assaf Razin, Joel Slemrod, Pages: 454, Published: 1992 Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007 Programming Languages and Systems, ESOP '96: 6th European Symposium on Programming, Linköping, Sweden, April 22-24, 1996 : Proceedings Authors: Hanne Riis Nielson, Pages: 403, Published: 1996 Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006 Web:How To ? :: Extend/ Add more Variables/properties to an Ad Posting ... Extend/ Add more Variables/properties to an Ad Posting. Last post 07-26-2006 8: 39 PM by marcgel. 7 replies. Sort Posts: ... ReSharper:: The Most Intelligent Add-In To Visual Studio 2008 - C# ... C# (up to 3.0): ReSharper 4 Full Edition and C# Edition extend language support ... properties and events, data sources and content placeholders. read more ... Flex 3 - Adding properties and methods to a component Defining public properties as variables. In the following example, you use the Control+I key combination to extend the TextArea control to let the user ... Accessing add-in's global variables Post Posted: Tue Sep 12, 2006 9:36 am Post subject: Re: Accessing add-in's global variables [Login to view extended thread Info.] ... is there a way to add variable arguments to addChild.. like ... You can extend whatever class your using and add the variables to it ... Timeline attached code is more as1 than as2, as2 differs really a ... Why “variables” in CSS are harmful That is a consideration for every addition to CSS: extending CSS makes implementing .... Adding an extra, independent structure would just make them more ... Jalbum Developer Center | Variables You can use user defined variables to add even more flexibility to the look of the skins ... Jalbum will look into certain property files (see top of page). ... Adding a classpath variable to the build path In the Properties page, select the Java Build Path page. On the Libraries tab, click Add Variable for adding a variable that refers to a JAR file. ... Contributing EL Variables Starting in WTP 3.0, Variable and Property Resolvers support a decorative mechanism for adding variables and properties. By setting the forRuntimeClass on ... How and when to use Extension Methods in C# and .NET Oct 25, 2008 ... Extension methods cannot access private variables in the type they are extending . You can consider Extension Methods as a 'legal' way to add ... Videos: XML11: An Abstract Windowing Protocol Google TechTalks
June 1, 2006
Arno Puder
Arno Puder received his masters and Ph.D. in computer science and is currently working as an Assistant Prof... Literate functional testing Google London Test Automation Conference (LTAC)
Google Tech Talks
September 7th, 2006
Presenters: Robert Chatley and Tom White Zeitgeist 2 : Addendum - Subtitles English / French Zeitgeist: Addendum, by Peter Joseph 2008
English Subtitles !
French
See ya later on thezeitgeistmovement.com
You can Download Srt file here :
EN:... django: Web Development for Perfectionists with Deadlines Google TechTalks
April 26, 2006
Jacob Kaplan-Moss
ABSTRACT
Django is one of the premier web frameworks for Python, and is often compared to Ruby-on... |
|
Search This Site:
|
|