void CuDlgPropertyPageSqlWizardInsert1::EnableWizardButtons() { CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); CString strItem; BOOL bEnable = FALSE; BOOL bManual = IsDlgButtonChecked (IDC_RADIO3); int i, nCount = m_cCheckListBoxColumn.GetCount(); for (i=0; i<nCount; i++) { if (m_cCheckListBoxColumn.GetCheck(i)) { m_cCheckListBoxColumn.GetText (i, strItem); if (strItem.CompareNoCase (m_strAll) != 0) { bEnable = TRUE; break; } } } if (bManual) { if (bEnable) pParent->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK); else pParent->SetWizardButtons(PSWIZB_BACK); } else pParent->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK); }
BOOL CuDlgPropertyPageSqlWizardUpdate1::OnSetActive() { CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); pParent->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK); EnableWizardButtons(); return CPropertyPage::OnSetActive(); }
void CuDlgPropertyPageSqlExpressionInParams::OnButton2Param() { int nAnswer = IDCANCEL; CxDlgPropertySheetSqlExpressionWizard* pParent = (CxDlgPropertySheetSqlExpressionWizard*)GetParent(); try { // // Select only mode: CxDlgPropertySheetSqlWizard sqlWizard (TRUE, this); sqlWizard.m_queryInfo = pParent->m_queryInfo; if (sqlWizard.DoModal() != IDCANCEL) { CString strStatement; sqlWizard.GetStatement (strStatement); strStatement.TrimLeft(); strStatement.TrimRight(); if (!strStatement.IsEmpty()) m_cParam1.ReplaceSel(strStatement, TRUE); } } catch (CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch(...) { // _T("Cannot initialize the SQL assistant."); AfxMessageBox (IDS_MSG_SQL_ASSISTANT, MB_ICONEXCLAMATION|MB_OK); } }
void CuDlgPropertyPageSqlWizardUpdate1::EnableWizardButtons() { CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); CString strItem; BOOL bEnable = FALSE; int i, nCount = m_cCheckListBoxColumn.GetCount(); // // Skip the first item: for (i=1; i<nCount; i++) { if (m_cCheckListBoxColumn.GetCheck(i)) { bEnable = TRUE; break; } } if (bEnable) pParent->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK); else pParent->SetWizardButtons(PSWIZB_BACK); }
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(); }
BOOL CuDlgPropertyPageSqlWizardUpdate3::OnSetActive() { CWaitCursor doWaitCursor; int i, idx, nCount; CString strItem; CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); pParent->SetWizardButtons(PSWIZB_FINISH|PSWIZB_BACK); CStringList& listStrColumn = pParent->m_PageUpdate2.m_listStrColumn; CuCheckListBox& checkListBox = pParent->m_PageUpdate1.m_cCheckListBoxColumn; m_cComboValues.ResetContent(); POSITION pos = listStrColumn.GetHeadPosition(); while (pos != NULL) { strItem = listStrColumn.GetNext (pos); m_cComboValues.AddString (strItem); } m_cComboValues.SetCurSel(0); // // Remove the columns in 'm_cListCtrl' that are not (checked) in 'checkListBox': nCount = m_cListCtrl.GetItemCount(); i = 0; while (i < nCount && nCount > 0) { strItem = m_cListCtrl.GetItemText (i, 0); idx = checkListBox.FindStringExact (-1, strItem); if (idx == LB_ERR || !checkListBox.GetCheck(idx)) { m_cListCtrl.DeleteItem (i); nCount = m_cListCtrl.GetItemCount(); continue; } i++; } CaColumn* lpData = NULL; // // Add the columns that are checked in 'checkListBox' but not in 'm_cListCtrl': LVFINDINFO lvfindinfo; idx = -1; memset (&lvfindinfo, 0, sizeof (LVFINDINFO)); lvfindinfo.flags = LVFI_STRING; nCount = checkListBox.GetCount(); for (i=0; i<nCount; i++) { lpData = (CaColumn*)checkListBox.GetItemData(i); if (checkListBox.GetCheck(i) && lpData) { checkListBox.GetText (i, strItem); lvfindinfo.psz = (LPCTSTR)strItem; if (m_cListCtrl.FindItem (&lvfindinfo) == -1) { idx = m_cListCtrl.GetItemCount(); m_cListCtrl.InsertItem (idx, strItem); m_cListCtrl.SetItemData (idx, (LPARAM)INGRESII_llIngresColumnType2AppType(lpData)); } } } EnableButtons(); return CPropertyPage::OnSetActive(); }
void CuDlgPropertyPageSqlWizardInsert1::OnRadioSubSelect() { CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); pParent->SetCategoryInsert2(FALSE); EnableWizardButtons(); }
void CuDlgPropertyPageSqlWizardInsert1::OnRadioManual() { CxDlgPropertySheetSqlWizard* pParent = (CxDlgPropertySheetSqlWizard*)GetParent(); pParent->SetCategoryInsert2(TRUE); EnableWizardButtons(); }