|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: 303: |
//classified.cs
//without putting all the code here....I'll just put some relevant info.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Classifieds.Data;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
namespace Classifieds.Data
{
public class classifieds
{
private static readonly string _connectionString = WebConfigurationManager.ConnectionStrings["DiscoverPAConnectionString1"].ConnectionString;
object image;
public classifieds() { }
public classifieds(string ItemDescription, object Image, string Title, decimal Price, string Email, string Phone, string CategoryID, string UserID)
{
this.Image = image;
}
public object Image
{
get { return image; }
set { image = value; }
}
//addclassifieds.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Classifieds.Data;
using System.Web.Configuration;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI;
namespace Classifieds.Data
{
public class addClassifieds
{
public int Count;
private List<classifieds> _Items;
private static readonly string _connectionString = WebConfigurationManager.ConnectionStrings["DiscoverPAConnectionString1"].ConnectionString;
public addClassifieds()
{
this.Items = new List<classifieds>();
}
public List<classifieds> Items
{
set{this._Items = value;}
get{return this._Items;}
}
public List<classifieds> GetAll()
{
List<classifieds> temp = new List<classifieds>();
SqlConnection con = new SqlConnection(_connectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "Select * From [classifieds]";
SqlDataReader sd = cmd.ExecuteReader(CommandBehavior.CloseConnection );
while(sd.Read())
{
classifieds c = new classifieds ();
c.ItemDescription = (string)sd["ItemDescription"];
c.Image = (object)sd["Image"];
c.Title = (string)sd["Title"];
c.Price = (decimal)sd["Price"];
c.Email = (string)sd["Email"];
c.Phone = (string)sd["Phone"];
c.CategoryID = (string)sd["CategoryID"];
c.UserID = (string)sd["UserID"];
temp.Add(c);
}
return temp;
}
public bool AddData(classifieds c)
{
bool newItem = true;
SqlConnection con = new SqlConnection(_connectionString);
SqlCommand cmd = new SqlCommand();
// cmd = new SqlCommand("SELECT * FROM classifieds WHERE itemDescription=@itemDescription", con);
//cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
// SqlDataReader reader;
cmd.CommandText = "SELECT * FROM classifieds where UserID = @UserID";
cmd.Parameters.AddWithValue("@UserID", c.UserID);
cmd.CommandText = "INSERT INTO classifieds (ItemDescription, Image, Title, Price, Email, Phone, CategoryID, UserID) Values (@ItemID, @ItemDescription, @Image, @Title, @Price, @Email, @Phone, @CategoryID, @UserID)";
// cmd.Parameters.AddWithValue("ItemID", c.ItemID);
cmd.Parameters.AddWithValue("@ItemDescription", c.ItemDescription);
cmd.Parameters.AddWithValue("@Image", c.Image);
cmd.Parameters.AddWithValue("@Title", c.Title);
cmd.Parameters.AddWithValue("@Price", c.Price);
cmd.Parameters.AddWithValue("@Email", c.Email);
cmd.Parameters.AddWithValue("@Phone", c.Phone);
cmd.Parameters.AddWithValue("@CategoryID", c.CategoryID);
cmd.Parameters.AddWithValue("@UserID", c.UserID);
con.Open();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
newItem = false;
}
// reader = cmd.ExecuteReader();
con.Close();
return newItem;
}
//addclassified.aspx.cs
//I added the whole file since my issue may be within here
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 System.Net.Mail;
using Classifieds.Data;
using System.IO;
public partial class Design_addClassified : System.Web.UI.Page
{
int tries = -1;
string UserN;
protected void Page_Load(object sender, EventArgs e)
{
Session["tries"] = tries;
tries++;
if (tries > 3)
{
Response.Redirect("enter.aspx");
}
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
txtUserID.Text = "";
txtEmail.Text = "";
txtPrice.Text = "";
txtDescription.Text = "";
txtTitle.Text = "";
txtPrice.Text = "";
txtPhone.Text = "";
DropDownList1.Text = "";
}
protected void btnAddItem_Click(object sender, EventArgs e)
{
string UserID = txtUserID.Text;
object Image = upImage.FileName;
// Stream Image = upImage.FileName;
// Stream Image = upImage.PostedFile.InputStream;
string Title = txtTitle.Text;
decimal Price = Convert.ToDecimal(txtPrice.Text);
string ItemDescription = txtDescription.Text;
string Email = txtEmail.Text;
string Phone = txtPhone.Text;
string CategoryID = DropDownList1.SelectedValue.ToString();
SqlDataSource DataSource = (SqlDataSource)btnAddItem.FindControl("SqlDataSource1");
classifieds c = new classifieds(ItemDescription, Image, Title, Price, Email, Phone, CategoryID, UserID);
addClassifieds ac = new addClassifieds();
if (ac.AddData(c) == true)
{
if (Session["UserN"] != null)
{
UserN = (string)Session["UserN"];
}
else
{
UserN = txtUserID.Text;
Session["UserN"] = UserN;
}
if (upImage.HasFile)
{
if (checkTheFileType(upImage.FileName))
{
String filePath = "~/Design/UploadImages/" + upImage.FileName;
upImage.SaveAs(MapPath(filePath));
}
}
classifieds cfds = new classifieds(ItemDescription, Image, Title, Price, Email, Phone, CategoryID, UserID);
ac.AddData(cfds);
Response.Redirect("~/Design/viewclassifieds3.aspx");
}
else
{
Response.Redirect("~/Design/error.aspx");
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
if (upImage.HasFile)
{
if (checkTheFileType(upImage.FileName))
{
String filePath = "~/Design/UploadImages/" + upImage.FileName;
upImage.SaveAs(MapPath(filePath));
}
}
}
bool checkTheFileType(string fileName)
{
string ext = Path.GetExtension(fileName);
//string ext = (MapPath(filePath(fileName)));
switch (ext.ToLower())
{
case ".gif":
return true;
case ".png":
return true;
case ".jpg":
return true;
case ".jpeg":
return true;
default:
return false;
}
}
}
//addclassified.aspx
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DiscoverPAConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:DiscoverPAConnectionString1.ProviderName %>"
SelectCommand="SELECT [itemID], [itemDescription], [image], [title], [price], [email], [phone], [categoryID], [userID] FROM [classifieds] WHERE (([userID] = @userID) AND ([itemID] = @itemID))">
<SelectParameters>
<asp:ControlParameter ControlID="lblUserID" Name="userID" PropertyName="Text"
Type="String" />
<asp:SessionParameter Name="UserID" SessionField="@UserID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName="Classifieds.Data.classifieds" InsertMethod="AddData"
SelectMethod="AddData" TypeName="Classifieds.Data.addClassifieds">
<SelectParameters>
<asp:SessionParameter Name="ItemID" SessionField="@ItemID" Type="String" />
<asp:SessionParameter Name="ItemDescription" SessionField="@ItemDescription" Type="String" />
<asp:SessionParameter Name="Image" SessionField="@Image" Type="String" />
<asp:SessionParameter Name="Title" SessionField="@Title" Type="String" />
<asp:SessionParameter Name="Price" SessionField="@Price" Type="String" />
<asp:SessionParameter Name="Email" SessionField="@Email" Type="String" />
<asp:SessionParameter Name="Phone" SessionField="@Phone" Type="String" />
<asp:SessionParameter Name="CategoryID" SessionField="@CategoryID" Type="String" />
<asp:SessionParameter Name="UserID" SessionField="@UserID" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
|
Advertisement
| Hall of Fame |