Example #1
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;
             }
         }
     }
 }
Example #2
0
 //会话列表选择项改变时,右侧会话信息改变
 private void SessionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sessionList.SelectedIndex != -1)
     {
         DBSession dbSession = DBSession.GetSession(sessionList.SelectedItem.ToString());
         if (dbSession != null)
         {
             gridSessionInfo.IsEnabled = true;
             this.DataContext          = dbSession;
             this.txtDBPwd.Password    = dbSession.Password;
             btnSave.IsEnabled         = false;
             btnTest.IsEnabled         = true;
             btnDelete.IsEnabled       = true;
             return;
         }
     }
     this.DataContext          = "";
     this.txtDBPwd.Password    = "";
     btnSave.IsEnabled         = false;
     btnTest.IsEnabled         = false;
     btnDelete.IsEnabled       = false;
     btnConnect.IsEnabled      = false;
     gridSessionInfo.IsEnabled = false;
 }