protected void Page_Load(object sender, EventArgs e) { //Check For Logon Class if (HttpContext.Current.Session["LogonInfo"] != null) { //Get Logon Info From Session _oLogon = ((LogonObject)HttpContext.Current.Session["LogonInfo"]); //Add Use ID TO Session HttpContext.Current.Session.Add("UserID", _oLogon.UserID); //Load Form Permissions if (FormSetup(_oLogon.UserID)) { //Setup Buttons Master.ShowSaveButton = false; Master.ShowNewButton = _userCanAdd; Master.ShowEditButton = _userCanEdit; Master.ShowDeleteButton = _userCanDelete; Master.ShowViewButton = _userCanView; Master.ShowPrintButton = true; Master.ShowPdfButton = false; Master.ShowXlsButton = true; Master.ShowMultiSelectButton = _userCanDelete; } } //Check For Post Back if (!IsPostBack) { //Bind Grid TSGrid.DataBind(); } else { var scriptManager = ScriptManager.GetCurrent(Page); if (scriptManager != null && scriptManager.IsInAsyncPostBack) { } //Get Control That Caused Post Back var controlName = Request.Params.Get("__EVENTTARGET"); //Check For Null if (!string.IsNullOrEmpty(controlName)) { //Determing What To Do switch (controlName.Replace("ctl00$Footer$", "")) { case "NewButton": { //Call View Routine AddNewRow(); break; } case "EditButton": { //Call View Routine EditSelectedRow(); break; } case "DeleteButton": { //Call View Routine DeleteSelectedRow(); break; } case "ViewButton": { //Call View Routine ViewSelectedRow(); break; } case "PrintButton": { //Call Print Routine PrintSelectedRow(); break; } case "ExportPDF": { //Call Export PDF Option ExportPdf(); break; } case "ExportXLS": { //Call Export XLS Option ExportXls(); break; } case "MultiSelect": { //Enable/Disable MultiSelect EnableMultiSelect(!(TSGrid.Columns[0].Visible)); break; } default: { //Do Nothing break; } } } } //Enable/Disable Buttons Master.ShowNewButton = !(TSGrid.Columns[0].Visible); Master.ShowEditButton = !(TSGrid.Columns[0].Visible); Master.ShowViewButton = !(TSGrid.Columns[0].Visible); Master.ShowPrintButton = !(TSGrid.Columns[0].Visible); //Clear Prior Selection If Edit Check Is No Longer Visible if (!(TSGrid.Columns[0].Visible)) { //Uncheck All TSGrid.Selection.UnselectAll(); } }
/// <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 ((TSGrid.Columns[0].Visible)) { //Get Selections var recordIdSelection = TSGrid.GetSelectedFieldValues("n_objtaskid"); //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 _objectTasks.ClearErrors(); //Delete Jobstep if (_objectTasks.Delete(recordToDelete)) { //Set Deletion Done deletionDone = true; } } //Check Deletion Done if (deletionDone) { //Perform Refresh TSGrid.DataBind(); } } } else { //Check For Job ID if (Selection.Contains("n_objtaskid")) { //Get ID recordToDelete = Convert.ToInt32(Selection.Get("n_objtaskid")); } //Set Continue Bool continueDeletion = (recordToDelete > 0); //Check Continue Bool if (continueDeletion) { //Clear Errors _objectTasks.ClearErrors(); //Delete Jobstep if (_objectTasks.Delete(recordToDelete)) { //Set Deletion Done deletionDone = true; } } //Check Deletion Done if (deletionDone) { //Perform Refresh TSGrid.DataBind(); } } } }