Exemplo n.º 1
0
        protected void btnSaveValue_Click(object sender, EventArgs e)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                int metricValueId = (hfIdValue.Value) != null?Int32.Parse(hfIdValue.Value) : 0;

                var metricValueService = new Rock.Model.MetricValueService();
                Rock.Model.MetricValue metricValue;

                if (metricValueId == 0)
                {
                    metricValue          = new Rock.Model.MetricValue();
                    metricValue.IsSystem = false;
                    metricValue.MetricId = Int32.Parse(hfIdMetric.Value);
                    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);
            }

            BindGridValue();

            modalValue.Hide();
            pnlValueList.Visible = true;
        }
Exemplo n.º 2
0
        protected void rGridValue_Delete(object sender, RowEventArgs e)
        {
            var metricValueService = new Rock.Model.MetricValueService();

            Rock.Model.MetricValue metricValue = metricValueService.Get((int)rGridValue.DataKeys[e.RowIndex]["id"]);
            if (metricValue != null)
            {
                metricValueService.Delete(metricValue, CurrentPersonId);
                metricValueService.Save(metricValue, CurrentPersonId);
            }

            BindGridValue();
        }
Exemplo n.º 3
0
        /// <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);

                if ( metricValue.IsValid )
                {
                    metricValueService.Save( metricValue, CurrentPersonId );
                    BindGrid();
                    hfMetricValueId.Value = string.Empty;
                    mdValueDialog.Hide();
                }
            }
        }
Exemplo n.º 4
0
        /// <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();
        }