Esempio n. 1
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            DBSession dbSession = new DBSession()
            {
                SessionName   = txtSessionName.Text,
                SessionRemark = txtSessionRemark.Text,
                ServerIP      = txtDBServer.Text,
                UserID        = txtDBUserID.Text,
                Password      = txtDBPwd.Password,
                Port          = txtDBPort.Text
            };

            if (treeDB.TestPing(dbSession))
            {
                btnConnect.IsEnabled = true;
            }
        }
Esempio n. 2
0
 //会话列表选择项改变时,右侧会话信息改变
 private void SessionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sessionList.SelectedIndex != -1)
     {
         DBSession dbSession = DBSession.GetSession(sessionList.SelectedItem.ToString());
         if (dbSession != null)
         {
             this.DataContext = dbSession;
             if (treeDB.TestPing(dbSession))
             {
                 MyTrees.treeDB.ConnectDB("");
                 if (UserAdmin.UserAdminEnabled)
                 {
                     lblTip.Text          = "该数据库启用了权限控制,需输入用户名和密码才能登陆!";
                     lblTip.Foreground    = Brushes.DarkRed;
                     lblUserID.Visibility = Visibility.Visible;
                     lblPwd.Visibility    = Visibility.Visible;
                     txtUserID.Visibility = Visibility.Visible;
                     txtPwd.Visibility    = Visibility.Visible;
                     btnConnect.IsEnabled = false;
                 }
                 else
                 {
                     lblTip.Text          = "该数据库没有启用权限控制,请直接点击按钮进行登陆!";
                     lblTip.Foreground    = Brushes.DarkGreen;
                     lblUserID.Visibility = Visibility.Collapsed;
                     lblPwd.Visibility    = Visibility.Collapsed;
                     txtUserID.Visibility = Visibility.Collapsed;
                     txtPwd.Visibility    = Visibility.Collapsed;
                     btnConnect.IsEnabled = true;
                 }
             }
             else
             {
                 lblTip.Text          = "该数据库无法连接,请与管理员联系,检查数据库配置文件是否正确!";
                 lblTip.Foreground    = Brushes.Red;
                 lblUserID.Visibility = Visibility.Collapsed;
                 lblPwd.Visibility    = Visibility.Collapsed;
                 txtUserID.Visibility = Visibility.Collapsed;
                 txtPwd.Visibility    = Visibility.Collapsed;
                 btnConnect.IsEnabled = false;
             }
         }
     }
 }