Exemplo n.º 1
0
/*====================================================*/

        public void PopulateDataTable()
        {
            XmlNodeList aPropertiesNodeList;

            DataColumn[] aPKArray;
            String       aColumnName;
            bool         aAddColumn = true;

            mObjDataTable = ObjDataSet.Tables.Add(DefinitionKey);

            //In the case of queries from the query tool, the columns of the data table are not built in advance;
            //instead, they are returned automatically by the data adapter based on the column names and aliases in
            //the SQL data set. This keeps us from setting data types for the columns; however, the only data type
            //we use besides "String" is "Byte[]", which is used for fields containing file data. These fields are
            //not available through the query tool.
            //Peter Larsen 12/17/03
            if (DefinitionKey == "AdHocQuery")
            {
                return;
            }

            aPropertiesNodeList = ObjDefNode.SelectNodes("Properties/Property");

            //populates data table with columns and column names
            //Data Provider will populate the columns with values
            Object aObj = new Object();

            Byte[] aByte = new Byte[1];
            foreach (XmlNode aPropertyNode in aPropertiesNodeList)
            {
                aColumnName = cXMLDoc.AttributeToString(aPropertyNode, "Key");
                String aTypeName = cXMLDoc.AttributeToString(aPropertyNode, "DataType");
                String aRSType   = cXMLDoc.AttributeToString(ObjDefNode, "RowSourceType", "");
                //If Parameter='True' it should not be added to the columns list.
                if (aRSType != "" && cXMLDoc.AttributeToBool(aPropertyNode, "Parameter", false))
                {
                    aAddColumn = false;
                }
                if (aAddColumn)
                {
                    DataColumn aDC = mObjDataTable.Columns.Add(aColumnName);
                    if (cXMLDoc.AttributeToBool(aPropertyNode, "IsPrimaryKey"))
                    {
                        aPKArray    = new DataColumn[1];
                        aPKArray[0] = (aDC);
                        //aDT.PrimaryKey = aPKArray;
                    }
                    if (aTypeName == "Byte[]")
                    {
                        ObjDataSet.Tables[DefinitionKey].Columns[aColumnName].DataType = aByte.GetType();
                    }
                    else
                    {
                        ObjDataSet.Tables[DefinitionKey].Columns[aColumnName].DataType = aObj.GetType();
                    }
                }
            }
        }
Exemplo n.º 2
0
/*====================================================*/
//Peter Larsen 11/12/2003
        private void AddDataObjects(DataTable aDT)
        {
            cDataObject aDataObject;
            XmlNode     aClassNode;

            aClassNode = ObjDefNode.SelectSingleNode("Class");
            foreach (DataRow aDR in aDT.Rows)
            {
                aDataObject = DataObjectFactory.CreateDataObject(aDR, this, aClassNode);
                Add(aDataObject);
            }
        }
Exemplo n.º 3
0
/*====================================================*/

        public cDataObject AddNewDataObject()
        {
            DataRow     aDataRow;
            cDataObject aDataObject;

            aDataRow = this.ObjDataSet.Tables[this.DefinitionKey].NewRow();
            this.ObjDataSet.Tables[this.DefinitionKey].Rows.Add(aDataRow);

            //aDataObject = new cDataObject(aDataRow, this, true);
            aDataObject = DataObjectFactory.CreateDataObject(aDataRow, this, ObjDefNode.SelectSingleNode("Class"));
            aDataObject.IsNewDataObject = true;

            this.Add(aDataObject);
            return(aDataObject);
        }