Example #1
0
        public Form1()
        {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");
            DashboardSqlDataSource dataSource = (DashboardSqlDataSource)dashboard.DataSources[0];
            GridDashboardItem      grid       = (GridDashboardItem)dashboard.Items[0];

            // Create a new dashboard parameter.
            StaticListLookUpSettings settings = new StaticListLookUpSettings();

            settings.Values = new string[] { "0.01", "0.05", "0.1" };
            DashboardParameter discountValue = new DashboardParameter("discountValue",
                                                                      typeof(double), 0.05, "Select discount:", true, settings);

            dashboard.Parameters.Add(discountValue);

            // Create a new calculated field and pass the created dashboard parameter
            // to a calculated field expression.
            CalculatedField isGreater = new CalculatedField();

            isGreater.DataMember = "SalesPerson";
            isGreater.Name       = "IsGreater";
            isGreater.Expression = "ToStr(Iif(Avg([Discount]) >= [Parameters.discountValue], 'TRUE', 'FALSE'))";
            dataSource.CalculatedFields.Add(isGreater);

            grid.Columns.Add(new GridMeasureColumn(new Measure("IsGreater")));
            dashboardViewer1.Dashboard = dashboard;
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            // Creates a new dashboard parameter.
            StaticListLookUpSettings staticSettings = new StaticListLookUpSettings();

            staticSettings.Values = new string[] { "1994", "1995", "1996" };
            DashboardParameter yearParameter = new DashboardParameter("yearParameter",
                                                                      typeof(string), "1995", "Select year:", true, staticSettings);

            dashboard.Parameters.Add(yearParameter);

            DashboardSqlDataSource dataSource       = (DashboardSqlDataSource)dashboard.DataSources[0];
            CustomSqlQuery         salesPersonQuery = (CustomSqlQuery)dataSource.Queries[0];

            salesPersonQuery.Parameters.Add(new QueryParameter("startDate", typeof(Expression),
                                                               new Expression("[Parameters.yearParameter] + '/01/01'")));
            salesPersonQuery.Parameters.Add(new QueryParameter("endDate", typeof(Expression),
                                                               new Expression("[Parameters.yearParameter] + '/12/31'")));
            salesPersonQuery.Sql =
                "select * from SalesPerson where OrderDate between @startDate and @endDate";

            dashboardViewer1.Dashboard = dashboard;
        }
Example #3
0
        public SampleReport()
        {
            InitializeComponent();

            // Initialize a list of lookup values for report columns.
            _reportColumns = new LookUpValueCollection()
            {
                new LookUpValue("ID", "ID"),
                new LookUpValue("Name", "Name"),
                new LookUpValue("Category", "Category"),
                new LookUpValue("Supplier", "Supplier"),
                new LookUpValue("UnitPrice", "Price"),
                new LookUpValue("UnitsInStock", "In Stock"),
                new LookUpValue("UnitsOnOrder", "On Order"),
                new LookUpValue("QuantityPerUnit", "Quantity Per Unit")
            };

            var reportColumnsLookUpSettings = new StaticListLookUpSettings();

            reportColumnsLookUpSettings.LookUpValues.AddRange(_reportColumns);

            // Assign the list of lookup values to the report's ReportColumns parameter.
            this.Parameters["ReportColumns"].LookUpSettings = reportColumnsLookUpSettings;

            // Specify default lookup values.
            this.Parameters["ReportColumns"].Value = new string[] { "ID", "Name", "Category", "Supplier", "UnitPrice" };
        }
Example #4
0
        public WorksOrderPrint CreateWorksOrderDayPrint()
        {
            var resources      = _appointmentsService.GetAllResources(CurrentTenantId).ToList();
            var combinedReport = new WorksOrderPrint {
                FilterString = "[WorksAppointmentResourcesId] In (?paramResourceIds)"
            };

            combinedReport.paramScheduleDate.Value = DateTime.Today;

            StaticListLookUpSettings paramResourceIdsSettings = (StaticListLookUpSettings)combinedReport.paramResourceIds.LookUpSettings;

            paramResourceIdsSettings.LookUpValues.AddRange(resources.Select(m => new LookUpValue(m.ResourceId, m.Name)));
            combinedReport.ParametersRequestBeforeShow += CombinedReport_ParametersRequestBeforeShow;

            return(combinedReport);
        }
        private void AddParameter(Dashboard dashboard)
        {
            DashboardParameter       myDashboardParameter      = new DashboardParameter();
            StaticListLookUpSettings staticListLookUpSettings1 = new StaticListLookUpSettings();

            myDashboardParameter.AllowMultiselect = true;
            // Parameter values displayed in the look-up editor.
            staticListLookUpSettings1.Values    = new string[] { "Alabama", "Ohio", "Utah" };
            myDashboardParameter.LookUpSettings = staticListLookUpSettings1;
            myDashboardParameter.Name           = "parameterState";
            myDashboardParameter.Type           = typeof(string);
            // Default parameter value.
            myDashboardParameter.Value = new List <string> {
                "Ohio", "Utah"
            };
            dashboard.Parameters.Add(myDashboardParameter);
        }
Example #6
0
        public static Parameter SetComboBox <TKey>(this Parameter parameter,
                                                   IReadOnlyDictionary <TKey, string> lookUpValues,
                                                   TKey?value = null) where TKey : struct
        {
            if (lookUpValues == null)
            {
                throw new ArgumentNullException(nameof(lookUpValues));
            }

            parameter.SetType(typeof(TKey?), value);
            parameter.MultiValue = false;

            var settings = new StaticListLookUpSettings();

            settings.LookUpValues.AddRange(lookUpValues.Select(c => new LookUpValue(c.Key, c.Value)));
            parameter.LookUpSettings = settings;

            return(parameter);
        }
Example #7
0
        public static Parameter SetDrowDown <TKey>(this Parameter parameter,
                                                   IReadOnlyDictionary <TKey, string> lookUpValues,
                                                   params TKey[] value)
        {
            if (lookUpValues == null)
            {
                throw new ArgumentNullException(nameof(lookUpValues));
            }

            parameter.SetType(typeof(TKey), value);
            parameter.MultiValue = true;

            var settings = new StaticListLookUpSettings();

            settings.LookUpValues.AddRange(lookUpValues.Select(c => new LookUpValue(c.Key, c.Value)));
            parameter.LookUpSettings = settings;

            return(parameter);
        }
Example #8
0
        static string GetDescription(StaticListLookUpSettings lookupSettings, string value)
        {
            LookUpValue lookup = lookupSettings.LookUpValues.FirstOrDefault(x => (string)x.Value == value);

            return(lookup != null ? lookup.Description : "");
        }