📄 monthstorage.cpp
字号:
// MonthStorage.cpp : implementation file
//
#include "stdafx.h"
#include "ShopManage.h"
#include "MonthStorage.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;
/////////////////////////////////////////////////////////////////////////////
// MonthStorage dialog
MonthStorage::MonthStorage(CWnd* pParent /*=NULL*/)
: CDialog(MonthStorage::IDD, pParent)
{
//{{AFX_DATA_INIT(MonthStorage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void MonthStorage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MonthStorage)
DDX_Control(pDX, IDC_MSList, m_MSList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(MonthStorage, CDialog)
//{{AFX_MSG_MAP(MonthStorage)
ON_BN_CLICKED(IDC_MSquit, OnMSquit)
ON_BN_CLICKED(IDC_MSupdate, OnMSupdate)
ON_BN_CLICKED(IDC_MSdelete, OnMSdelete)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MonthStorage message handlers
void MonthStorage::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
BOOL MonthStorage::OnInitDialog()
{
CDialog::OnInitDialog();
m_MSList.ModifyStyle(LVS_EDITLABELS,0);
m_MSList.ModifyStyle(0,LVS_REPORT);
m_MSList.ModifyStyle(0,LVS_SHOWSELALWAYS);
m_MSList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_GRIDLINES|LVS_EX_ONECLICKACTIVATE|LVS_EX_FLATSB);
m_MSList.InsertColumn(0,"商品ID");
m_MSList.InsertColumn(1,"单价");
m_MSList.InsertColumn(2,"数量");
m_MSList.InsertColumn(3,"金额");
//设置列宽度
m_MSList.SetColumnWidth(0,100);
m_MSList.SetColumnWidth(1,100);
m_MSList.SetColumnWidth(2,100);
m_MSList.SetColumnWidth(3,100);
return TRUE;
}
void MonthStorage::OnMSquit()
{
// TODO: Add your control notification handler code here
EndDialog(0);
}
void MonthStorage::OnMSupdate()
{
// TODO: Add your control notification handler code here
CString sql,info[6];
sql.Format("select * from MonthStorage");
/*********************************************/
Record1->raw_Close();
Record1->Open((_variant_t)sql,DataConn.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
if(Record1->RecordCount > 0)
{
int row = 0;
m_MSList.DeleteAllItems();
while (!Record1->adoEOF)
{
m_MSList.InsertItem(100,"");
for (int col = 0;col <4;col++)
{
m_MSList.SetItemText(row,col,(TCHAR*)(_bstr_t)Record1->GetFields()->GetItem((long)col)->Value);
}
row += 1;
Record1->MoveNext();
}
}
}
void MonthStorage::OnMSdelete()
{
// TODO: Add your control notification handler code here
CString sql;
sql.Format("delete from MonthStorage");
try
{
Record1->raw_Close();
Record1->Open((_variant_t)sql,DataConn.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
this->MessageBox("操作成功","提示");
}
catch(_com_error& e)
{
MessageBox(e.ErrorMessage(),"提示");
}
}
void MonthStorage::OnClose()
{
// TODO: Add your message handler code here and/or call default
//CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -