protected void Page_Load(object sender, EventArgs e) { if (Session["login"] != null) { string username = null; if (Session["id"] != null) { int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID); } if (Session["userName"] != null) { username = clsRidjindalEncryption.Decrypt(Session["userName"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string email = null; if (Session["email"] != null) { email = clsRidjindalEncryption.Decrypt(Session["email"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string pwd = null; if (Session["pwd"] != null) { pwd = clsRidjindalEncryption.Decrypt(Session["pwd"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } if (Login.checkLogin(username, email, pwd, clsRidjindalEncryption.Decrypt(Session["login"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256) == "1") == null || userID == -1) { Response.Redirect("Login.aspx"); } int id = Convert.ToInt32(userID.ToString()); GetCount(id); wishListTxt.InnerText = Session["Count"].ToString(); GetCartCount(id); cartTxt.InnerText = Session["CartCount"].ToString(); usernametxt.InnerText = username; //wishListTxt.InnerText = Login.countWishList(userID).ToString(); //cartTxt.InnerText = Login.countCart(userID).ToString(); lhptxt.InnerText = (Login.UserLHP(userID) + Login.getProgramsCount(userID)).ToString(); if (!IsPostBack) { SqlConnection con = new SqlConnection(Login.GetConnectionString()); string query = "select * from LH_programs_list where id not in(select program from LH_Programs where user_Id = @userID)"; con.Open(); SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@userID", userID); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { createProgram(int.Parse(dr["id"].ToString()), dr["logo"].ToString()); } programList.Controls.Add(new HtmlGenericControl("li")); con.Close(); query = "select * from LH_category"; con.Open(); cmd = new SqlCommand(query, con); dr = cmd.ExecuteReader(); while (dr.Read()) { ListItem option = new ListItem(dr["category_name"].ToString(), dr["id"].ToString()); programCategory.Items.Add(option); } } SqlConnection con1 = new SqlConnection(Login.GetConnectionString()); string query1 = "select * from LH_Programs join LH_Programs_List on LH_Programs.program = LH_programs_list.id where user_Id = @userID"; con1.Open(); SqlCommand cmd1 = new SqlCommand(query1, con1); cmd1.Parameters.AddWithValue("@userID", userID); SqlDataReader dr1 = cmd1.ExecuteReader(); while (dr1.Read()) { createRegisteredProgram(int.Parse(dr1["id"].ToString()), dr1["logo"].ToString()); } registered.Controls.Add(new HtmlGenericControl("li")); con1.Close(); } else { Response.Redirect("Logout.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] != null) { string username = null; if (Session["id"] != null) { int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID); } if (Session["userName"] != null) { username = clsRidjindalEncryption.Decrypt(Session["userName"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string email = null; if (Session["email"] != null) { email = clsRidjindalEncryption.Decrypt(Session["email"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string pwd = null; if (Session["pwd"] != null) { pwd = clsRidjindalEncryption.Decrypt(Session["pwd"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } if (Login.checkLogin(username, email, pwd, clsRidjindalEncryption.Decrypt(Session["login"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256) == "1") == null || userID == -1) { Response.Redirect("Login.aspx"); } int cnt = 0; lhptxt.InnerText = (Login.UserLHP(userID) + Login.getProgramsCount(userID)).ToString();; hdfuserid.Value = userID.ToString(); int nuserid = Convert.ToInt32(hdfuserid.Value); GetCountWishlist(nuserid); GetCountofCart(nuserid); cartuser.InnerText = username; SqlConnection conn = new SqlConnection(Login.GetConnectionString()); string strsql1 = "select * from LH_Programs join LH_Rates on LH_Programs.program = LH_Rates.Program_ID join LH_programs_list on LH_Programs.program = LH_programs_list.ID where LH_Rates.Approved = 1 and LH_Programs.User_Id = @userID"; conn.Open(); SqlCommand cmd1 = new SqlCommand(strsql1, conn); cmd1.Parameters.AddWithValue("@userID", hdfuserid.Value); SqlDataReader dr2 = cmd1.ExecuteReader(); int i = 0; while (dr2.Read()) { i++; Createprogram(int.Parse(dr2["User_Id"].ToString()), double.Parse(dr2["Rate"].ToString()), dr2["logo"].ToString(), dr2["name"].ToString(), dr2["points"].ToString(), dr2["program"].ToString(), i, dr2["username"].ToString()); // wishlistbar(dr2[16].ToString()); } conn.Close(); SqlConnection con1 = new SqlConnection(Login.GetConnectionString()); string strsql = "select * from LH_product LHP join LH_Cart LHC on LHC.product_ID = LHP.ID " + "join LH_product_image LHI on LHI.ID = (select top 1 LHII.ID from LH_product_image LHII where LHII.product_id = LHP.ID) WHERE LHC.user_ID=@userID"; con1.Open(); SqlCommand cmd = new SqlCommand(strsql, con1); cmd.Parameters.AddWithValue("@userID", hdfuserid.Value); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cnt++; CreateCart(dr["title"].ToString(), dr["description"].ToString(), float.Parse(dr["price"].ToString()), dr["image"].ToString(), dr["ID"].ToString()); kk.InnerText = Convert.ToString(cnt); // string totlpts = totalpnts.InnerText; } con1.Close(); } else { Response.Redirect("logout.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["login"] != null) { string username = null; if (Session["id"] != null) { int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID); } if (Session["userName"] != null) { username = clsRidjindalEncryption.Decrypt(Session["userName"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string email = null; if (Session["email"] != null) { email = clsRidjindalEncryption.Decrypt(Session["email"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string pwd = null; if (Session["pwd"] != null) { pwd = clsRidjindalEncryption.Decrypt(Session["pwd"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } bool isSession = (Session["login"] != null) ? clsRidjindalEncryption.Decrypt(Session["login"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256) == "1" : false; if (Login.checkLogin(username, email, pwd, isSession) == null || userID == -1) { Response.Redirect("Login.aspx"); } usernametxt.InnerText = username; lhptxt.InnerText = (Login.UserLHP(userID) + Login.getProgramsCount(userID)).ToString(); hdfuserid.Value = userID.ToString(); int nuserid = Convert.ToInt32(hdfuserid.Value); GetCountWishlist(nuserid); GetCountofCart(nuserid); SqlConnection con = new SqlConnection(Login.GetConnectionString()); string strsql = "select * from LH_product LHP join LH_wishList LHW on LHW.productID = LHP.ID " + "join LH_product_image LHI on LHI.ID = (select top 1 LHII.ID from LH_product_image LHII where LHII.product_id = LHP.ID) WHERE LHW.userID=@UserId"; con.Open(); SqlCommand cmd = new SqlCommand(strsql, con); // cmd.Parameters.AddWithValue("@hdfuserid", hdfuserid.Value); cmd.Parameters.AddWithValue("@UserId", hdfuserid.Value); SqlDataReader dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { createProduct(int.Parse(dr[0].ToString()), dr["image"].ToString(), dr["title"].ToString(), dr["description"].ToString(), float.Parse(dr["price"].ToString()), i, int.Parse(dr["earnedLP"].ToString())); i++; } con.Close(); con.Open(); strsql = "select * from LH_Programs join LH_Rates on LH_Programs.Id = LH_Rates.Program_ID join LH_programs_list on LH_Programs.program = LH_programs_list.ID where LH_Rates.Approved = 1 and LH_Programs.User_Id = @userID"; cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("userID", 4); dr = cmd.ExecuteReader(); while (dr.Read()) { HtmlGenericControl walletGrid = new HtmlGenericControl("div"); walletContainer.Controls.Add(walletGrid); } con.Close(); //if ((Session["id"] == null || !int.TryParse(Session["id"].ToString(), out userID)) && (Request.Cookies["id"] == null || !int.TryParse(Request.Cookies["id"].Value, out userID))) //{ // Response.Redirect("Login.aspx"); //} //else //{ // // wishIconList_ex.InnerText = Session["Count"].ToString(); // //txtuserid.Text = Session["Id"].ToString(); // if ((Session["username"] == null || !int.TryParse(Session["username"].ToString(), out Username)) && (Request.Cookies["username"] == null || !int.TryParse(Request.Cookies["Username"].Value, out Username))) // wishuser.InnerText = Session["username"].ToString(); //} } else { Response.Redirect("logout.aspx"); } } catch (System.Data.SqlClient.SqlException ex) { string msg = "Insert Error:"; msg += ex.Message; throw new Exception(msg); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] != null) { string username = null; if (Session["id"] != null) { int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID); } if (Session["userName"] != null) { username = clsRidjindalEncryption.Decrypt(Session["userName"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string email = null; if (Session["email"] != null) { email = clsRidjindalEncryption.Decrypt(Session["email"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string pwd = null; if (Session["pwd"] != null) { pwd = clsRidjindalEncryption.Decrypt(Session["pwd"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } if (Login.checkLogin(username, email, pwd, clsRidjindalEncryption.Decrypt(Session["login"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256) == "1") == null || userID == -1) { Response.Redirect("Login.aspx"); } int productID; if (Request.QueryString["id"] == null || !int.TryParse(Request.QueryString["id"], out productID)) { Response.Redirect("Products.aspx"); } else { lhptxt.InnerText = (Login.UserLHP(userID) + Login.getProgramsCount(userID)).ToString(); usernametxt.InnerText = username; hdfuserid.Value = userID.ToString(); wishListTxt.InnerText = Login.countWishList(userID).ToString(); cartTxt.InnerText = Login.countCart(userID).ToString(); title_label.InnerText = productID.ToString(); SqlConnection con = new SqlConnection(Login.GetConnectionString()); SqlConnection con1 = new SqlConnection(Login.GetConnectionString()); string strsql = "select * from LH_product join LH_category on LH_product.category = LH_category.id where LH_product.id =@productID"; con.Open(); SqlCommand cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("@productID", productID); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { title_label.InnerText = dr["title"].ToString(); titleTxt.InnerText = dr["title"].ToString(); categoryLink.HRef = "products.aspx?id=" + dr["id"].ToString(); categoryLink.InnerText = dr["category_name"].ToString(); wishList.Attributes["onclick"] = "javascript: fnAddWishIcon(" + productID + ");"; price.InnerText = dr["price"].ToString(); strsql = "select * from LH_product_image where product_id =@productID"; con1.Open(); cmd = new SqlCommand(strsql, con1); cmd.Parameters.AddWithValue("@productID", productID); SqlDataReader dr1 = cmd.ExecuteReader(); bool firstImageFlag = true; while (dr1.Read()) { HtmlGenericControl li = new HtmlGenericControl("li"); if (firstImageFlag) { li.Attributes["class"] = "active"; firstImageFlag = false; firstImage.Src = dr1["image"].ToString(); } HtmlGenericControl img = new HtmlGenericControl("img"); img.Attributes["src"] = dr1["image"].ToString(); li.Controls.Add(img); productImage.Controls.Add(li); } } SqlConnection conn = new SqlConnection(Login.GetConnectionString()); string strsql1 = "select * from LH_Programs join LH_Rates on LH_Programs.program = LH_Rates.Program_ID join LH_programs_list on LH_Programs.program = LH_programs_list.ID where LH_Rates.Approved = 1 and LH_Programs.User_Id = @userID"; conn.Open(); SqlCommand cmd1 = new SqlCommand(strsql1, conn); cmd1.Parameters.AddWithValue("@userID", hdfuserid.Value); SqlDataReader dr2 = cmd1.ExecuteReader(); int i = 0; while (dr2.Read()) { i++; Createprogram(int.Parse(dr2[1].ToString()), dr2[10].ToString(), dr2["logo"].ToString(), dr2["name"].ToString(), dr2["points"].ToString(), dr2["program"].ToString(), i); // wishlistbar(dr2[16].ToString()); } conn.Close(); } } else { Response.Redirect("logout.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] != null) { string username = null; if (Session["id"] != null) { int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID); } if (Session["userName"] != null) { username = clsRidjindalEncryption.Decrypt(Session["userName"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string email = null; if (Session["email"] != null) { email = clsRidjindalEncryption.Decrypt(Session["email"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } string pwd = null; if (Session["pwd"] != null) { pwd = clsRidjindalEncryption.Decrypt(Session["pwd"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256); } bool isSession = (Session["login"] != null) ? clsRidjindalEncryption.Decrypt(Session["login"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256) == "1" : false; if (Login.checkLogin(username, email, pwd, isSession) == null || userID == -1) { Response.Redirect("Login.aspx"); } usernametxt.InnerText = username.ToString(); hdfuserid.Value = userID.ToString(); int nuserid = Convert.ToInt32(hdfuserid.Value); GetCountWishlist(nuserid); GetCountofCart(nuserid); //wishListTxt.InnerText = Login.countWishList(userID).ToString(); //cartTxt.InnerText = Login.countCart(userID).ToString(); lhptxt.InnerText = (Login.UserLHP(userID) + Login.getProgramsCount(userID)).ToString(); usernametxt.InnerText = username; SqlConnection con = new SqlConnection(Login.GetConnectionString()); SqlCommand cmd; string strsql; SqlDataReader dr; try { if (Request.QueryString["cat"] == null || !int.TryParse(Request.QueryString["cat"], out cat)) { strsql = "SELECT LP.ID,LP.title,LP.description,LP.price,LP.earnedLP,LP.category,LPI.ID,LPI.image,LPI.product_id,LHW.ID,CASE WHEN LHW.ID IS NULL THEN '0' ELSE '1' END AS IsSelected FROM LH_PRODUCT LP JOIN LH_PRODUCT_IMAGE LPI ON LPI.ID =" + "(SELECT TOP 1 LPII.ID FROM LH_PRODUCT_IMAGE LPII WHERE LPII.PRODUCT_ID=LP.ID) LEFT join LH_WISHLIST LHW ON LHW.ID =" + "(SELECT ID FROM LH_WISHLIST LHWW WHERE LHWW.PRODUCTID = LP.ID AND USERID = @userID) "; con.Open(); cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("@userID", userID); dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { createProduct(int.Parse(dr[0].ToString()), dr["image"].ToString(), dr["title"].ToString(), dr["description"].ToString(), float.Parse(dr["price"].ToString()), dr["IsSelected"].ToString(), i, int.Parse(dr["earnedLP"].ToString())); i++; } con.Close(); } else { con = new SqlConnection(Login.GetConnectionString()); strsql = "SELECT LP.ID,LP.title,LP.earnedLP,LP.description,LP.price,LP.category,LPI.ID,LPI.product_id,LPI.image,LHW.ID,CASE WHEN LHW.ID IS NULL THEN '0' ELSE '1' END AS IsSelected FROM LH_PRODUCT LP JOIN LH_PRODUCT_IMAGE LPI ON LPI.ID =" + "(SELECT TOP 1 LPII.ID FROM LH_PRODUCT_IMAGE LPII WHERE LPII.PRODUCT_ID=LP.ID) LEFT join LH_WISHLIST LHW ON LHW.ID =" + "(SELECT ID FROM LH_WISHLIST LHWW WHERE LHWW.PRODUCTID = LP.ID AND USERID = @userID) where LP.category = @category"; con.Open(); cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("@userID", userID); cmd.Parameters.AddWithValue("@category", cat); dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { createProduct(int.Parse(dr[0].ToString()), dr["image"].ToString(), dr["title"].ToString(), dr["description"].ToString(), float.Parse(dr["price"].ToString()), dr["IsSelected"].ToString(), i, int.Parse(dr["earnedLP"].ToString())); i++; } con.Close(); strsql = "select * from LH_Category where id = @id"; con.Open(); cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("@id", cat); dr = cmd.ExecuteReader(); while (dr.Read()) { pagetitle.InnerText = dr["category_name"].ToString(); } con.Close(); } con.Open(); strsql = "select * from LH_Programs join LH_Rates on LH_Programs.program = LH_Rates.Program_ID join LH_programs_list on LH_Programs.program = LH_programs_list.ID where LH_Rates.Approved = 1 and LH_Programs.User_Id = @userID"; cmd = new SqlCommand(strsql, con); cmd.Parameters.AddWithValue("@userID", userID); dr = cmd.ExecuteReader(); float total = 0; while (dr.Read()) { HtmlGenericControl walletGrid = new HtmlGenericControl("div"); walletGrid.Attributes["class"] = "wallet-grid"; HtmlGenericControl name = new HtmlGenericControl("h4"); name.InnerText = dr["name"].ToString(); walletGrid.Controls.Add(name); HtmlGenericControl ul = new HtmlGenericControl("ul"); HtmlGenericControl li1 = new HtmlGenericControl("li"); li1.Controls.Add(new LiteralControl("You hace <b>" + dr["points"] + "</b> Points")); ul.Controls.Add(li1); HtmlGenericControl li2 = new HtmlGenericControl("li"); li2.Controls.Add(new LiteralControl("Value mony: <b>" + float.Parse(dr["rate"].ToString()) * float.Parse(dr["points"].ToString()) + " SAR</b>")); ul.Controls.Add(li2); HtmlGenericControl points = new HtmlGenericControl("h5"); points.Attributes["class"] = "points"; points.Controls.Add(new LiteralControl(float.Parse(dr["rate"].ToString()) * float.Parse(dr["points"].ToString()) + " Loly Points (i)")); ul.Controls.Add(points); walletGrid.Controls.Add(ul); walletContainer.Controls.Add(walletGrid); total += float.Parse(dr["rate"].ToString()) * float.Parse(dr["points"].ToString()); } con.Close(); string query = "select LHP from LH_User where Id = @id"; con.Open(); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@id", userID); dr = cmd.ExecuteReader(); int earned = 0; while (dr.Read()) { earned = int.Parse(dr["LHP"].ToString()); } balance.InnerText = earned.ToString(); con.Close(); totaltxt.InnerText = total.ToString(); strsql = "select * from LH_category"; con.Open(); cmd = new SqlCommand(strsql, con); dr = cmd.ExecuteReader(); while (dr.Read()) { categoryItems.Controls.Add(new LiteralControl(" <li><a href='products.aspx?cat=" + dr["id"] + "'>" + dr["category_name"] + "</a></li>")); } con.Close(); } catch (Exception exc) { throw; } } else { Response.Redirect("logout.aspx"); } }