Ejemplo n.º 1
0
 public bool ShowSelTableFieldForm(TDatasetItem DatasetItem, MWizard.fmServerWzd.GetFieldNamesExFunc GetFieldNameEx, ListView DestListView, DbConnection Conn, ClientType DatabaseType)
 {
     FDatasetItem = DatasetItem;
     FDatasetItem.AddAll = false;
     FDatabaseName = FDatasetItem.DatabaseName;
     FTableName = FDatasetItem.TableName;
     FDestListView = DestListView;
     FGetFieldNamesExFunc = GetFieldNameEx;
     FConnection = Conn;
     FDatabaseType = DatabaseType;
     Init();
     return ShowDialog() == DialogResult.OK;
 }
Ejemplo n.º 2
0
        public void ShowSelKeyField(TDatasetItem Master, TDatasetItem Detail)
        {
            FMasterItem = Master;
            FDetailItem = Detail;
            DisplayField(Master, lbMasterFields);
            DisplayField(Detail, lbDetailFields);
            foreach (TFieldAttrItem aItem in Detail.FieldAttrItems)
            {
                if (aItem.ParentRelationField != null && aItem.ParentRelationField != "")
                    lbRelationFields.Items.Add(aItem.ParentRelationField + "=" + aItem.DataField);
            }

            ShowDialog();
        }
Ejemplo n.º 3
0
 private void DisplayField(TDatasetItem DataSetItem, ListBox aListBox)
 {
     aListBox.Items.Clear();
     foreach (TFieldAttrItem FAI in DataSetItem.FieldAttrItems)
     {
         aListBox.Items.Add(FAI.DataField);
     }
 }
Ejemplo n.º 4
0
        private void LoadDatasets(XmlNode Node)
        {
            int I;
            TDatasetItem DI;
            XmlNode DatasetNode, FieldAttrsNode;
            for (I = 0; I < Node.ChildNodes.Count; I++)
            {
                DatasetNode = Node.ChildNodes[I];
                DI = new TDatasetItem();
                DI.Name = DatasetNode.Attributes["Name"].Value;
                DI.DatabaseType = FDatabaseType;
                DI.DatabaseName = DatasetNode.Attributes["DatabaseName"].Value;
                DI.TableName = DatasetNode.Attributes["TableName"].Value;
                FieldAttrsNode = WzdUtils.FindNode(null, DatasetNode, "FieldAttrItems");
                LoadFieldAttrs(FieldAttrsNode, DI.FieldAttrItems, DatasetNode.Attributes["RelFields"].Value);
                Datasets.Add(DI);
            }

            for (I = 0; I < Node.ChildNodes.Count; I++)
            {
                DatasetNode = Node.ChildNodes[I];
                if (DatasetNode.Attributes["ParentItem"].Value != "")
                {
                    TWCFDatasetItem ChildItem = Datasets.FindItem(DatasetNode.Attributes["Name"].Value);
                    TWCFDatasetItem ParentItem = Datasets.FindItem(DatasetNode.Attributes["ParentItem"].Value);
                    ChildItem.ParentItem = ParentItem;
                }
            }
        }
Ejemplo n.º 5
0
        private void CreateUpdateComponent(Srvtools.InfoCommand IC, TDatasetItem DatasetItem, int Index)
        {
            string TempName = WzdUtils.RemoveSpecialCharacters(DatasetItem.TableName);
            string ComponentName = CreateUniqueComponentName(FDataModule, "uc" + TempName);
            if (ComponentName.Contains("."))
            {
                ComponentName = ComponentName.Remove(0, ComponentName.IndexOf('.') + 1);
                ComponentName = "uc" + ComponentName;
            }
            UpdateComponent UC = FDesignerHost.CreateComponent(typeof(UpdateComponent), ComponentName) as UpdateComponent;
            UC.SelectCmd = IC;
            UC.Site.Name = "AA";
            int I;

            TFieldAttrItem FAI;
            FieldAttr FA;
            for (I = 0; I < DatasetItem.FieldAttrItems.Count; I++)
            {
                FAI = (TFieldAttrItem)DatasetItem.FieldAttrItems[I];
                FA = new FieldAttr(FAI.DataField);
                FA.CheckNull = FAI.CheckNull;
                UC.FieldAttrs.Add(FA);
            }
            UC.Site.Name = ComponentName;
        }
Ejemplo n.º 6
0
        private Component CreateDataset(TDatasetItem DatasetItem, int Index)
        {
            string TempName = WzdUtils.RemoveSpecialCharacters(DatasetItem.TableName);
            string ComponentName = CreateUniqueComponentName(FDataModule, TempName);
            if (ComponentName.Contains("."))
                ComponentName = ComponentName.Remove(0, ComponentName.IndexOf('.') + 1);
            InfoCommand IC = FDesignerHost.CreateComponent(typeof(InfoCommand), ComponentName) as InfoCommand;
            IC.InfoConnection = FConnection;
            //IComponentChangeService componentChangeService = FDesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            //componentChangeService.OnComponentChanging(IC, TypeDescriptor.GetProperties(IC)["InfoConnection"]);
            //componentChangeService.OnComponentChanged(IC, TypeDescriptor.GetProperties(IC)["InfoConnection"], null, IC.InfoConnection);

            String sQL = "select * from " + WzdUtils.Quote(DatasetItem.TableName, FConnection.InternalDbConnection) + " where 1=0";
            IDbCommand cmd = FConnection.CreateCommand();
            cmd.CommandText = sQL;
            if (FConnection.State == ConnectionState.Closed)
            { FConnection.Open(); }
            DataSet schemaTable = new DataSet();
            IDbDataAdapter ida = WzdUtils.AllocateDataAdapter(DatasetItem.DatabaseType);
            ida.SelectCommand = cmd;
            ida.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            ida.Fill(schemaTable);

            if (schemaTable.Tables[0].Columns.Count == DatasetItem.FieldAttrItems.Count || DatasetItem.FieldAttrItems.Count == 0)
            {
                DatasetItem.AddAll = true;
            }

            String sTableName = WzdUtils.Quote(DatasetItem.TableName, IC.InfoConnection.InternalDbConnection);
            if (DatasetItem.AddAll)
            {
                IC.CommandText = String.Format("SELECT {0}.* FROM {0}", sTableName);
            }
            else
            {
                String SelectedFields = "";
                foreach (TFieldAttrItem FA in DatasetItem.FieldAttrItems)
                {
                    SelectedFields = SelectedFields + String.Format("{0}." + WzdUtils.Quote("{1}", IC.InfoConnection.InternalDbConnection) + ",", sTableName, FA.DataField);
                }
                if (SelectedFields.Length > 0)
                    SelectedFields = SelectedFields.Substring(0, SelectedFields.Length - 1);
                IC.CommandText = String.Format("SELECT {0} FROM {1}", SelectedFields, sTableName);
            }
            DatasetItem.Command = IC;
            int I;
            TFieldAttrItem FAI;
            IC.KeyFields.Clear();
            Srvtools.KeyItem KI;
            for (I = 0; I < DatasetItem.FieldAttrItems.Count; I++)
            {
                FAI = (TFieldAttrItem)DatasetItem.FieldAttrItems[I];
                if (FAI.IsKey)
                {
                    KI = new Srvtools.KeyItem();
                    KI.KeyName = FAI.DataField;
                    IC.KeyFields.Add(KI);
                }
            }
            return IC;
        }
Ejemplo n.º 7
0
 private void AddDatasetNode(TreeNode Node)
 {
     TDatasetItem Item = new TDatasetItem();
     Item.DatabaseType = FServerData.DatabaseType;
     FServerData.Datasets.Add(Item);
     Item.DatabaseName = FServerData.DatabaseName;
     Item.TableName = Node.Text;
     Node.Tag = Item;
     if (Node.Parent != null)
     {
         TDatasetItem ParentItem = (TDatasetItem)Node.Parent.Tag;
         ParentItem.ChildItem = Item;
         Item.ParentItem = ParentItem;
     }
 }
Ejemplo n.º 8
0
 private void UpdatelvSelectedFields(TDatasetItem DatasetItem)
 {
     cbIsKey.Checked = false;
     cbCheckNull.Checked = false;
     //cbIsRelationKey.Checked = false;
     lvSelectedFields.Items.Clear();
     if (DatasetItem != null)
     {
         lvSelectedFields.BeginUpdate();
         for (int num1 = 0; num1 < DatasetItem.FieldAttrItems.Count; num1++)
         {
             TFieldAttrItem item1 = DatasetItem.FieldAttrItems[num1] as TFieldAttrItem;
             ListViewItem item2 = lvSelectedFields.Items.Add(item1.DataField);
             item2.SubItems.Add(item1.Description);
             item2.Tag = item1;
         }
         lvSelectedFields.EndUpdate();
         btnDeleteField.Enabled = lvSelectedFields.Items.Count > 0;
     }
 }
Ejemplo n.º 9
0
        private void GetFieldNamesEx(TDatasetItem aDatasetItem, string DatabaseName, string TableName, String DataSetName, ListView SrcListView, ListView DestListView)
        {
            int I, J = 0;
            bool Found = false;
            ListViewItem lvi = null;
            //TFieldAttrItem tai;
            TStringList aPhysFieldNameList = new TStringList();
            TStringList aFieldCaptionList = new TStringList();

            if (aDatasetItem != null)
            {
                aPhysFieldNameList = aDatasetItem.FieldList;
                aFieldCaptionList = aDatasetItem.FieldCaptionList;
            }
            else
            {
                GetFieldList(DatabaseName, TableName, aPhysFieldNameList);
            }

            /*
            for (I = 0; I < DestListView.Items.Count - 1; I++)
            {
                lvi = DestListView.Items[I];
                if (aPhysFieldNameList.IndexOf(lvi.Text) < 0)
                {
                    tai = (TFieldAttrItem)lvi.Tag;
                    }
            }
            */

            SrcListView.Items.Clear();
            for (I = 0; I < aPhysFieldNameList.Count; I++)
            {
                Found = false;
                for (J = 0; J < DestListView.Items.Count; J++)
                {
                    lvi = DestListView.Items[J];
                    if (string.Compare(aPhysFieldNameList[I].ToString(), lvi.Text, false) == 0)
                    {
                        Found = true;
                        break;
                    }
                }
                if (Found == false)
                {
                    lvi = SrcListView.Items.Add(aPhysFieldNameList[I].ToString());
                    lvi.SubItems.Add(aFieldCaptionList.Values(lvi.Text));
                }

            }

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