Esempio 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;
                }
            }
        }
Esempio n. 2
0
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            DBSession dbSession = new DBSession();

            this.DataContext = dbSession;
            DBSession.SaveSession(dbSession);
            sessionList.Items.Add(dbSession.SessionName);
            sessionList.SelectedItem = dbSession.SessionName;
        }