Esempio n. 1
0
        private void Form_Database_Load(object sender, EventArgs e)
        {
            Form.CheckForIllegalCrossThreadCalls = false;

            var serverList = new Common.Config_Servers().GetAll();

            foreach (var server in serverList)
            {
                Model.Servers ser = new Servers();
                ser.DatabaseName = server.Database;
                ser.ID           = server.Name;
                ser.Name         = server.ServerName;
                ser.Password     = server.Pwd;
                ser.Port         = server.Port.IsInt() ? server.Port.ToInt() : -1;
                ser.Server       = server.ServerName;
                Model.DatabaseType dbtype;
                ser.Type   = Enum.TryParse(server.Type, out dbtype) ? dbtype : DatabaseType.Empty;
                ser.UserID = server.Uid;

                Common.Config.AddServerList(ser);

                TreeNode RootNode = new TreeNode();
                RootNode.Name               = server.ServerName;
                RootNode.Text               = string.Format("{0}({1}{2})", server.ServerName, server.Type.ToString(), server.Uid.IsNullOrEmpty() ? "" : string.Format("-{0}", server.Uid));
                RootNode.ImageIndex         = 0;
                RootNode.SelectedImageIndex = 0;
                RootNode.Tag = new Model.TreeNodeTag()
                {
                    Type = TreeNodeType.Server, Tag = ser
                };
                tvDatabase.Nodes.Add(RootNode);
            }
        }
        private void Form_AddDatabase_MySql_Load(object sender, EventArgs e)
        {
            Common.Config_Servers CS = new Common.Config_Servers();
            csList = CS.GetAll().Where(p => p.Type == this.dbType.ToString());
            foreach (var li in csList)
            {
                this.comboBox_mysql_server.Items.Add(li.ServerName);
            }

            Model.ConfigServers cs = CS.GetDefault(this.dbType);
            if (cs != null)
            {
                this.comboBox_mysql_server.Text = cs.ServerName;
                this.textBox_mysql_pwd.Text     = cs.Pwd;
                this.textBox_mysql_uid.Text     = cs.Uid;
                this.checkBox1.Checked          = !cs.Pwd.IsNullOrEmpty();
            }
        }