photo added on web application

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Text;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
namespace Rating
{
public class Photo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblTotal;
protected System.Web.UI.WebControls.Label lblScore;
protected System.Web.UI.WebControls.Label lblVotes;
protected System.Web.UI.WebControls.Label lblView;
protected System.Web.UI.WebControls.Label lblAjax;
protected System.Web.UI.WebControls.Label lblRating;
protected System.Web.UI.WebControls.Label lblDescription;
protected System.Web.UI.WebControls.Label lblAddedby;
protected System.Web.UI.WebControls.Image imgPhoto;
protected System.Web.UI.WebControls.Literal ltlAll;
protected System.Web.UI.WebControls.Label lblTitle;

private void Page_Load(object sender, System.EventArgs e)
{
int RatedBy = 0;
int Score = 0;
string Title ="Title";
int myid =1;

if (Request.QueryString["id"]!= null)
myid= Convert.ToInt32(Request.QueryString["id"]);

string query = "SELECT * FROM " + ConfigurationSettings.AppSettings["MyPhotos"] + " WHERE ID=" + myid ;


clsDataAccess mydataAccess = new clsDataAccess();
mydataAccess.openConnection();
SqlDataReader mydr = mydataAccess.getData(query);

if (mydr.HasRows)
{
while( mydr.Read())
{
if (mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["ScoreByField"]))!=null)
Score = Convert.ToInt32(mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["ScoreField"])).ToString());

if (mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["RatedByField"]))!=null)
RatedBy= Convert.ToInt32(mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["RatedByField"])).ToString());

if (mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["TitleField"]))!=null)
Title = mydr.GetValue(Convert.ToInt32(ConfigurationSettings.AppSettings["TitleField"])).ToString() ;

myid = Convert.ToInt32(mydr.GetValue(0));

double myScore = Convert.ToDouble(Score);
double myRatedBy = Convert.ToDouble(RatedBy);

double ORating = 0.0;

if (myRatedBy>0)
ORating = myScore/myRatedBy;

string myTotalRatingString = "";

if ((ORating <1)&&(ORating>0))
myTotalRatingString = ".5";
else if (ORating ==1.0)
myTotalRatingString = "1";
else if ((ORating >1)&&(ORating<2))
myTotalRatingString = "1.5";
else if (ORating ==2.0)
myTotalRatingString = "2";
else if ((ORating >2)&&(ORating<3))
myTotalRatingString = "2.5";
else if (ORating ==3.0)
myTotalRatingString = "3";
else if ((ORating >3)&&(ORating<4))
myTotalRatingString = "3.5";
else if (ORating ==4.0)
myTotalRatingString = "4";
else if ((ORating >4)&&(ORating<5))
myTotalRatingString = "4.5";
else if (ORating ==5.0)
myTotalRatingString = "5";
else if (ORating ==0.0)
myTotalRatingString = "0";

string lblRatingAjax = "" ;

string DisplayStarsAjax="";
string DisplayMsgAjax="";

if (Request.Cookies["RatedAjax" + myid] == null)
{
DisplayStarsAjax = "";
DisplayMsgAjax = "";
}
else
{
HttpCookie cookieAjax = Request.Cookies["RatedAjax" + myid];
DisplayStarsAjax = "";
DisplayMsgAjax = "";
}
string lblRatingAmz;
if (Request.Cookies["RatedAmz" + myid] == null)
{
lblRatingAmz = "";
}
else
{
HttpCookie cookieAmz = Request.Cookies["RatedAmz" + myid];

StringBuilder sb1 = new StringBuilder();
string myAmzRated = sb1.Append( @"

" )
.Append( @"" )
.Append( @"" )
.Append( @"
" )
.Append( @"" + lblRatingAjax + "
" )
.Append( @"
")
.ToString();
lblRatingAmz = myAmzRated;
}




StringBuilder sb = new StringBuilder();
string myString = sb.Append( @"" )
.Append( @"")
.Append( @"
" )
.Append( " " + Title + "
")
//.Append( @"
")
//.Append( @" Added By:" + AddedBy + "
")
.Append( @" Rate: Amazon way - IFrames
" + lblRatingAmz)
.Append( @"
Rate: AJAX way - no refresh
" )
.Append( @"
")
.Append( @"")
.Append( @"")
.Append( @"")
.Append( @"
" + lblRatingAjax )
.Append( @"
")
.Append( @"
")
.Append( @"" + DisplayStarsAjax + "")
.Append( @"
")
.Append( @"
")
.Append( @"" + DisplayMsgAjax + "")
.Append( @"
")
.Append( @"
")
.Append( @"")
.Append( @"")
.Append( @"
Statistics
Votes:")
.Append( @"
" + RatedBy.ToString())
.Append( @"
rating(s)
Score: ")
.Append( @"
" + Score.ToString())
.Append( @"
/
" + (RatedBy * 5).ToString())
.Append( @"
")
.ToString( ) ;



ltlAll.Text = ltlAll.Text + myString;


}
mydr.Close();
mydataAccess.closeConnection();
}







}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{

InitializeComponent();
base.OnInit(e);
}


private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: