/// <summary>
        /// 添加关联字段
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bAddField_Click(object sender, EventArgs e)
        {
            string        tableName     = "";
            List <string> fieldNameList = new List <string>();

            Node currentNode = keyFieldTree.SelectedNode;

            if (currentNode != null)
            {
                if (currentNode.Level == 1)
                {
                    tableName = currentNode.Parent.Text;
                }
                else
                {
                    tableName = currentNode.Text;
                }
            }

            AddFieldRelationForm aForm = new AddFieldRelationForm(conn, tableName, fieldNameList, metaDataTable);

            if (aForm.ShowDialog() == DialogResult.OK)
            {
                tableName = aForm.TableName;

                foreach (string fieldName in aForm.FieldNameList)
                {
                    Node tableNode = null;

                    foreach (Node node in keyFieldTree.Nodes)
                    {
                        if (node.Text == tableName)
                        {
                            tableNode = node;
                            break;
                        }
                    }

                    if (tableNode == null)
                    {
                        tableNode      = new Node();
                        tableNode.Text = tableName;
                        tableNode.Tag  = tableName;
                        keyFieldTree.Nodes.Add(tableNode);
                    }

                    Node fieldNode = null;

                    foreach (Node node in tableNode.Nodes)
                    {
                        if (node.Text == fieldName)
                        {
                            fieldNode = node;
                            break;
                        }
                    }

                    if (fieldNode == null)
                    {
                        string sqlString = string.Format("INSERT INTO sys_field_relation (TableName, KeyField) VALUES ('{0}', '{1}')",
                                                         tableName, GetFieldName(fieldName));
                        Helper.ExecuteCommand("sys_field_relation", sqlString, conn);
                        //ExecuteSqlCommand(sqlString);

                        fieldNode      = new Node();
                        fieldNode.Text = fieldName;
                        fieldNode.Tag  = "";
                        tableNode.Nodes.Add(fieldNode);
                        tableNode.Expand();
                    }
                    else
                    {
                        MessageBox.Show("当前关联字段已经存在!", "添加关联字段", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
        /// <summary>
        /// 添加关联字段
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bAddField_Click(object sender, EventArgs e)
        {
            string tableName = "";
            List<string> fieldNameList = new List<string>();

            Node currentNode = keyFieldTree.SelectedNode;

            if (currentNode != null)
            {
                if (currentNode.Level == 1)
                {
                    tableName = currentNode.Parent.Text;
                }
                else
                {
                    tableName = currentNode.Text;
                }
            }

            AddFieldRelationForm aForm = new AddFieldRelationForm(conn, tableName, fieldNameList, metaDataTable);

            if (aForm.ShowDialog() == DialogResult.OK)
            {
                tableName = aForm.TableName;

                foreach (string fieldName in aForm.FieldNameList)
                {
                    Node tableNode = null;

                    foreach (Node node in keyFieldTree.Nodes)
                    {
                        if (node.Text == tableName)
                        {
                            tableNode = node;
                            break;
                        }
                    }

                    if (tableNode == null)
                    {
                        tableNode = new Node();
                        tableNode.Text = tableName;
                        tableNode.Tag = tableName;
                        keyFieldTree.Nodes.Add(tableNode);
                    }

                    Node fieldNode = null;

                    foreach (Node node in tableNode.Nodes)
                    {
                        if (node.Text == fieldName)
                        {
                            fieldNode = node;
                            break;
                        }
                    }

                    if (fieldNode == null)
                    {
                        string sqlString = string.Format("INSERT INTO sys_field_relation (TableName, KeyField) VALUES ('{0}', '{1}')",
                                                         tableName, GetFieldName(fieldName));
                    	Helper.ExecuteCommand("sys_field_relation", sqlString, conn);
                    	//ExecuteSqlCommand(sqlString);

                        fieldNode = new Node();
                        fieldNode.Text = fieldName;
                        fieldNode.Tag = "";
                        tableNode.Nodes.Add(fieldNode);
                        tableNode.Expand();
                    }
                    else
                    {
                        MessageBox.Show("当前关联字段已经存在!", "添加关联字段", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }                
            }
        }
        /// <summary>
        /// 添加关联关系
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bAddRelation_Click(object sender, EventArgs e)
        {
            Node keyFieldNode = keyFieldTree.SelectedNode;

            if (keyFieldNode != null && keyFieldNode.Level == 1)
            {
                string        tableName     = "";
                List <string> fieldNameList = new List <string>();
                Node          tableNode     = relationTree.SelectedNode;

                if (tableNode != null)
                {
                    if (tableNode.Level == 1)
                    {
                        tableNode = tableNode.Parent;
                    }

                    tableName = tableNode.Text;

                    foreach (Node fieldNode in tableNode.Nodes)
                    {
                        fieldNameList.Add(fieldNode.Text);
                    }
                }

                AddFieldRelationForm aForm = new AddFieldRelationForm(conn, tableName, fieldNameList, metaDataTable);

                if (aForm.ShowDialog() == DialogResult.OK)
                {
                    tableNode = null;

                    foreach (Node node in relationTree.Nodes)
                    {
                        if (node.Text == aForm.TableName)
                        {
                            tableNode = node;
                            break;
                        }
                    }

                    if (tableNode == null)
                    {
                        tableNode      = new Node();
                        tableNode.Text = aForm.TableName;
                        tableNode.Tag  = aForm.TableName;
                        relationTree.Nodes.Add(tableNode);
                    }

                    foreach (string s in aForm.FieldNameList)
                    {
                        bool exist = false;

                        foreach (Node node in tableNode.Nodes)
                        {
                            if (node.Text == s)
                            {
                                exist = true;
                                break;
                            }
                        }

                        if (!exist)
                        {
                            Node fieldNode = new Node();
                            fieldNode.Text = s;
                            fieldNode.Tag  = s;
                            tableNode.Nodes.Add(fieldNode);
                        }
                    }

                    tableNode.Expand();

                    string relationData = GetRelationData();
                    UpdateFieldRelationData(relationData);
                }
            }
            else
            {
                MessageBox.Show("请先选择要添加关联关系的字段!", "添加关联关系", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// 添加关联关系
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bAddRelation_Click(object sender, EventArgs e)
        {
            Node keyFieldNode = keyFieldTree.SelectedNode;

            if (keyFieldNode != null && keyFieldNode.Level == 1)
            {
                string tableName = "";
                List<string> fieldNameList = new List<string>();
                Node tableNode = relationTree.SelectedNode;

                if (tableNode != null)
                {
                    if (tableNode.Level == 1)
                    {
                        tableNode = tableNode.Parent;
                    }

                    tableName = tableNode.Text;

                    foreach (Node fieldNode in tableNode.Nodes)
                    {
                        fieldNameList.Add(fieldNode.Text);
                    }
                }

                AddFieldRelationForm aForm = new AddFieldRelationForm(conn, tableName, fieldNameList, metaDataTable);

                if (aForm.ShowDialog() == DialogResult.OK)
                {
                    tableNode = null;

                    foreach (Node node in relationTree.Nodes)
                    {
                        if (node.Text == aForm.TableName)
                        {
                            tableNode = node;
                            break;
                        }
                    }

                    if (tableNode == null)
                    {
                        tableNode = new Node();
                        tableNode.Text = aForm.TableName;
                        tableNode.Tag = aForm.TableName;
                        relationTree.Nodes.Add(tableNode);
                    }

                    foreach (string s in aForm.FieldNameList)
                    {
                        bool exist = false;

                        foreach (Node node in tableNode.Nodes)
                        {
                            if (node.Text == s)
                            {
                                exist = true;
                                break;
                            }
                        }

                        if (!exist)
                        {
                            Node fieldNode = new Node();
                            fieldNode.Text = s;
                            fieldNode.Tag = s;
                            tableNode.Nodes.Add(fieldNode);
                        }
                    }

                    tableNode.Expand();

                    string relationData = GetRelationData();
                    UpdateFieldRelationData(relationData);
                }
            }
            else
            {
                MessageBox.Show("请先选择要添加关联关系的字段!", "添加关联关系", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }