/// <summary>
        /// 加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentForm_Load(object sender, EventArgs e)
        {
            Hxj.IDBO.IDbObject dbObject = null;
            if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2000.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2005.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.Sqlite3.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQLite.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.MySQL.DbObject(ConnectionModel.ConnectionString);
            }
            else
            {
                MessageBox.Show("未知数据库类型!");
                return;
            }
            columnsdt = dbObject.GetColumnInfoList(DatabaseName, TableName);

            gridColumns.DataSource = columnsdt;

            DataTable primarykeydt = dbObject.GetKeyName(DatabaseName, TableName);

            cbPrimarykey.Items.Clear();

            if (null != primarykeydt && primarykeydt.Rows.Count > 0)
            {
                foreach (DataRow dr in primarykeydt.Rows)
                {
                    cbPrimarykey.Items.Add(dr["ColumnName"].ToString());
                }

                cbPrimarykey.SelectedIndex = 0;
            }

            txtClassName.Text = TableName.Trim().Replace(' ', '_');
            txtnamespace.Text = Utils.ReadNamespace();

        }
Exemple #2
0
        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentForm_Load(object sender, EventArgs e)
        {
            Hxj.IDBO.IDbObject dbObject = null;
            if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2000.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2005.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.Sqlite3.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQLite.DbObject(ConnectionModel.ConnectionString);
            }
            else if (ConnectionModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.MySQL.DbObject(ConnectionModel.ConnectionString);
            }
            else
            {
                MessageBox.Show("未知数据库类型!");
                return;
            }
            columnsdt = dbObject.GetColumnInfoList(DatabaseName, TableName);

            gridColumns.DataSource = columnsdt;

            DataTable primarykeydt = dbObject.GetKeyName(DatabaseName, TableName);

            cbPrimarykey.Items.Clear();

            if (null != primarykeydt && primarykeydt.Rows.Count > 0)
            {
                foreach (DataRow dr in primarykeydt.Rows)
                {
                    cbPrimarykey.Items.Add(dr["ColumnName"].ToString());
                }

                cbPrimarykey.SelectedIndex = 0;
            }

            txtClassName.Text = TableName.Trim().Replace(' ', '_');
            txtnamespace.Text = Utils.ReadNamespace();
        }
Exemple #3
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();

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

            IDBO.IDbObject dbObject;

            if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(""), dbObject.GetVIEWs(""));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2000.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2005.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
        }
Exemple #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();

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

            IDBO.IDbObject dbObject;

            if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(""), dbObject.GetVIEWs(""));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2000.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQL2005.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);
                gettables(node, dbObject.GetTables(node.Text), dbObject.GetVIEWs(node.Text));
            }
        }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        private void getDatabaseinfo()
        {
            TreeNode node = tview.SelectedNode;

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

            IDBO.IDbObject dbObject;

            if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);



                gettables(tnode, dbObject.GetTables(""), dbObject.GetVIEWs(""));


            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Sqlite3.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQLite.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);

                gettables(tnode, dbObject.GetTables(""), dbObject.GetVIEWs(""));

            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()) || conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
                    dbObject = new Hxj.DbObjects.SQL2000.DbObject(conModel.ConnectionString);
                else
                    dbObject = new Hxj.DbObjects.SQL2005.DbObject(conModel.ConnectionString);

                if (conModel.Database.Equals("all"))
                {
                    DataTable dt = dbObject.GetDBList();

                    foreach (DataRow dr in dt.Rows)
                    {
                        TreeNode tnode = new TreeNode(dr[0].ToString(), 1, 1);
                        tnode.Tag = conModel.ConnectionString.Replace("master", dr[0].ToString());
                        tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                        node.Nodes.Add(tnode);

                        gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                    }

                }
                else
                {
                    TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                    tnode.Tag = conModel.ConnectionString;
                    tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                    node.Nodes.Add(tnode);

                    gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                }
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);

                gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.MySQL.DbObject(conModel.ConnectionString);

                if (conModel.Database.Equals("all"))
                {
                    DataTable dt = dbObject.GetDBList();

                    foreach (DataRow dr in dt.Rows)
                    {
                        TreeNode tnode = new TreeNode(dr[0].ToString(), 1, 1);
                        tnode.Tag = conModel.ConnectionString.Replace("master", dr[0].ToString());
                        tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                        node.Nodes.Add(tnode);

                        gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                    }

                }
                else
                {
                    TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                    tnode.Tag = conModel.ConnectionString;
                    tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                    node.Nodes.Add(tnode);

                    gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                }
            }
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        private void getDatabaseinfo()
        {
            TreeNode node = tview.SelectedNode;

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

            IDBO.IDbObject dbObject;

            if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MsAccess.ToString()))
            {
                dbObject = new Hxj.DbObjects.OleDb.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);



                gettables(tnode, dbObject.GetTables(""), dbObject.GetVIEWs(""));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Sqlite3.ToString()))
            {
                dbObject = new Hxj.DbObjects.SQLite.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);

                gettables(tnode, dbObject.GetTables(""), dbObject.GetVIEWs(""));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()) || conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer9.ToString()))
            {
                if (conModel.DbType.Equals(Dos.ORM.DatabaseType.SqlServer.ToString()))
                {
                    dbObject = new Hxj.DbObjects.SQL2000.DbObject(conModel.ConnectionString);
                }
                else
                {
                    dbObject = new Hxj.DbObjects.SQL2005.DbObject(conModel.ConnectionString);
                }

                if (conModel.Database.Equals("all"))
                {
                    DataTable dt = dbObject.GetDBList();

                    foreach (DataRow dr in dt.Rows)
                    {
                        TreeNode tnode = new TreeNode(dr[0].ToString(), 1, 1);
                        tnode.Tag = conModel.ConnectionString.Replace("master", dr[0].ToString());
                        tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                        node.Nodes.Add(tnode);

                        gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                    }
                }
                else
                {
                    TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                    tnode.Tag = conModel.ConnectionString;
                    tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                    node.Nodes.Add(tnode);

                    gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                }
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.Oracle.ToString()))
            {
                dbObject = new Hxj.DbObjects.Oracle.DbObject(conModel.ConnectionString);

                TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                tnode.Tag = conModel.ConnectionString;
                tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                node.Nodes.Add(tnode);

                gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
            }
            else if (conModel.DbType.Equals(Dos.ORM.DatabaseType.MySql.ToString()))
            {
                dbObject = new Hxj.DbObjects.MySQL.DbObject(conModel.ConnectionString);

                if (conModel.Database.Equals("all"))
                {
                    DataTable dt = dbObject.GetDBList();

                    foreach (DataRow dr in dt.Rows)
                    {
                        TreeNode tnode = new TreeNode(dr[0].ToString(), 1, 1);
                        tnode.Tag = conModel.ConnectionString.Replace("master", dr[0].ToString());
                        tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                        node.Nodes.Add(tnode);

                        gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                    }
                }
                else
                {
                    TreeNode tnode = new TreeNode(conModel.Database, 1, 1);
                    tnode.Tag = conModel.ConnectionString;
                    tnode.ContextMenuStrip = contextMenuStripOneDataBase;
                    node.Nodes.Add(tnode);

                    gettables(tnode, dbObject.GetTables(tnode.Text), dbObject.GetVIEWs(tnode.Text));
                }
            }
        }