Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            objgen.validatelogin();
            if (!Page.IsPostBack)
            {
                if (!objda.checkUserInroles("3"))
                {
                    Response.Redirect("UserDashboard.aspx");
                }
                ClsAdmin objadmin = new ClsAdmin();
                objadmin.action    = "select";
                objadmin.companyId = Session["companyid"].ToString();
                ds = objadmin.ManageSettings();
                var ad_origin = new AddressData
                {
                    Address = ds.Tables[0].Rows[0]["address"].ToString(),
                    City    = ds.Tables[0].Rows[0]["cityid"].ToString(),
                    State   = ds.Tables[0].Rows[0]["stateid"].ToString(),
                    Country = ds.Tables[0].Rows[0]["countryid"].ToString(),
                    Zip     = ds.Tables[0].Rows[0]["zip"].ToString()
                };
                Session["origin"] = ad_origin;
                hidaddress.Value  = ad_origin.ToString();


                fillgrid();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>


        /// <summary>
        /// event fires when clicks to Edit/Delete in List
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///


        private void BindGMap(DataTable datatable)
        {
            try
            {
                List <ProgramAddresses> AddressList = new List <ProgramAddresses>();

                foreach (DataRow dr in datatable.Rows)
                {
                    //Full address to show on description
                    //string FullAddress = dr["name"].ToString() + " " + dr["Address"].ToString() + " " + dr["cityname"].ToString() + ", " + dr["countryname"].ToString() + " " + dr["stateName"].ToString() + " " + dr["zip"].ToString();


                    ProgramAddresses MapAddress = new ProgramAddresses();



                    var ad = new AddressData
                    {
                        Address = dr["street"].ToString(),
                        City    = dr["city"].ToString(),
                        State   = dr["state"].ToString(),
                        Country = dr["country"].ToString(),
                        Zip     = dr["zip"].ToString()
                    };


                    MapAddress.description = dr["clientname"].ToString() + "<br/> " + ad.ToString();
                    hidaddress2.Value      = ad.ToString();
                    string straddress = "<b>" + dr["clientname"].ToString() + "</b></br>";
                    straddress          += ad.ToString();
                    divaddress.InnerHtml = straddress;
                    var locationService = new GoogleLocationService();



                    var point = locationService.GetLatLongFromAddress(ad);

                    try
                    {
                        //Assign  Map Latitude an Logitude fetched from Map Location Service
                        MapAddress.lat = point.Latitude;

                        MapAddress.lng = point.Longitude;

                        //Add these description, Latitude and Logitude to the Addresses List
                        AddressList.Add(MapAddress);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            var ad1 = new AddressData
                            {
                                Address = "",
                                City    = dr["city"].ToString(),
                                State   = dr["state"].ToString(),
                                Country = dr["country"].ToString(),
                                Zip     = dr["zip"].ToString()
                            };



                            var point1 = locationService.GetLatLongFromAddress(ad1);

                            //Assign  Map Latitude an Logitude fetched from Map Location Service
                            MapAddress.lat = point1.Latitude;

                            MapAddress.lng = point1.Longitude;

                            //Add these description, Latitude and Logitude to the Addresses List
                            AddressList.Add(MapAddress);
                        }
                        catch
                        {
                            divmsgmap.Visible  = true;
                            divshowmap.Visible = false;
                        }
                    }
                }

                //Convert complete address list to json string
                string jsonString = JsonSerializer <List <ProgramAddresses> >(AddressList);

                //if (jsonString == "")
                //{


                //}


                if (jsonString != null && jsonString != "")
                {
                    // divmsgmap.Visible = true;
                    divmsgmap.Visible  = false;
                    divshowmap.Visible = true;
                    //Call Client side GoogleMap function to Plot the address on Map
                    ScriptManager.RegisterArrayDeclaration(Page, "markers", jsonString);
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "GoogleMap();", true);
                }
                else
                {
                    divmsgmap.Visible  = true;
                    divshowmap.Visible = false;
                }
            }

            catch (Exception ex)
            {
                divmsgmap.Visible  = true;
                divshowmap.Visible = false;
            }
        }