home *** CD-ROM | disk | FTP | other *** search
- // QueryDlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "Biblio.h"
- #include "QueryDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CQueryDlg dialog
-
-
- CQueryDlg::CQueryDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CQueryDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CQueryDlg)
- m_strWhere = _T("");
- m_pSet = 0;
- //}}AFX_DATA_INIT
- }
-
-
- void CQueryDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CQueryDlg)
- DDX_Control(pDX, IDC_OPERATION, m_ctlOperation);
- DDX_Control(pDX, IDC_FIELDNAME, m_ctlFieldName);
- DDX_Control(pDX, IDC_WHERE, m_ctlWhere);
- DDX_Text(pDX, IDC_WHERE, m_strWhere);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CQueryDlg, CDialog)
- //{{AFX_MSG_MAP(CQueryDlg)
- ON_CBN_SELENDOK(IDC_FIELDNAME, OnSelendokFieldName)
- ON_CBN_SELENDOK(IDC_OPERATION, OnSelendokOperation)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CQueryDlg message handlers
-
- BOOL CQueryDlg::OnInitDialog()
- {
- ASSERT(m_pSet != 0);
- CDialog::OnInitDialog();
-
- // Load the recordset field names into the fieldname combobox
- int nFields = m_pSet->GetFieldCount();
- for(int i = 0; i < nFields; i++)
- {
- CDaoFieldInfo dfi;
- m_pSet->GetFieldInfo(i, dfi);
- m_ctlFieldName.AddString(dfi.m_strName);
- }
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void CQueryDlg::OnSelendokFieldName()
- {
- // The fieldname has changed. Update the WHERE clause.
- CString strField("[");
- CString strCurSel;
- int index = m_ctlFieldName.GetCurSel();
-
- if(-1 == index)
- return;
-
- m_ctlFieldName.GetLBText(index, strCurSel);
- strField += strCurSel;
- strField += "] ";
-
- m_ctlWhere.ReplaceSel(strField);
- }
-
-
- void CQueryDlg::OnSelendokOperation()
- {
- // The operation has set. Update the WHERE clause.
- CString strOperation(" ");
- CString strCurSel;
- int index = m_ctlOperation.GetCurSel();
-
- if(-1 == index)
- return;
-
- m_ctlOperation.GetLBText(index, strCurSel);
- strOperation += strCurSel;
- strOperation += " ";
-
- m_ctlWhere.ReplaceSel(strOperation);
- }
-