Example #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (int.TryParse(txtPort.Text, out var port))
     {
         _dbConfigInfo.ServerName   = txtServerName.Text.Trim();
         _dbConfigInfo.UserName     = txtUserName.Text.Trim();
         _dbConfigInfo.UserPassword = txtPwd.Text.Trim();
         _dbConfigInfo.Port         = port;
         _dbConfigInfo.DataBase     = txtDataBase.Text.Trim();
         if (rbMySQL.Checked)
         {
             _dbConfigInfo.DbType = SQLDbTypes.MySQL;
         }
         else
         {
             _dbConfigInfo.DbType = SQLDbTypes.SQLServer;
         }
         DbConfigUtil.SaveDbConfig(_dbConfigInfo);
         DialogResult = DialogResult.OK;
     }
     else
     {
         MessageBox.Show(@"端口必须是整数!", @"警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #2
0
        private void TopMenuItem2_Click(object sender, EventArgs e)
        {
            DbConfigInfo dbConfigInfo = DbConfigUtil.GetDbConfig();

            if (dbConfigInfo != null)
            {
                Global.GetInstance().DB = dbConfigInfo;
            }

            try
            {
                Global.GetInstance().Tables = BSqlFunction.GetInstance().GetTables();
                CreateTreeNode();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #3
0
 private void InitData()
 {
     _dbConfigInfo      = DbConfigUtil.GetDbConfig();
     txtServerName.Text = _dbConfigInfo.ServerName;
     txtUserName.Text   = _dbConfigInfo.UserName;
     txtPwd.Text        = _dbConfigInfo.UserPassword;
     txtPort.Text       = _dbConfigInfo.Port.ToString("D");
     txtDataBase.Text   = _dbConfigInfo.DataBase;
     if (_dbConfigInfo.DbType == SQLDbTypes.MySQL)
     {
         rbMySQL.Checked = true;
     }
     else
     {
         rbSQLServer.Checked = true;
     }
     //cmbbSQLType.SelectedValue = dbConfigInfo.DbType;
     //cmbbSQLType.SelectedIndex = cmbbSQLType.Items.IndexOf(dbConfigInfo.DbType);
     //cmbbSQLType.SelectedText = dbConfigInfo.DbType;
 }