Ejemplo n.º 1
0
        protected void rGridMetric_Delete(object sender, RowEventArgs e)
        {
            var metricService = new Rock.Model.MetricService();

            Rock.Model.Metric metric = metricService.Get((int)rGridMetric.DataKeys[e.RowIndex]["id"]);
            if (metric != null)
            {
                metricService.Delete(metric, CurrentPersonId);
                metricService.Save(metric, CurrentPersonId);
            }

            BindGridMetric();
        }
Ejemplo n.º 2
0
        protected void btnSaveMetric_Click(object sender, EventArgs e)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                var metricService = new Rock.Model.MetricService();
                Rock.Model.Metric metric;
                int metricId = (hfIdMetric.Value) != null?Int32.Parse(hfIdMetric.Value) : 0;

                if (metricId == 0)
                {
                    metric          = new Rock.Model.Metric();
                    metric.IsSystem = false;
                    metricService.Add(metric, CurrentPersonId);
                }
                else
                {
                    metric = metricService.Get(metricId);
                }

                metric.Category    = tbCategory.Text;
                metric.Title       = tbTitle.Text;
                metric.Subtitle    = tbSubtitle.Text;
                metric.Description = tbDescription.Text;
                metric.MinValue    = tbMinValue.Text != "" ? Int32.Parse(tbMinValue.Text, NumberStyles.AllowThousands) : (int?)null;
                metric.MaxValue    = tbMinValue.Text != "" ? Int32.Parse(tbMaxValue.Text, NumberStyles.AllowThousands) : (int?)null;
                metric.Type        = cbType.Checked;
                metric.CollectionFrequencyValueId = Int32.Parse(ddlCollectionFrequency.SelectedValue);
                metric.Source    = tbSource.Text;
                metric.SourceSQL = tbSourceSQL.Text;

                metricService.Save(metric, CurrentPersonId);
            }

            BindCategoryFilter();
            BindGridMetric();

            pnlMetricDetails.Visible = false;
            pnlMetricList.Visible    = true;
        }