void CDlgSAPrefs6::OnBnClickedPtTest() { CString conn_str = "", ip_addr = "", port = "", user = "", pass = "", dbname = "", e = ""; CMainFrame *pMyMainWnd = (CMainFrame *) (theApp.m_pMainWnd); m_pt_ip.GetWindowText(ip_addr); m_pt_port.GetWindowText(port); m_pt_user.GetWindowText(user); m_pt_pass.GetWindowText(pass); m_pt_dbname.GetWindowText(dbname); conn_str = "host=" + ip_addr; conn_str += " port=" + port; conn_str += " user="******" password="******" dbname='" + dbname; conn_str += "'"; // Set busy cursor pMyMainWnd->set_wait_cursor(true); pMyMainWnd->BeginWaitCursor(); // Test the connection parameters PGconn *pgconn = PQconnectdb(conn_str.GetString()); // Unset busy cursor pMyMainWnd->EndWaitCursor(); pMyMainWnd->set_wait_cursor(false); if (PQstatus(pgconn) == CONNECTION_OK) { write_log_pokertracker(1, "Test: PostgreSQL DB opened successfully <%s/%s/%s>\n", ip_addr, port, dbname); if (PQisthreadsafe()) { write_log_pokertracker(1, "Test: PostgreSQL library is thread safe.\n\n"); OH_MessageBox_Interactive("PostgreSQL DB opened successfully", "Success", MB_OK); } else { write_log_pokertracker(1, "Test: PostgreSQL library is *NOT* thread safe! This is a problem!\n\n"); OH_MessageBox_Interactive("PostgreSQL DB opened successfully, but\nPostgreSQL library is *NOT* thread safe!\nThis is a problem!", "Success (partial)", MB_OK); } PQfinish(pgconn); } else { write_log_pokertracker(1, "Test: ERROR opening PostgreSQL DB: %s\n\n", PQerrorMessage(pgconn)); e = "ERROR opening PostgreSQL DB:\n"; e += PQerrorMessage(pgconn); e += "\nConn string:"; e += conn_str; OH_MessageBox_Interactive(e.GetString(), "ERROR", MB_OK); PQfinish(pgconn); } }
void CChangePasswdDlg::OnBnClickedOk() { // TODO: Add your control notification handler code here CString cur_passwd, new_passwd, re_new_passwd; m_editCPW.GetWindowText(cur_passwd); if(cur_passwd.GetLength() <= 0) { AfxMessageBox("Please enter the current password!"); return; } m_editNewPW.GetWindowText(new_passwd); if(new_passwd.GetLength() <= 0) { AfxMessageBox("Please enter the new password!"); return; } m_editReNewPw.GetWindowText(re_new_passwd); if(re_new_passwd.GetLength() <= 0) { AfxMessageBox("Please re-enter the new password!"); return; } CMainFrame* frame = (CMainFrame*)AfxGetMainWnd(); CInquisitorDoc *pDoc = (CInquisitorDoc *)frame->GetActiveDocument(); if(cur_passwd != pDoc->passwd) { AfxMessageBox("The input of the current password is incorrect!"); return; } if(new_passwd != re_new_passwd) { AfxMessageBox("The new password does not match the re-typed one!"); return; } frame->BeginWaitCursor(); CString msg; int t = irodsWinChangePasswd(pDoc->conn, cur_passwd, new_passwd); if(t < 0) { CString msgHead = CString("Change Password error: "); pDoc->disp_err_msgbox(msgHead, t); } else { pDoc->passwd = new_passwd; msg = "Change Password succeeded."; frame->statusbar_msg(msg); AfxMessageBox(msg); } frame->EndWaitCursor(); OnOK(); }