示例#1
0
        /// <summary>
        /// Handles the Delete event of the gStepProgram control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gStepProgram_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();

            var stepProgramService = new StepProgramService(rockContext);

            var stepProgram = stepProgramService.Get(e.RowKeyId);

            if (stepProgram == null)
            {
                mdGridWarning.Show("This item could not be found.", ModalAlertType.Information);
                return;
            }

            string errorMessage;

            if (!stepProgramService.CanDelete(stepProgram, out errorMessage))
            {
                mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                return;
            }

            stepProgramService.Delete(stepProgram);

            rockContext.SaveChanges();

            BindGrid();
        }