using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class BusinessUsersListing : System.Web.UI.Page { PublicMethods clsPublic = new PublicMethods(); EMUPDataContext dbEmup = new EMUPDataContext(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //Int32 startzip = 0; //Int32 endzip = 0; string strLoc = ""; //string zipcode; string strIP = string.Empty; strIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(strIP)) strIP = Request.ServerVariables["REMOTE_ADDR"]; lblCategory.Text = getCategory(); try { if (Request.QueryString["Sloc"] != null) { string strcity = Convert.ToString(Convert.ToString(Request.QueryString["Sloc"])).Split(',')[0]; Session["loc"] = strcity; //Session["Sloc"] = (Convert.ToString(Request.QueryString["Sloc"]).Split(',')[0], Convert.ToString(Request.QueryString["Sloc"].Substring(Request.QueryString["Sloc"].LastIndexOf(',') + 1))); string strstate = Convert.ToString(Convert.ToString(Request.QueryString["Sloc"])).Split(',')[1]; strLoc = strcity + "," + strstate; Session["Sloc"] = strLoc; clsPublic.GetLatLong(Convert.ToString(Request.QueryString["Sloc"]).Split(',')[0], Convert.ToString(Request.QueryString["Sloc"].Substring(Request.QueryString["Sloc"].LastIndexOf(',') + 1))); GetDetails(Convert.ToDouble(clsPublic.salti), Convert.ToDouble(clsPublic.slong)); } else if (Request.Cookies["locInfo"] != null) { Session["loc"] = Convert.ToString(Server.HtmlEncode(Request.Cookies["locInfo"]["loc"])); Session["Sloc"] = Convert.ToString(Server.HtmlEncode(Request.Cookies["locInfo"]["Sloc"])); GetDetails(Convert.ToDouble(Server.HtmlEncode(Request.Cookies["locInfo"]["lat"])), Convert.ToDouble(Server.HtmlEncode(Request.Cookies["locInfo"]["long"]))); } else if (Convert.ToString(Session["loc"]) != "") { string strcity = Convert.ToString(Convert.ToString(Session["Sloc"])).Split(',')[0]; Session["loc"] = strcity; string strstate = Convert.ToString(Convert.ToString(Session["Sloc"])).Split(',')[1]; clsPublic.GetLatLong(Convert.ToString(Session["Sloc"]).Split(',')[0], Convert.ToString(Session["Sloc"]).Split(',')[1]); GetDetails(Convert.ToDouble(clsPublic.salti), Convert.ToDouble(clsPublic.slong)); } else { DataTable dt = clsPublic.GetLocation(strIP); lblCity.Text = dt.Rows[0]["City"].ToString() + "," + dt.Rows[0]["RegionCode"].ToString() + "," + dt.Rows[0]["CountryName"].ToString(); Session["Sloc"] = dt.Rows[0]["City"].ToString() + "," + dt.Rows[0]["RegionCode"].ToString(); Session["loc"] = dt.Rows[0]["City"].ToString(); clsPublic.GetLatLong(Convert.ToString(dt.Rows[0]["City"].ToString()), Convert.ToString(dt.Rows[0]["RegionCode"].ToString())); GetDetails(Convert.ToDouble(clsPublic.salti), Convert.ToDouble(clsPublic.slong)); } } catch { GetDetails(); } } } private void GetDetails() { // gvPremiumLisitings.DataSource = clsPublic.GetProvidersListings(27, "Premium"); // gvPremiumLisitings.DataBind(); gvServceListing.DataSource = clsPublic.GetProvidersListings(27); gvServceListing.DataBind(); } private void GetDetails(string strLoc) { //gvPremiumLisitings.DataSource = GetProvidersListings(27, strLoc, "Premium"); //gvPremiumLisitings.DataBind(); gvServceListing.DataSource = GetProvidersListings(27, strLoc, "Free"); gvServceListing.DataBind(); } private void GetDetails(int StartZip, int EndZip) { //gvPremiumLisitings.DataSource = clsPublic.GetProvidersListings(27, StartZip, EndZip, "Premium"); //gvPremiumLisitings.DataBind(); gvServceListing.DataSource = clsPublic.GetProvidersListings(27, StartZip, EndZip, "Free"); gvServceListing.DataBind(); } private void GetDetails(double latitude, double longitude) { //gvPremiumLisitings.DataSource = clsPublic.GetProvidersListings(27, StartZip, EndZip, "Premium"); //gvPremiumLisitings.DataBind(); gvServceListing.DataSource = clsPublic.GetBUsersByRadius(latitude, longitude, 27, 21); gvServceListing.DataBind(); } //private void GetDetails(string strLoc) //{ // gvPremiumLisitings.DataSource = GetProvidersListings(Convert.ToInt16(Request.QueryString["Id"]),strLoc,"Premium"); // gvPremiumLisitings.DataBind(); // gvServceListing.DataSource = GetProvidersListings(Convert.ToInt16(Request.QueryString["Id"]), strLoc,"Free"); // gvServceListing.DataBind(); //} public IQueryable GetProvidersListings(int intCatId, string strLoc, string strtype) { var objA = from objG in dbEmup.UserDets where objG.Role == "Business" && objG.CategoryId == intCatId && objG.OperationLocatoin == strLoc && objG.UserType == strtype orderby objG.UserSerNo descending select new { UserId = objG.UserSerNo, Name = objG.Name, Category = objG.CategoryDet.Categoryname, ContactNo = objG.BusinessContact, Location = objG.OperationLocatoin, BusinessName = objG.BusinessName, Website = Convert.ToString(objG.Website), AboutUs = Convert.ToString(objG.AboutUs), JhalakBusinessD = objG.BusinessName.Replace(" ", "-").Replace(",", "").Replace(":", "").Replace("!", "").Replace("@", "").Replace("#", "").Replace("$", "").Replace("%", "").Replace("^", "").Replace("&", "").Replace("*", "").Replace("(", "").Replace(")", "").Replace("+", "").Replace("=", "").Replace("{", "").Replace("}", "").Replace(";", "").Replace("'", "").Replace("<", "").Replace(">", "").Replace("/", "").Replace("?", "").Replace("|", "").Trim() + "-" + objG.UserSerNo, }; return objA; } //public IQueryable GetProvidersListings(int intCatId, string strtype) //{ // var objA = from objG in dbEmup.UserDets // where objG.Role == "Business" && objG.CategoryId == intCatId && objG.UserType == strtype // orderby objG.UserSerNo descending // select new // { // UserId = objG.UserSerNo, // Name = objG.Name, // Category = objG.CategoryDet.Categoryname, // ContactNo = objG.BusinessContact, // Location = objG.OperationLocatoin, // BusinessName = objG.BusinessName, // Website = Convert.ToString(objG.Website), // AboutUs = Convert.ToString(objG.AboutUs), // }; // return objA; //} //public IQueryable GetProvidersListings(int intCatId) //{ // var objA = from objG in dbEmup.UserDets // where objG.Role == "Business" && objG.CategoryId == intCatId // orderby objG.CreatedDate descending // select new // { // UserId = objG.UserSerNo, // Name = objG.Name, // Category = objG.CategoryDet.Categoryname, // ContactNo = objG.BusinessContact, // Location = objG.Location, // BusinessName = objG.BusinessName, // Website = Convert.ToString(objG.Website), // AboutUs = Convert.ToString(objG.AboutUs), // }; // return objA; //} private string getCategory() { var objC = from objD in dbEmup.CategoryDets where objD.CategoryId == Convert.ToInt16(Request.QueryString["Id"]) select objD; CategoryDet objCC = objC.SingleOrDefault(); return Convert.ToString(objCC.Categoryname); //var cat = dbEmup.UserDets.Where(v => v.CategoryId == Convert.ToInt16(Request.QueryString["Id"])).Select(c => c.CategoryDet.Categoryname); //return Convert.ToString(cat); } //protected void gvServceListing_ItemDataBound(object sender, RepeaterItemEventArgs e) //{ // try // { // foreach (RepeaterItem ri in gvServceListing.Items) // { // HyperLink box = ri.FindControl("hpVerified") as HyperLink; // Label lblUserNo = ri.FindControl("lblUserNo") as Label; // string ss = box.Text; // if (ss == "Verified") // { // box.CssClass = "no-link i2-color cls-verified"; // box.NavigateUrl = "#"; // } // else // { // box.NavigateUrl = "https://jhalak.com/Sign-Up.aspx?v=" + Convert.ToString(lblUserNo.Text); // box.CssClass = "no-link i2-color cls-verify "; // box.Text = "Verify"; // } // } // } // catch (Exception ex) // { // } //} protected void gvServceListing_PageIndexChanging(object sender, GridViewPageEventArgs e) { HttpCookie cookieLoc = Request.Cookies.Get("locInfo"); gvServceListing.PageIndex = e.NewPageIndex; if (Request.QueryString["Sloc"] != null) { clsPublic.GetLatLong(Convert.ToString(Request.QueryString["Sloc"]).Split(',')[0], Convert.ToString(Request.QueryString["Sloc"].Substring(Request.QueryString["Sloc"].LastIndexOf(',') + 1))); GetDetails(Convert.ToDouble(clsPublic.salti), Convert.ToDouble(clsPublic.slong)); } else if (Request.Cookies["locInfo"] != null) { Session["loc"] = Convert.ToString(Server.HtmlEncode(Request.Cookies["locInfo"]["loc"])); Session["Sloc"] = Convert.ToString(Server.HtmlEncode(Request.Cookies["locInfo"]["Sloc"])); GetDetails(Convert.ToDouble(Server.HtmlEncode(Request.Cookies["locInfo"]["lat"])), Convert.ToDouble(Server.HtmlEncode(Request.Cookies["locInfo"]["long"]))); } else if (Convert.ToString(Session["loc"]) != "") { string strcity = Convert.ToString(Convert.ToString(Session["Sloc"])).Split(',')[0]; Session["loc"] = strcity; string strstate = Convert.ToString(Convert.ToString(Session["Sloc"])).Split(',')[1]; clsPublic.GetLatLong(Convert.ToString(Session["Sloc"]).Split(',')[0], Convert.ToString(Session["Sloc"]).Split(',')[1]); GetDetails(Convert.ToDouble(clsPublic.salti), Convert.ToDouble(clsPublic.slong)); } else { GetDetails(); } } protected void gvServceListing_RowDataBound(object sender, GridViewRowEventArgs e) { HiddenField adtype = (HiddenField)e.Row.FindControl("hdtype"); Image imgtype = (Image)e.Row.FindControl("imgtype"); if (adtype != null) { if (Convert.ToString(adtype.Value) == "Premium") { imgtype.Visible = true; } else { imgtype.Visible = false; } } } }