Example #1
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            pnlUpdateMessage.Visible = false;
            pnlResults.Visible       = true;

            int?accountId = apAccount.SelectedValue.AsIntegerOrNull();

            if (!accountId.HasValue)
            {
                return;
            }

            var      dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(drpSlidingDateRange.DelimitedValues);
            DateTime?start     = dateRange.Start ?? (DateTime?)System.Data.SqlTypes.SqlDateTime.MinValue;
            DateTime?end       = dateRange.End ?? ( DateTime? )System.Data.SqlTypes.SqlDateTime.MaxValue;

            var minPledgeAmount = nrePledgeAmount.LowerValue;
            var maxPledgeAmount = nrePledgeAmount.UpperValue;

            var minComplete = nrePercentComplete.LowerValue;
            var maxComplete = nrePercentComplete.UpperValue;

            var minGiftAmount = nreAmountGiven.LowerValue;
            var maxGiftAmount = nreAmountGiven.UpperValue;

            int  includeOption  = rblInclude.SelectedValueAsInt() ?? 0;
            bool includePledges = includeOption != 1;
            bool includeGifts   = includeOption != 0;

            DataSet ds = FinancialPledgeService.GetPledgeAnalytics(accountId.Value, start, end,
                                                                   minPledgeAmount, maxPledgeAmount, minComplete, maxComplete, minGiftAmount, maxGiftAmount,
                                                                   includePledges, includeGifts);

            System.Data.DataView dv = ds.Tables[0].DefaultView;

            if (gList.SortProperty != null)
            {
                try
                {
                    var sortProperties = new List <string>();
                    foreach (string prop in gList.SortProperty.Property.SplitDelimitedValues(false))
                    {
                        sortProperties.Add(string.Format("[{0}] {1}", prop, gList.SortProperty.DirectionString));
                    }
                    dv.Sort = sortProperties.AsDelimited(", ");
                }
                catch
                {
                    dv.Sort = "[LastName] ASC, [NickName] ASC";
                }
            }
            else
            {
                dv.Sort = "[LastName] ASC, [NickName] ASC";
            }

            gList.DataSource = dv;
            gList.DataBind();
        }