Exemplo n.º 1
0
        /// <summary>
        /// Deletes Selected Row
        /// </summary>
        private void DeleteSelectedRow()
        {
            //Check Permissions
            if (_userCanDelete)
            {
                //Create Deletion Bool
                var deletionDone = false;

                //Create Deltion Continue Bool
                bool continueDeletion;

                //Create Deletion Key
                var recordToDelete = -1;

                //Check For Multi Selection
                if ((ObjectGrid.Columns[0].Visible))
                {
                    //Get Selections
                    var recordIdSelection = ObjectGrid.GetSelectedFieldValues("n_taskid");

                    //Process Multi Selection
                    foreach (var record in recordIdSelection)
                    {
                        //Get ID
                        recordToDelete = Convert.ToInt32(record.ToString());

                        //Set Continue Bool
                        continueDeletion = (recordToDelete > 0);

                        //Check Continue Bool
                        if (continueDeletion)
                        {
                            //Clear Errors
                            _oMaintenanceObject.ClearErrors();

                            //Delete Jobstep
                            if (_oMaintenanceObject.Delete(recordToDelete))
                            {
                                //Set Deletion Done
                                deletionDone = true;
                            }
                        }

                        //Check Deletion Done
                        if (deletionDone)
                        {
                            //Perform Refresh
                            ObjectGrid.DataBind();
                        }
                    }
                }
                else
                {
                    //Check For Job ID
                    if (Selection.Contains("n_objectid"))
                    {
                        //Get ID
                        recordToDelete = Convert.ToInt32(Selection.Get("n_objectid"));
                    }

                    //Set Continue Bool
                    continueDeletion = (recordToDelete > 0);

                    //Check Continue Bool
                    if (continueDeletion)
                    {
                        //Clear Errors
                        _oMaintenanceObject.ClearErrors();

                        //Delete Jobstep
                        if (_oMaintenanceObject.Delete(recordToDelete))
                        {
                            //Set Deletion Done
                            deletionDone = true;
                        }
                    }

                    //Check Deletion Done
                    if (deletionDone)
                    {
                        //Perform Refresh
                        ObjectGrid.DataBind();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void MapItem()
        {
            var sel         = Selection.Count;
            var MapSelected = ObjectGrid.GetSelectedFieldValues("objectid", "n_objectid", "Latitude", "Longitude", "description", "Area", "AssetNumber", "LocationID");

            if (sel > 0 || MapSelected.Count > 0)
            {
                if (HttpContext.Current.Session["MapSelected"] != null)
                {
                    //Remove Value
                    HttpContext.Current.Session.Remove("MapSelected");
                }

                if (MapSelected.Count > 0)
                {
                    HttpContext.Current.Session.Add("MapSelected", MapSelected);
                }

                //Check For Row Value In Hidden Field (Set Via JS)
                if (Selection.Contains("n_objectid") && MapSelected.Count < 1)
                {
                    //Check For Previous Session n_objectid
                    if (HttpContext.Current.Session["n_objectid"] != null)
                    {
                        //Remove Value
                        HttpContext.Current.Session.Remove("n_objectid");
                    }
                    //Add Session N_objectid
                    HttpContext.Current.Session.Add("n_objectid", Selection.Get("n_objectid"));

                    //Check for previous session object ID
                    if (HttpContext.Current.Session["objectid"] != null)
                    {
                        //Remove Value
                        HttpContext.Current.Session.Remove("objectid");
                    }
                    //Add session object ID
                    HttpContext.Current.Session.Add("objectid", Selection.Get("objectid"));


                    //Check For Previous Session Latitude
                    if (HttpContext.Current.Session["Latitude"] != null)
                    {
                        //Remove Value
                        HttpContext.Current.Session.Remove("Latitude");
                    }
                    //Add Session Latitude
                    HttpContext.Current.Session.Add("Latitude", Selection.Get("Latitude"));


                    //Check For Previous Session Longitude
                    if (HttpContext.Current.Session["Longitude"] != null)
                    {
                        //Remove Value
                        HttpContext.Current.Session.Remove("Longitude");
                    }
                    //Add Session Longitude
                    HttpContext.Current.Session.Add("Longitude", Selection.Get("Longitude"));

                    //Check for previous session object description
                    if (HttpContext.Current.Session["description"] != null)
                    {
                        //Remove Value
                        HttpContext.Current.Session.Remove("description");
                    }
                    //Add session object description
                    HttpContext.Current.Session.Add("objectDescription", Selection.Get("description"));

                    //Check for Previous Session Object Area
                    if (Session["Area"] != null)
                    {
                        Session.Remove("Area");
                    }
                    Session.Add("Area", Selection.Get("Area"));

                    //Check for previous Session Object Asset number
                    if (Session["AssetNumber"] != null)
                    {
                        Session.Remove("AssetNumber");
                    }
                    Session.Add("AssetNumber", Selection.Get("AssetNumber"));

                    //Check for previous Session Object Location
                    if (Session["LocationID"] != null)
                    {
                        Session.Remove("LocationID");
                    }
                    Session.Add("LocationID", Selection.Get("LocationID"));
                }
                //Redirect To Report Page
                Response.Redirect("~/Pages/Map/MapForm.aspx", true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script language='javascript'>alert('Error trying to Map Items, No rows were selected.');</script>");
            };
        }