protected void _grdZones_ItemCommand(object source, DataGridCommandEventArgs e) { string _unitID = Request.QueryString["unitID"].ToString(); if (e.CommandName == "Edit") { Label geofenceID = (Label)e.Item.FindControl("_lblGeofenceID"); Session["geofenceID"] = geofenceID.Text; Response.Redirect("~/Map/SafetyZoneSetup.aspx?unitID=" + _unitID + ""); } else if (e.CommandName == "Delete") { Geofence _gf = new Geofence(); ProcessSafetyZone _zone = new ProcessSafetyZone(AlarmasABC.BLL.InvokeOperations.operations.DELETE); Label geofenceID = (Label)e.Item.FindControl("_lblGeofenceID"); string _comID = Session["trkCompany"].ToString(); try { _gf.UnitID = int.Parse(_unitID); _gf.Id = int.Parse(geofenceID.Text); _gf.ComID = int.Parse(_comID); _zone.GeoInfo = _gf; _zone.invoke(); LoadZoneList(_unitID); _lblMessage.Text = "Safety Zone Deleted Successfully."; if (_grdZones.Items.Count < 1) { _lblMessage.Text = "No Safety Zone for this Unit"; _grdZones.Visible = false; } } catch(Exception ex) { } } }
private void updateGeofence() { try { GoogleLocation _location = GoogleLocation.Parse(_centerPoint.Value); Geofence _geoObj = new Geofence(); ProcessSafetyZone _safetyZoneUpdate = new ProcessSafetyZone(AlarmasABC.BLL.InvokeOperations.operations.UPDATE); _geoObj.Id = int.Parse(geofenceID); _geoObj.ComID = int.Parse(Session["trkCompany"].ToString()); _geoObj.Name = _txtZoneName.Text.ToString(); _geoObj.Email = _txtEmail.Text.ToString(); _geoObj.UnitID = int.Parse(Request.QueryString["unitID"].ToString()); _geoObj.CenterLat = decimal.Parse(_location.Latitude.ToString()); _geoObj.CenterLong = decimal.Parse(_location.Longitude.ToString()); _geoObj.Radius = decimal.Parse(_Radius.Value); _geoObj.IsActive = _rdoON.Checked; _geoObj.SpeedingPhoneNum = _txtPhoneNumber.Text.Trim(); _geoObj.IsSMS = _ckOnSMS.Checked; _safetyZoneUpdate.GeoInfo = _geoObj; _safetyZoneUpdate.invoke(); _lblMessage.ForeColor = System.Drawing.Color.Green; _lblMessage.Text = "Geofence update successfully "; _Update.Value = ""; } catch (Exception ex) { ex.Message.ToString(); _lblMessage.ForeColor = System.Drawing.Color.Red; _lblMessage.Text = "Geofence update fail"; } }
private void LoadZoneList(string _unitID) { DataSet _ds = new DataSet(); int _comID = int.Parse(Session["trkCompany"].ToString()); ProcessSafetyZone _zoneList = new ProcessSafetyZone(AlarmasABC.BLL.InvokeOperations.operations.SELECT); try { _zoneList.ComID = _comID; _zoneList.UnitID = int.Parse(_unitID); _zoneList.invoke(); _ds = _zoneList.Ds; _grdZones.DataSource = _ds; _grdZones.DataBind(); } catch (Exception ex) { ex.Message.ToString(); } if (_grdZones.Items.Count < 1) { _grdZones.Visible = false; _lblMessage.Text = "No zones are defined for this unit. Click the \"Create New Zone\" button to add one."; _lblMessage.CssClass = ""; //Response.Redirect("~/Map/SafetyZoneSetup.aspx?unitID="+_unitID+""); } }