protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/Messages"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/Messages"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId == 0) { PanelNoProfile.Visible = true; PanelMessages.Visible = false; } else { PanelNoProfile.Visible = false; PanelMessages.Visible = true; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_messagesAllRead", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sqlConn.Open(); sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); sqlConn.Dispose(); if (GridViewMessagesLists.Rows.Count == 0) { LabelNoRecord.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/Friends"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/Friends"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId == 0) { Response.Redirect("~/Error/NoPrimaryProfile"); } DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_friends", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = PrimaryProfileId; sda.Fill(ds); dt = ds.Tables[0]; if (dt.Rows.Count == 0) { LabelNoFriend.Visible = true; } else { DataTable dt2 = new DataTable(); DataRow dr2 = null; //define the columns dt2.Columns.Add(new DataColumn("FriendId", typeof(string))); dt2.Columns.Add(new DataColumn("FriendName", typeof(string))); dt2.Columns.Add(new DataColumn("PhotoUrl", typeof(string))); dt2.Columns.Add(new DataColumn("Location", typeof(string))); dt2.Columns.Add(new DataColumn("Job", typeof(string))); //create new row dr2 = dt2.NewRow(); for (int i = 0; i < dt.Rows.Count; i++) { //create new row dr2 = dt2.NewRow(); //add values to each rows dr2["FriendId"] = dt.Rows[i]["OtherId"].ToString(); dr2["FriendName"] = dt.Rows[i]["FriendName"].ToString(); if (dt.Rows[i]["City"].ToString() != "") { dr2["Location"] = "<img alt='' height='16' src='Images/Information/location.png' width='16' /> " + dt.Rows[i]["City"].ToString(); } if (dt.Rows[i]["JobTitle"].ToString() != "") { dr2["Job"] = "<img alt='' height='16' src='Images/Information/job.png' width='16' /> " + dt.Rows[i]["JobTitle"].ToString(); } if (Convert.ToBoolean(dt.Rows[i]["HasPhoto"].ToString())) { dr2["PhotoUrl"] = "~/Files/ProfilesPhotos/" + dt.Rows[i]["OtherId"].ToString() + "-60.jpg"; } else { dr2["PhotoUrl"] = "~/Files/ProfilesPhotos/nophoto60-people.png"; } //add the row to DataTable dt2.Rows.Add(dr2); } DataListProfiles.Visible = true; DataListProfiles.DataSource = dt2; DataListProfiles.DataBind(); } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/Panel"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/Panel"); } DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_panelInfo", sqlConn); SqlDataAdapter sda2 = new SqlDataAdapter("sp_personalProfileDetails", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sda.Fill(ds); dt = ds.Tables[0]; LabelFavoritePeople.Text = dt.Rows[0]["FavoritePeople"].ToString(); LabelFavoritePlaces.Text = dt.Rows[0]["FavoritePlaces"].ToString(); LabelFavoriteProducts.Text = dt.Rows[0]["FavoriteProducts"].ToString(); LabelProfilesOwn.Text = dt.Rows[0]["ProfilesOwn"].ToString(); LabelProfilesModerate.Text = dt.Rows[0]["ProfilesModerate"].ToString(); LabelProfilesCreate.Text = dt.Rows[0]["ProfilesCreate"].ToString(); LabelMessages.Text = dt.Rows[0]["ReminderMessagesCount"].ToString(); LabelNotifications.Text = dt.Rows[0]["ReminderNotificationsCount"].ToString(); LabelRequests.Text = dt.Rows[0]["ReminderRequestsCount"].ToString(); LabelSupport.Text = dt.Rows[0]["ReminderSupportCount"].ToString(); Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId == 0) { HyperLinkPersonalProfileName.NavigateUrl = "PrimaryProfileAdd"; HyperLinkPersonalProfileName.Text = "پروفایل شخصی خود را ایجاد نمایید!"; HyperLinkPersonalProfilePhoto.NavigateUrl = "~/PrimaryProfileAdd"; HyperLinkPersonalProfilePhoto.ImageUrl = "~/Images/Elements/addprimaryprofile80.png"; LabelCategoryName.Visible = false; ImageCategory.Visible = false; } else { DataTable dt2 = new DataTable(); DataSet ds2 = new DataSet(); sda2.SelectCommand.CommandType = CommandType.StoredProcedure; sda2.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = PrimaryProfileId; sda2.Fill(ds2); dt2 = ds2.Tables[0]; HyperLinkPersonalProfileName.Text = dt2.Rows[0]["ProfileName"].ToString(); HyperLinkPersonalProfileName.NavigateUrl = "~/Profile/" + PrimaryProfileId.ToString(); HyperLinkPersonalProfilePhoto.NavigateUrl = "~/Profile/" + PrimaryProfileId.ToString(); LabelCategoryName.Text = dt2.Rows[0]["CategoryName"].ToString(); ImageCategory.ImageUrl = "~/Images/TypesImages/Category" + dt2.Rows[0]["ProfileCategoryId"].ToString() + "-24.png"; if (Convert.ToBoolean(dt2.Rows[0]["HasPhoto"].ToString())) { HyperLinkPersonalProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/" + PrimaryProfileId.ToString() + "-60.jpg"; } else { } sda2.Dispose(); } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sda2.Dispose(); sqlConn.Dispose(); } }
protected void GridViewMessages_DataBound(object sender, EventArgs e) { Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_messagesRead", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@OwnerId", SqlDbType.Int).Value = PrimaryProfileId; sqlCmd.Parameters.Add("@OtherId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"].ToString()); sqlConn.Open(); sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); sqlConn.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/Messages"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/Messages"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); DataTable dtUserName = new DataTable(); DataTable dtOtherName = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_messagesSenderReceiverInfo", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@OwnerId", SqlDbType.Int).Value = PrimaryProfileId; sda.SelectCommand.Parameters.Add("@OtherId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"].ToString()); sda.Fill(ds); dtUserName = ds.Tables[0]; dtOtherName = ds.Tables[1]; if (dtUserName.Rows.Count == 0 || dtOtherName.Rows.Count == 0) //news doesn't exist { Response.Redirect("~/Messages"); } else //news exists { HiddenFieldOwnerName.Value = dtUserName.Rows[0]["UserName"].ToString(); HiddenFieldOtherName.Value = dtOtherName.Rows[0]["OtherName"].ToString(); Page.Title = "پیغام ها : " + dtOtherName.Rows[0]["OtherName"].ToString(); ; } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } string HostUrl = ConfigurationManager.AppSettings["HostUrl"].ToString(); //Mouseover ImageButtonSend.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/send-on.png'"); ImageButtonSend.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/send-off.png'"); }
protected string FormatSenderName(object Sender) { Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); bool SenderType = Convert.ToBoolean(Sender.ToString()); DataTable dtUserName = new DataTable(); DataTable dtOtherName = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_messagesSenderReceiverInfo", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@OwnerId", SqlDbType.Int).Value = PrimaryProfileId; sda.SelectCommand.Parameters.Add("@OtherId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"].ToString()); sda.Fill(ds); dtUserName = ds.Tables[0]; dtOtherName = ds.Tables[1]; if (SenderType) { return dtUserName.Rows[0]["UserName"].ToString(); } else { return dtOtherName.Rows[0]["OtherName"].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { bool userLogin = false; if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { } else { userLogin = true; Session["UserId"] = UserId.ToString(); } } bool userHasProfile = false; int PrimaryProfileId = 0; if (userLogin) { Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId != 0) { userHasProfile = true; } } //see if profile exists DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_profileInfo", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"]); sda.Fill(ds); dt = ds.Tables[0]; } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } //////////// Profile doesn't exist if (dt.Rows.Count == 0) { Response.Redirect("~/Error/NoProfile"); } else { //////////// Profile is redistrected if(!Convert.ToBoolean(dt.Rows[0]["ProfileStatus"].ToString())) { Response.Redirect("~/Error/RedistrictedProfile"); } else { //////////// Popularity is disabled if (!Convert.ToBoolean(dt.Rows[0]["PopularityStatus"].ToString())) { PanelPopularity.Visible = false; } //////////// Popularity is enabled else { LabelPopularityRateCount.Text = dt.Rows[0]["RatingCount"].ToString(); if (dt.Rows[0]["RatingCount"].ToString() == "0" || dt.Rows[0]["RatingScore"].ToString() == "0") { LabelPopularityPercent.Text = "0"; ImagePopularityImage.ImageUrl = "~/Images/Popularity/1.png"; } else { int PopularityPercent = (20 * Convert.ToInt32(dt.Rows[0]["RatingScore"].ToString())) / Convert.ToInt32(dt.Rows[0]["RatingCount"].ToString()); LabelPopularityPercent.Text = PopularityPercent.ToString(); ImagePopularityImage.ImageUrl = "~/Images/Popularity/" + ((PopularityPercent * 36) / 100).ToString() + ".png"; } PanelPopularity.Visible = true; } } //////////// Profile is verified if (Convert.ToBoolean(dt.Rows[0]["VerificationStatus"].ToString())) { ImageVerificationProfileStatus.Visible = true; } //////////// Profile is not verified else { ImageVerificationProfileStatus.Visible = false; } //////////// Show profile's photo if (Convert.ToBoolean(dt.Rows[0]["HasPhoto"].ToString())) { ImageProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/" + Page.RouteData.Values["Id"] + "-220.jpg"; } else { switch (Convert.ToInt32(dt.Rows[0]["ProfileTypeId"].ToString())) { case 1: { ImageProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/nophoto220-people.png"; break; } case 2: { ImageProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/nophoto220-places.png"; break; } case 3: { ImageProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/nophoto220-products.png"; break; } } } //////////// Show profile's ownership switch (Convert.ToInt32(dt.Rows[0]["OwnershipStatus"].ToString())) { case 1: { LabelOwnershipStatus.Text = "شخصی"; break; } case 2: { LabelOwnershipStatus.Text = "دارای مالک"; break; } case 3: { LabelOwnershipStatus.Text = "عمومی"; break; } } //////////// Show action buttons if (userLogin && userHasProfile) { bool isVisitorOwner = false; bool isVisitorCreator = false; bool isPersonalProfile = false; bool isVisitorFriend = false; bool isVisitorFan = false; if (dt.Rows[0]["OwnerId"].ToString() == Session["UserId"].ToString()) { isVisitorOwner = true; } if (dt.Rows[0]["CreatorId"].ToString() == Session["UserId"].ToString()) { isVisitorCreator = true; } if (Convert.ToInt32(dt.Rows[0]["OwnershipStatus"].ToString()) == 1) { isPersonalProfile = true; } if (isVisitorOwner || isVisitorCreator) { HyperLinkEditPhoto.NavigateUrl = "~/Profile/" + Page.RouteData.Values["Id"].ToString() + "/EditPhoto"; PanelEditPhoto.Visible = true; } if (!isVisitorOwner && isPersonalProfile) { DataTable dtFriend = new DataTable(); DataSet dsFriend = new DataSet(); SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sdaFriend = new SqlDataAdapter("sp_isUserFriend", sqlConn2); SqlDataAdapter sdaFan = new SqlDataAdapter("sp_isUserFan", sqlConn2); try { sdaFriend.SelectCommand.CommandType = CommandType.StoredProcedure; sdaFriend.SelectCommand.Parameters.Add("@OwnerId", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["OwnerId"].ToString()); sdaFriend.SelectCommand.Parameters.Add("@OtherId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sdaFriend.Fill(dsFriend); dtFriend = dsFriend.Tables[0]; DataTable dtFan = new DataTable(); DataSet dsFan = new DataSet(); if (dtFriend.Rows.Count != 0) { isVisitorFriend = true; } sdaFan.SelectCommand.CommandType = CommandType.StoredProcedure; sdaFan.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"]); sdaFan.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sdaFan.Fill(dsFan); dtFan = dsFan.Tables[0]; if (dtFan.Rows.Count != 0) { isVisitorFan = true; } } catch (Exception ex) { } finally { sqlConn2.Close(); sdaFriend.Dispose(); sdaFan.Dispose(); sqlConn2.Dispose(); } } if (isVisitorOwner) { PanelActionsMessage.Visible = false; PanelActionsFriend.Visible = false; PanelTaskEdit.Visible = true; } else { PanelTaskClaim.Visible = true; PanelTaskReport.Visible = true; if (isPersonalProfile && isVisitorFriend) { PanelActionsFriend.Visible = true; ImageButtonActionsFriend.ImageUrl = "~/Images/Buttons/friendremove-off.png"; //Mouseover ImageButtonActionsFriend.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/friendremove-on.png'"); ImageButtonActionsFriend.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/friendremove-off.png'"); } else if (isPersonalProfile && !isVisitorFriend) { PanelActionsFriend.Visible = true; ImageButtonActionsFriend.ImageUrl = "~/Images/Buttons/friendadd-off.png"; //Mouseover ImageButtonActionsFriend.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/friendadd-on.png'"); ImageButtonActionsFriend.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/friendadd-off.png'"); } if (Convert.ToInt32(dt.Rows[0]["OwnershipStatus"].ToString()) == 1 || Convert.ToInt32(dt.Rows[0]["OwnershipStatus"].ToString()) == 2) { PanelActionsMessage.Visible = true; ImageButtonActionsMessage.ImageUrl = "~/Images/Buttons/sendmessage-off.png"; //Mouseover ImageButtonActionsMessage.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/sendmessage-on.png'"); ImageButtonActionsMessage.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/sendmessage-off.png'"); } } if (isVisitorFan) { PanelActionsLike.Visible = true; ImageButtonActionsLike.ImageUrl = "~/Images/Buttons/favoriteremove-off.png"; //Mouseover ImageButtonActionsLike.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/favoriteremove-on.png'"); ImageButtonActionsLike.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/favoriteremove-off.png'"); } else { PanelActionsLike.Visible = true; ImageButtonActionsLike.ImageUrl = "~/Images/Buttons/favoriteadd-off.png"; //Mouseover ImageButtonActionsLike.Attributes.Add("onmouseover", "this.src='" + HostUrl + "/Images/Buttons/favoriteadd-on.png'"); ImageButtonActionsLike.Attributes.Add("onmouseout", "this.src='" + HostUrl + "/Images/Buttons/favoriteadd-off.png'"); } } else { PanelActionsLike.Visible = true; ImageButtonActionsLike.Enabled = false; ImageButtonActionsLike.ImageUrl = "~/Images/Buttons/favoriteadd-grey.png"; switch (Convert.ToInt32(dt.Rows[0]["OwnershipStatus"].ToString())) { case 1: { PanelActionsFriend.Visible = true; ImageButtonActionsFriend.Enabled = false; ImageButtonActionsFriend.ImageUrl = "~/Images/Buttons/friendadd-grey.png"; PanelActionsMessage.Visible = true; ImageButtonActionsMessage.Enabled = false; ImageButtonActionsMessage.ImageUrl = "~/Images/Buttons/sendmessage-grey.png"; break; } case 2: { PanelActionsMessage.Visible = true; ImageButtonActionsMessage.Enabled = false; ImageButtonActionsMessage.ImageUrl = "~/Images/Buttons/sendmessage-grey.png"; break; } } if (userLogin) { if (!userHasProfile) { PanelActionsShowMessage.Visible = true; HyperLinkActionsMessage.Text = "ابتدا پروفایل اصلی خود را ایجاد نمایید."; HyperLinkActionsMessage.NavigateUrl = "~/PersonalProfileAdd"; RatingProfile.ReadOnly = true; } } else { PanelActionsShowMessage.Visible = true; HyperLinkActionsMessage.Text = "وارد سیستم شوید."; HyperLinkActionsMessage.NavigateUrl = "~/Login"; RatingProfile.ReadOnly = true; } } //////////// Show profile basic info LabelProfileId.Text = Page.RouteData.Values["Id"].ToString(); LabelProfileName.Text = dt.Rows[0]["ProfileFName"].ToString() + " " + dt.Rows[0]["ProfileLName"].ToString(); Page.Title = dt.Rows[0]["ProfileFName"].ToString() + " " + dt.Rows[0]["ProfileLName"].ToString(); ImageProfileType.ImageUrl = "~/Images/TypesImages/ProfileType" + dt.Rows[0]["ProfileTypeId"].ToString() + ".png"; LabelProfileType.Text = dt.Rows[0]["ProfileTypeName"].ToString(); ImageProfileCategory.ImageUrl = "~/Images/TypesImages/category" + dt.Rows[0]["ProfileCategoryId"].ToString() + "-24.png"; LabelProfileCategory.Text = dt.Rows[0]["CategoryName"].ToString(); LabelStatsFavorite.Text = dt.Rows[0]["Favorites"].ToString(); LabelStatsVisists.Text = dt.Rows[0]["Visits"].ToString(); LabelProfileCreateDate.Text = ShowDate(dt.Rows[0]["CreateDate"].ToString()); //////////// Show profile specific info by profile type ////////////////Show rating if (userLogin) { SqlConnection sqlConn3 = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); DataTable dtRating = new DataTable(); DataSet dsRating = new DataSet(); SqlDataAdapter sdaRating = new SqlDataAdapter("sp_profileUserRatingGet", sqlConn3); try { sdaRating.SelectCommand.CommandType = CommandType.StoredProcedure; sdaRating.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"]); sdaRating.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sdaRating.Fill(dsRating); dtRating = dsRating.Tables[0]; if (dtRating.Rows.Count != 0) { RatingProfile.CurrentRating = Convert.ToInt32(dtRating.Rows[0]["Rate"].ToString()); } } catch (Exception ex) { } finally { sqlConn3.Close(); sdaRating.Dispose(); sqlConn3.Dispose(); } } ////////////////Tools Tabs SqlConnection sqlConn4 = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); DataTable dtTools = new DataTable(); DataSet dsTools = new DataSet(); SqlDataAdapter sdaTools = new SqlDataAdapter("sp_profileTools", sqlConn4); try { sdaTools.SelectCommand.CommandType = CommandType.StoredProcedure; sdaTools.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"]); sdaTools.Fill(dsTools); dtTools = dsTools.Tables[0]; string selectedTool = " "; try { if (Page.RouteData.Values["ToolName"].ToString().Length > 0) { selectedTool = Page.RouteData.Values["ToolName"].ToString(); } } catch { } StringBuilder sbToolsTabs = new StringBuilder(); if (dtTools.Rows.Count != 0) { for (int i = 0; i < dtTools.Rows.Count; i++) { if (dtTools.Rows[i]["ProfileToolNameEn"].ToString() == selectedTool) { sbToolsTabs.AppendLine("<div id='Menu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "' class='ProfileMenuItemSelected'>"); sbToolsTabs.AppendLine("<a href='" + HostUrl + "/Profile/" + Page.RouteData.Values["Id"] + "/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "'><img alt='' height='30' src='" + HostUrl + "/Images/Tools/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "/Tab-on.png' width='120' /></a>"); sbToolsTabs.AppendLine("</div>"); } else { sbToolsTabs.AppendLine("<div id='Menu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "' class='ProfileMenuItem' onmouseover='document.getElementById('Menu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "').style.width = '120px';' onmouseout='document.getElementById('Menu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "').style.width = '37px';'>"); sbToolsTabs.AppendLine("<a href='" + HostUrl + "/Profile/" + Page.RouteData.Values["Id"] + "/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "'><img id='imageMenu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "' alt='' height='30' src='" + HostUrl + "/Images/Tools/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "/Tab-off.png' width='120' onmouseover='document.getElementById('imageMenu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "').src = '" + HostUrl + "/Images/Tools/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "/Tab-on.png';' onmouseout='document.getElementById('imageMenu" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "').src = '" + HostUrl + "/Images/Tools/" + dtTools.Rows[i]["ProfileToolNameEn"].ToString() + "/Tab-off.png';'/></a>"); sbToolsTabs.AppendLine("</div>"); } } LiteralToolsTabs.Text = sbToolsTabs.ToString(); } sdaTools.Dispose(); } catch (Exception ex) { } finally { sqlConn4.Close(); sdaTools.Dispose(); sqlConn4.Dispose(); } HyperLinkTaskEdit.NavigateUrl = HostUrl + "/Profile/" + Page.RouteData.Values["Id"].ToString() + "/Edit"; HyperLinkTaskReport.NavigateUrl = HostUrl + "/Profile/" + Page.RouteData.Values["Id"].ToString() + "/Report"; HyperLinkTaskClaim.NavigateUrl = HostUrl + "/Profile/" + Page.RouteData.Values["Id"].ToString() + "/Claim"; //////////// Show profile view try { if (Page.RouteData.Values["ToolName"].ToString().Length > 0) { string pathToUserControl = "~/ProfileTools/" + Page.RouteData.Values["ToolName"].ToString() + ".ascx"; var ucSrc = LoadControl(pathToUserControl); PanelTool.Controls.Add(ucSrc); } } catch { } //////////// Profile view string cookieName = Page.RouteData.Values["Id"].ToString(); cookieName = (((Convert.ToInt32(cookieName) + 5) * 1364) - 9).ToString(); if (Request.Cookies[cookieName] == null) { HttpCookie _profileViewCookie = new HttpCookie(cookieName); _profileViewCookie[cookieName] = cookieName; _profileViewCookie.Expires = DateTime.Now.AddHours(2); Response.Cookies.Add(_profileViewCookie); SqlConnection sqlConn5 = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlCommand sqlCmd = new SqlCommand("sp_profileView", sqlConn5); try { sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@ProfileId", SqlDbType.Int).Value = Convert.ToInt32(Page.RouteData.Values["Id"]); sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { sqlConn5.Close(); sqlCmd.Dispose(); sqlConn5.Dispose(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/ProfileAdd"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/ProfileAdd"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId == 0) { Response.Redirect("~/Error/NoPrimaryProfile"); } //Mouseover ImageButtonAdd.Attributes.Add("onmouseover", "this.src='Images/Buttons/addprofile-on.png'"); ImageButtonAdd.Attributes.Add("onmouseout", "this.src='Images/Buttons/addprofile-off.png'"); TextBoxProfileName.Attributes.Add("value", "نام پروفایل"); TextBoxProfileName.Attributes.Add("onfocus", "if (this.value=='نام پروفایل') this.value='';"); TextBoxProfileName.Attributes.Add("onblur", "if (this.value=='') this.value='نام پروفایل';"); DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_userProfileAddRequests", sqlConn); SqlDataAdapter sdaGC = new SqlDataAdapter("sp_categories", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sda.Fill(ds); dt = ds.Tables[0]; int ProfileRequestsVerified = Convert.ToInt32(dt.Rows[0]["ProfileRequestsVerified"].ToString()); int ProfileRequestsRejected = Convert.ToInt32(dt.Rows[0]["ProfileRequestsRejected"].ToString()); int ProfileRequestsPending = Convert.ToInt32(dt.Rows[0]["ProfileRequestsPending"].ToString()); int ProfileRequestsPercent = 0; if (ProfileRequestsVerified == 0) { ProfileRequestsPercent = 0; } else { ProfileRequestsPercent = ProfileRequestsVerified / (ProfileRequestsVerified + ProfileRequestsRejected) * 100; } LabelRequestsCount.Text = (ProfileRequestsVerified + ProfileRequestsRejected + ProfileRequestsPending).ToString(); LabelRequestsVerifiedCount.Text = ProfileRequestsVerified.ToString(); LabelRequestsVerifiedPercent.Text = ProfileRequestsPercent.ToString(); LabelRequestsPendingCount.Text = ProfileRequestsPending.ToString(); //GC : General Categories DataTable dtPeopleGC = new DataTable(); DataTable dtPlacesGC = new DataTable(); DataTable dtProductsGC = new DataTable(); DataSet dsGC = new DataSet(); sdaGC.SelectCommand.CommandType = CommandType.StoredProcedure; sdaGC.Fill(dsGC); dtPeopleGC = dsGC.Tables[0]; dtPlacesGC = dsGC.Tables[1]; dtProductsGC = dsGC.Tables[2]; StringBuilder sbPeopleGC = new StringBuilder(); if (dtPeopleGC.Rows.Count != 0) { for (int i = 0; i < dtPeopleGC.Rows.Count; i++) { sbPeopleGC.AppendLine(dtPeopleGC.Rows[i]["CategoryName"].ToString()); sbPeopleGC.AppendLine("<br/>"); } LiteralGCPeople.Text = sbPeopleGC.ToString(); } StringBuilder sbPlacesGC = new StringBuilder(); if (dtPlacesGC.Rows.Count != 0) { for (int i = 0; i < dtPlacesGC.Rows.Count; i++) { sbPlacesGC.AppendLine(dtPlacesGC.Rows[i]["CategoryName"].ToString()); sbPlacesGC.AppendLine("<br/>"); } LiteralGCPlaces.Text = sbPlacesGC.ToString(); } StringBuilder sbProductsGC = new StringBuilder(); if (dtProductsGC.Rows.Count != 0) { for (int i = 0; i < dtProductsGC.Rows.Count; i++) { sbProductsGC.AppendLine(dtProductsGC.Rows[i]["CategoryName"].ToString()); sbProductsGC.AppendLine("<br/>"); } LiteralGCProducts.Text = sbProductsGC.ToString(); } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sdaGC.Dispose(); sqlConn.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/PrimaryProfileAdd"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/PrimaryProfileAdd"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId != 0) { Response.Redirect("~/Profile/" + PrimaryProfileId.ToString()); } else { DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_primaryProfileStep", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["UserId"]); sda.Fill(ds); dt = ds.Tables[0]; if (dt.Rows.Count == 0) { showHideItems(1); } else { showHideItems(Convert.ToInt32(dt.Rows[0]["Step"].ToString())); } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["VC"] != null) { string VC = Request.Cookies["VC"].Values["VC"]; Classes.LoginSession ls = new Classes.LoginSession(); int UserId = ls.getUserId(VC); if (UserId == 0) { Response.Redirect("~/Login/myProfiles"); } else { Session["UserId"] = UserId.ToString(); } } else { Response.Redirect("~/Login/myProfiles"); } Classes.userPrimaryProfile upp = new Classes.userPrimaryProfile(); int PrimaryProfileId = upp.getUserPrimaryProfileId(Convert.ToInt32(Session["UserId"])); if (PrimaryProfileId == 0) { HyperLinkPersonalProfileName.NavigateUrl = "~/PrimaryProfileAdd"; HyperLinkPersonalProfileName.Text = "پروفایل شخصی خود را ایجاد نمایید!"; HyperLinkPersonalProfilePhoto.NavigateUrl = "~/PrimaryProfileAdd"; HyperLinkPersonalProfilePhoto.ImageUrl = "~/Images/Elements/addprimaryprofile80.png"; HyperLinkProfileAdd.NavigateUrl = "~/PrimaryProfileAdd"; HyperLinkProfileAdd.Text = "ایجاد پروفایل شخصی"; } else { DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProfilesConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_personalProfileDetails", sqlConn); try { sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@ProfileId", SqlDbType.Int).Value = PrimaryProfileId; sda.Fill(ds); dt = ds.Tables[0]; HyperLinkPersonalProfileName.Text = dt.Rows[0]["ProfileName"].ToString(); HyperLinkPersonalProfileName.NavigateUrl = "~/Profile/" + PrimaryProfileId.ToString(); HyperLinkPersonalProfilePhoto.NavigateUrl = "~/Profile/" + PrimaryProfileId.ToString(); if (Convert.ToBoolean(dt.Rows[0]["HasPhoto"].ToString())) { HyperLinkPersonalProfilePhoto.ImageUrl = "~/Files/ProfilesPhotos/" + PrimaryProfileId.ToString() + "-60.jpg"; } else { } } catch (Exception ex) { } finally { sqlConn.Close(); sda.Dispose(); sqlConn.Dispose(); } HyperLinkProfileAdd.NavigateUrl = "ProfileAdd"; HyperLinkProfileAdd.Text = "ایجاد پروفایل"; } }