Пример #1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            object obj = this.dbList.SelectedItem;
            if (obj != null)
            {
                db = dbs[obj.ToString()] as DB;
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {

            }
        }
Пример #2
0
 DB showForm(DBType t, DB db = null)
 {
     NewForm newForm = new NewForm(t);
     if (db != null) newForm.db = db;
     if (newForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         return newForm.db;
     }
     return null;
 }
Пример #3
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     string val = this.dbList.SelectedItem.ToString();
     db = dbs[val] as DB;
     DialogResult = System.Windows.Forms.DialogResult.OK;
 }
Пример #4
0
        bool save()
        {
            string name = this.textName.Text.Trim();
            string server = this.textServer.Text.Trim();
            string p = this.textPort.Text.Trim();
            int port;
            if (!Int32.TryParse(p, out port))
            {
                MessageBox.Show("Port is not a number!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            string username = this.textUsername.Text.Trim();
            string password = this.textPassword.Text.Trim();
            string database = this.textDatabase.Text.Trim();
            if (db == null)
            {
                db = new DB();
            }
            db.name = name;
            db.server = server;
            db.port = port;
            db.username = username;
            db.password = password;
            db.dbname = database;

            Setting.addDB(db);

            return true;
        }
Пример #5
0
        void loadDB(DB db)
        {
            if (db == null) return;
            TreeNode rootNode = new TreeNode(db.name);
            //rootNode.ImageIndex = 0;
            //rootNode.SelectedImageIndex = 0;
            rootNode.Tag = db;
            rootNode.Name = db.name;
            rootNode.ImageIndex = 0;
            rootNode.SelectedImageIndex = 0;
            //if (this.treeViewDB.Nodes.ContainsKey(rootNode.Name))
            //{
            //    this.treeViewDB.Nodes.RemoveByKey(rootNode.Name);
            //}
            this.treeViewDB.Nodes.Add(rootNode);

            string err;
            if (db.test(out err))
            {

                loadDatabase(rootNode, db);
            }
            else
            {
                ShowMsg.Error(err);
            }
        }
Пример #6
0
        void loadDatabase(TreeNode parentNode, DB db)
        {
            var server = db.getMongoServer();
            string dbName = db.dbname;
            List<string> dbNames = string.IsNullOrEmpty(dbName) ? server.GetDatabaseNames().ToList() : db.dbList;
            if (dbNames != null && dbNames.Any())
            {
                foreach (string d in dbNames)
                {
                    TreeNode dbNode = new TreeNode(d);
                    dbNode.Name = d;
                    dbNode.ImageIndex = 1;
                    dbNode.SelectedImageIndex = 1;
                    parentNode.Nodes.Add(dbNode);

                    loadCollection(dbNode, server, d);
                }
            }
        }
Пример #7
0
        void loadDB(DB db)
        {
            TreeNode rootNode = new TreeNode(db.name);
            //rootNode.ImageIndex = 0;
            //rootNode.SelectedImageIndex = 0;
            rootNode.Name = db.name;
            this.treeViewDB.Nodes.Add(rootNode);
            var server = db.getMongoServer();
            List<string> dbNames = string.IsNullOrEmpty(db.dbname) ? server.GetDatabaseNames().ToList() : new List<string> { db.dbname };
            if (dbNames != null && dbNames.Any())
            {
                foreach (string d in dbNames)
                {
                    TreeNode dbNode = new TreeNode(d);
                    //dbNode.ImageIndex = 0;
                    //dbNode.SelectedImageIndex = 0;
                    dbNode.Name = d;
                    rootNode.Nodes.Add(dbNode);

                    loadCollection(dbNode, server, d);
                }
            }
        }