⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbview.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
📖 第 1 页 / 共 5 页
字号:
namespace Codematic
{
    using Crownwood.Magic.Controls;
    using LTP.CmConfig;
    using LTP.CodeBuild;
    using LTP.CodeHelper;
    using LTP.DBFactory;
    using LTP.IDBO;
    using LTP.SplashScrForm;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;

    public class DbView : Form
    {
        private ToolStripMenuItem adfsToolStripMenuItem;
        private IContainer components;
        private IDbObject dbobj;
        private ContextMenuStrip DbTreeContextMenu;
        public static bool isMdb;
        private LoginMySQL loginMysql = new LoginMySQL();
        private LoginForm logo = new LoginForm();
        private LoginOledb logoOledb = new LoginOledb();
        private LoginOra logoOra = new LoginOra();
        private bool m_bLayoutCalled;
        private MainForm mainfrm;
        private string path = Application.StartupPath;
        private TreeNode serverlistNode;
        private ModuleSettings setting;
        private ToolStripButton toolbtn_AddServer;
        private ToolStripButton toolbtn_Connect;
        private ToolStripButton toolbtn_Refrush;
        private ToolStripButton toolbtn_unConnect;
        private ToolStrip toolStrip1;
        private ToolStripSeparator toolStripMenuItem1;
        private ToolStripSeparator toolStripSeparator1;
        private ToolStripSeparator toolStripSeparator2;
        private TreeNode TreeClickNode;
        private ImageList treeImgs;
        public TreeView treeView1;
        private ToolStripMenuItem 添加服务器ToolStripMenuItem;

        public DbView(Form mdiParentForm)
        {
            this.mainfrm = (MainForm) mdiParentForm;
            this.InitializeComponent();
            this.treeView1.ExpandAll();
        }

        private void AddSinglePage(Control control, string Title)
        {
            if (!this.mainfrm.tabControlMain.Visible)
            {
                this.mainfrm.tabControlMain.Visible = true;
            }
            bool flag = false;
            Crownwood.Magic.Controls.TabPage page = null;
            foreach (Crownwood.Magic.Controls.TabPage page2 in this.mainfrm.tabControlMain.TabPages)
            {
                if (page2.Control.Name == control.Name)
                {
                    flag = true;
                    page = page2;
                }
            }
            if (!flag)
            {
                this.AddTabPage(Title, control);
            }
            else
            {
                this.mainfrm.tabControlMain.SelectedTab = page;
            }
        }

        private void AddTabPage(string pageTitle, Control ctrForm)
        {
            if (!this.mainfrm.tabControlMain.Visible)
            {
                this.mainfrm.tabControlMain.Visible = true;
            }
            Crownwood.Magic.Controls.TabPage page = new Crownwood.Magic.Controls.TabPage();
            page.Title = pageTitle;
            page.Control = ctrForm;
            this.mainfrm.tabControlMain.TabPages.Add(page);
            this.mainfrm.tabControlMain.SelectedTab = page;
        }

        private void AddTabPage(string pageTitle, Control ctrForm, MainForm mainfrm)
        {
            if (!mainfrm.tabControlMain.Visible)
            {
                mainfrm.tabControlMain.Visible = true;
            }
            Crownwood.Magic.Controls.TabPage page = new Crownwood.Magic.Controls.TabPage();
            page.Title = pageTitle;
            page.Control = ctrForm;
            mainfrm.tabControlMain.TabPages.Add(page);
            mainfrm.tabControlMain.SelectedTab = page;
        }

        private void ConnectServer(TreeNode serverNode, string dbtype, string ServerIp, string DbName, bool ConnectSimple)
        {
            IDbObject obj2 = DBOMaker.CreateDbObj(dbtype);
            this.mainfrm.StatusLabel1.Text = "加载数据库树...";
            SplashScreen.ShowSplashScreen();
            Application.DoEvents();
            SplashScreen.SetStatus("加载数据库树...");
            DbSettings settings = DbConfig.GetSetting(dbtype, ServerIp, DbName);
            obj2.DbConnectStr = settings.ConnectStr;
            serverNode.Nodes.Clear();
            if ((dbtype == "SQL2000") || (dbtype == "SQL2005"))
            {
                try
                {
                    if ((settings.DbName == "master") || (settings.DbName == ""))
                    {
                        List<string> dBList = obj2.GetDBList();
                        if (dBList.Count > 0)
                        {
                            this.mainfrm.toolComboBox_DB.Items.Clear();
                            foreach (string str in dBList)
                            {
                                TreeNode node = new TreeNode(str);
                                node.ImageIndex = 2;
                                node.SelectedImageIndex = 2;
                                node.Tag = "db";
                                serverNode.Nodes.Add(node);
                                this.mainfrm.toolComboBox_DB.Items.Add(str);
                            }
                            if (this.mainfrm.toolComboBox_DB.Items.Count > 0)
                            {
                                this.mainfrm.toolComboBox_DB.SelectedIndex = 0;
                            }
                        }
                    }
                    else
                    {
                        TreeNode node2 = new TreeNode(settings.DbName);
                        node2.ImageIndex = 2;
                        node2.SelectedImageIndex = 2;
                        node2.Tag = "db";
                        serverNode.Nodes.Add(node2);
                        this.mainfrm.toolComboBox_DB.Items.Clear();
                        this.mainfrm.toolComboBox_DB.Items.Add(settings.DbName);
                        DataTable tabViews = obj2.GetTabViews(settings.DbName);
                        if (tabViews != null)
                        {
                            this.mainfrm.toolComboBox_Table.Items.Clear();
                            foreach (DataRow row in tabViews.Rows)
                            {
                                string item = row["name"].ToString();
                                this.mainfrm.toolComboBox_Table.Items.Add(item);
                            }
                            if (this.mainfrm.toolComboBox_Table.Items.Count > 0)
                            {
                                this.mainfrm.toolComboBox_Table.SelectedIndex = 0;
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    LogInfo.WriteLog(exception);
                    MessageBox.Show(this, "连接服务器失败!请检查服务器是否已经启动或工作正常!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
            }
            if (dbtype == "Oracle")
            {
                TreeNode node3 = new TreeNode(ServerIp);
                node3.ImageIndex = 2;
                node3.SelectedImageIndex = 2;
                node3.Tag = "db";
                serverNode.Nodes.Add(node3);
                this.mainfrm.toolComboBox_DB.Items.Add(ServerIp);
                this.mainfrm.toolComboBox_DB.SelectedIndex = 0;
                DataTable table2 = obj2.GetTabViews(ServerIp);
                if (table2 != null)
                {
                    this.mainfrm.toolComboBox_Table.Items.Clear();
                    foreach (DataRow row2 in table2.Rows)
                    {
                        string str3 = row2["name"].ToString();
                        this.mainfrm.toolComboBox_Table.Items.Add(str3);
                    }
                    if (this.mainfrm.toolComboBox_Table.Items.Count > 0)
                    {
                        this.mainfrm.toolComboBox_Table.SelectedIndex = 0;
                    }
                }
            }
            if (dbtype == "MySQL")
            {
                try
                {
                    string dbName = settings.DbName;
                    switch (dbName)
                    {
                        case "mysql":
                        case "":
                        {
                            List<string> list2 = obj2.GetDBList();
                            if (list2.Count > 0)
                            {
                                this.mainfrm.toolComboBox_DB.Items.Clear();
                                foreach (string str5 in list2)
                                {
                                    TreeNode node4 = new TreeNode(str5);
                                    node4.ImageIndex = 2;
                                    node4.SelectedImageIndex = 2;
                                    node4.Tag = "db";
                                    serverNode.Nodes.Add(node4);
                                    this.mainfrm.toolComboBox_DB.Items.Add(str5);
                                }
                                if (this.mainfrm.toolComboBox_DB.Items.Count > 0)
                                {
                                    this.mainfrm.toolComboBox_DB.SelectedIndex = 0;
                                }
                            }
                            goto Label_05E4;
                        }
                    }
                    TreeNode node5 = new TreeNode(dbName);
                    node5.ImageIndex = 2;
                    node5.SelectedImageIndex = 2;
                    node5.Tag = "db";
                    serverNode.Nodes.Add(node5);
                    this.mainfrm.toolComboBox_DB.Items.Clear();
                    this.mainfrm.toolComboBox_DB.Items.Add(dbName);
                    DataTable table3 = obj2.GetTabViews(dbName);
                    if (table3 != null)
                    {
                        this.mainfrm.toolComboBox_Table.Items.Clear();
                        foreach (DataRow row3 in table3.Rows)
                        {
                            row3["name"].ToString();
                            this.mainfrm.toolComboBox_Table.Items.Add(dbName);
                        }
                    }
                }
                catch (Exception exception2)
                {
                    LogInfo.WriteLog(exception2);
                    MessageBox.Show(this, "连接服务器失败!请检查服务器是否已经启动或工作正常!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
            }
        Label_05E4:
            if (dbtype == "OleDb")
            {
                string text = ServerIp.Substring(ServerIp.LastIndexOf(@"\") + 1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -