}
{ }
if (rs.GetRecordCount() > 0) { } else { }
AfxMessageBox(_T(\用户表为空!\)); CString strUsername; CString strPassword;
rs.GetCollect(_T(\), strUsername); rs.GetCollect(_T(\), strPassword); if (strUsername.Compare(m_strUsername) == 0) { } else { }
AfxMessageBox(_T(\用户名错误!\));
if (strPassword.Compare(m_strPassword) == 0) { } else { }
AfxMessageBox(_T(\密码错误!\)); EndDialog(TRUE);
主界面
面板
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// 添加搜索主面板
bNameValid = strTemp.LoadString(IDS_RIBBON_SEARCH); ASSERT(bNameValid);
CMFCRibbonCategory* pSearchCategory = m_wndRibbonBar.AddCategory(strTemp, IDB_WRITESMALL, // 利用面板工厂创建条目面板
m_pEntryPanel = new CEntryPanel(IDS_RIBBON_ENTRY, managerFactory); // 初始化面板内容
m_pEntryPanel->InitializeContainer(); // 利用面板工厂创建类别面板
m_pClassPanel = new CClassPanel(IDS_RIBBON_CLASS, managerFactory); // 初始化面板内容
m_pClassPanel->InitializeContainer(); // 面板工厂(管理)
CPanelFactory managerFactory(pManagerCategory); // 添加管理主面板
bNameValid = strTemp.LoadString(IDS_RIBBON_MANAGER); ASSERT(bNameValid);
CMFCRibbonCategory* pManagerCategory = m_wndRibbonBar.AddCategory(strTemp, IDB_WRITESMALL,
IDB_WRITELARGE);
IDB_WRITELARGE);
////////////////////////////////////////////////////////////////////////////////////
// 添加统计主面板
bNameValid = strTemp.LoadString(IDS_RIBBON_STAT); ASSERT(bNameValid);
CMFCRibbonCategory* pStatCategory = m_wndRibbonBar.AddCategory(strTemp, IDB_WRITESMALL, // 利用面板工厂创建搜索面板
m_pSearchPanel = new CSearchPanel(IDS_RIBBON_SEARCH, searchFactory); // 初始化面板内容
m_pSearchPanel->InitializeContainer(); // 面板工厂(搜索)
CPanelFactory searchFactory(pSearchCategory);
IDB_WRITELARGE);
// 利用面板工厂创建统计面板
m_pStatPanel = new CStatPanel(IDS_RIBBON_STAT, statFactory); // 初始化面板内容
m_pStatPanel->InitializeContainer(); // 面板工厂(统计)
CPanelFactory statFactory(pStatCategory);
列表视图
void CEntryGrid::OnInitialUpdate() {
CAdoRecordSet rs; CString strSQL;
strSQL = _T(\条目编号, e_tag AS 条目名称, e_class AS 消费类型, e_price AS // TODO: 在此添加专用代码和/或调用基类 // 设定列表样式
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE); dwStyle |= LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL; ::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle); dwStyle = m_listCtrl.GetExtendedStyle();
dwStyle |= LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT; m_listCtrl.SetExtendedStyle(dwStyle); CListView::OnInitialUpdate();
单价, e_quantity AS 数量, e_date AS 购买时间, e_description AS 备注FROM entry\);
}
CPayoutManagerApp::OpenRecordSet(rs, strSQL + _T(\), adCmdText); long colCount = rs.GetFieldsCount(); // 插入列名
for (long i = 0; i < colCount; i++) { }
ListData(&rs);
CString columnName = rs.GetFieldName(i);
m_listCtrl.InsertColumn((int)i, columnName, 0, 100);
void CEntryGrid::ListData(CAdoRecordSet* pRs) {
BOOL bCreated(FALSE); if (pRs == NULL) {
bCreated = TRUE;
pRs = new CAdoRecordSet(); CString strSQL;
strSQL = _T(\条目编号, e_tag AS 条目名称, e_class AS 消费类型, e_price
AS 单价, e_quantity AS 数量, e_date AS 购买时间, e_description AS 备注FROM entry\);
for (long i = 0; i < rowCount; i++) {
CString item; long j = 0; // 插入条目编号
pRs->GetCollect(j, item); m_listCtrl.InsertItem(i, item); // 插入内容
for (j = 1; j < colCount; j++) {
if (j == (colCount - 2)) {
COleDateTime dtDate;
pRs->GetCollect(_T(\购买时间\), dtDate); item = dtDate.Format(_T(\));
}
m_listCtrl.DeleteAllItems();
long colCount = pRs->GetFieldsCount(); long rowCount = pRs->GetRecordCount(); m_listCtrl.SetColumnWidth(colCount - 1, 200); pRs->MoveFirst();
CPayoutManagerApp::OpenRecordSet(*pRs, strSQL + _T(\), adCmdText);
}
}
}
} else { }
m_listCtrl.SetItemText(i, j, item);
pRs->GetCollect(j, item);
pRs->MoveNext();
if (bCreated == TRUE) { }
delete pRs;
管理面板
void CEntryPanel::OnClickedBnAdd(void) {
UpdateData();
CEntry entry(m_strNo, m_strTag, m_strClass, m_strPrice, m_strQuantity, m_strDate,
m_strDescription); }
void CEntryPanel::OnClickedBnMod(void) {
UpdateData(); CEntry entry; MakeEntry(entry); if (entry.Add()) { } else { }
AfxMessageBox(_T(\添加失败\)); AfxMessageBox(_T(\添加成功\)); NotifyOthersToUpdate();