Пример #1
0
 internal void InitGrid()
 {
     db                     = new DB(ConnectionModel.DbType, ConnectionModel.ConnectionString);
     dbInfo                 = db.Info;
     lstCol                 = dbInfo.GetAllColumnInfo(this.TableName);
     table_Comment          = dbInfo.GetTableComment(TableName);
     gridColumns.DataSource = lstCol;
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        private void getDatabaseinfo(TreeNode currNode)
        {
            TreeNode node = currNode;

            Entity.Connection conModel = list.Find(t => t.ID.ToString().Equals(node.Tag.ToString(), StringComparison.OrdinalIgnoreCase));

            DB     db     = null;
            DBInfo dbInfo = null;

            db     = new DB(conModel.DbType, conModel.ConnectionString);
            dbInfo = db.Info;

            if (!conModel.Database.Equals("all"))
            {
                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);

                gettables(tnode, dbInfo.TableNames, dbInfo.GetAllViews());
            }
            else
            {
                DataTable dt = new DataTable();
                if (conModel.DbType == DataBaseType.MsSql)
                {
                    dt = db.QueryTable("Select name from master..sysdatabases");
                }
                else if (conModel.DbType == DataBaseType.MySql)
                {
                    dt = db.QueryTable("SHOW DATABASES");
                }


                foreach (DataRow dr in dt.Rows)
                {
                    TreeNode tnode = new TreeNode(dr[0].ToString(), 1, 1);
                    if (conModel.DbType == DataBaseType.MsSql)
                    {
                        tnode.Tag = conModel.ConnectionString.Replace("master", dr[0].ToString());
                    }
                    else if (conModel.DbType == DataBaseType.MySql)
                    {
                        tnode.Tag = conModel.ConnectionString.ToLower().Replace("database=", "database=" + dr[0].ToString());
                    }

                    tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                    node.Nodes.Add(tnode);

                    db     = new DB(conModel.DbType, tnode.Tag.ToString());
                    dbInfo = db.Info;

                    gettables(tnode, dbInfo.TableNames, dbInfo.GetAllViews());
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 生成表结构 html文件
        /// </summary>
        private void Builder()
        {
            //使用目录
            string useDir = string.Empty;

            //if (CkRetainHtml.Checked)//保留html文件
            //{
            useDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            //}
            //else
            //{
            //    useDir = Path.GetTempPath();
            //}


            chm_html_path = Path.Combine(useDir, txtCHM_Name.Text);
            string tempPath = chm_html_path;

            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }
            else
            {
                Directory.Delete(tempPath, true);
                Directory.CreateDirectory(tempPath);
            }

            indexHtmlpath = Path.Combine(tempPath, defaultHtml);

            DB     db     = new DB(connectionModel.DbType, connectionModel.ConnectionString);
            DBInfo dbInfo = db.Info;

            Dictionary <string, string> dict_tabComment = dbInfo.GetAllTableComment();

            ChmHtmlHelper.CreateDirHtml("数据库表目录", dict_tabComment, indexHtmlpath);


            //创建表结构的html
            tempPath = Path.Combine(tempPath, "表结构");
            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }
            else
            {
                Directory.Delete(tempPath, true);
                Directory.CreateDirectory(tempPath);
            }

            List <TableInfo> lstTableInfo = dbInfo.GetAllTableInfos();

            ChmHtmlHelper.CreateHtml(lstTableInfo, tempPath);
        }
Пример #4
0
        /// <summary>
        /// 刷新数据库表和视图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 刷新ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            TreeNode node = tview.SelectedNode;

            node.Nodes.Clear();

            Entity.Connection conModel = list.Find(delegate(Entity.Connection con) { return(con.ID.ToString().Equals(node.Parent.Tag.ToString())); });

            DB db = null;

            db = new DB(conModel.DbType, conModel.ConnectionString);
            DBInfo dbInfo = db.Info;

            gettables(node, dbInfo.TableNames, dbInfo.GetAllViews());
        }