//代码生成器
        private void menuItemBuildCodeForTable_Click(object sender, EventArgs e)
        {
            TreeNode tn = tvDatabase.SelectedNode;
            SOTable table = tn.Tag as SOTable;
            CodeBuilder builder = null;

            //保证代码生成器使用一个实例
            if (this.DockPanel.ActiveDocument != null && this.DockPanel.ActiveDocument is CodeBuilder)
            {
                builder = this.DockPanel.ActiveDocument as CodeBuilder;
                builder.Table = table;
                builder.ColumnList = dbSchema.GetTableColumnList(table);
                builder.LoadColumnList();
            }
            else
            {
                builder = new CodeBuilder();
                builder.Table = table;
                builder.ColumnList = dbSchema.GetTableColumnList(table);
                builder.LoadColumnList();//???:初始化列表CheckBox状态时,数据需要Load两次才能将CheckBox列全部初始化为选中状态
                builder.Show(this.DockPanel);
            }
        }
Beispiel #2
0
        //使用自定义模板批量生成代码
        //private void menuItemBatchBuildCustomCode_Click(object sender, EventArgs e)
        //{
        //    SODatabase db = null;
        //    TreeNode node = tv.SelectedNode;

        //    if (node.Tag is PDModel)
        //    {
        //        PDModel m = node.Tag as PDModel;
        //        db = SOConverter.ToSODatabase(m);
        //    }
        //    else
        //    {
        //        PDPackage p = node.Tag as PDPackage;
        //        db = SOConverter.ToSODatabase(p);
        //    }

        //    BatchBuildCustomCode dialog = new BatchBuildCustomCode(db);
        //    dialog.ShowDialog();
        //}

        #endregion

        #region 表节点右键菜单事件处理

        //代码生成器
        private void menuItemBuildCodeForTable_Click(object sender, EventArgs e)
        {
            TreeNode tn = tv.SelectedNode;
            SOTable table = SOConverter.ToSOTable(tn.Tag as PDTable);
            CodeBuilder builder = null;

            //保证代码生成器使用一个实例
            if (this.DockPanel.ActiveDocument != null && this.DockPanel.ActiveDocument is CodeBuilder)
            {
                builder = this.DockPanel.ActiveDocument as CodeBuilder;
                builder.Table = table;
                builder.ColumnList = table.ColumnList;
                builder.LoadColumnList();
            }
            else
            {
                builder = new CodeBuilder();
                builder.Table = table;
                builder.ColumnList = table.ColumnList;
                builder.LoadColumnList();
                builder.Show(this.DockPanel);
            }
        }