void LoadUserInfo() { UserInfoBll userBll = new UserInfoBll(); DataTable dt = userBll.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); if (dt.Rows.Count > 0) { lblName.Text = dt.Rows[0]["FirstName"].ToString() + " "+dt.Rows[0]["LastName"].ToString(); if (dt.Rows[0]["Gender"].ToString() == "1") lblGender.Text = "Male"; else if (dt.Rows[0]["Gender"].ToString() == "2") lblGender.Text = "Female"; else if (dt.Rows[0]["Gender"].ToString() == "0") lblGender.Text = "Rather not say"; lblEmail.Text = dt.Rows[0]["Email"].ToString(); lblMobile.Text = dt.Rows[0]["Mobile"].ToString(); lblAddress.Text = dt.Rows[0]["Address"].ToString(); lblStreetname.Text = dt.Rows[0]["StreetName"].ToString(); lblCountry.Text = dt.Rows[0]["CountryName"].ToString(); lblCity.Text = dt.Rows[0]["CityName"].ToString(); lblState.Text = dt.Rows[0]["StateName"].ToString(); lblZipcode.Text = dt.Rows[0]["ZipCode"].ToString(); } }
void LoadUserInfo() { UserInfoBll userBll = new UserInfoBll(); DataTable dt = userBll.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); if (dt.Rows.Count > 0) { strUsername = dt.Rows[0]["UserName"].ToString(); strPassword = dt.Rows[0]["UserPassword"].ToString(); hdnPassword.Value = strPassword; txtFirstName.Text = dt.Rows[0]["FirstName"].ToString(); txtLastName.Text=dt.Rows[0]["LastName"].ToString(); RadioButtonList1.SelectedValue = dt.Rows[0]["Gender"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); strEmail = dt.Rows[0]["Email"].ToString(); txtMobile.Text = dt.Rows[0]["Mobile"].ToString(); txtAddress.Text = dt.Rows[0]["Address"].ToString(); txtStreetname.Text = dt.Rows[0]["StreetName"].ToString(); ddlCountry.Text = dt.Rows[0]["CountryName"].ToString(); for (int i = 0; i < ddlCountry.Items.Count; i++) { if (ddlCountry.Items[i].Text == dt.Rows[0]["CountryName"].ToString()) ddlCountry.SelectedIndex = i; } for (int i = 0; i < ddlCity.Items.Count; i++) { if (ddlCity.Items[i].Text == dt.Rows[0]["CityName"].ToString()) ddlCity.SelectedIndex = i; } for (int i = 0; i < ddlState.Items.Count; i++) { if (ddlState.Items[i].Text == dt.Rows[0]["StateName"].ToString()) ddlState.SelectedIndex = i; } txtZipcode.Text = dt.Rows[0]["ZipCode"].ToString(); } }
protected void btnSaveAd_Click(object sender, EventArgs e) { //string str = fileuploadImg.PostedFile.FileName; HttpFileCollection fileCollection = Request.Files; for (int i = 0; i < fileCollection.Count; i++) { HttpPostedFile uploadfile = fileCollection[i]; string fileName = Path.GetFileName(uploadfile.FileName); } AdDetailsBll adbll = new AdDetailsBll(); UserInfoBll usrinfo = new UserInfoBll(); dt = usrinfo.SelectProfile(Convert.ToInt32(strUserId)); // userid try { #region .. CREATE AD POST .. int intAdpostId = adbll.CreateAdPost( Convert.ToInt32(strAdpostId), txtTitle.Text.ToString(), txtDesc.Text.ToString(), txtKeywords.Text.ToString(), Convert.ToInt32(strUserId), Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()), Convert.ToDecimal(txtPrice.Text.ToString()), Convert.ToInt32(dt.Rows[0]["StateId"].ToString()), Convert.ToInt32(dt.Rows[0]["CityId"].ToString()), Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()), dt.Rows[0]["ZipCode"].ToString(), Convert.ToDateTime(DatePicker1.SelectedDate.ToString()), "NEW", 0 ); #endregion adbll.CreateAdImageDetails(Convert.ToInt32(strImageId), Convert.ToInt32(strAdpostId), strAllImgPath, txtVidolink.Text.ToString()); Response.Redirect("MyAdposts.aspx"); } catch (System.Threading.ThreadAbortException th) { } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["UserType"] != null) { Session.Add("UserType", Request.Cookies["UserType"].Value.ToString()); } if (Request.QueryString.Count == 1) { if (this.Page.Title.Contains("Activa") == false) { if (Session["UserId"] == null) Session.Add("UserId", Request.QueryString["uid"].ToString()); } } else if (Request.Cookies["UserId"] != null) { Session.Add("UserId", Request.Cookies["UserId"].Value.ToString()); } if (this.Page.Title.Contains("Admin") || (Session["UserId"] != null && Session["UserType"] != null && Session["UserType"].ToString() == "2")) { welcomeMessage.InnerText = "Welcome Admin"; isShowHideControl = "2"; } else if (Session["UserId"] == null) { welcomeMessage.InnerText = "Welcome Guest"; isShowHideControl = "0"; } else { UserInfoBll usr = new UserInfoBll(); DataTable dt = usr.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); if (dt.Rows.Count > 0) { welcomeMessage.InnerText = "Welcome " + dt.Rows[0]["UserName"].ToString(); } isShowHideControl = "1"; } //if (welcomeMessage.InnerText.Contains("Guest") || string.IsNullOrWhiteSpace(welcomeMessage.InnerText)) //{ // isShowHideControl = "0"; //} //else if (welcomeMessage.InnerText.Contains("Admin")) //{ // isShowHideControl = "2"; //} //else //{ // isShowHideControl = "1"; //} //// To find IP address of a machine behind LAN you can use this code //string strHostName = Dns.GetHostName(); //IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); ////lblIPAddress.Text = Convert.ToString(ipEntry.AddressList[1]); ////lblHostName.Text = Convert.ToString(ipEntry.HostName); ////string clientIPLocation = string.Empty; //Find IP Address Behind Proxy Or Client Machine In ASP.NET string IPAdd = string.Empty; IPAdd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(IPAdd)) { IPAdd = Request.ServerVariables["REMOTE_ADDR"]; //lblIPBehindProxy.Text = IPAdd; } string JSON = GetLocation(IPAdd); if (!string.IsNullOrWhiteSpace(JSON)) { JavaScriptSerializer Serializer = new JavaScriptSerializer(); dynamic dynamicResult = Serializer.Deserialize<dynamic>(JSON); //Response.Write(dynamicResult["countryName"].ToString()); //Response.Write(dynamicResult["countryCode"].ToString()); //Response.Write(dynamicResult["city"].ToString()); //Response.Write(dynamicResult["region"].ToString()); //Response.Write(dynamicResult["latitude"].ToString()); //Response.Write(dynamicResult["longitude"].ToString()); currentLocation.InnerText = string.Format(" / Country: {0}/{1}, City: {2}/{3} ", dynamicResult["countryName"].ToString(), dynamicResult["countryCode"].ToString(),dynamicResult["city"].ToString(), dynamicResult["region"].ToString()); if (Session["Location"] == null) Session.Add("Location", dynamicResult["city"].ToString()); //Session.Add("Location", "wyoming"); } else { string userHostIpAddress = IPAdd; // "117.197.193.243"; IPAddress ipAddress; //Response.Write("<script>alert('"+userHostIpAddress+"')</Script>"); if (userHostIpAddress == "::1") { userHostIpAddress = "117.197.193.243"; } if (IPAddress.TryParse(userHostIpAddress, out ipAddress)) { string country = ipAddress.Country(); // return value: UNITED STATES string iso3166TwoLetterCode = ipAddress.Iso3166TwoLetterCode(); // return value: US currentLocation.InnerText = string.Format("Country: {0} / Location: {1} ", country, iso3166TwoLetterCode); if (Session["Location"] == null) Session.Add("Location", iso3166TwoLetterCode); //Session.Add("Location", "wyoming"); //Label1.Text = country; } } }
protected void btnAddPost_Click(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Login.aspx"); } else { #region .. VALIDATION .. int intError = 0; if (DatePicker1.SelectedDate.ToString() == "1/1/0001 12:00:00 AM") { intError++; ErrDate.Visible = true; ErrDate.Text = "Select Date"; } if (ddlCategory.SelectedIndex == 0) { intError++; ErrCategory.Text = "Select Category"; ErrCategory.Visible = true; } if (FileUpload1.HasFile) { if (FileUpload1.PostedFile.ContentLength > 1048576) { errFile1.Visible = true; errFile1.Text = "Exceeds maximum limit 1 MB"; intError++; } else errFile1.Visible = false; } if (FileUpload2.HasFile) { if (FileUpload2.PostedFile.ContentLength > 1048576) { errFile2.Visible = true; errFile2.Text = "Exceeds maximum limit 1 MB"; intError++; } else errFile2.Visible = false; } if (FileUpload3.HasFile) { if (FileUpload3.PostedFile.ContentLength > 1048576) { errFile3.Visible = true; errFile3.Text = "Exceeds maximum limit 1 MB"; intError++; } else errFile3.Visible = false; } if (FileUpload4.HasFile) { if (FileUpload4.PostedFile.ContentLength > 1048576) { errFile4.Visible = true; errFile4.Text = "Exceeds maximum limit 1 MB"; intError++; } else errFile4.Visible = false; } if (FileUpload5.HasFile) { if (FileUpload5.PostedFile.ContentLength > 1048576) { errFile5.Visible = true; errFile5.Text = "Exceeds maximum limit 1 MB"; intError++; } else errFile5.Visible = false; } #endregion if (intError == 0) { AdDetailsBll adbll = new AdDetailsBll(); UserInfoBll usrinfo = new UserInfoBll(); DataTable dt = usrinfo.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); // userid try { #region .. CREATE AD POST .. int intAdpostId = adbll.CreateAdPost( 0, txtTitle.Text.ToString(), txtDesc.Text.ToString(), txtKeywords.Text.ToString(), Convert.ToInt32(Session["UserId"].ToString()), Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()), Convert.ToDecimal(txtPrice.Text.ToString()), Convert.ToInt32(dt.Rows[0]["StateId"].ToString()), Convert.ToInt32(dt.Rows[0]["CityId"].ToString()), Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()), dt.Rows[0]["ZipCode"].ToString(), Convert.ToDateTime(DatePicker1.SelectedDate.ToString()), "NEW", 0 ); #endregion #region .. CREATE AD POST IMAGE .. string path = string.Empty; string strImgFinalPath = ""; string finalPath = string.Empty; string filePath = string.Empty; int userId = Convert.ToInt32(Session["UserId"].ToString()); string sFilename = ""; if (FileUpload1.PostedFile != null) { HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; fileSavePath = "/Data/TS_" + userId + "/Images/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload1.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } } strImgFinalPath = finalPath; if (FileUpload2.PostedFile != null) { HttpPostedFile myFile = FileUpload2.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload2.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload3.PostedFile != null) { HttpPostedFile myFile = FileUpload3.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload3.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload4.PostedFile != null) { HttpPostedFile myFile = FileUpload4.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload4.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload5.PostedFile != null) { HttpPostedFile myFile = FileUpload5.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload5.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } adbll.CreateAdImageDetails(0, intAdpostId, strImgFinalPath, txtVidolink.Text.ToString()); #endregion Response.Redirect("ViewAds.aspx?aid=" + intAdpostId.ToString() + "&uid=" + Session["UserId"].ToString()); } catch (System.Threading.ThreadAbortException th) { } catch (Exception ex) { } } } }