Пример #1
0
        public void Apply()
        {
            XmlNode rNode = _Draw.GetReportNode();

            _Draw.RemoveElement(rNode, "ReportParameters");             // remove old ReportParameters
            if (this.lbParameters.Items.Count <= 0)
            {
                return;                                 // nothing in list?  all done
            }
            XmlNode rpsNode = _Draw.SetElement(rNode, "ReportParameters", null);

            foreach (ReportParm repParm in lbParameters.Items)
            {
                if (repParm.Name == null || repParm.Name.Length <= 0)
                {
                    continue;                           // shouldn't really happen
                }
                XmlNode repNode = _Draw.CreateElement(rpsNode, "ReportParameter", null);
                // Create the name attribute
                _Draw.SetElementAttribute(repNode, "Name", repParm.Name);

                _Draw.SetElement(repNode, "DataType", repParm.DataType);
                // Handle default values
                ApplyDefaultValues(repNode, repParm);

                _Draw.SetElement(repNode, "Nullable", repParm.AllowNull? "true": "false");
                _Draw.SetElement(repNode, "AllowBlank", repParm.AllowBlank? "true": "false");
                _Draw.SetElement(repNode, "MultiValue", repParm.MultiValue ? "true" : "false");
                _Draw.SetElement(repNode, "Prompt", repParm.Prompt);

                // Handle ValidValues
                ApplyValidValues(repNode, repParm);
            }
        }
Пример #2
0
        private XmlNode GetXmlData()
        {
            XmlDocumentFragment fDoc = _Draw.ReportDocument.CreateDocumentFragment();

            XmlNode rows = _Draw.CreateElement(fDoc, "fyi:Rows", null);

            foreach (DataRow dr in _DataTable.Rows)
            {
                XmlNode row       = _Draw.CreateElement(rows, "Row", null);
                bool    bRowBuilt = false;
                foreach (DataColumn dc in _DataTable.Columns)
                {
                    if (dr[dc] == DBNull.Value)
                    {
                        continue;
                    }
                    string val = dr[dc].ToString();
                    if (val == null)
                    {
                        continue;
                    }
                    _Draw.CreateElement(row, dc.ColumnName, val);
                    bRowBuilt = true;                           // we've populated at least one column; so keep row
                }
                if (!bRowBuilt)
                {
                    rows.RemoveChild(row);
                }
            }
            return(rows);
        }
Пример #3
0
        public void Apply()
        {
            // Remove the old filters
            XmlNode sorts = null;

            _Draw.RemoveElement(_SortingParent, "Sorting");
            // Loop thru and add all the filters
            foreach (DataGridViewRow dr in dgSorting.Rows)
            {
                string expr = dr.Cells[0].Value as string;
                bool   dir  = dr.Cells[1].Value == null? true: (bool)dr.Cells[1].Value;

                if (expr == null || expr.Length <= 0)
                {
                    continue;
                }

                if (sorts == null)
                {
                    sorts = _Draw.CreateElement(_SortingParent, "Sorting", null);
                }

                XmlNode sNode = _Draw.CreateElement(sorts, "SortBy", null);
                _Draw.CreateElement(sNode, "SortExpression", expr);
                _Draw.CreateElement(sNode, "Direction", dir?"Ascending":"Descending");
            }
        }
Пример #4
0
        public void Apply()
        {
            // Remove the old filters
            XmlNode sorts = null;

            _Draw.RemoveElement(_SortingParent, "Sorting");
            // Loop thru and add all the filters
            foreach (DataRow dr in _DataTable.Rows)
            {
                if (dr[0] == DBNull.Value)
                {
                    continue;
                }
                string expr = (string)dr[0];
                bool   dir  = dr[1] == DBNull.Value? true: (bool)dr[1];

                if (expr.Length <= 0)
                {
                    continue;
                }

                if (sorts == null)
                {
                    sorts = _Draw.CreateElement(_SortingParent, "Sorting", null);
                }

                XmlNode sNode = _Draw.CreateElement(sorts, "SortBy", null);
                _Draw.CreateElement(sNode, "SortExpression", expr);
                _Draw.CreateElement(sNode, "Direction", dir?"Ascending":"Descending");
            }
        }
        private void SetChartDataValue(int i, string expr)
        {
            DesignXmlDraw dr    = _pt.Draw;
            string        expr1 = i == 1 ? expr : _pt.ChartData.DataValue.Expression;
            string        expr2 = i == 2 ? expr : _pt.ChartData.DataValue2.Expression;
            string        expr3 = i == 3 ? expr : _pt.ChartData.DataValue3.Expression;

            foreach (XmlNode node in _pt.Nodes)
            {
                XmlNode chartdata   = dr.SetElement(node, "ChartData", null);
                XmlNode chartseries = dr.SetElement(chartdata, "ChartSeries", null);
                XmlNode datapoints  = dr.SetElement(chartseries, "DataPoints", null);
                XmlNode datapoint   = dr.SetElement(datapoints, "DataPoint", null);
                XmlNode datavalues  = dr.SetElement(datapoint, "DataValues", null);
                dr.RemoveElementAll(datavalues, "DataValue");
                XmlNode datavalue = dr.SetElement(datavalues, "DataValue", null);
                dr.SetElement(datavalue, "Value", expr1);

                string type = _pt.Type.ToLowerInvariant();
                if (type == "scatter" || type == "bubble")
                {
                    datavalue = dr.CreateElement(datavalues, "DataValue", null);
                    dr.SetElement(datavalue, "Value", expr2);
                    if (type == "bubble")
                    {
                        datavalue = dr.CreateElement(datavalues, "DataValue", null);
                        dr.SetElement(datavalue, "Value", expr3);
                    }
                }
            }
        }
Пример #6
0
        private void CreateTableRow(XmlNode tblNode, string elementName)
        {
            XmlNode node = _Draw.GetNamedChildNode(tblNode, elementName);

            if (node == null)
            {
                node = _Draw.CreateElement(tblNode, elementName, null);
                XmlNode tblRows = _Draw.CreateElement(node, "TableRows", null);
                _Draw.InsertTableRow(tblRows);
            }
            return;
        }
        public void Apply()
        {
            XmlNode rNode = _Draw.GetReportNode();

            _Draw.RemoveElement(rNode, "EmbeddedImages");               // remove old EmbeddedImages
            if (this.lbImages.Items.Count <= 0)
            {
                return;                                 // nothing in list?  all done
            }
            XmlNode eiNode = _Draw.SetElement(rNode, "EmbeddedImages", null);

            foreach (EmbeddedImageValues eiv in lbImages.Items)
            {
                if (eiv.Name == null || eiv.Name.Length <= 0)
                {
                    continue;                                                           // shouldn't really happen
                }
                XmlNode iNode = _Draw.CreateElement(eiNode, "EmbeddedImage", null);

                // Create the name attribute
                _Draw.SetElementAttribute(iNode, "Name", eiv.Name);
                _Draw.SetElement(iNode, "MIMEType", eiv.MIMEType);
                _Draw.SetElement(iNode, "ImageData", eiv.ImageData);
            }
        }
Пример #8
0
        private void ApplyChanges(XmlNode rNode)
        {
            if (_names != null)
            {
                rNode = _Draw.FindCreateNextInHierarchy(rNode, _names);
            }

            XmlNode xNode = _Draw.GetNamedChildNode(rNode, "Style");

            //Added to create a node in case a node doesn't have
            // a style node when attempting to save.
            if (xNode == null)
            {
                _Draw.SetElement(rNode, "Style", "");
                xNode = _Draw.GetNamedChildNode(rNode, "Style");
            }



            if (fEndColor)
            {
                _Draw.SetElement(xNode, "BackgroundGradientEndColor", cbEndColor.Text);
            }
            if (fBackColor)
            {
                _Draw.SetElement(xNode, "BackgroundColor", cbBackColor.Text);
            }
            if (fGradient)
            {
                _Draw.SetElement(xNode, "BackgroundGradientType", cbGradient.Text);
            }
            if (fBackImage)
            {
                _Draw.RemoveElement(xNode, "BackgroundImage");
                if (!rbNone.Checked)
                {
                    XmlNode bi = _Draw.CreateElement(xNode, "BackgroundImage", null);
                    if (rbDatabase.Checked)
                    {
                        _Draw.SetElement(bi, "Source", "Database");
                        _Draw.SetElement(bi, "Value", cbValueDatabase.Text);
                        _Draw.SetElement(bi, "MIMEType", cbMIMEType.Text);
                    }
                    else if (rbExternal.Checked)
                    {
                        _Draw.SetElement(bi, "Source", "External");
                        _Draw.SetElement(bi, "Value", tbValueExternal.Text);
                    }
                    else if (rbEmbedded.Checked)
                    {
                        _Draw.SetElement(bi, "Source", "Embedded");
                        _Draw.SetElement(bi, "Value", cbValueEmbedded.Text);
                    }
                    _Draw.SetElement(bi, "BackgroundRepeat", cbRepeat.Text);
                }
            }
        }
Пример #9
0
        public void Apply()
        {
            // Remove the old filters
            XmlNode filters = null;

            _Draw.RemoveElement(_FilterParent, "Filters");

            // Loop thru and add all the filters
            foreach (DataRow dr in _DataTable.Rows)
            {
                if (dr[0] == DBNull.Value || dr[1] == DBNull.Value || dr[2] == DBNull.Value)
                {
                    continue;
                }
                string fe = (string)dr[0];
                string op = (string)dr[1];
                string fv = (string)dr[2];
                if (fe.Length <= 0 || op.Length <= 0 || fv.Length <= 0)
                {
                    continue;
                }
                if (filters == null)
                {
                    filters = _Draw.CreateElement(_FilterParent, "Filters", null);
                }

                XmlNode fNode = _Draw.CreateElement(filters, "Filter", null);
                _Draw.CreateElement(fNode, "FilterExpression", fe);
                _Draw.CreateElement(fNode, "Operator", op);
                XmlNode fvNode = _Draw.CreateElement(fNode, "FilterValues", null);
                if (op == "In")
                {
                    string[] vs = fv.Split(',');
                    foreach (string v in vs)
                    {
                        _Draw.CreateElement(fvNode, "FilterValue", v.Trim());
                    }
                }
                else if (op == "Between")
                {
                    string[] vs = fv.Split(new char[] { ',' }, 2);
                    foreach (string v in vs)
                    {
                        _Draw.CreateElement(fvNode, "FilterValue", v.Trim());
                    }
                }
                else
                {
                    _Draw.CreateElement(fvNode, "FilterValue", fv);
                }
            }
        }
Пример #10
0
        private void CreateTableRow(XmlNode tblNode, string elementName, bool bRepeatOnNewPage)
        {
            XmlNode node = _Draw.GetNamedChildNode(tblNode, elementName);

            if (node == null)
            {
                node = _Draw.CreateElement(tblNode, elementName, null);
                XmlNode tblRows = _Draw.CreateElement(node, "TableRows", null);
                _Draw.InsertTableRow(tblRows);
            }
            if (bRepeatOnNewPage)
            {
                _Draw.SetElement(node, "RepeatOnNewPage", "true");
            }
            else
            {
                _Draw.RemoveElement(node, "RepeatOnNewPage");
            }

            return;
        }
Пример #11
0
        private XmlNode GetXmlData()
        {
            XmlDocumentFragment fDoc = _Draw.ReportDocument.CreateDocumentFragment();

            XmlNode rows = _Draw.CreateElement(fDoc, "fyi:Rows", null);

            foreach (DataRow dr in _DataTable.Rows)
            {
                XmlNode row       = _Draw.CreateElement(rows, "Row", null);
                bool    bRowBuilt = false;
                foreach (DataColumn dc in _DataTable.Columns)
                {
                    if (dr[dc] == DBNull.Value)
                    {
                        continue;
                    }
                    string val;
                    if (dc.DataType == typeof(DateTime))
                    {
                        val = Convert.ToString(dr[dc],
                                               System.Globalization.DateTimeFormatInfo.InvariantInfo);
                    }
                    else
                    {
                        val = Convert.ToString(dr[dc], NumberFormatInfo.InvariantInfo);
                    }
                    if (val == null)
                    {
                        continue;
                    }
                    _Draw.CreateElement(row, dc.ColumnName, val);
                    bRowBuilt = true;                           // we've populated at least one column; so keep row
                }
                if (!bRowBuilt)
                {
                    rows.RemoveChild(row);
                }
            }
            return(rows);
        }
Пример #12
0
        public void Apply()
        {
            // Remove the old filters
            XmlNode filters = null;

            _Draw.RemoveElement(_FilterParent, "Filters");

            // Loop thru and add all the filters
            foreach (DataGridViewRow dr in this.dgFilters.Rows)
            {
                string fe = dr.Cells[0].Value as string;
                string op = dr.Cells[1].Value as string;
                string fv = dr.Cells[2].Value as string;
                if (fe == null || fe.Length <= 0 ||
                    op == null || op.Length <= 0 ||
                    fv == null || fv.Length <= 0)
                {
                    continue;
                }
                if (filters == null)
                {
                    filters = _Draw.CreateElement(_FilterParent, "Filters", null);
                }

                XmlNode fNode = _Draw.CreateElement(filters, "Filter", null);
                _Draw.CreateElement(fNode, "FilterExpression", fe);
                _Draw.CreateElement(fNode, "Operator", op);
                XmlNode fvNode = _Draw.CreateElement(fNode, "FilterValues", null);
                if (op == "In")
                {
                    string[] vs = fv.Split(',');
                    foreach (string v in vs)
                    {
                        _Draw.CreateElement(fvNode, "FilterValue", v.Trim());
                    }
                }
                else if (op == "Between")
                {
                    string[] vs = fv.Split(new char[] { ',' }, 2);
                    foreach (string v in vs)
                    {
                        _Draw.CreateElement(fvNode, "FilterValue", v.Trim());
                    }
                }
                else
                {
                    _Draw.CreateElement(fvNode, "FilterValue", fv);
                }
            }
        }
Пример #13
0
        private void ApplyGridLines(XmlNode node, string type, CheckBox show, ComboBox color, ComboBox style, TextBox width)
        {
            XmlNode m = _Draw.GetNamedChildNode(node, type);

            if (m == null)
            {
                m = _Draw.CreateElement(node, type, null);
            }

            _Draw.SetElement(m, "ShowGridLines", show.Checked? "true": "false");
            XmlNode st = _Draw.GetNamedChildNode(m, "Style");

            if (st == null)
            {
                st = _Draw.CreateElement(m, "Style", null);
            }

            XmlNode work = _Draw.GetNamedChildNode(st, "BorderColor");

            if (work == null)
            {
                work = _Draw.CreateElement(st, "BorderColor", null);
            }
            _Draw.SetElement(work, "Default", color.Text);

            work = _Draw.GetNamedChildNode(st, "BorderStyle");
            if (work == null)
            {
                work = _Draw.CreateElement(st, "BorderStyle", null);
            }
            _Draw.SetElement(work, "Default", style.Text);

            work = _Draw.GetNamedChildNode(st, "BorderWidth");
            if (work == null)
            {
                work = _Draw.CreateElement(st, "BorderWidth", null);
            }
            _Draw.SetElement(work, "Default", width.Text);
        }
Пример #14
0
        public void Apply()
        {
            XmlNode rNode = _Draw.GetReportNode();

            _Draw.RemoveElement(rNode, "DataSources");                  // remove old DataSources
            if (this.lbDataSources.Items.Count <= 0)
            {
                return;                                 // nothing in list?  all done
            }
            XmlNode dsNode = _Draw.SetElement(rNode, "DataSources", null);

            foreach (DataSourceValues dsv in lbDataSources.Items)
            {
                if (dsv.Name == null || dsv.Name.Length <= 0)
                {
                    continue;                                                           // shouldn't really happen
                }
                XmlNode dNode = _Draw.CreateElement(dsNode, "DataSource", null);

                // Create the name attribute
                _Draw.SetElementAttribute(dNode, "Name", dsv.Name);

                if (dsv.bDataSourceReference)
                {
                    _Draw.SetElement(dNode, "DataSourceReference", dsv.DataSourceReference);
                    continue;
                }
                // must fill out the connection properties
                XmlNode cNode = _Draw.CreateElement(dNode, "ConnectionProperties", null);
                _Draw.SetElement(cNode, "DataProvider", dsv.DataProvider);
                _Draw.SetElement(cNode, "ConnectString", dsv.ConnectionString);
                _Draw.SetElement(cNode, "IntegratedSecurity", dsv.IntegratedSecurity? "true": "false");
                if (dsv.Prompt != null && dsv.Prompt.Length > 0)
                {
                    _Draw.SetElement(cNode, "Prompt", dsv.Prompt);
                }
            }
        }
Пример #15
0
        public void Apply()
        {
            _Draw.SetElement(_Subreport, "ReportName", this.tbReportFile.Text);
            if (this.tbNoRows.Text.Trim().Length == 0)
            {
                _Draw.RemoveElement(_Subreport, "NoRows");
            }
            else
            {
                _Draw.SetElement(_Subreport, "NoRows", tbNoRows.Text);
            }

            _Draw.SetElement(_Subreport, "MergeTransactions", this.chkMergeTrans.Checked? "true": "false");

            // Remove the old filters
            XmlNode parms = _Draw.GetCreateNamedChildNode(_Subreport, "Parameters");

            while (parms.FirstChild != null)
            {
                parms.RemoveChild(parms.FirstChild);
            }
            // Loop thru and add all the filters
            foreach (DataRow dr in _DataTable.Rows)
            {
                if (dr[0] == DBNull.Value || dr[1] == DBNull.Value)
                {
                    continue;
                }
                string name = (string)dr[0];
                string val  = (string)dr[1];
                if (name.Length <= 0 || val.Length <= 0)
                {
                    continue;
                }
                XmlNode pNode = _Draw.CreateElement(parms, "Parameter", null);
                _Draw.SetElementAttribute(pNode, "Name", name);
                _Draw.SetElement(pNode, "Value", val);
            }
            if (!parms.HasChildNodes)
            {
                _Subreport.RemoveChild(parms);
            }
        }
Пример #16
0
        private void ApplyCodeModules()
        {
            XmlNode rNode = _Draw.GetReportNode();

            _Draw.RemoveElement(rNode, "CodeModules");
            if (!HasRows(this._DTCM, 1))
            {
                return;
            }

            // Set the CodeModules
            XmlNode cms = _Draw.CreateElement(rNode, "CodeModules", null);

            foreach (DataRow dr in _DTCM.Rows)
            {
                if (dr[0] == DBNull.Value ||
                    dr[0].ToString().Trim().Length <= 0)
                {
                    continue;
                }

                _Draw.CreateElement(cms, "CodeModule", dr[0].ToString());
            }
        }
Пример #17
0
        public void ApplyChanges(XmlNode node)
        {
            if (fChartType)
            {
                _Draw.SetElement(node, "Type", this.cbChartType.Text);
            }
            if (ftooltip)//now controls the displaying of Y value
            {
                _Draw.SetElement(node, "fyi:Tooltip", this.chkToolTip.Checked.ToString());
            }
            if (ftooltipX)// controls the displaying of X value
            {
                _Draw.SetElement(node, "fyi:TooltipX", this.chkToolTip.Checked.ToString());
            }
            if (tooltipXFormat)
            {
                _Draw.SetElement(node, "fyi:TooltipXFormat", this.txtXToolFormat.Text);
            }
            if (tooltipYFormat)
            {
                _Draw.SetElement(node, "fyi:TooltipYFormat", this.txtYToolFormat.Text);
            }

            if (fVector) //AJM GJL 14082008
            {
                _Draw.SetElement(node, "fyi:RenderAsVector", this.cbVector.Text);
            }
            if (fSubtype)
            {
                _Draw.SetElement(node, "Subtype", this.cbSubType.Text);
            }
            if (fPalette)
            {
                _Draw.SetElement(node, "Palette", this.cbPalette.Text);
            }
            if (fRenderElement)
            {
                _Draw.SetElement(node, "ChartElementOutput", this.cbRenderElement.Text);
            }
            if (fPercentWidth)
            {
                _Draw.SetElement(node, "PointWidth", this.tbPercentWidth.Text);
            }
            if (fNoRows)
            {
                _Draw.SetElement(node, "NoRows", this.tbNoRows.Text);
            }
            if (fDataSet)
            {
                _Draw.SetElement(node, "DataSetName", this.cbDataSet.Text);
            }
            if (fPageBreakStart)
            {
                _Draw.SetElement(node, "PageBreakAtStart", this.chkPageBreakStart.Checked? "true": "false");
            }
            if (fPageBreakEnd)
            {
                _Draw.SetElement(node, "PageBreakAtEnd", this.chkPageBreakEnd.Checked? "true": "false");
            }
            if (fChartData)
            {
                //        <ChartData>
                //          <ChartSeries>
                //            <DataPoints>
                //              <DataPoint>
                //                <DataValues>
                //                  <DataValue>
                //                    <Value>=Sum(Fields!Sales.Value)</Value>
                //                  </DataValue>   --- you can have up to 3 DataValue elements
                //                </DataValues>
                //                <DataLabel>
                //                  <Style>
                //                    <Format>c</Format>
                //                  </Style>
                //                </DataLabel>
                //                <Marker />
                //              </DataPoint>
                //            </DataPoints>
                //          </ChartSeries>
                //        </ChartData>
                XmlNode chartdata   = _Draw.SetElement(node, "ChartData", null);
                XmlNode chartseries = _Draw.SetElement(chartdata, "ChartSeries", null);
                XmlNode datapoints  = _Draw.SetElement(chartseries, "DataPoints", null);
                XmlNode datapoint   = _Draw.SetElement(datapoints, "DataPoint", null);
                XmlNode datavalues  = _Draw.SetElement(datapoint, "DataValues", null);
                _Draw.RemoveElementAll(datavalues, "DataValue");
                XmlNode datalabel = _Draw.SetElement(datapoint, "DataLabel", null);
                XmlNode datavalue = _Draw.SetElement(datavalues, "DataValue", null);
                _Draw.SetElement(datavalue, "Value", this.cbChartData.Text);

                string type = cbChartType.Text.ToLowerInvariant();
                if (type == "scatter" || type == "bubble")
                {
                    datavalue = _Draw.CreateElement(datavalues, "DataValue", null);
                    _Draw.SetElement(datavalue, "Value", this.cbChartData2.Text);
                    if (type == "bubble")
                    {
                        datavalue = _Draw.CreateElement(datavalues, "DataValue", null);
                        _Draw.SetElement(datavalue, "Value", this.cbChartData3.Text);
                    }
                }
                _Draw.SetElement(datalabel, "Value", this.cbDataLabel.Text);
                _Draw.SetElement(datalabel, "Visible", this.chkDataLabel.Checked.ToString());
            }
        }
Пример #18
0
        public void Apply()
        {
            XmlNode rNode  = _Draw.GetReportNode();
            XmlNode dsNode = _Draw.GetNamedChildNode(rNode, "DataSets");

            XmlNode dNode = this._dsNode;

            // Create the name attribute
            _Draw.SetElementAttribute(dNode, "Name", _dsv.Name);

            _Draw.RemoveElement(dNode, "Query");        // get rid of old query
            XmlNode qNode = _Draw.CreateElement(dNode, "Query", null);

            _Draw.SetElement(qNode, "DataSourceName", _dsv.DataSourceName);
            if (_dsv.Timeout > 0)
            {
                _Draw.SetElement(qNode, "Timeout", _dsv.Timeout.ToString());
            }

            _Draw.SetElement(qNode, "CommandText", _dsv.CommandText);

            // Handle QueryParameters
            _Draw.RemoveElement(qNode, "QueryParameters");      // get rid of old QueryParameters
            XmlNode qpsNode = _Draw.CreateElement(qNode, "QueryParameters", null);

            foreach (DataRow dr in _dsv.QueryParameters.Rows)
            {
                if (dr[0] == DBNull.Value || dr[1] == null)
                {
                    continue;
                }
                string name = (string)dr[0];
                if (name.Length <= 0)
                {
                    continue;
                }
                XmlNode qpNode = _Draw.CreateElement(qpsNode, "QueryParameter", null);
                _Draw.SetElementAttribute(qpNode, "Name", name);
                _Draw.SetElement(qpNode, "Value", (string)dr[1]);
            }
            if (!qpsNode.HasChildNodes)  // if no parameters we don't need to define them
            {
                _Draw.RemoveElement(qNode, "QueryParameters");
            }

            // Handle Fields
            _Draw.RemoveElement(dNode, "Fields");       // get rid of old Fields
            XmlNode fsNode = _Draw.CreateElement(dNode, "Fields", null);

            foreach (DataRow dr in _dsv.Fields.Rows)
            {
                if (dr[0] == DBNull.Value)
                {
                    continue;
                }
                if (dr[1] == DBNull.Value && dr[2] == DBNull.Value)
                {
                    continue;
                }
                XmlNode fNode = _Draw.CreateElement(fsNode, "Field", null);
                _Draw.SetElementAttribute(fNode, "Name", (string)dr[0]);
                if (dr[1] != DBNull.Value &&
                    dr[1] is string &&
                    (string)dr[1] != string.Empty)
                {
                    _Draw.SetElement(fNode, "DataField", (string)dr[1]);
                }
                else if (dr[2] != DBNull.Value &&
                         dr[2] is string &&
                         (string)dr[2] != string.Empty)
                {
                    _Draw.SetElement(fNode, "Value", (string)dr[2]);
                }
                else
                {
                    _Draw.SetElement(fNode, "DataField", (string)dr[0]);        // make datafield same as name
                }
                // Handle typename if any
                if (dr[3] != DBNull.Value &&
                    dr[3] is string &&
                    (string)dr[3] != string.Empty)
                {
                    _Draw.SetElement(fNode, _UseTypenameQualified ? "rd:TypeName" : "TypeName", (string)dr[3]);
                }
            }
        }
Пример #19
0
        public void Apply()
        {
            if (!HasRows())                                       // No expressions in grouping; get rid of grouping
            {
                _Draw.RemoveElement(_GroupingParent, "Grouping"); // can't have a grouping
                return;
            }

            // Get the group
            XmlNode grouping = _Draw.GetCreateNamedChildNode(_GroupingParent, "Grouping");

            _Draw.SetGroupName(grouping, tbName.Text.Trim());

            // Handle the label
            if (_GroupingParent.Name == "DynamicSeries" ||
                _GroupingParent.Name == "DynamicCategories")
            {
                if (this.cbLabelExpr.Text.Length > 0)
                {
                    _Draw.SetElement(_GroupingParent, "Label", cbLabelExpr.Text);
                }
                else
                {
                    _Draw.RemoveElement(_GroupingParent, "Label");
                }
            }
            else
            {
                if (this.cbLabelExpr.Text.Length > 0)
                {
                    _Draw.SetElement(grouping, "Label", cbLabelExpr.Text);
                }
                else
                {
                    _Draw.RemoveElement(grouping, "Label");
                }

                _Draw.SetElement(grouping, "PageBreakAtStart", this.chkPBS.Checked? "true": "false");
                _Draw.SetElement(grouping, "PageBreakAtEnd", this.chkPBE.Checked? "true": "false");
                if (cbParentExpr.Text.Length > 0)
                {
                    _Draw.SetElement(grouping, "Parent", cbParentExpr.Text);
                }
                else
                {
                    _Draw.RemoveElement(grouping, "Parent");
                }
            }


            // Loop thru and add all the group expressions
            XmlNode grpExprs = _Draw.GetCreateNamedChildNode(grouping, "GroupExpressions");

            grpExprs.RemoveAll();
            string firstexpr = null;

            foreach (DataRow dr in _DataTable.Rows)
            {
                if (dr[0] == DBNull.Value)
                {
                    continue;
                }
                string ge = (string)dr[0];
                if (ge.Length <= 0)
                {
                    continue;
                }
                _Draw.CreateElement(grpExprs, "GroupExpression", ge);
                if (firstexpr == null)
                {
                    firstexpr = ge;
                }
            }
            if (!grpExprs.HasChildNodes)
            {                   // With no group expressions there are no groups
                grouping.RemoveChild(grpExprs);
                grouping.ParentNode.RemoveChild(grouping);
                grouping = null;
            }

            if (_GroupingParent.Name == "TableGroup" && grouping != null)
            {
                if (this.chkGrpHeader.Checked)
                {
                    XmlNode header = _Draw.GetCreateNamedChildNode(_GroupingParent, "Header");
                    _Draw.SetElement(header, "RepeatOnNewPage", chkRepeatHeader.Checked? "true": "false");
                    XmlNode tblRows = _Draw.GetCreateNamedChildNode(header, "TableRows");
                    if (!tblRows.HasChildNodes)
                    {                           // We need to create a row
                        _Draw.InsertTableRow(tblRows);
                    }
                }
                else
                {
                    _Draw.RemoveElement(_GroupingParent, "Header");
                }

                if (this.chkGrpFooter.Checked)
                {
                    XmlNode footer = _Draw.GetCreateNamedChildNode(_GroupingParent, "Footer");
                    _Draw.SetElement(footer, "RepeatOnNewPage", chkRepeatFooter.Checked? "true": "false");
                    XmlNode tblRows = _Draw.GetCreateNamedChildNode(footer, "TableRows");
                    if (!tblRows.HasChildNodes)
                    {                           // We need to create a row
                        _Draw.InsertTableRow(tblRows);
                    }
                }
                else
                {
                    _Draw.RemoveElement(_GroupingParent, "Footer");
                }
            }
            else if (_GroupingParent.Name == "DynamicColumns" ||
                     _GroupingParent.Name == "DynamicRows")
            {
                XmlNode ritems = _Draw.GetNamedChildNode(_GroupingParent, "ReportItems");
                if (ritems == null)
                {
                    ritems = _Draw.GetCreateNamedChildNode(_GroupingParent, "ReportItems");
                }
                XmlNode item = ritems.FirstChild;
                if (item == null)
                {
                    item = _Draw.GetCreateNamedChildNode(ritems, "Textbox");
                    XmlNode vnode = _Draw.GetCreateNamedChildNode(item, "Value");
                    vnode.InnerText = firstexpr == null? "": firstexpr;
                }
            }
        }