예제 #1
0
BOOL CuDlgPropertyPageSqlWizardUpdate2::GetListColumns (CaDBObject* pTable, CStringList& listColumn)
{
	CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent();
	CTypedPtrList<CObList, CaDBObject*> listObject;
	ASSERT(pTable);
	if (!pTable)
		return FALSE;
	CaLLQueryInfo info(pParent->m_queryInfo);
	if (pTable->GetObjectID() == OBT_TABLE)
		info.SetObjectType(OBT_TABLECOLUMN);
	else
		info.SetObjectType(OBT_VIEWCOLUMN);
	info.SetItem2(pTable->GetName(), pTable->GetOwner());
	BOOL bOk = theApp.INGRESII_QueryObject (&info, listObject);
	if (!bOk)
		return FALSE;

	CString strItem;
	POSITION pos = listObject.GetHeadPosition();
	while (pos != NULL)
	{
		CaDBObject* pObj = listObject.GetNext(pos);

		strItem.Format (
			_T("%s.%s.%s"),
			(LPCTSTR)INGRESII_llQuoteIfNeeded(pTable->GetOwner()),
			(LPCTSTR)INGRESII_llQuoteIfNeeded(pTable->GetName()),
			(LPCTSTR)INGRESII_llQuoteIfNeeded(pObj->GetName()));
		listColumn.AddTail(strItem);
		delete pObj;
	}

	return TRUE;
}
예제 #2
0
BOOL CuDlgPropertyPageSqlWizardUpdate3::OnWizardFinish() 
{
	CWaitCursor doWaitCursor;
	int i, idx, nCount1, nCount2;
	CString strStatement; 
	CString strItem;
	CString strValue;

	m_cListCtrl.HideProperty (TRUE);
	CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent();
	CComboBox& comboTable      = pParent->m_PageUpdate1.m_cComboTable;
	CuListCtrlCheckBox& listTable  = pParent->m_PageUpdate2.m_cListTable;
	CuListCtrlCheckBox& listView   = pParent->m_PageUpdate2.m_cListView;
	CEdit& editCriteria        = pParent->m_PageUpdate2.m_cEditCriteria;
	idx = comboTable.GetCurSel();
	if (idx == CB_ERR)
	{
		pParent->SetStatement (NULL);
		return TRUE;
	}
	//
	// Check Values:
	nCount1 = m_cListCtrl.GetItemCount();
	for (i=0; i<nCount1; i++)
	{
		strValue = m_cListCtrl.GetItemText (i, CuEditableListCtrlSqlWizardUpdateValue::VALUE);
		strValue.TrimLeft();
		strValue.TrimRight();
		if (strValue.IsEmpty())
		{
			// _T("Not all the columns have values.\nDo you want to continue ?"); //UK IDS_A_COLUMNS_VALUE
			if (AfxMessageBox (IDS_MSG_COLUMNS_VALUE, MB_ICONEXCLAMATION|MB_OKCANCEL) == IDOK)
				break;
			else
			{
				return FALSE;
			}
		}
	}

	//
	// Generate: UPDATE x
	strStatement.Format (_T(" %s "), cstrUpdate);
	CaDBObject* pTable = (CaDBObject*)comboTable.GetItemData(idx);
	ASSERT(pTable);
	if(!pTable)
		return FALSE;
	if (pTable->GetOwner().IsEmpty())
		strStatement += INGRESII_llQuoteIfNeeded(pTable->GetName());
	else
	{
		strStatement += INGRESII_llQuoteIfNeeded(pTable->GetOwner());
		strStatement += _T(".");
		strStatement += INGRESII_llQuoteIfNeeded(pTable->GetName());
	}

	//
	// Generate: FROM a, b, c:
	BOOL bOne = TRUE;
	CString strListItem = _T("");
	nCount1 = listTable.GetItemCount();
	nCount2 = listView.GetItemCount();
	for (i=0; i<nCount1; i++)
	{
		if (listTable.GetItemChecked(i))
		{
			CaDBObject* pTable =(CaDBObject*)listTable.GetItemData(i);
			ASSERT(pTable);
			if (!pTable)
				continue;
			if (!bOne)
				strListItem += _T(", ");
			bOne = FALSE;
			if (pTable->GetOwner().IsEmpty())
				strListItem += INGRESII_llQuoteIfNeeded(pTable->GetName());
			else
			{
				strListItem += INGRESII_llQuoteIfNeeded(pTable->GetOwner());
				strListItem += _T(".");
				strListItem += INGRESII_llQuoteIfNeeded(pTable->GetName());
			}
		}
	}
	for (i=0; i<nCount2; i++)
	{
		if (listView.GetItemChecked(i))
		{
			CaDBObject* pView =(CaDBObject*)listView.GetItemData(i);
			ASSERT(pView);
			if (!pView)
				continue;
			if (!bOne)
				strListItem += _T(", ");
			bOne = FALSE;
			if (pView->GetOwner().IsEmpty())
				strListItem += INGRESII_llQuoteIfNeeded(pView->GetName());
			else
			{
				strListItem += INGRESII_llQuoteIfNeeded(pView->GetOwner());
				strListItem += _T(".");
				strListItem += INGRESII_llQuoteIfNeeded(pView->GetName());
			}

		}
	}
	if (!strListItem.IsEmpty())
	{
		strStatement += _T(" ");
		strStatement += cstrFrom;
		strStatement += _T(" ");
		strStatement += strListItem;
	}
	//
	// SET column = expr ...:
	strListItem = _T("");
	bOne = TRUE;
	nCount1 = m_cListCtrl.GetItemCount();
	for (i=0; i<nCount1; i++)
	{
		strItem  = m_cListCtrl.GetItemText (i, CuEditableListCtrlSqlWizardUpdateValue::COLUMN);
		strValue = m_cListCtrl.GetItemText (i, CuEditableListCtrlSqlWizardUpdateValue::VALUE);
		strValue.TrimLeft();
		strValue.TrimRight();
		if (strValue.IsEmpty())
			continue;
		if (!bOne)
			strListItem += _T(", ");
		bOne = FALSE;
		if (strListItem.IsEmpty())
		{
			strListItem += cstrSet;
			strListItem += _T(" ");
		}

		strListItem += INGRESII_llQuoteIfNeeded(strItem);
		strListItem += _T(" = ");
		strListItem += strValue;
	}
	if (strListItem.IsEmpty())
	{
		pParent->SetStatement (NULL);
		return TRUE;
	}
	strStatement += _T(" ");
	strStatement += strListItem;

	//
	// Generate the WHERE ...:
	editCriteria.GetWindowText (strItem);
	strItem.TrimLeft();
	strItem.TrimRight();
	if (!strItem.IsEmpty())
	{
		strStatement += _T(" ");
		strStatement += cstrWhere;
		strStatement += _T(" ");
		strStatement += strItem;
	}
	pParent->SetStatement (strStatement);

	return CPropertyPage::OnWizardFinish();
}