public object Clone()
        {
            DatabaseView obj = new DatabaseView();

            obj.fields   = (FieldList)fields.Clone();
            obj.ViewName = ViewName;
            obj.InUse    = InUse;
            return(obj);
        }
 public void LoadViews()
 {
     Views = null;
     try
     {
         if (dbCon.TheConnection is OleDbConnection)
         {
         }
         else if (dbCon.TheConnection is SqlConnection)
         {
             dbWrapper db = new dbWrapper();
             db.CreateCommand(dbCon);
             db.SetCommandText("SELECT [name] FROM sysobjects (nolock) WHERE [type] = 'V'");
             db.SetCommandType(System.Data.CommandType.Text);
             db.CreateAdapter();
             System.Data.DataSet ds = new System.Data.DataSet("DS");
             db.Fill(ds, "Views");
             if (ds.Tables.Count > 0)
             {
                 if (ds.Tables[0].Rows.Count > 0)
                 {
                     Views = new DatabaseView[ds.Tables[0].Rows.Count];
                     for (int i = 0; i < Views.Length; i++)
                     {
                         Views[i]          = new DatabaseView();
                         Views[i].ViewName = ds.Tables[0].Rows[i][0].ToString();
                     }
                 }
             }
         }
         else
         {
             DataTable vs = dbCon.GetViews();
             if (vs != null && vs.Rows.Count > 0)
             {
                 Views = new DatabaseView[vs.Rows.Count];
                 for (int i = 0; i < Views.Length; i++)
                 {
                     Views[i]          = new DatabaseView();
                     Views[i].ViewName = vs.Rows[i][0].ToString();
                 }
             }
         }
     }
     catch
     {
     }
 }
 public void LoadSchema(DatabaseSchema schema)
 {
     if (srcType == enumRecSource.Table)
     {
         if (tableDef == null)
         {
             tableDef = schema.FindTable(TableName);
         }
     }
     else if (srcType == enumRecSource.View)
     {
         if (viewDef == null)
         {
             viewDef = schema.FindView(TableName);
         }
     }
 }
Exemplo n.º 4
0
        public void LoadData(QueryParser p, string sTable, enumRecSource recSrc)
        {
            parser        = p;
            lblTable.Text = sTable;
            schema        = p.GetSchema();
            srcType       = recSrc;
            int i;

            for (i = 0; i < p.query.T.Count; i++)
            {
                p.query.T[i].LoadSchema(schema);
            }
            if (srcType == enumRecSource.Table)
            {
                newTable = schema.FindTable(sTable);
            }
            else if (srcType == enumRecSource.View)
            {
                newView = schema.FindView(sTable);
            }
            //
            ds = new System.Data.DataSet("Rel");
            ds.Tables.Add("JF");
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Columns.Add();
            ds.Tables[0].Columns.Add();
            //
            ds.Tables[0].Columns[0].Caption    = Resource1.addT0;
            ds.Tables[0].Columns[0].ColumnName = "NewField";
            ds.Tables[0].Columns[0].DataType   = typeof(string);
            ds.Tables[0].Columns[0].MaxLength  = 80;
            //
            ds.Tables[0].Columns[1].Caption    = Resource1.addT1;
            ds.Tables[0].Columns[1].ColumnName = "JoinTable";
            ds.Tables[0].Columns[1].DataType   = typeof(string);
            ds.Tables[0].Columns[1].MaxLength  = 80;
            //
            ds.Tables[0].Columns[2].Caption    = Resource1.addT2;
            ds.Tables[0].Columns[2].ColumnName = "JoinField";
            ds.Tables[0].Columns[2].DataType   = typeof(string);
            ds.Tables[0].Columns[2].MaxLength  = 80;
            //
            DataGridColumnStyle TextCol;
            DataGridTableStyle  myGridTableStyle = new DataGridTableStyle();

            myGridTableStyle.MappingName = "JF";
            for (i = 0; i < 3; i++)
            {
                TextCol             = new DataGridTextBoxColumn();
                TextCol.MappingName = ds.Tables[0].Columns[i].ColumnName;
                TextCol.HeaderText  = ds.Tables[0].Columns[i].Caption;
                TextCol.Width       = 120;
                myGridTableStyle.GridColumnStyles.Add(TextCol);
            }
            dataGrid1.TableStyles.Clear();
            dataGrid1.TableStyles.Add(myGridTableStyle);
            //
            dataGrid1.SetDataBinding(ds, "JF");
            //
            cbx0.Parent = dataGrid1;
            cbx1.Parent = dataGrid1;
            cbx2.Parent = dataGrid1;
            //
            cbx0.Items.Clear();
            int n = 0;

            if (srcType == enumRecSource.Table)
            {
                n = newTable.FieldCount;
            }
            else if (srcType == enumRecSource.View)
            {
                n = newView.FieldCount;
            }
            for (i = 0; i < n; i++)
            {
                if (srcType == enumRecSource.Table)
                {
                    cbx0.Items.Add(newTable.GetField(i));
                }
                else if (srcType == enumRecSource.View)
                {
                    cbx0.Items.Add(newView.GetField(i));
                }
            }
            //
            cbx1.Items.Clear();
            for (i = 0; i < p.query.T.Count; i++)
            {
                cbx1.Items.Add(p.query.T[i]);
            }
            //
            cbx2.Items.Clear();
        }