Ejemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (DBSession.GetSessionNames().Contains(txtSessionName.Text) &&
                txtSessionName.Text != sessionList.SelectedItem.ToString())
            {
                MessageBox.Show("会话“" + txtSessionName.Text + "”已经存在,请修改会话名称!");
            }
            else
            {
                DBSession dbSession = new DBSession()
                {
                    SessionName   = txtSessionName.Text,
                    SessionRemark = txtSessionRemark.Text,
                    ServerIP      = txtDBServer.Text,
                    UserID        = txtDBUserID.Text,
                    Password      = txtDBPwd.Password,
                    Port          = txtDBPort.Text
                };
                DBSession.SaveSession(dbSession);
                btnSave.IsEnabled = false;

                if (txtSessionName.Text != sessionList.SelectedItem.ToString())
                {
                    DBSession.DeleteSession(sessionList.SelectedItem.ToString());
                    sessionList.Items[sessionList.SelectedIndex] = txtSessionName.Text;
                }
            }
        }
Ejemplo n.º 2
0
        public ConnDBView(InvokeDelegate startupDelegate, IMyTreeDB treeDB)
        {
            InitializeComponent();
            this.startupDelegate = startupDelegate;
            this.treeDB          = treeDB as MyTreeDBMysql;

            //会话列表
            List <string> sessionNames = DBSession.GetSessionNames();

            foreach (string session in sessionNames)
            {
                sessionList.Items.Add(session);
            }
        }