?? resourceinfo.cpp
字號:
// ResourceInfo.cpp : implementation file
//
#include "stdafx.h"
#include "train.h"
#include "ResourceInfo.h"
#include "ResourceSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResourceInfo dialog
CResourceInfo::CResourceInfo(CWnd* pParent /*=NULL*/)
: CDialog(CResourceInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CResourceInfo)
m_name = _T("");
m_price = 0.0;
m_quantity = 0;
m_notice = _T("");
//}}AFX_DATA_INIT
}
void CResourceInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResourceInfo)
DDX_Text(pDX, IDC_EDIT1, m_name);
DDX_Text(pDX, IDC_EDIT2, m_price);
DDX_Text(pDX, IDC_EDIT3, m_quantity);
DDX_Text(pDX, IDC_EDIT4, m_notice);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResourceInfo, CDialog)
//{{AFX_MSG_MAP(CResourceInfo)
ON_BN_CLICKED(IDC_BUTTONRESET, OnButtonreset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResourceInfo message handlers
void CResourceInfo::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString strSQL;
// CResourceSet m_recordset(&m_database);
int i=1;
int flag=0;
while(!flag){
CResourceSet m_recordset(&m_database);
strSQL.Format("select * from TM_RESOURCE where RESOURCE_ID=%d",i);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
if(m_recordset.GetRecordCount()==0){
strSQL.Format("insert into TM_RESOURCE values(%d,\'%s\',%d,%f,%d,\'%s\')",i,m_name,0,m_price,m_quantity,m_notice);
m_database.ExecuteSQL(strSQL);
m_database.Close();
CDialog::OnOK();
flag=1;
}
i++;
//m_recordset.Delete();
}
//這兒要加入查找最大主鍵的代碼,不知道怎么反復查詢
}
void CResourceInfo::OnCancel()
{
// TODO: Add extra cleanup here
m_database.Close();
CDialog::OnCancel();
}
void CResourceInfo::OnButtonreset()
{
// TODO: Add your control notification handler code here
m_name.Empty();
m_price=0;
m_quantity=0;
m_notice.Empty();
UpdateData(FALSE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -