private string GetFileLocation(string fileName)
        {
            string blockId = BlockId.ToString();

            var cache = (string)GetCacheItem(blockId + fileName);

            if (cache != null)
            {
                return(cache);
            }

            //Set CWD
            string styleLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/";

            Environment.CurrentDirectory = Server.MapPath(styleLocation);

            string path = blockId + "/";

            string fileLocation;

            if (File.Exists(path + fileName))
            {
                fileLocation = "~~/Styles/" + blockId + "/" + fileName;
            }
            else
            {
                fileLocation = "~~/Styles/" + fileName;
            }
            AddCacheItem(blockId + fileName, fileLocation);
            return(fileLocation);
        }
 public override string ToString()
 {
     return("BlockId = " + BlockId.ToString() +
            "\nCommands:\n" + string.Join(Environment.NewLine, Commands.Select(x => "   " + x.ToString())) +
            "\nInputBlocksNumbers = {" + string.Join("; ", InputBlocks.Select(x => x.ToString())) +
            "}\nOutputBlocksNumbers = {" + string.Join("; ", OutputBlocks.Select(x => x.ToString())) + "}");
 }
        private void ProcessLess()
        {
            string blockId = BlockId.ToString();

            string lessLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/" + blockId + "/";

            Environment.CurrentDirectory = Server.MapPath(lessLocation);

            string bootstrapLocation = lessLocation + "bootstrap.less";
            var    bootstrapMapped   = Server.MapPath(bootstrapLocation);
            var    bootstrapFile     = File.ReadAllText(bootstrapMapped);
            var    bootstrapCSS      = Less.Parse(bootstrapFile);

            SavePageFile(bootstrapCSS, "bootstrap.css");

            string themeLocation = lessLocation + "theme.less";
            var    themeMapped   = Server.MapPath(themeLocation);
            var    themeFile     = File.ReadAllText(themeMapped);
            var    themeCSS      = Less.Parse(themeFile);

            SavePageFile(themeCSS, "theme.css");

            RemoveCacheItem(blockId + "bootstrap.css");
            RemoveCacheItem(blockId + "theme.css");
        }
示例#4
0
        private void AddRequestBlockIds(BlockId key, long value)
        {
            CacheItemPolicy policy = new CacheItemPolicy()
            {
                AbsoluteExpiration = DateTime.Now.AddHours(1),
            };

            this.request_ids.Add(key.ToString(), value, policy);
        }
示例#5
0
        string BlockCacheKey(string parameter)
        {
            string key = "com_shepherdchurch_cacheandredirect_" + parameter;

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("BlockKey")))
            {
                key += "_" + GetAttributeValue("BlockKey");
            }
            else
            {
                key += "_" + BlockId.ToString();
            }

            return(key);
        }
示例#6
0
        private List <int> GetChildGroupIds(RockContext rockContext)
        {
            var childGroupIds = (List <int>)GetCacheItem(BlockId.ToString());

            if (childGroupIds != null && childGroupIds.Any())
            {
                return(childGroupIds);
            }

            var parentGroup = new GroupService(rockContext).Get(GetAttributeValue("Group").AsGuid());

            if (parentGroup != null)
            {
                childGroupIds = GetChildGroups(parentGroup).Select(g => g.Id).ToList();
                AddCacheItem(BlockId.ToString(), childGroupIds, 300);
                return(childGroupIds);
            }
            return(new List <int>());
        }
        private void SavePageFile(string content, string fileName)
        {
            string lessLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/";

            Environment.CurrentDirectory = Server.MapPath(lessLocation);

            string blockId = BlockId.ToString();
            string path    = blockId + "/";

            //If a directory for this block does not exist
            //Create the directory and copy the custom bootsrap
            //and template less files to the folder
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                File.Copy("themeCustom.less", path + "theme.less");
                File.Copy("bootstrapCustom.less", path + "bootstrap.less");
            }


            // Truncate the file if it exists.
            if (File.Exists(path + fileName))
            {
                using (FileStream fs = File.Open(path + fileName, FileMode.Truncate))
                {
                    Byte[] info = new UTF8Encoding(true).GetBytes(content);
                    // Add some information to the file.
                    fs.Write(info, 0, info.Length);
                }
            }
            else
            {
                // Create the file.
                using (FileStream fs = File.Create(path + fileName))
                {
                    Byte[] info = new UTF8Encoding(true).GetBytes(content);
                    // Add some information to the file.
                    fs.Write(info, 0, info.Length);
                }
            }
        }
示例#8
0
        // <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Page.IsPostBack)
            {
                return;
            }

            var rockContext = new RockContext();
            var dvService   = new DefinedValueService(rockContext);

            LoadSourceGuids();

            // Output variables direct to the ascx
            metricBlockNumber.Value = BlockId.ToString();
            metricBlockId.Value     = BlockName.Replace(" ", "").ToString();
            metricTitle.Value       = BlockName;
            metricWidth.Value       = GetAttributeValue("NumberofColumns");

            DisplayTextValue();
        }
示例#9
0
文件: Tracker.cs 项目: zzms/NBitcoin
            internal JObject ToJson()
            {
                var obj = new JObject();

                if (BlockId != null)
                {
                    obj.Add("Height", Height);
                    obj.Add("BlockId", BlockId.ToString());
                    obj.Add("Proof", Encoders.Hex.EncodeData(this.Proof.ToBytes()));
                }
                obj.Add("AddedDate", AddedDate);
                obj.Add("UnconfirmedSeen", UnconfirmedSeen);
                obj.Add("Transaction", Encoders.Hex.EncodeData(this.Transaction.ToBytes()));
                if (this.ReceivedCoins != null)
                {
                    obj.Add("ReceivedCoins", new JArray(ReceivedCoins.Select(c => ToJson(c))));
                }
                if (this.SpentCoins != null)
                {
                    obj.Add("SpentCoins", new JArray(SpentCoins.Select(c => ToJson(c))));
                }
                return(obj);
            }
        private string GetPageFile(string fileName)
        {
            string lessLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/";

            Environment.CurrentDirectory = Server.MapPath(lessLocation);

            string blockId = BlockId.ToString();
            string path    = blockId + "/";

            if (File.Exists(path + fileName))
            {
                using (var fs = File.OpenText(path + fileName))
                {
                    return(fs.ReadToEnd());
                }
            }
            else
            {
                using (var fs = File.OpenText(fileName))
                {
                    return(fs.ReadToEnd());
                }
            }
        }
示例#11
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            ddlMaritalStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS)), true);
            ddlConnectionStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)), true);
            ddlRecordStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS)));
            ddlReason.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON)), true);

            ddlGivingGroup.Items.Clear();
            ddlGivingGroup.Items.Add(new ListItem(None.Text, None.IdValue));
            if (Person != null)
            {
                var personService = new PersonService(new RockContext());
                foreach (var family in personService.GetFamilies(Person.Id).Select(a => new { a.Name, a.Id, a.Members }))
                {
                    string familyNameWithFirstNames = GetFamilyNameWithFirstNames(family.Name, family.Members);
                    ddlGivingGroup.Items.Add(new ListItem(familyNameWithFirstNames, family.Id.ToString()));
                }
            }

            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);

            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            btnSave.Visible = IsUserAuthorized(Rock.Security.Authorization.EDIT);

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);

            grdPreviousNames.Actions.ShowAdd   = true;
            grdPreviousNames.Actions.AddClick += grdPreviousNames_AddClick;
        }
示例#12
0
        private void DisplayForm(Person person)
        {
            pnlMain.Visible = true;

            ddlTitle.SetValue(person.TitleValueId);
            iuPhoto.BinaryFileId = person.PhotoId;
            tbNickName.Text      = person.NickName;
            tbFirstName.Text     = person.FirstName;
            tbMiddleName.Text    = person.MiddleName;
            tbLastName.Text      = person.LastName;
            ddlSuffix.SetValue(person.SuffixValueId);

            var families = person.GetFamilies();

            //If there is more than one family don't show family role
            if (families.Count() > 1)
            {
                ddlFamilyRole.Visible = false;
            }
            else
            {
                ddlFamilyRole.SelectedValue = person.GetFamilyRole().Guid == Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ? "A" : "C";

                var familyMemberRole = person.GetFamilyMembers(true)
                                       .Where(m => person.Id == m.PersonId)
                                       .Select(m => m.GroupRole)
                                       .FirstOrDefault();

                if (familyMemberRole != null)
                {
                    ddlFamilyRole.SelectedValue = familyMemberRole.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ? "A" : "C";
                }
            }


            //PhoneNumber
            var mobilePhoneType = DefinedValueCache.Get(new Guid(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE));

            var phoneNumbers     = new List <PhoneNumber>();
            var phoneNumberTypes = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_PHONE_TYPE));

            if (phoneNumberTypes.DefinedValues.Any())
            {
                foreach (var phoneNumberType in phoneNumberTypes.DefinedValues)
                {
                    var phoneNumber = person.PhoneNumbers.FirstOrDefault(n => n.NumberTypeValueId == phoneNumberType.Id);
                    if (phoneNumber == null)
                    {
                        var numberType = new DefinedValue();
                        numberType.Id    = phoneNumberType.Id;
                        numberType.Value = phoneNumberType.Value;

                        phoneNumber = new PhoneNumber {
                            NumberTypeValueId = numberType.Id, NumberTypeValue = numberType
                        };
                        phoneNumber.IsMessagingEnabled = mobilePhoneType != null && phoneNumberType.Id == mobilePhoneType.Id;
                    }
                    else
                    {
                        // Update number format, just in case it wasn't saved correctly
                        phoneNumber.NumberFormatted = PhoneNumber.FormattedNumber(phoneNumber.CountryCode, phoneNumber.Number);
                    }

                    phoneNumbers.Add(phoneNumber);
                }
            }
            rContactInfo.DataSource = phoneNumbers;
            rContactInfo.DataBind();


            //email
            tbEmail.Text            = person.Email;
            cbIsEmailActive.Checked = person.IsEmailActive;

            rblEmailPreference.SetValue(person.EmailPreference.ConvertToString(false));
            rblCommunicationPreference.SetValue(person.CommunicationPreference == CommunicationType.SMS ? "2" : "1");

            //demographics
            bpBirthday.SelectedDate = person.BirthDate;
            ddlGender.SetValue(person.Gender.ConvertToInt());
            ddlMaritalStatus.SetValue(person.MaritalStatusValueId);
            dpAnniversaryDate.SelectedDate = person.AnniversaryDate;

            if (!person.HasGraduated ?? false)
            {
                int gradeOffset    = person.GradeOffset.Value;
                var maxGradeOffset = ddlGradePicker.MaxGradeOffset;

                // keep trying until we find a Grade that has a gradeOffset that that includes the Person's gradeOffset (for example, there might be combined grades)
                while (!ddlGradePicker.Items.OfType <ListItem>().Any(a => a.Value.AsInteger() == gradeOffset) && gradeOffset <= maxGradeOffset)
                {
                    gradeOffset++;
                }

                ddlGradePicker.SetValue(gradeOffset);
                ypGraduation.SelectedYear = person.GraduationYear;
            }
            else
            {
                ddlGradePicker.SelectedIndex = 0;
                ypGraduation.SelectedYear    = person.GraduationYear;
            }
            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);

            //Family Info
            var location = person.GetHomeLocation();

            acAddress.SetValues(location);
            ddlCampus.SetValue(person.GetCampus());
        }
示例#13
0
 /// <summary>
 /// String representation of the block
 /// </summary>
 public override string ToString()
 {
     return(BlockId.ToString() + (BlockMeta != 0 ? ":" + BlockMeta.ToString() : ""));
 }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);
            ddlTitle.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)).Id;
            ddlTitle.Items.Insert(0, new ListItem());
            ddlSuffix.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)).Id;
            ddlSuffix.Items.Insert(0, new ListItem());
            RockPage.AddCSSLink(ResolveRockUrl("~/Styles/fluidbox.css"));
            RockPage.AddScriptLink(ResolveRockUrl("~/Scripts/imagesloaded.min.js"));
            RockPage.AddScriptLink(ResolveRockUrl("~/Scripts/jquery.fluidbox.min.js"));

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("RequiredAdultPhoneTypes")))
            {
                _RequiredPhoneNumberGuids = GetAttributeValue("RequiredAdultPhoneTypes").Split(',').Select(Guid.Parse).ToList();
            }
            rContactInfo.ItemDataBound += rContactInfo_ItemDataBound;
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);
        }
示例#16
0
 private void Invalid(BlockId id)
 {
     this.request_ids.Remove(id.ToString());
     this.is_fetch = true;
 }
示例#17
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlMaritalStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS)), true);

            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);

            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);

            base.BlockUpdated += GroupMemberProfileDetails_BlockUpdated;
        }
示例#18
0
 public static bool IsBackground(this BlockId bid) => bid.ToString().StartsWith("Bg");
示例#19
0
        // <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                // check the page context
                bool pageScope = GetAttributeValue("ContextScope") == "Page";

                // If the blocks respect page context let's set those vars
                if (pageScope)
                {
                    // Get Current Campus Context
                    CampusContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Campus)));

                    // Get Current Schedule Context
                    ScheduleContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Schedule)));

                    // Get Current Group Context
                    GroupContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(Group)));

                    // Get Current GroupType Context
                    GroupTypeContext = RockPage.GetCurrentContext(EntityTypeCache.Read(typeof(GroupType)));
                }

                // Output variables direct to the ascx
                metricBlockNumber.Value = BlockId.ToString();
                metricBlockId.Value     = BlockName.Replace(" ", "").ToString();
                metricTitle.Value       = BlockName;
                metricDisplay.Value     = GetAttributeValue("MetricDisplayType");
                metricWidth.Value       = GetAttributeValue("NumberofColumns");

                PrimaryMetricKey    = GetAttributeValue("PrimaryMetricKey");
                ComparisonMetricKey = GetAttributeValue("ComparisonMetricKey");

                var churchMetricPeriod = GetAttributeValue("MetricPeriod");
                var metricComparison   = GetAttributeValue("MetricComparison");
                var metricDisplayType  = GetAttributeValue("MetricDisplayType");

                var rockContext   = new RockContext();
                var metricService = new MetricService(rockContext);

                var primarySourceGuids = GetAttributeValue("PrimaryMetricSource")
                                         .SplitDelimitedValues()
                                         .AsGuidList();

                var comparisonSourceGuids = GetAttributeValue("ComparisonMetricSource")
                                            .SplitDelimitedValues()
                                            .AsGuidList();

                // lookup the metric sources
                List <int> primaryMetricSource = metricService.GetByGuids(primarySourceGuids)
                                                 .Select(a => a.Id).ToList();

                List <int> comparisonMetricSource = metricService.GetByGuids(comparisonSourceGuids)
                                                    .Select(a => a.Id).ToList();

                DateRange dateRange = new DateRange(DateTime.Now.AddMonths(-6), DateTime.Now);

                // Show data if metric source is selected
                if (primaryMetricSource.Any() || !string.IsNullOrEmpty(PrimaryMetricKey))
                {
                    if (metricDisplayType.Equals("Text"))
                    {
                        DisplayTextValue(dateRange, primaryMetricSource, comparisonMetricSource);
                    }
                    else if (metricDisplayType.Equals("Line"))
                    {
                        DisplayLineValue(dateRange, primaryMetricSource);
                    }
                    else if (metricDisplayType.Equals("Donut"))
                    {
                        DisplayDonutValue(dateRange, primaryMetricSource);
                    }
                }
                else
                {
                    // nothing selected, display an error message
                    churchMetricWarning.Visible = true;
                }
            }

            // unused variables
            // var metricCustomDates = GetAttributeValue( "CustomDates" );
            // MetricCompareLastYear = GetAttributeValue( "CompareAgainstLastYear" ).ToString();
            // var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( this.GetAttributeValue( "SlidingDateRange" ) ?? string.Empty );
        }
示例#20
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            rblMaritalStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS)));
            rblStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)));
            ddlRecordStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS)));
            ddlReason.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON)), true);

            ddlGivingGroup.Items.Clear();
            ddlGivingGroup.Items.Add(new ListItem(None.Text, None.IdValue));
            if (Person != null)
            {
                var personService = new PersonService(new RockContext());
                foreach (var family in personService.GetFamilies(Person.Id))
                {
                    ddlGivingGroup.Items.Add(new ListItem(family.Name, family.Id.ToString()));
                }
            }

            DateTime?gradeTransitionDate = GlobalAttributesCache.Read().GetValue("GradeTransitionDate").AsDateTime();

            if (gradeTransitionDate.HasValue)
            {
                _gradeTransitionDate = gradeTransitionDate.Value;
            }

            ddlGrade.Items.Clear();
            ddlGrade.Items.Add(new ListItem("", ""));
            ddlGrade.Items.Add(new ListItem("K", "0"));
            ddlGrade.Items.Add(new ListItem("1st", "1"));
            ddlGrade.Items.Add(new ListItem("2nd", "2"));
            ddlGrade.Items.Add(new ListItem("3rd", "3"));
            ddlGrade.Items.Add(new ListItem("4th", "4"));
            ddlGrade.Items.Add(new ListItem("5th", "5"));
            ddlGrade.Items.Add(new ListItem("6th", "6"));
            ddlGrade.Items.Add(new ListItem("7th", "7"));
            ddlGrade.Items.Add(new ListItem("8th", "8"));
            ddlGrade.Items.Add(new ListItem("9th", "9"));
            ddlGrade.Items.Add(new ListItem("10th", "10"));
            ddlGrade.Items.Add(new ListItem("11th", "11"));
            ddlGrade.Items.Add(new ListItem("12th", "12"));

            int gradeFactorReactor = (RockDateTime.Now < _gradeTransitionDate) ? 12 : 13;

            string script = string.Format(@"
    $('#{0}').change(function(){{
        if ($(this).val() != '') {{
            $('#{1}').val( {2} + ( {3} - parseInt( $(this).val() ) ) );
    
        }}
    }});

    $('#{1}').change(function(){{
        if ($(this).val() == '') {{
            $('#{0}').val('');
        }} else {{
            var grade = {3} - ( parseInt( $(this).val() ) - {4} );
            if (grade >= 0 && grade <= 12) {{
                $('#{0}').val(grade.toString());
            }} else {{
                $('#{0}').val('');
            }}
        }}
    }});

", ddlGrade.ClientID, ypGraduation.ClientID, _gradeTransitionDate.Year, gradeFactorReactor, RockDateTime.Now.Year);

            ScriptManager.RegisterStartupScript(ddlGrade, ddlGrade.GetType(), "grade-selection-" + BlockId.ToString(), script, true);

            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);
        }