#include "stdafx.h" #include "AmountSettingHeadDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //#ifdef _WIN64 #include"TGAs.h" //#endif TGridSheetHead::TGridSheetHead() { AppendCol(_T("表列"), 60); AppendCol(_T("列宽"), 60); AppendCol(_T("显示"), 60); } void TGridSheetHead::OnCellComboString(WDGridCell&cell,CComboBox&combo) { if(cell.GetColIndex()==2) { combo.AddString(_T("显示")); combo.AddString(_T("不显示")); } } ///////////////////////////////////////////////////////////////////////////// // CAmountSettingHeadDlg dialog CAmountSettingHeadDlg::CAmountSettingHeadDlg(CWnd* pParent /*=NULL*/) : CDialog(CAmountSettingHeadDlg::IDD, pParent) { //{{AFX_DATA_INIT(CAmountSettingHeadDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CAmountSettingHeadDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAmountSettingHeadDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAmountSettingHeadDlg, CDialog) //{{AFX_MSG_MAP(CAmountSettingHeadDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAmountSettingHeadDlg message handlers BOOL CAmountSettingHeadDlg::OnInitDialog() { CDialog::OnInitDialog(); m_grid.Clear(); m_grid.Create(this, IDC_LIST_COL); m_grid.FitLastCol(); m_grid.SetNoAppendButton(); m_grid.SetNoDefaultMenu(); m_grid.SetColPosFix(); m_grid.SetColFixLength(); m_grid.SetNoPaste(); m_grid.GetCol(2).SetComboSel(); COLORREF color = RGB(255,0,0); m_grid.GetCol(1).SetTextColor(color); m_grid.GetCol(2).SetTextColor(color); ResetGrid(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CAmountSettingHeadDlg::ResetGrid() { m_lstHead.Reset(); CodeBase db; int Number; CString csType, csValue, csRemark; XString fullFile; if(!FindFile(_T("DataStore.dbf"), fullFile)) { Callme(_T("对不起,没有发现DataStore.dbf文件!")); return; } XDbfTable *pTable = db.Open(fullFile); if(!pTable) { Callme(_T("DataStore.dbf文件出错!")); return; } pTable->MoveFirst(); while(!pTable->IsEOF()) { GET_FIELD(pTable, _T("TypeNumber"), Number); GET_FIELD(pTable, _T("TypeName"), csType); GET_FIELD(pTable, _T("TypeValue"), csValue); GET_FIELD(pTable, _T("REMARK"), csRemark); if(Number == 43) { CBlockStruct *pData = new CBlockStruct(); pData->m_csDesName = csValue; pData->m_csRecord = csRemark; pData->m_csTKName = csType; m_lstHead.Append(pData); } pTable->MoveNext(); } m_grid.Clear(); int len = m_lstHead.Length(); for(int i=0;im_csTKName); m_grid.GetCell(i, 1).SetText(m_lstHead[i]->m_csDesName); if(m_lstHead[i]->m_csRecord == _T("1")) m_grid.GetCell(i, 2).SetText(_T("显示")); else m_grid.GetCell(i, 2).SetText(_T("不显示")); } } void CAmountSettingHeadDlg::OnOK() { XString fullFile; if(!FindFile(_T("DataStore.dbf"), fullFile)) { MessageBox(_T("对不起,没有发现DataStore.dbf文件!")); return; } CodeBase db; XDbfTable *pTable = db.Open(fullFile); if(!pTable) return; int Number; CString csType, csValue, csRemark; for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext()) { GET_FIELD(pTable, _T("TypeNumber"), Number); GET_FIELD(pTable, _T("TypeName"), csType); if(Number == 43) { for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()) { WDGridRow *pRow = m_grid.CurRow(); CString csName1 = (*pRow)[0].GetText().cs(); CString csName2 = (*pRow)[1].GetText().cs(); CString csName3 = (*pRow)[2].GetText().cs(); if(csType == csName1) { SET_FIELD(pTable, _T("TypeValue"), (const TCHAR*)csName2); if (csName3 == _T("显示")) { SET_FIELD(pTable, _T("REMARK"), _T("1")); } else { SET_FIELD(pTable, _T("REMARK"), _T("0")); } break; } } } } CDialog::OnOK(); }