/// <summary> /// Handles the Click event of the btnSaveValue control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnSaveValue_Click(object sender, EventArgs e) { using (new Rock.Data.UnitOfWorkScope()) { int metricValueId = hfMetricValueId.ValueAsInt(); var metricValueService = new MetricValueService(); MetricValue metricValue; if (metricValueId == 0) { metricValue = new MetricValue(); metricValue.IsSystem = false; metricValue.MetricId = hfMetricId.ValueAsInt(); metricValueService.Add(metricValue, CurrentPersonId); } else { metricValue = metricValueService.Get(metricValueId); } metricValue.Value = tbValue.Text; metricValue.Description = tbValueDescription.Text; metricValue.xValue = tbXValue.Text; metricValue.Label = tbLabel.Text; metricValue.isDateBased = cbIsDateBased.Checked; metricValue.MetricId = Int32.Parse(ddlMetricFilter.SelectedValue); metricValueService.Save(metricValue, CurrentPersonId); } BindGrid(); modalValue.Hide(); }
/// <summary> /// Handles the Delete event of the gMetricValues 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 gMetricValues_Delete(object sender, RowEventArgs e) { var metricValueService = new MetricValueService(); MetricValue metricValue = metricValueService.Get((int)e.RowKeyValue); if (metricValue != null) { metricValueService.Delete(metricValue, CurrentPersonId); metricValueService.Save(metricValue, CurrentPersonId); } BindGrid(); }