CXTPReportRecord* CReportCtrl::TransferAddRecord(void) { ASSERT (m_pAddOpRecord != NULL); CXTPReportRecord *pRec = new CXTPReportRecord(); for (int i=0; i<m_nColCount; ++i) { const ColInfo &col = m_cols[i]; if (col.fmt != FmtIdOnly) { CXTPReportRecordItem *pItem = new CXTPReportRecordItem(); if (!col.check) { pItem->SetCaption(m_pAddOpRecord->GetItem(i)->GetCaption(NULL)); } else { pItem->SetEditable(col.editable); pItem->HasCheckbox(col.check); pItem->SetChecked(m_pAddOpRecord->GetItem(i)->IsChecked()); } pRec->AddItem(pItem); } } PutRecordAux(pRec); GetRecords()->InsertAt(m_pAddOpRecord->GetIndex(),pRec); ClearAddRecord(); Populate(); return pRec; }
void CMedic::RefreshReport( CMedicSet *pMedicSet ) { CMainFrame *p = (CMainFrame *)AfxGetMainWnd(); CXTPReportControl *pReport = p->m_wndReportCtrl; CXTPReportRecords *pRecords = pReport->GetRecords(); pRecords->RemoveAll(); CXTPReportRecord *pRecord; CXTPReportRecordItem *pItem; CString strPrice; while(!pMedicSet->IsEOF()) { pRecord = new CXTPReportRecord(); pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicID)); pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicName)); pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicType)); CTime ProduceData = pMedicSet->m_ProduceDate; pRecord->AddItem(new CXTPReportRecordItemText(ProduceData.Format(_T("%Y-%m-%d")))); if (0 == pMedicSet->m_MedicNumber) { pItem = pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_MedicNumber)); pItem->SetBackgroundColor(RGB(255,0,0)); } else pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_MedicNumber)); strPrice.Format("%.2f",pMedicSet->m_MedicPrice); pRecord->AddItem(new CXTPReportRecordItemText(strPrice)); pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_GuarantPeriod)); pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_ProduceCompany)); pReport->AddRecord(pRecord); pMedicSet->MoveNext(); } pReport->Populate(); }
void CSimpleReport::ColSetBold(int r, int c, BOOL x) { CXTPReportRecord* pRec = GetRecords()->GetAt(r); if (!pRec) return; CXTPReportRecordItem* p = pRec->GetItem(c); if (p) p->SetBold(x); }
CXTPReportRecordItem* CReportCtrl::NewButtonItem(int nIcon) { CXTPReportRecordItem *pItem = new CXTPReportRecordItem(); CXTPReportRecordItemControl* pButton = pItem->GetItemControls()->AddControl(xtpItemControlTypeButton); pButton->SetAlignment(xtpItemControlLeft); pButton->SetIconIndex(PBS_NORMAL, nIcon); pButton->SetIconIndex(PBS_PRESSED,nIcon); pButton->SetSize(CSize(OpColWidth, 0)); pItem->SetEditable(TRUE); return pItem; }
void CSimpleReport::ColReplace(int r, int c, const char* s) { CXTPReportRecord* pRec = GetRecords()->GetAt(r); if (!pRec) return; CXTPReportRecordItem* p = pRec->GetItem(c); if (p) p->SetCaption(s); }
void CXTPReportRecord::RemoveAll() { for (int nItem = GetItemCount() - 1; nItem >= 0; nItem--) { CXTPReportRecordItem* pItem = m_arrItems.GetAt(nItem); if (pItem) pItem->InternalRelease(); } m_arrItems.RemoveAll(); CMDTARGET_RELEASE(m_pPreviewItem); }
void CSimpleReport::ColSetColor(int r, int c, COLORREF fore, COLORREF back) { CXTPReportRecord* pRec = GetRecords()->GetAt(r); if (!pRec) return; CXTPReportRecordItem* p = pRec->GetItem(c); if (p) { p->SetBackgroundColor(back); p->SetTextColor(fore); } }
BOOL CReportCtrl::OnValueChanged(NMHDR* pNotifyStruct, LRESULT *pResult) { XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct; CXTPReportRecordItem *pItem = pItemNotify->pItem; CString str; if (GetInplaceList()->GetSafeHwnd() != NULL) return FALSE; else GetInplaceEdit()->GetWindowText(str); str.Trim(); switch (m_cols[pItem->GetIndex()].fmt) { case FmtStr: pItem->SetCaption(str); break; case FmtId: { int nId = _ttoi(str); if (nId > 0) { pItem->SetCaption(CNumericString(nId)); } else { AlertError(_T("请填入正确的数值")); return TRUE; } } break; case FmtIdStr: if (!str.IsEmpty()) { pItem->SetCaption(str); } else { AlertError(_T("字段不能为空,请重新输入")); return TRUE; } break; } return TRUE; }
CXTPReportRecordItem* CReportCtrl::RecordItemFromCol(const ColInfo &c,const _variant_t &v) { CXTPReportRecordItem *pItem = new CXTPReportRecordItem(); pItem->SetEditable(c.editable); if (!c.check) { pItem->SetCaption(CString(v)); } else { pItem->HasCheckbox(c.check); pItem->SetChecked((bool)v); } return pItem; }
void CReportCtrl::FillRecordset(_RecordsetPtr &rst,FillRecordAux funcAux) { if (rst != NULL) while (!rst->adoEOF) { FieldsPtr fields = rst->Fields; CXTPReportRecord *pRec = new CXTPReportRecord(); for (int i=0; i<m_nColCount; ++i) { if (m_cols[i].fmt ==FmtIdOnly) pRec->SetBookmark(fields->Item[m_cols[i].field]->Value); else pRec->AddItem(RecordItemFromCol(m_cols[i],fields->Item[m_cols[i].field]->Value)); } PutRecordAux(pRec); if (funcAux != NULL) funcAux(fields,pRec); AddRecord(pRec); rst->MoveNext(); } if (m_nOpFlag & OpAdd) { m_pAddOpRecord = new CXTPReportRecord(); for (int i=0; i<m_nColCount; ++i) { const ColInfo &col= m_cols[i]; if (m_cols[i].fmt != FmtIdOnly) { CXTPReportRecordItem *pItem = new CXTPReportRecordItem(); pItem->HasCheckbox(col.check); m_pAddOpRecord->AddItem(pItem); } } PutAddRecordAux(); AddRecord(m_pAddOpRecord); } Populate(); }
BOOL CXTPReportGroupRow::CalculateByChilds(CXTPReportRow* pPassedRow, int col_start, int col_end, double& dPassedValue) { BOOL bRet = FALSE; CXTPReportRow* pRow = NULL; CXTPReportRecord* pRec = NULL; CXTPReportRecordItem* pItem = NULL; for (int row = 0; row < pPassedRow->GetChilds(FALSE)->GetCount(); row++) { pRow = pPassedRow->GetChilds(FALSE)->GetAt(row); if (pRow && !pRow->IsGroupRow()) { pRec = pRow->GetRecord(); if (pRec) { bRet = TRUE; for (int col = col_start; col < col_end; col++) { if (col < pRec->GetItemCount()) { pItem = pRec->GetItem(col); if (pItem) { CString s = pItem->GetCaption(NULL); dPassedValue += pItem->StringToDouble(s); } } } } } else if (pRow && pRow->IsGroupRow()) { bRet = CalculateByChilds(pRow, col_start, col_end, dPassedValue); } } return bRet; }