📄 newrecord.cpp
字号:
// NewRecord.cpp : implementation file
//
#include "stdafx.h"
#include "ShopManage.h"
#include "NewRecord.h"
#include "DataManage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _RecordsetPtr Record1;
extern _ConnectionPtr DataConn;
extern _RecordsetPtr DataRecord;
extern _CommandPtr Com;
/////////////////////////////////////////////////////////////////////////////
// NewRecord dialog
NewRecord::NewRecord(CWnd* pParent /*=NULL*/)
: CDialog(NewRecord::IDD, pParent)
{
//{{AFX_DATA_INIT(NewRecord)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void NewRecord::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(NewRecord)
DDX_Control(pDX, IDC_Unit, m_Unit);
DDX_Control(pDX, IDC_Type, m_Type);
DDX_Control(pDX, IDC_Price, m_Price);
DDX_Control(pDX, IDC_Name, m_Name);
DDX_Control(pDX, IDC_LeastCount, m_LeastCount);
DDX_Control(pDX, IDC_Home, m_Home);
DDX_Control(pDX, IDC_GoodsID, m_GoodsID);
DDX_Control(pDX, IDC_Count, m_Count);
DDX_Control(pDX, IDC_AigoRate, m_AigoRate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(NewRecord, CDialog)
//{{AFX_MSG_MAP(NewRecord)
ON_BN_CLICKED(IDC_NewRecordclose, OnNewRecordclose)
ON_BN_CLICKED(IDC_Storage, OnStorage)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// NewRecord message handlers
void NewRecord::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void NewRecord::OnNewRecordclose()
{
// TODO: Add your control notification handler code here
EndDialog(0);
}
void NewRecord::OnStorage()
{
// TODO: Add your control notification handler code here
CString sql,info[10];
int Count,LeastCount;
float Price,AigoRate;
CDataManage dm;
/****************************************************/
m_GoodsID.GetWindowText(info[0]);
m_Name.GetWindowText(info[1]);
m_Type.GetWindowText(info[2]);
m_Home.GetWindowText(info[3]);
m_Unit.GetWindowText(info[4]);
m_Price.GetWindowText(info[5]);//price
m_AigoRate.GetWindowText(info[6]);//aigorate
m_Count.GetWindowText(info[7]);//count
m_LeastCount.GetWindowText(info[8]);//leastcount
/****************************************************/
if(info[0].GetLength() == 0)
{
MessageBox("请输入商品ID","提示");
return;
}
/*********************************************/
Price = (float)atof(info[5]);
AigoRate = (float)atof(info[6]);
Count = atoi(info[7]);
LeastCount = atoi(info[8]);
sql.Format("insert into Storage values('%s','%s','%s','%s','%s','%f','%f','%d','%d')",info[0],info[1],info[2],info[3],info[4],Price,AigoRate,Count,LeastCount);
try
{
dm.ConnectDataBase();
Record1->Open(_variant_t("Storage"),
_variant_t((IDispatch *)DataConn,true), adOpenKeyset,
adLockOptimistic, adCmdTable);
}
catch (_com_error& e)
{
MessageBox(e.ErrorMessage(),"提示");
}
try
{
dm.ExecSQL(sql);
//Record1->raw_Close();
//Record1->Open((_variant_t)sql,DataConn.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
MessageBox("操作成功","提示");
}
catch(_com_error & e)
{
MessageBox(e.ErrorMessage(),"提示");
}
/********************************************/
m_GoodsID.SetWindowText("");
m_Name.SetWindowText("");
m_Type.SetWindowText("");
m_Home.SetWindowText("");
m_Unit.SetWindowText("");
m_Price.SetWindowText("");
m_AigoRate.SetWindowText("");
m_Count.SetWindowText("");
m_LeastCount.SetWindowText("");
}
void NewRecord::OnClose()
{
// TODO: Add your message handler code here and/or call default
//CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -