home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 May / Disc 2 / PCU0503CD2.iso / Crystal / Samples / CPP / 32bit / Mycall / TABLELOG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-18  |  4.8 KB  |  188 lines

  1. // tablelog.cpp : implementation file
  2. //
  3.  
  4.  
  5. #include "stdafx.h"
  6. //#include "crpeplus.h"
  7. #include "mycall.h"
  8. #include "tablelog.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CTableLogon dialog
  17.  
  18.  
  19. CTableLogon::CTableLogon(CWnd* pParent /*=NULL*/)
  20.     : CDialog(CTableLogon::IDD, pParent)
  21. {
  22.     //{{AFX_DATA_INIT(CTableLogon)
  23.     m_Propagate = FALSE;
  24.     m_TDatabaseName = _T("");
  25.     m_TUserID = _T("");
  26.     m_TPassword = _T("");
  27.     m_TServerName = _T("");
  28.     //}}AFX_DATA_INIT
  29.  
  30.  
  31.  
  32. }
  33.  
  34. CTableLogon::CTableLogon(CMYCALLDoc* myCallDoc, CWnd* pParent) 
  35. : CDialog(CTableLogon::IDD, pParent)
  36. {
  37.     m_Propagate = FALSE;
  38.     m_TDatabaseName = _T("");
  39.     m_TUserID = _T("");
  40.     m_TPassword = _T("");
  41.     m_TServerName = _T("");
  42.     m_myCallDoc = myCallDoc;
  43. }
  44.  
  45. void CTableLogon::DoDataExchange(CDataExchange* pDX)
  46. {
  47.     CDialog::DoDataExchange(pDX);
  48.     //{{AFX_DATA_MAP(CTableLogon)
  49.     DDX_Control(pDX, ID_SETLOGON, m_SetLogon);
  50.     DDX_Check(pDX, IDC_PROPAGATE, m_Propagate);
  51.     DDX_Text(pDX, IDC_EDIT2, m_TDatabaseName);
  52.     DDV_MaxChars(pDX, m_TDatabaseName, 128);
  53.     DDX_Text(pDX, IDC_EDIT3, m_TUserID);
  54.     DDV_MaxChars(pDX, m_TUserID, 128);
  55.     DDX_Text(pDX, IDC_EDIT4, m_TPassword);
  56.     DDV_MaxChars(pDX, m_TPassword, 128);
  57.     DDX_Text(pDX, IDC_EDIT1, m_TServerName);
  58.     DDV_MaxChars(pDX, m_TServerName, 128);
  59.     //}}AFX_DATA_MAP
  60. }
  61.  
  62.  
  63. BEGIN_MESSAGE_MAP(CTableLogon, CDialog)
  64.     //{{AFX_MSG_MAP(CTableLogon)
  65.     ON_CBN_DROPDOWN(IDC_Tables, OnDropdownTables)
  66.     ON_CBN_SELCHANGE(IDC_Tables, OnSelchangeTables)
  67.     ON_BN_CLICKED(ID_SETLOGON, OnSetTableLogon)
  68.     ON_BN_CLICKED(IDC_TEST, OnTestLogon)
  69.     //}}AFX_MSG_MAP
  70. END_MESSAGE_MAP()
  71.  
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CTableLogon message handlers
  75.  
  76.  
  77. void CTableLogon::UpdateTableInfo(int ntable, int updatetext ) 
  78. {
  79.     CRPELogOnInfo logoninfo;
  80.  
  81.     CEdit *SName1, *SName2, *SName3;
  82.  
  83.     if (m_myCallDoc->m_crpeJob->GetNthTableLogonInfo(ntable, &logoninfo))
  84.     {
  85.         m_TServerName = logoninfo.m_serverName;
  86.         m_TDatabaseName = logoninfo.m_databaseName;
  87.         m_TUserID = logoninfo.m_userID;
  88.  
  89.         /* do you need to send messag */
  90.         if (updatetext)
  91.         {
  92.             SName1 = (CEdit *) GetDlgItem(IDC_EDIT1);
  93.             SName1->SetWindowText(logoninfo.m_serverName);
  94.             SName2 = (CEdit *) GetDlgItem(IDC_EDIT2);
  95.             SName2->SetWindowText(logoninfo.m_databaseName);
  96.             SName3 = (CEdit *) GetDlgItem(IDC_EDIT3);
  97.             SName3->SetWindowText(logoninfo.m_userID);
  98.         }
  99.     }
  100.     else
  101.     m_myCallDoc->m_statusString = "PE Error: " + m_myCallDoc->m_crpeJob->GetErrorText();
  102.          
  103. }
  104.  
  105. BOOL CTableLogon::OnInitDialog()
  106. {
  107.  
  108.     CDialog::OnInitDialog();
  109.  
  110.     pCombo = (CComboBox *) GetDlgItem(IDC_Tables);
  111.     short nTables;
  112.     if (nTables = m_myCallDoc->m_crpeJob->GetNTables())
  113.     {
  114.         int nIndex;
  115.         CRPETableLocation tableLocation;
  116.            for (int i = 0; i < nTables; i++)
  117.         {
  118.  
  119.             if (m_myCallDoc->m_crpeJob->GetNthTableLocation(i, &tableLocation)) 
  120.             {
  121.                 nIndex = pCombo->AddString (tableLocation.m_location);
  122.                 if (nIndex != CB_ERR)
  123.                     pCombo->SetItemData(nIndex, i);
  124.             }
  125.             else
  126.                 m_myCallDoc->m_statusString = "PE Error: " + m_myCallDoc->m_crpeJob->GetErrorText();
  127.  
  128.         }
  129.         //select the first one
  130.            pCombo->SetCurSel (0);
  131.     } 
  132.     else 
  133.         m_myCallDoc->m_statusString = "PE Error: " + m_myCallDoc->m_crpeJob->GetErrorText();
  134.  
  135.     
  136.     return TRUE;  // return TRUE unless you set the focus to a control
  137.                   // EXCEPTION: OCX Property Pages should return FALSE
  138. }
  139.  
  140. void CTableLogon::OnDropdownTables() 
  141. {
  142.     // TODO: Add your control notification handler code here
  143.     
  144. }
  145.  
  146. int CTableLogon::DoModal() 
  147. {
  148.     // TODO: Add your specialized code here and/or call the base class
  149.     
  150.     UpdateTableInfo(0,0);
  151.     return CDialog::DoModal();
  152. }
  153.  
  154. void CTableLogon::OnSelchangeTables() 
  155. {
  156.     // TODO: Add your control notification handler code here
  157.     UpdateTableInfo(pCombo->GetCurSel(),1);
  158.  
  159. }
  160.  
  161. void CTableLogon::OnSetTableLogon() 
  162. {
  163.     // TODO: Add your control notification handler code here
  164.     UpdateData(TRUE);
  165.     
  166.     CRPELogOnInfo tablelogoninfo;
  167.     strcpy(tablelogoninfo.m_serverName, m_TServerName);
  168.     strcpy(tablelogoninfo.m_databaseName, m_TDatabaseName);
  169.     strcpy(tablelogoninfo.m_userID, m_TUserID);
  170.     strcpy(tablelogoninfo.m_password, m_TPassword);
  171.  
  172.     if (!m_myCallDoc->m_crpeJob->SetNthTableLogonInfo(pCombo->GetCurSel(),&tablelogoninfo, m_Propagate)) 
  173.         m_myCallDoc->m_statusString = "PE Error: " + m_myCallDoc->m_crpeJob->GetErrorText();
  174.     else
  175.         m_myCallDoc->m_statusString = "Table Logon Set";
  176. }
  177.  
  178. void CTableLogon::OnTestLogon() 
  179. {
  180.     // TODO: Add your control notification handler code here
  181.     
  182.     if (!m_myCallDoc->m_crpeJob->TestNthTableConnectivity(pCombo->GetCurSel()))
  183.         AfxMessageBox("Logon Info is Incorrect");
  184.     else
  185.         AfxMessageBox("Table Logon Info is Correct");
  186.     
  187. }
  188.