Exemplo n.º 1
0
        public override void Refresh()
        {
            base.Refresh();

            //rebuild data grid

            Grid            = new ObjectGrid();
            Grid.DataSource = DataSource;
            Grid.DataBind();

            //add New button
            IButton newRecord = Platform.Current.Create <IButton>();

            newRecord.Text   = Resources.Strings.OKHOSTING_ORM_UI_SelectController_New;
            newRecord.Click += NewRecord_Click;

            //create our own grid
            IGrid container = Platform.Current.Create <IGrid>();

            container.ColumnCount = 1;
            container.RowCount    = 2;

            container.SetContent(0, 0, Grid.Content);
            container.SetContent(1, 0, newRecord);

            Platform.Current.Page.Title   = Resources.Strings.OKHOSTING_ORM_UI_SelectController_List + ' ' + Translator.Translate(DataSource.DataType.InnerType);
            Platform.Current.Page.Content = container;
        }
Exemplo n.º 2
0
        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
                ObjectGrid.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(!(ObjectGrid.Columns[0].Visible));
                        break;
                    }

                    default:
                    {
                        //Do Nothing
                        break;
                    }
                    }
                }
            }

            //Enable/Disable Buttons
            Master.ShowNewButton   = !(ObjectGrid.Columns[0].Visible);
            Master.ShowEditButton  = !(ObjectGrid.Columns[0].Visible);
            Master.ShowViewButton  = !(ObjectGrid.Columns[0].Visible);
            Master.ShowPrintButton = !(ObjectGrid.Columns[0].Visible);

            //Clear Prior Selection If Edit Check Is No Longer Visible
            if (!(ObjectGrid.Columns[0].Visible))
            {
                //Uncheck All
                ObjectGrid.Selection.UnselectAll();
            }
        }
Exemplo n.º 3
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();
                    }
                }
            }
        }