Ejemplo n.º 1
0
 private void bTestConnection_Click(object sender, System.EventArgs e)
 {
     if (DesignerUtility.TestConnection(this.cbDataProvider.Text, tbConnection.Text))
     {
         MessageBox.Show("Connection succeeded!", "Test Connection");
     }
 }
Ejemplo n.º 2
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics g          = e.Graphics;
            Color    BlockColor = Color.Empty;
            int      left       = RECTCOLOR_LEFT;

            if (e.State == DrawItemState.Selected || e.State == DrawItemState.None)
            {
                e.DrawBackground();
            }
            if (e.Index == -1)
            {
                BlockColor = SelectedIndex < 0 ? BackColor : DesignerUtility.ColorFromHtml(this.Text, Color.Empty);
            }
            else
            {
                BlockColor = DesignerUtility.ColorFromHtml((string)this.Items[e.Index], Color.Empty);
            }
            // Fill rectangle
            if (BlockColor.IsEmpty && this.Text.StartsWith("="))
            {
                g.DrawString("fx", this.Font, Brushes.Black, e.Bounds);
            }
            else
            {
                g.FillRectangle(new SolidBrush(BlockColor), left, e.Bounds.Top + RECTCOLOR_TOP, RECTCOLOR_WIDTH,
                                ItemHeight - 2 * RECTCOLOR_TOP);
            }
            base.OnDrawItem(e);
        }
Ejemplo n.º 3
0
        private void tvTablesColumns_ExpandTable(TreeNode tNode)
        {
            if (tNode.Parent == null)                   // Check for Tables or Views
            {
                return;
            }

            if (tNode.FirstNode.Text != "")             // Have we already filled it out?
            {
                return;
            }

            // Need to obtain the column information for the requested table/view
            // suppress redraw until tree view is complete
            tvTablesColumns.BeginUpdate();

            string           sql        = "SELECT * FROM " + DesignerUtility.NormalizeSqlName(tNode.Text);
            List <SqlColumn> tColumns   = DesignerUtility.GetSqlColumns(_Draw, _DataSource, sql);
            bool             bFirstTime = true;

            foreach (SqlColumn sc in tColumns)
            {
                if (bFirstTime)
                {
                    bFirstTime           = false;
                    tNode.FirstNode.Text = sc.Name;
                }
                else
                {
                    tNode.Nodes.Add(sc.Name);
                }
            }

            tvTablesColumns.EndUpdate();
        }
Ejemplo n.º 4
0
 void SetPadding(string l, PropertyExpr pe)
 {
     if (!_pri.IsExpression(pe.Expression))
     {
         DesignerUtility.ValidateSize(pe.Expression, true, false);
     }
     SetStyleValue(l, pe.Expression);
 }
        static internal bool GetConnnectionInfo(DesignXmlDraw d, string ds, out string dataProvider, out string connection)
        {
            XmlNode dsNode = d.DataSourceName(ds);

            dataProvider = null;
            connection   = null;
            if (dsNode == null)
            {
                return(false);
            }

            string dataSourceReference = d.GetElementValue(dsNode, "DataSourceReference", null);

            if (dataSourceReference != null)
            {
                //  This is not very pretty code since it is assuming the structure of the windows parenting.
                //    But there isn't any other way to get this information from here.
                Control  p  = d;
                MDIChild mc = null;
                while (p != null && !(p is RdlDesigner))
                {
                    if (p is MDIChild)
                    {
                        mc = (MDIChild)p;
                    }

                    p = p.Parent;
                }
                if (p == null || mc == null || mc.SourceFile == null)
                {
                    MessageBox.Show("Unable to locate DataSource Shared file.  Try saving report first");
                    return(false);
                }
                string filename = Path.GetDirectoryName(mc.SourceFile) + Path.DirectorySeparatorChar + dataSourceReference;
                if (!DesignerUtility.GetSharedConnectionInfo((DesignerForm)p, filename, out dataProvider, out connection))
                {
                    return(false);
                }
            }
            else
            {
                XmlNode dp = DesignXmlDraw.FindNextInHierarchy(dsNode, "ConnectionProperties", "DataProvider");
                if (dp == null)
                {
                    return(false);
                }
                dataProvider = dp.InnerText;
                dp           = DesignXmlDraw.FindNextInHierarchy(dsNode, "ConnectionProperties", "ConnectString");
                if (dp == null)
                {
                    return(false);
                }
                connection = dp.InnerText;
            }
            return(true);
        }
Ejemplo n.º 6
0
        private void bGetFilename_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Data source reference files (*.dsr)|*.dsr" +
                         "|All files (*.*)|*.*";
            ofd.FilterIndex = 1;
            if (tbFilename.Text.Length > 0)
            {
                ofd.FileName = tbFilename.Text;
            }
            else
            {
                ofd.FileName = "*.dsr";
            }

            ofd.Title        = "Specify Data Source Reference File Name";
            ofd.DefaultExt   = "dsr";
            ofd.AddExtension = true;

            try
            {
                if (_FileName != null)
                {
                    ofd.InitialDirectory = Path.GetDirectoryName(_FileName);
                }
            }
            catch
            {
            }
            try
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string dsr = DesignerUtility.RelativePathTo(
                            Path.GetDirectoryName(_FileName), Path.GetDirectoryName(ofd.FileName));

                        string f = Path.GetFileNameWithoutExtension(ofd.FileName);

                        tbFilename.Text = dsr == "" ? f : dsr + Path.DirectorySeparatorChar + f;
                    }
                    catch
                    {
                        tbFilename.Text = Path.GetFileNameWithoutExtension(ofd.FileName);
                    }
                }
            }
            finally
            {
                ofd.Dispose();
            }
        }
Ejemplo n.º 7
0
 private void cbDataProvider_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (cbDataProvider.Text == "ODBC")
     {
         lODBC.Visible = cbOdbcNames.Visible = true;
         DesignerUtility.FillOdbcNames(cbOdbcNames);
     }
     else
     {
         lODBC.Visible = cbOdbcNames.Visible = false;
     }
 }
Ejemplo n.º 8
0
        public void Apply()
        {
            XmlNode rNode = _Draw.GetReportNode();

            _Draw.SetElement(rNode, "Width", DesignerUtility.MakeValidSize(tbWidth.Text, false));
            _Draw.SetElement(rNode, "Author", tbReportAuthor.Text);
            _Draw.SetElement(rNode, "Description", tbReportDescription.Text);
            _Draw.SetElement(rNode, "PageWidth", tbPageWidth.Text);
            _Draw.SetElement(rNode, "PageHeight", tbPageHeight.Text);
            if (tbMarginLeft.Text.Trim().Length > 0)
            {
                _Draw.SetElement(rNode, "LeftMargin", tbMarginLeft.Text);
            }
            else
            {
                _Draw.RemoveElement(rNode, "LeftMargin");
            }
            if (tbMarginRight.Text.Trim().Length > 0)
            {
                _Draw.SetElement(rNode, "RightMargin", tbMarginRight.Text);
            }
            else
            {
                _Draw.RemoveElement(rNode, "RightMargin");
            }
            if (tbMarginBottom.Text.Trim().Length > 0)
            {
                _Draw.SetElement(rNode, "BottomMargin", tbMarginBottom.Text);
            }
            else
            {
                _Draw.RemoveElement(rNode, "BottomMargin");
            }
            if (tbMarginTop.Text.Trim().Length > 0)
            {
                _Draw.SetElement(rNode, "TopMargin", tbMarginTop.Text);
            }
            else
            {
                _Draw.RemoveElement(rNode, "TopMargin");
            }
            // Page header settings
            XmlNode phNode = _Draw.GetCreateNamedChildNode(rNode, "PageHeader");

            _Draw.SetElement(phNode, "PrintOnFirstPage", this.chkPHFirst.Checked?"true":"false");
            _Draw.SetElement(phNode, "PrintOnLastPage", this.chkPHLast.Checked?"true":"false");
            // Page footer settings
            XmlNode pfNode = _Draw.GetCreateNamedChildNode(rNode, "PageFooter");

            _Draw.SetElement(pfNode, "PrintOnFirstPage", this.chkPFFirst.Checked?"true":"false");
            _Draw.SetElement(pfNode, "PrintOnLastPage", this.chkPFLast.Checked?"true":"false");
        }
Ejemplo n.º 9
0
        private void tbSize_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            TextBox tb = sender as TextBox;

            if (tb == null)
            {
                return;
            }

            try { DesignerUtility.ValidateSize(tb.Text, false, false); }
            catch (Exception ex)
            {
                e.Cancel = true;
                MessageBox.Show(string.Format("Size value of {0} is invalid.\r\n", tb.Text, ex.Message), tb.Tag + " Field Invalid");
            }
        }
Ejemplo n.º 10
0
        public bool IsValid()
        {
            XmlNode ri = this._ReportItems[0] as XmlNode;

            if (tbName.Enabled && fName)
            {
                string nerr = _Draw.NameError(ri, this.tbName.Text);
                if (nerr != null)
                {
                    MessageBox.Show(nerr, "Name");
                    return(false);
                }
            }
            string name = "";

            try
            {                   // allow minus if Line and only one item selected
                bool bMinus = ri.Name == "Line" && tbName.Enabled? true: false;
                if (fLeft)
                {
                    name = "Left";
                    DesignerUtility.ValidateSize(this.tbLeft.Text, true, false);
                }
                if (fTop)
                {
                    name = "Top";
                    DesignerUtility.ValidateSize(this.tbTop.Text, true, false);
                }
                if (fWidth)
                {
                    name = "Width";
                    DesignerUtility.ValidateSize(this.tbWidth.Text, true, bMinus);
                }
                if (fHeight)
                {
                    name = "Height";
                    DesignerUtility.ValidateSize(this.tbHeight.Text, true, bMinus);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, name + " Size is Invalid");
                return(false);
            }

            return(true);
        }
        public bool IsValid()
        {
            try
            {
                if (fWidth)
                {
                    DesignerUtility.ValidateSize(this.tbColumnWidth.Text, true, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Width is Invalid");
                return(false);
            }

            if (fHidden)
            {
                string vh = this.tbHidden.Text.Trim();
                if (vh.Length > 0)
                {
                    if (vh.StartsWith("="))
                    {
                    }
                    else
                    {
                        vh = vh.ToLower();
                        switch (vh)
                        {
                        case "true":
                        case "false":
                            break;

                        default:
                            MessageBox.Show(String.Format("{0} must be an expression or 'true' or 'false'", tbHidden.Text), "Hidden is Invalid");
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 12
0
        private void bRefresh_Click(object sender, System.EventArgs e)
        {
            // Need to clear all the fields and then replace with the columns
            //   of the SQL statement
            List <SqlColumn> cols = DesignerUtility.GetSqlColumns(_Draw, cbDataSource.Text, tbSQL.Text);

            if (cols == null || cols.Count <= 0)
            {
                return;                                         // something didn't work right
            }
            _dsv.Fields.Rows.Clear();
            string[] rowValues = new string[4];
            foreach (SqlColumn sc in cols)
            {
                rowValues[0] = sc.Name;
                rowValues[1] = sc.Name;
                rowValues[2] = "";
                rowValues[3] = sc.DataType.FullName;
                _dsv.Fields.Rows.Add(rowValues);
            }
        }
Ejemplo n.º 13
0
        private void bMove_Click(object sender, System.EventArgs e)
        {
            if (tvTablesColumns.SelectedNode == null ||
                tvTablesColumns.SelectedNode.Parent == null)
            {
                return;                         // this is the Tables/Views node
            }
            TreeNode node = tvTablesColumns.SelectedNode;
            string   t    = node.Text;

            if (tbSQL.Text == "")
            {
                if (node.Parent.Parent == null)
                {                                      // select table; generate full select for table
                    tvTablesColumns_ExpandTable(node); // make sure we've obtained the columns

                    StringBuilder sb   = new StringBuilder("SELECT ");
                    TreeNode      next = node.FirstNode;
                    while (true)
                    {
                        sb.Append(DesignerUtility.NormalizeSqlName(next.Text));
                        next = next.NextNode;
                        if (next == null)
                        {
                            break;
                        }
                        sb.Append(", ");
                    }
                    sb.Append(" FROM ");
                    sb.Append(DesignerUtility.NormalizeSqlName(node.Text));
                    t = sb.ToString();
                }
                else
                {                       // select column; generate select of that column
                    t = "SELECT " + DesignerUtility.NormalizeSqlName(node.Text) + " FROM " + DesignerUtility.NormalizeSqlName(node.Parent.Text);
                }
            }

            tbSQL.SelectedText = t;
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            //base.OnPaint(e);
            int row       = 0;
            int col       = 0;
            int max_rows  = MaxRows;
            int max_cols  = MaxColumns;
            int col_width = ColumnWidth;

            foreach (string c in StaticLists.ColorListColorSort)
            {
                Color clr = DesignerUtility.ColorFromHtml(c, Color.Empty);
                g.FillRectangle(new SolidBrush(clr),
                                new System.Drawing.Rectangle((col * col_width) + ITEM_PAD, (row * ITEM_HEIGHT) + ITEM_PAD, col_width - ITEM_PAD, ITEM_HEIGHT - ITEM_PAD));
                row++;
                if (row >= max_rows)
                {
                    row = 0;
                    col++;
                }
            }
        }
Ejemplo n.º 15
0
        private void bLoad_Click(object sender, System.EventArgs e)
        {
            // Load the data from the SQL; we append the data to what already exists
            try
            {
                // Obtain the connection information
                XmlNode rNode  = _Draw.GetReportNode();
                XmlNode dsNode = _Draw.GetNamedChildNode(rNode, "DataSources");
                if (dsNode == null)
                {
                    return;
                }
                XmlNode datasource = null;
                foreach (XmlNode dNode in dsNode)
                {
                    if (dNode.Name != "DataSource")
                    {
                        continue;
                    }
                    XmlAttribute nAttr = dNode.Attributes["Name"];
                    if (nAttr == null)                          // shouldn't really happen
                    {
                        continue;
                    }
                    if (nAttr.Value != _dsv.DataSourceName)
                    {
                        continue;
                    }
                    datasource = dNode;
                    break;
                }
                if (datasource == null)
                {
                    MessageBox.Show(string.Format("Datasource '{0}' not found.", _dsv.DataSourceName), "Load Failed");
                    return;
                }
                // get the connection information
                string connection   = "";
                string dataProvider = "";

                string dataSourceReference = _Draw.GetElementValue(datasource, "DataSourceReference", null);
                if (dataSourceReference != null)
                {
                    //  This is not very pretty code since it is assuming the structure of the windows parenting.
                    //    But there isn't any other way to get this information from here.
                    Control  p  = _Draw;
                    MDIChild mc = null;
                    while (p != null && !(p is RdlDesigner))
                    {
                        if (p is MDIChild)
                        {
                            mc = (MDIChild)p;
                        }

                        p = p.Parent;
                    }
                    if (p == null || mc == null || mc.SourceFile == null)
                    {
                        MessageBox.Show("Unable to locate DataSource Shared file.  Try saving report first");
                        return;
                    }
                    string filename = Path.GetDirectoryName(mc.SourceFile) + Path.DirectorySeparatorChar + dataSourceReference;
                    if (!DesignerUtility.GetSharedConnectionInfo((DesignerForm)p, filename, out dataProvider, out connection))
                    {
                        return;
                    }
                }
                else
                {
                    XmlNode cpNode = DesignXmlDraw.FindNextInHierarchy(datasource, "ConnectionProperties", "ConnectString");
                    connection = cpNode == null ? "" : cpNode.InnerText;

                    XmlNode datap = DesignXmlDraw.FindNextInHierarchy(datasource, "ConnectionProperties", "DataProvider");
                    dataProvider = datap == null ? "" : datap.InnerText;
                }
                // Populate the data table
                DesignerUtility.GetSqlData(dataProvider, connection, _dsv.CommandText, null, _DataTable);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Load Failed");
            }
        }
Ejemplo n.º 16
0
        private void PopulateRows(XmlNode rows)
        {
            object[] rowValues = new object[_DataTable.Columns.Count];

            bool bSkipMsg = false;

            foreach (XmlNode rNode in rows.ChildNodes)
            {
                if (rNode.Name != "Row")
                {
                    continue;
                }
                int  col       = 0;
                bool bBuiltRow = false;                 // if all columns will be null we won't add the row
                foreach (DataColumn dc in _DataTable.Columns)
                {
                    XmlNode dNode = _Draw.GetNamedChildNode(rNode, dc.ColumnName);
                    if (dNode != null)
                    {
                        bBuiltRow = true;
                    }

                    if (dNode == null)
                    {
                        rowValues[col] = null;
                    }
                    else if (dc.DataType == typeof(string))
                    {
                        rowValues[col] = dNode.InnerText;
                    }
                    else
                    {
                        object box;
                        try
                        {
                            if (dc.DataType == typeof(int))
                            {
                                box = Convert.ToInt32(dNode.InnerText, NumberFormatInfo.InvariantInfo);
                            }
                            else if (dc.DataType == typeof(decimal))
                            {
                                box = Convert.ToDecimal(dNode.InnerText, NumberFormatInfo.InvariantInfo);
                            }
                            else if (dc.DataType == typeof(long))
                            {
                                box = Convert.ToInt64(dNode.InnerText, NumberFormatInfo.InvariantInfo);
                            }
                            else if (DesignerUtility.IsNumeric(dc.DataType))    // catch all numeric
                            {
                                box = Convert.ToDouble(dNode.InnerText, NumberFormatInfo.InvariantInfo);
                            }
                            else if (dc.DataType == typeof(DateTime))
                            {
                                box = Convert.ToDateTime(dNode.InnerText,
                                                         System.Globalization.DateTimeFormatInfo.InvariantInfo);
                            }
                            else
                            {
                                box = dNode.InnerText;
                            }
                            rowValues[col] = box;
                        }
                        catch (Exception e)
                        {
                            if (!bSkipMsg)
                            {
                                if (MessageBox.Show(string.Format("Unable to convert {1} to {0}: {2}",
                                                                  dc.DataType.ToString(), dNode.InnerText, e.Message) + Environment.NewLine + "Do you want to see any more errors?",
                                                    "Error Reading Data Rows", MessageBoxButtons.YesNo) == DialogResult.No)
                                {
                                    bSkipMsg = true;
                                }
                            }
                            rowValues[col] = dNode.InnerText;
                        }
                    }
                    col++;
                }
                if (bBuiltRow)
                {
                    _DataTable.Rows.Add(rowValues);
                }
            }
        }
Ejemplo n.º 17
0
        private void InitValues(string sql)
        {
            this.tbSQL.Text = sql;

            // Fill out the tables, columns and parameters

            // suppress redraw until tree view is complete
            tvTablesColumns.BeginUpdate();

            // Get the schema information
            List <SqlSchemaInfo> si = DesignerUtility.GetSchemaInfo(_Draw, _DataSource);

            if (si != null && si.Count > 0)
            {
                TreeNode ndRoot = new TreeNode("Tables");
                tvTablesColumns.Nodes.Add(ndRoot);
                if (si == null)                         // Nothing to initialize
                {
                    return;
                }
                bool bView = false;
                foreach (SqlSchemaInfo ssi in si)
                {
                    if (!bView && ssi.Type == "VIEW")
                    {                           // Switch over to views
                        ndRoot = new TreeNode("Views");
                        tvTablesColumns.Nodes.Add(ndRoot);
                        bView = true;
                    }

                    // Add the node to the tree
                    TreeNode aRoot = new TreeNode(ssi.Name);
                    ndRoot.Nodes.Add(aRoot);
                    aRoot.Nodes.Add("");
                }
            }
            // Now do parameters
            TreeNode qpRoot = null;

            foreach (DataRow dr in _QueryParameters.Rows)
            {
                if (dr[0] == DBNull.Value || dr[1] == null)
                {
                    continue;
                }
                string pName = (string)dr[0];
                if (pName.Length == 0)
                {
                    continue;
                }
                if (qpRoot == null)
                {
                    qpRoot = new TreeNode("Query Parameters");
                    tvTablesColumns.Nodes.Add(qpRoot);
                }
                if (pName[0] == '@')
                {
                    pName = "@" + pName;
                }
                // Add the node to the tree
                TreeNode aRoot = new TreeNode(pName);
                qpRoot.Nodes.Add(aRoot);
            }

            tvTablesColumns.EndUpdate();
        }
 void SetMargin(string l, string v)
 {
     DesignerUtility.ValidateSize(v, true, false);
     _pr.SetReportValue(l, v);
 }
Ejemplo n.º 19
0
        public void ApplyChanges(XmlNode node)
        {
            if (tbName.Enabled && fName)
            {
                _Draw.SetName(node, tbName.Text.Trim());
            }

            if (fLeft)
            {
                _Draw.SetElement(node, "Left", DesignerUtility.MakeValidSize(tbLeft.Text, true));
            }

            if (fTop)
            {
                _Draw.SetElement(node, "Top", DesignerUtility.MakeValidSize(tbTop.Text, true));
            }

            bool bLine = node.Name == "Line";

            if (fWidth)
            {
                _Draw.SetElement(node, "Width", DesignerUtility.MakeValidSize(tbWidth.Text, bLine, bLine));
            }

            if (fHeight)
            {
                _Draw.SetElement(node, "Height", DesignerUtility.MakeValidSize(tbHeight.Text, bLine, bLine));
            }

            if (fZIndex)
            {
                _Draw.SetElement(node, "ZIndex", tbZIndex.Text);
            }

            if (fColSpan)
            {
                XmlNode ris   = node.ParentNode;
                XmlNode tcell = ris.ParentNode;
                if (tcell.Name == "TableCell")
                {                       // SetTableCellColSpan does all the heavy lifting;
                                        //    ie making sure the # of columns continue to match
                    _Draw.SetTableCellColSpan(tcell, tbColSpan.Value.ToString());
                }
            }

            if (fDataElementStyle)
            {
                _Draw.SetElement(node, "DataElementStyle", this.cbDataElementStyle.Text);
            }
            if (fHideDuplicates)
            {
                _Draw.SetElement(node, "HideDuplicates", this.cbHideDuplicates.Text);
            }
            if (fCanGrow)
            {
                _Draw.SetElement(node, "CanGrow", this.chkCanGrow.Checked? "true": "false");
            }
            if (fCanShrink)
            {
                _Draw.SetElement(node, "CanShrink", this.chkCanShrink.Checked? "true": "false");
            }
            if (fDataElementStyle)
            {
                _Draw.SetElement(node, "DataElementStyle", this.cbDataElementStyle.Text);
            }
            if (fToggleImage)
            {
                if (cbToggleImage.Text.Length <= 0)
                {
                    _Draw.RemoveElement(node, "ToggleImage");
                }
                else
                {
                    XmlNode ti = _Draw.SetElement(node, "ToggleImage", null);
                    _Draw.SetElement(ti, "InitialState", cbToggleImage.Text);
                }
            }
        }