Exemple #1
0
 private void LoadFieldAttrs(XmlNode Node, TFieldAttrItems AttrItems, String KeyFields)
 {
     TFieldAttrItem FAI;
     int I;
     XmlNode AttrNode;
     for (I = 0; I < Node.ChildNodes.Count; I++)
     {
         AttrNode = Node.ChildNodes[I];
         FAI = new TFieldAttrItem();
         FAI.DataField = AttrNode.Attributes["DataField"].Value;
         FAI.Description = AttrNode.Attributes["Description"].Value;
         FAI.IsKey = AttrNode.Attributes["IsKey"].Value == "1";
         FAI.CheckNull = AttrNode.Attributes["CheckNull"].Value == "1";
         FAI.IsRelationKey = AttrNode.Attributes["IsRelationKey"].Value == "1"; //IsKeyField(KeyFields, FAI.DataField);
         FAI.ParentRelationField = AttrNode.Attributes["ParentRelationField"].Value;
         AttrItems.Add(FAI);
     }
 }
 private void AddDestFieldItem(ListViewItem lvi)
 {
     TFieldAttrItem Item = new TFieldAttrItem();
     FDatasetItem.FieldAttrItems.Add(Item);
     Item.DataField = lvi.Text;
     if (lvi.SubItems.Count > 1)
         Item.Description = lvi.SubItems[1].Text;
     lvi.Tag = Item;
 }
Exemple #3
0
        private void GetFieldNames(string EntityName, ListView SrcListView)
        {
            ListViewItem lvi;
            SrcListView.Items.Clear();
            SrcListView.BeginUpdate();

            String FProjectPath = System.IO.Path.GetDirectoryName(GlobalProject.FullName);
            String FProjectName = GlobalProject.Name;
            TreeNode Node = tvTables.SelectedNode;
            TWCFDatasetItem FDatasetItem = (TWCFDatasetItem)Node.Tag;

            EFServerTools.Design.MetadataProvider aMetadataProvider = new EFServerTools.Design.MetadataProvider(FProjectPath, FProjectName);
            String strEntityTypeName = aMetadataProvider.GetEntitySetType(FDatasetItem.ContainerName, FDatasetItem.TableName);
            List<string> lPropertyNames = aMetadataProvider.GetPropertyNames(FDatasetItem.ContainerName, strEntityTypeName);
            for (int i = 0; i < lPropertyNames.Count; i++)
            {
                lvi = SrcListView.Items.Add(lPropertyNames[i]);
                lvi.SubItems.Add(lvi.Text);

                TFieldAttrItem Item = new TFieldAttrItem();
                FDatasetItem.FieldAttrItems.Add(Item);
                Item.DataField = lvi.Text;
                if (lvi.SubItems.Count > 1)
                    Item.Description = lvi.SubItems[1].Text;
                lvi.Tag = Item;
            }

            if (SrcListView.Items.Count > 0)
                SrcListView.Items[0].Selected = true;

            SrcListView.EndUpdate();
            SrcListView.Sort();

            btnDeleteField.Enabled = SrcListView.Items.Count > 0;
        }
Exemple #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TreeNode Node = tvTables.SelectedNode;
            string TableName = "";
            MWizard.fmSelTableField F;

            if (Node != null)
                TableName = Node.Text;
            F = new fmSelTableField();
            if (F.ShowSelTableFieldForm(FServerData, FServerData.DatabaseName, ref TableName, InternalConnection))
            {
                Node = tvTables.Nodes.Add(TableName);
                Node.Name = TableName;
                AddDatasetNode(Node);
                tvTables.SelectedNode = Node;

                String sQL = "select * from " + WzdUtils.Quote(TableName, GlobalConnection) + " where 1=0";
                IDbCommand cmd = GlobalConnection.CreateCommand();
                cmd.CommandText = sQL;
                if (GlobalConnection.State == ConnectionState.Closed)
                { GlobalConnection.Open(); }

                DataSet schemaTable = new DataSet();
                IDbDataAdapter ida = WzdUtils.AllocateDataAdapter(FServerData.DatabaseType);
                ida.SelectCommand = cmd;
                ida.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                ida.Fill(schemaTable);

                lvSelectedFields.Items.Clear();
                TDatasetItem tdsItem = null;
                foreach (TDatasetItem item in FServerData.Datasets)
                {
                    if (item.TableName == Node.Text)
                    {
                        tdsItem = item;
                        break;
                    }
                }

                foreach (DataColumn DR in schemaTable.Tables[0].Columns)
                {
                    lvSelectedFields.Items.Add(DR.ColumnName);
                    TFieldAttrItem Item = new TFieldAttrItem();
                    tdsItem.FieldAttrItems.Add(Item);
                    Item.DataField = lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].Text;
                    if (lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].SubItems.Count > 1)
                    {
                        if (tdsItem.FieldCaptionList.Count > 0)
                        {
                            Item.Description = tdsItem.FieldCaptionList.Values(Item.DataField);
                        }
                        else
                        {
                            Item.Description = lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].SubItems[1].Text;
                        }
                    }
                    else
                    {
                        if (tdsItem.FieldCaptionList.Count > 0)
                        {
                            Item.Description = tdsItem.FieldCaptionList.Values(Item.DataField);
                            //lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].SubItems.Add(tdsItem.FieldCaptionList.Values(Item.DataField));
                        }
                    }
                    if (!String.IsNullOrEmpty(Item.Description))
                        lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].SubItems.Add(Item.Description);
                    lvSelectedFields.Items[lvSelectedFields.Items.Count - 1].Tag = Item;
                }

                foreach (DataColumn DR in schemaTable.Tables[0].PrimaryKey)
                {
                    for (int I = 0; I < lvSelectedFields.Items.Count; I++)
                    {
                        if (lvSelectedFields.Items[I].Text == DR.ColumnName)
                        {
                            TFieldAttrItem fi = (TFieldAttrItem)lvSelectedFields.Items[I].Tag;
                            fi.IsKey = true;
                        }
                    }
                }

                Node.Tag = tdsItem;
                if (lvSelectedFields.Items.Count > 0)
                {
                    lvSelectedFields.Items[0].Selected = true;
                }

                btnDeleteField.Enabled = lvSelectedFields.Items.Count > 0;
            }
        }