📄 recordsearch.cpp
字号:
// RecordSearch.cpp : implementation file
//
#include "stdafx.h"
#include "Cbsystem.h"
#include "RecordSearch.h"
#include "WriteRecord.h"
#include "WPower.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern void LvInsertData(LVITEM lvitem,CListCtrl *pList);
extern BOOL WhUpdateDB(LPWSTR lpsz,LPWSTR lpsz1);
/////////////////////////////////////////////////////////////////////////////
// CRecordSearch dialog
CRecordSearch::CRecordSearch(CWnd* pParent /*=NULL*/)
: CDialog(CRecordSearch::IDD, pParent)
{
//{{AFX_DATA_INIT(CRecordSearch)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CRecordSearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRecordSearch)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRecordSearch, CDialog)
//{{AFX_MSG_MAP(CRecordSearch)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecordSearch message handlers
void CRecordSearch::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
NM_LISTVIEW * phdn = (NM_LISTVIEW *)pNMHDR;
CListCtrl * pList;
int num = phdn->iItem;
pList = (CListCtrl *)GetDlgItem(IDC_LIST1);
CString s = pList->GetItemText(num,0);
CString s1 = pList->GetItemText(num,1);
CString s2 = pList->GetItemText(num,2);
CString s3 = pList->GetItemText(num,4);
CString s4 = pList->GetItemText(num,3);
//CWriteRecord * dlg = new CWriteRecord;
CWPower * dlg = new CWPower;
UpdateData(TRUE);
dlg->m_id = s1;
dlg->m_name = s2;
dlg->m_bh = s;
dlg->m_powerold = s4;
dlg->m_power=s3;
UpdateData(FALSE);
if(dlg->DoModal() == IDOK)
{
if(WhUpdateDB((LPWSTR)(LPCTSTR)dlg->m_bh,(LPWSTR)(LPCTSTR)dlg->m_power))
{
CString szPower;
pList->SetItemText(num, 4, (LPWSTR)(LPCTSTR)dlg->m_power);
szPower.Format(TEXT("本月用电量为 : %d [度]"),_wtol(dlg->m_power) - _wtol(s4));
/*if((_wtol(dlg->m_power) - _wtol(s4)) <= 0)
{
szPower += TEXT("[注意]:\n 此月电表过周或输入有误???");
AfxMessageBox(szPower);
}
else
AfxMessageBox(szPower);*/
}
else
{
AfxMessageBox(TEXT("更新数据库失败!!!"));
return;
}
}
else
{
return;
}
*pResult = 0;
}
BOOL CRecordSearch::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
pList1 = (CListCtrl *)GetDlgItem(IDC_LIST1);
pList1->SetExtendedStyle(LVS_EX_FULLROWSELECT);//|LVS_EX_GRIDLINES
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
lvc.iSubItem = 0;
lvc.pszText = TEXT("计量表号");
lvc.cx = 85;
pList1->InsertColumn(0,&lvc);
lvc.iSubItem = 1;
lvc.pszText = TEXT("用户名称");
lvc.cx = 80;
pList1->InsertColumn(1,&lvc);
lvc.iSubItem = 2;
lvc.pszText = TEXT("户号");
lvc.cx = 75;
pList1->InsertColumn(2,&lvc);
lvc.iSubItem = 3;
lvc.pszText = TEXT("上期抄见");
lvc.cx = 68;
pList1->InsertColumn(3,&lvc);
lvc.iSubItem = 4;
lvc.pszText = TEXT("本期抄见");
lvc.cx = 68;
pList1->InsertColumn(4,&lvc);
//**************************//
AfxGetApp()->BeginWaitCursor();
LvInsertData(lvitem,pList1);
AfxGetApp()->EndWaitCursor();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CRecordSearch::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::Create(IDD, pParentWnd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -