public EPField GetField(int Index)
 {
     if (srcType == enumRecSource.Table)
     {
         if (tableDef != null)
         {
             return(tableDef.GetField(Index));
         }
     }
     else if (srcType == enumRecSource.View)
     {
         if (viewDef != null)
         {
             return(viewDef.GetField(Index));
         }
     }
     return(null);
 }
예제 #2
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();
        }