Exemplo n.º 1
0
        public void ShowGridForm()
        {
            gridView           = new GridView();
            gridControl        = new GridControl();
            form               = new XtraForm();
            form.Icon          = Marbid.Module.Win.Properties.Resources.mareinico;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.Text          = ReportName;
            gridControl.ViewCollection.Add(gridView);
            gridControl.Dock = DockStyle.Fill;
            DataSet dataSet = new DataSet();

            DataRetrieval retrieval = new DataRetrieval();
            List <ParameterDictionary> paramDictionary;

            if (parameterDefinition.Count > 0)
            {
                ParameterForm parameterForm = new ParameterForm();
                parameterForm.ParameterDefinition = parameterDefinition;
                if (parameterForm.ShowParameterDialog() == DialogResult.Cancel)
                {
                    return;
                }

                paramDictionary      = parameterForm.ParameterDictionary;
                retrieval.Parameters = paramDictionary;
            }

            retrieval.ConnectionString = connectionString;
            retrieval.QueryString      = queryString;
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            try
            {
                dataSet = retrieval.GetDataSet("ReportData", dataSet);
            }
            finally
            {
                //Close Wait Form
                SplashScreenManager.CloseForm(false);
            }
            gridControl.DataSource = dataSet.Tables["ReportData"];
            gridView.PopulateColumns();
            gridControl.ForceInitialize();
            form.Controls.Add(gridControl);
            form.Shown += GridForm_Shown;
            GridView view = (GridView)gridControl.MainView;

            foreach (GridColumn col in view.Columns)
            {
                col.OptionsColumn.ReadOnly = true;
                if (col.ColumnType == typeof(System.Decimal) || col.ColumnType == typeof(System.Double))
                {
                    col.DisplayFormat.FormatType   = FormatType.Numeric;
                    col.DisplayFormat.FormatString = "n2";
                    col.SummaryItem.SummaryType    = DevExpress.Data.SummaryItemType.Sum;
                }
            }
            form.Height            = 768;
            form.Width             = 1024;
            view.PopupMenuShowing += GridView_PopupMenuShowing;
            SplashScreenManager.CloseForm(false);
            form.Show();
        }
Exemplo n.º 2
0
        public void ShowPivotForm()
        {
            pivotGrid               = new PivotGridControl();
            pivotGrid.Dock          = System.Windows.Forms.DockStyle.Fill;
            pivotForm               = new XtraForm();
            pivotForm.Icon          = Marbid.Module.Win.Properties.Resources.mareinico;
            pivotForm.StartPosition = FormStartPosition.CenterScreen;
            pivotForm.Text          = "Pivot Grid: " + ReportName;
            pivotForm.Controls.Add(pivotGrid);
            DataRetrieval retrieval = new DataRetrieval();

            pivotForm.Height = 768;
            pivotForm.Width  = 1024;
            List <ParameterDictionary> paramDictionary;

            if (ParameterDefinition.Count > 0)
            {
                ParameterForm parameterForm = new ParameterForm();
                parameterForm.ParameterDefinition = ParameterDefinition;
                if (parameterForm.ShowParameterDialog() == DialogResult.Cancel)
                {
                    return;
                }
                paramDictionary      = parameterForm.ParameterDictionary;
                retrieval.Parameters = paramDictionary;
            }
            retrieval.ConnectionString = ConnectionString;
            retrieval.QueryString      = QueryString;
            DataSet dataSet = new DataSet();

            SplashScreenManager.ShowForm(typeof(WaitForm1));
            try
            {
                dataSet = retrieval.GetDataSet("ReportData", dataSet);
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
            pivotGrid.OptionsMenu.EnableFormatRulesMenu = true;
            pivotGrid.DataSource        = dataSet.Tables["ReportData"];
            pivotGrid.PopupMenuShowing += PivotGrid_PopupMenuShowing;
            pivotGrid.CellDoubleClick  += PivotGrid_CellDoubleClick;

            if (!String.IsNullOrWhiteSpace(LayoutData))
            {
                MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write(LayoutData);
                writer.Flush();
                stream.Position = 0;
                pivotGrid.RestoreLayoutFromStream(stream, opt);
            }
            else
            {
                pivotGrid.RetrieveFields();
                foreach (PivotGridField field in pivotGrid.Fields)
                {
                    if (field.DataType == typeof(System.Double) || field.DataType == typeof(System.Decimal))
                    {
                        field.CellFormat.FormatType   = FormatType.Numeric;
                        field.CellFormat.FormatString = "n2";
                        field.AllowedAreas            = PivotGridAllowedAreas.DataArea;
                    }
                    else
                    {
                        field.SummaryType = DevExpress.Data.PivotGrid.PivotSummaryType.Count;
                    }
                }
            }
            pivotForm.Show();
        }