/
index.aspx.cs
302 lines (274 loc) · 12 KB
/
index.aspx.cs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//////////////////////////////////////////////////////////////////////////
///
/// Project: Boardhunt
/// File: index.aspx.cs
/// Project log:
/// 6/06/06 - Not the best date to start a project log
/// Got the file upload working
/// Error in writing path to DB - check type
/// 6/07/06 - Changed imgPath type in SQL DB to txt 'char'
/// Posting seems to work but buggy with complex filenames
/// 7/25/06 - Added GlobalAuthenticate()
/// 9/22/06 - All project logging witll be done on this page from this point forward
/// Globalized SignInOutUpMyAcct link
/// Organized global.css; Still needs a revamp
/// UserMenu delete is now working! ...I was very happy about this.
/// Web.Config now using global connectString - mucho cleaner
/// 9/28/06 - Fixed width to allow decimal values
/// post cell added to stylesheet
/// fixed layout on post_item
/// 10/02/06 - Added Edit_profile.aspx page: Allows users to change personal settings like email or phone num.
/// 10/13/06 - revised styles to pages; Little bugs and nuiances taken care of with Fab
/// 10/16/06 - Added snowboards, sponsor me link, added colors to user menu, longer desc enables - change in db field
/// 10/20/06 - Fixed edit_item undate issue. *STATIC is the word of the day! Fixing posting images/verification
/// DataBound first control for Fins!
/// 10/27/06 - Last few days: Javascript for 255 char max on textarea, "No results display"
/// 10/29/06 - Fixed Login: Page load got removed somehow
/// 10/31/06 - Massive database fix
/// 11/06/06 - New stuff happening on architecture. Will *NOT* have "One Page For All" as this will prevent from several
/// people working simutaneously on the project
/// Posts done for all categories except for Gear; Sell and Wanted will use same Post page; Same search results page
/// and multiple ItemDetails, and edit details pages. Other than that wishing I had a real office!
/// 12/09/06 - Update entry count on post (for surf only) todo: other post pages
/// 01/17/07 - Bugfix post_snow.aspx: We'll now allow a user to enter in a dec height value but remove it before posting
/// Changed copyright
/// About revision #1
/// Hide paging controls when no paging is needed
/// 02/09/07 - Putting in the mandatory post preview page; A lot more work than I thought!
/// 04/04/07 - There are 4 pics now for ItemDetails
/// Check for null URLreferral object to allow cut/paste
/// ItemDetails format display (width, thickness)
/// 04/06/07 - Search results link now reads "Search Again"
/// Deactivated all links but surf
/// Clear button for Register Page
/// "My Account" is now "My Menu"
/// Acct type removed for edit profile page
/// 04/07/07 - Remember Me implemented (that wasn't so hard now was it???)
/// 04/10/07 - Validator fixes on Login and Register pages
/// Error checking on post_item (num/denum)
/// Currency display fix for all list controls
/// Started fixes to edit_item (4 pics)
/// 04/19/07 - Fix 4 Pic display on Item_edit (still buggy)
/// Add text warning for 200kb imgs
/// Favs bugfix - twas broke
/// bugfix on edit profile
/// Preview page shined up some
/// camera now an imagelink
/// dynamic resizing for s1x1.gif for empty pics
/// Edit_item details box word wrapping text now
/// help text style made bolder
/// All managers hide controls and show result label
/// Removed confusing edit button for pics
///
///
///
//////////////////////////////////////////////////////////////////////////
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DALLayer;
namespace BoardHunt
{
public partial class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton lnkSignIn;
protected System.Web.UI.WebControls.LinkButton lnkSignUp;
//protected System.Web.UI.WebControls.LinkButton lnkPost;
//protected System.Web.UI.WebControls.DropDownList cboLocation;
protected System.Web.UI.WebControls.TextBox txtKeywords;
protected System.Web.UI.WebControls.Label lblSold;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//int i = Request.Url.ToString().IndexOf("www.");
//if (i == -1)
//{
// //Response.Clear();
// //Response.Status = "301 Moved Permanently";
// //Response.AddHeader("Location", System.Configuration.ConfigurationSettings.AppSettings["ServerURL"].ToString());
// //Response.End();
//}
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lnkSignIn.Click += new System.EventHandler(this.lnkSignIn_Click);
this.lnkSignUp.Click += new System.EventHandler(this.lnkSignUp_Click);
//this.lnkPost.Click += new System.EventHandler(this.lnkPost_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
// Put user code to initialize the page here
if (!Page.IsPostBack)
{
lnkSignIn.Text = Global.SetLnkSignIn();
lnkSignUp.Text = Global.SetLnkSignUp();
BindData();
}
//ErrorLog.ErrorRoutine(false, "Ver: " + System.Environment.Version);
//ErrorLog.ErrorRoutine(false, "SerVer: " + Request.ServerVariables["SERVER_SOFTWARE"]);
}
/*
*/
public void BindData()
{
return;
string strSQL = string.Empty;
strSQL = "SELECT COUNT(*) as scount FROM tblEntry WHERE iStatus = 3";
IDBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;
try
{
dbManager.Open();
dbManager.ExecuteReader(CommandType.Text, strSQL);
if (dbManager.DataReader.Read())
{
lblSold.Text = dbManager.DataReader["scount"].ToString() + " Boards SOLD";
}
}
catch (Exception ex)
{
ErrorLog.ErrorRoutine(false, "index:bindData:Error:" + ex.Message);
}
finally
{
dbManager.Close();
dbManager.Dispose();
}
}
/*
*/
public void ImageButton_Click(Object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
string qryString;
qryString = string.Empty;
if (e.CommandName == "imgBtnSearch")
{
if (e.CommandArgument.ToString() != "0")
qryString += "iCat=1&bt=" + e.CommandArgument;
else
qryString += "iCat=1";
//if (txtKeywords.Text.Length > 0)
//{
// desc = HttpUtility.UrlEncode(Global.CheckString(txtKeywords.Text));
// qryString += "&desc=" + desc;
//}
string redirHere = "Surfboardsforsale.aspx?" + qryString;
Response.Redirect(redirHere, true);
}
}
/*
*/
public void txtKeywords_Click(Object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
}
/*
*/
public string FormatHeightFt(object heightFt)
{
return heightFt.ToString() + "\'";
}
/*
*/
public string FormatHeightIn(object heightIn)
{
return heightIn.ToString() + "\"" + " ";
}
/*
*/
//Fired when user clicks the DataList item. NOTE: This handler will not fire unless VIEWSTATE is set to False.
public void GetValues(object src, CommandEventArgs e)
{
Response.Redirect("surfboard.aspx?" + "iD=" + e.CommandArgument.ToString() + "&uId=" + e.CommandName.ToString() + "&iCat=1");
}
/*
*/
//Returns truncated string with configurable number of characters
public string FormatDetails(object oChunk, object oVal)
{
//set cLen to oVal
int cLen = Convert.ToInt32(oVal);
//get string
string txtChunk = oChunk.ToString();
//if the string length is greater than our cut-off pt. -- prepare to truncate
if (txtChunk.Length > cLen)
{
int n = cLen;
//check if substring @ cLen pos. is char or whitespace
if (txtChunk.Substring(n, 1).ToString() != " ")
{
do
{
//TODO: look into this
//if (n >= cLength)
//return txtChunk;
n++;
if (n == txtChunk.Length) break;
if (txtChunk.Substring(n, 1).ToString() == " ")
{
break;
}
} while (n < txtChunk.Length);
}
//remove characters after cLen chars.
if (txtChunk.Length > n)
{
txtChunk = txtChunk.Remove(n, txtChunk.Length - n) + "...";
}
}
return txtChunk;
////PAD with HTML white space here
//char c = '#';
//txtChunk = oChunk.ToString().PadRight(15, c);
//return Global.ReplaceEx(txtChunk, "#", @" ");
}
/*
*/
public void View_ItemDetail(object sender, DataListCommandEventArgs e)
{
}
/*
*/
protected void lnkSignIn_Click(object sender, System.EventArgs e)
{
Global.NavigatePage(lnkSignIn.Text);
}
/*
*/
protected void lnkSignUp_Click(object sender, System.EventArgs e)
{
Global.NavigatePage(lnkSignUp.Text);
}
/*
*/
private void lnkPost_Click(object sender, System.EventArgs e)
{
Response.Redirect("post.aspx",true);
}
protected void btnSearchSurfboard_Click(object sender, EventArgs e)
{
Response.Redirect("Surfboardsforsale.aspx", true);
}
protected void btnSellSurfboard_Click(object sender, EventArgs e)
{
Response.Redirect("post.aspx", true);
}
}
}