?? creatplandlg.cpp
字號:
// CreatPlanDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SuperMarket.h"
#include "CreatPlanDlg.h"
#include "afxdb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreatPlanDlg dialog
CCreatPlanDlg::CCreatPlanDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCreatPlanDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCreatPlanDlg)
m_momey = 0.0f;
m_spcount = 0;
m_spnumber =_T("");
//}}AFX_DATA_INIT
}
void CCreatPlanDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCreatPlanDlg)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Text(pDX, IDC_momey, m_momey);
DDX_Text(pDX, IDC_SPCOUNT, m_spcount);
DDX_Text(pDX, IDC_SPNUMBER, m_spnumber);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCreatPlanDlg, CDialog)
//{{AFX_MSG_MAP(CCreatPlanDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreatPlanDlg message handlers
void CCreatPlanDlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_spnumber=="")
{
MessageBox("請輸入商品編號!");
}
else
{
CString str0,str1,str2,str3,str4,strSQL;
CDatabase dbTemp;
float totol=0;
dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理數(shù)據(jù)庫.mdb;");
CRecordset rs( &dbTemp);
rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 商品信息表 where 商品編號='"+m_spnumber+"'");
if (!rs.IsEOF())
{
rs.GetFieldValue((short)0,str0); //從商品信息表中讀入商品信息
rs.GetFieldValue((short)1,str1);
rs.GetFieldValue((short)2,str2);
rs.GetFieldValue((short)4,str4);
}
else
{
MessageBox("商品不存在,請確認(rèn)后從新輸入!");
m_spnumber="";
UpdateData(false);
}
rs.Close();
price = atof(str2);
totol=price*m_spcount;
total=total+totol;
str4.Format("%f",totol);
str3.Format("%d",m_spcount); //顯示到窗口
m_list.InsertItem (add_time,str0);//寫第一列;
m_list.SetItemText (add_time,1,str1);//第二列;
m_list.SetItemText (add_time,2,str2);//第三列;
m_list.SetItemText (add_time,3,str3);//第四列;
m_list.SetItemText (add_time,4,str4);//第四列;
add_time = add_time + 1;
UpdateData(false);
m_spnumber;
}
}
BOOL CCreatPlanDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CTime temptime;
m_time = temptime.GetCurrentTime();
UpdateData(false);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
// m_list.SetExtendedStyle(LVS_EX_GRIDLINES);
m_list.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_ONECLICKACTIVATE);
m_list.InsertColumn(0,"編號",LVCFMT_LEFT,80);
m_list.InsertColumn(1,"名稱",LVCFMT_LEFT,145);
m_list.InsertColumn(2,"價格",LVCFMT_LEFT,80);
m_list.InsertColumn(3,"數(shù)量",LVCFMT_LEFT,100);
m_list.InsertColumn(4,"總額",LVCFMT_LEFT,100);
UpdateData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -