📄 update.cpp
字号:
// Update.cpp : implementation file
//
#include "stdafx.h"
#include "Tele.h"
#include "Update.h"
#include "brow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Clipboard.h"
#include <stdlib.h>
/////////////////////////////////////////////////////////////////////////////
// CUpdate dialog
CUpdate::CUpdate(CWnd* pParent /*=NULL*/)
: CDialog(CUpdate::IDD, pParent)
{
m_pListCtrl = NULL;
//{{AFX_DATA_INIT(CUpdate)
m_strName = _T("");
m_strTele = _T("");
m_strRemarks = _T("");
m_strSignal = _T("");
m_strTest = _T("电话号码已复制内存中");
//}}AFX_DATA_INIT
m_bFlush = FALSE;
}
void CUpdate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUpdate)
DDX_Control(pDX, IDC_STATIC_REMARK, m_MyStatic);
DDX_Text(pDX, IDC_EDIT1, m_strName);
DDX_Text(pDX, IDC_EDIT2, m_strTele);
DDX_Text(pDX, IDC_EDIT3, m_strRemarks);
DDX_Text(pDX, IDC_EDIT4, m_strSignal);
DDX_Text(pDX, IDC_STATIC_REMARK, m_strTest);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUpdate, CDialog)
//{{AFX_MSG_MAP(CUpdate)
ON_BN_CLICKED(IDC_BUTTON_UPDATE, OnButtonUpdate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUpdate message handlers
void CUpdate::OnButtonUpdate()
{
UpdateData(TRUE);
if ( (strcmp(m_strName,"") == 0) || (strcmp(m_strTele,"") == 0) || (strcmp(m_strSignal,"") == 0) )
{
AfxMessageBox("信息不全");
return;
}
CBrow *pMainWnd = static_cast<CBrow*>
(reinterpret_cast<CTeleApp*>(AfxGetApp())->m_pMainWnd);
CString strTemp = pMainWnd->GetCurrentTime();
CString strSql
= "UPDATE telelist SET name = '"
+ m_strName +
"',tele ='"
+ m_strTele +
"',remarks='"
+ m_strRemarks +
"',[date]='"
+ strTemp +
"' WHERE ID ="
+ m_strSignal;
((static_cast<CTeleApp *>(AfxGetApp()))->g_pDb)->Execute(strSql);
pMainWnd->Select("SELECT * FROM telelist Order By [date] DESC");
pMainWnd->m_strSQL = strSql;
pMainWnd->UpdateData(FALSE);
AfxMessageBox("更新完毕");
}
BOOL CUpdate::OnInitDialog()
{
CDialog::OnInitDialog();
CADORecordset* pRs = new CADORecordset(CTeleApp::g_pDb);
CString TempSql;
char a[100];
CString strSql;
CString strA;
int iCounter;
if(pRs->Open( (LPCTSTR) ("SELECT * FROM telelist where ID =" + CBrow::g_strItem) ) )
pRs->GetFieldValue("name",m_strName);
pRs->GetFieldValue("tele",m_strTele);
pRs->GetFieldValue("remarks",m_strRemarks);
pRs->GetFieldValue("ID",m_strSignal);
pRs->GetFieldValue("recent",iCounter);
pRs->Close();
delete pRs;
UpdateData(FALSE);
GetDlgItem(IDC_EDIT2)->SetFocus();
UpdateData();
int nSize = m_strTele.GetLength();
char* buf = new char[nSize + 1];
strcpy (buf, m_strTele);
CClipboard::SetText(buf);
delete[] buf;
m_MyStatic.ResetBkColor(RGB(0,0,255));
m_MyStatic.ResetTxColor(RGB(255,255,255));
m_MyStatic.ResetFont(12,"Aerial");
m_bFlush=TRUE;
m_MyStatic.OnFlushing(m_bFlush,0);
/*
nLength=strCounter.GetLength();
temp=new char[nLength];
memcpy(temp,strCounter.GetBuffer(nLength), nLength);
nConvert = atoi(temp);
nConvert += 1;
itoa(nConvert, a, 10);
strA = a;
*/
iCounter += 1;
itoa(iCounter, a, 10);
strA = a;
strSql = "UPDATE telelist SET recent = " + strA;
strSql += " WHERE ID =" + m_strSignal;
((static_cast<CTeleApp *>(AfxGetApp()))->g_pDb)->Execute(strSql);
/*
CString strSql
= "UPDATE telelist SET name = '"
+ m_strName +
"',tele ='"
+ m_strTele +
"',remarks='"
+ m_strRemarks +
"' WHERE ID ="
+ m_strSignal;
((static_cast<CTeleApp *>(AfxGetApp()))->g_pDb)->Execute(strSql);
*/
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -