Exemplo n.º 1
0
void CuDlgPropertyPageSqlExpressionInParams::OnButton3Param() 
{
	CxDlgPropertySheetSqlExpressionWizard* pParent = (CxDlgPropertySheetSqlExpressionWizard*)GetParent();
	CxDlgPropertySheetSqlExpressionWizard wizdlg;
	wizdlg.m_queryInfo = pParent->m_queryInfo;
	wizdlg.m_nFamilyID    = FF_DATABASEOBJECTS;
	wizdlg.m_nAggType     = pParent->m_nAggType;
	wizdlg.m_nCompare     = pParent->m_nCompare;
	wizdlg.m_nIn_notIn    = pParent->m_nIn_notIn;
	wizdlg.m_nSub_List    = pParent->m_nSub_List;
	//
	// Initialize Tables or Views:
	POSITION pos = pParent->m_listObject.GetHeadPosition();
	try
	{
		while (pos != NULL)
		{
			CaDBObject* pObject = pParent->m_listObject.GetNext (pos);
			CaDBObject* pNewObject = new CaDBObject(*pObject);
			pNewObject->SetObjectID(pObject->GetObjectID());
			wizdlg.m_listObject.AddTail (pNewObject);
		}
		
		pos = pParent->m_listStrColumn.GetHeadPosition();
		while (pos != NULL)
		{
			CString strItem = pParent->m_listStrColumn.GetNext(pos);
			wizdlg.m_listStrColumn.AddTail (strItem);
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
		return;
	}
	catch(...)
	{
		// _T("Cannot initialize the SQL assistant.");
		AfxMessageBox (IDS_MSG_SQL_ASSISTANT, MB_ICONEXCLAMATION|MB_OK);
		return;
	}
	int nResult = wizdlg.DoModal();
	if (nResult == IDCANCEL)
		return;

	CString strStatement;
	wizdlg.GetStatement (strStatement);
	if (strStatement.IsEmpty())
		return;
	m_cParam3.ReplaceSel (strStatement);	
}
Exemplo n.º 2
0
void CuDlgPropertyPageSqlWizardUpdate2::OnButtonCriteria() 
{
	CWaitCursor doWaitCursor;
	CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent();
	CxDlgPropertySheetSqlExpressionWizard wizdlg;
	wizdlg.m_queryInfo = pParent->m_queryInfo;
	wizdlg.m_nFamilyID    = FF_PREDICATES;
	wizdlg.m_nAggType     = IDC_RADIO1;
	wizdlg.m_nCompare     = IDC_RADIO1;
	wizdlg.m_nIn_notIn    = IDC_RADIO1;
	wizdlg.m_nSub_List    = IDC_RADIO1;
	//
	// Initialize Tables or Views from the checked items:
	try
	{
		CString strItem;
		int i, nCount = m_cListTable.GetItemCount();
		for (i=0; i<nCount; i++)
		{
			if (m_cListTable.GetItemChecked(i))
			{
				CaDBObject* pObj = (CaDBObject*)m_cListTable.GetItemData (i);
				CaDBObject* pNewObject = new CaDBObject(*pObj);
				pNewObject->SetObjectID(OBT_TABLE);
				wizdlg.m_listObject.AddTail (pNewObject);
			}
		}
		nCount = m_cListView.GetItemCount();
		for (i=0; i<nCount; i++)
		{
			if (m_cListView.GetItemChecked(i))
			{
				CaDBObject* pObj = (CaDBObject*)m_cListView.GetItemData (i);
				CaDBObject* pNewObject = new CaDBObject(*pObj);
				pNewObject->SetObjectID(OBT_VIEW);
				wizdlg.m_listObject.AddTail (pNewObject);
			}
		}
		//
		// Append the current Table:
		CComboBox& comboTable = pParent->m_PageUpdate1.m_cComboTable;
		int nSel = comboTable.GetCurSel();
		if (nSel != CB_ERR)
		{
			CaDBObject* pObj = (CaDBObject*)comboTable.GetItemData (nSel);
			//
			// Check to see if the current table has already been added:
			BOOL b2Add = TRUE;
			POSITION pf = wizdlg.m_listObject.GetHeadPosition();
			while (pf != NULL)
			{
				CaDBObject* p = (CaDBObject*) wizdlg.m_listObject.GetNext (pf);
				if (p->GetName().CompareNoCase (pObj->GetName()) == 0 && p->GetOwner().CompareNoCase (pObj->GetOwner()) == 0)
				{
					b2Add = FALSE;
					break;
				}
			}
			if (b2Add)
			{
				CaDBObject* pNewObject = new CaDBObject(*pObj);
				if (pParent->m_PageUpdate1.IsDlgButtonChecked (IDC_RADIO1))
					pNewObject->SetObjectID(OBT_TABLE);
				else
					pNewObject->SetObjectID(OBT_VIEW);
				wizdlg.m_listObject.AddTail (pNewObject);
			}
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
		return;
	}
	catch (CeSqlException e)
	{
		AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK);
	}
	catch(...)
	{
		// _T("Cannot initialize the SQL assistant.");
		AfxMessageBox (IDS_MSG_SQL_ASSISTANT, MB_ICONEXCLAMATION|MB_OK);
		return;
	}
	int nResult = wizdlg.DoModal();
	if (nResult == IDCANCEL)
		return;

	CString strStatement;
	wizdlg.GetStatement (strStatement);
	if (strStatement.IsEmpty())
		return;
	m_cEditCriteria.ReplaceSel (strStatement);
}