OosSearchDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:3k
- // OosSearchDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "OosSearchDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COosSearchDlg dialog
- COosSearchDlg::COosSearchDlg(CWnd* pParent /*=NULL*/)
- : CDialog(COosSearchDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(COosSearchDlg)
- m_count = 0;
- //}}AFX_DATA_INIT
- }
- void COosSearchDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(COosSearchDlg)
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Text(pDX, IDC_EDIT1, m_count);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(COosSearchDlg, CDialog)
- //{{AFX_MSG_MAP(COosSearchDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COosSearchDlg message handlers
- void COosSearchDlg::OnOK() //缺货查询
- {
- // TODO: Add extra validation here
-
- // CDialog::OnOK();
- m_list.DeleteAllItems();
- UpdateData();
- CDatabase dbTemp;
- CString str0,str1,str2,str3,str4;
- int count,times=0;
-
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- CRecordset rs( &dbTemp); //查询
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 商品信息");
- while(!rs.IsEOF())
- {
- rs.GetFieldValue((short)0,str0);
- rs.GetFieldValue((short)1,str1);
- rs.GetFieldValue((short)2,str2);
- rs.GetFieldValue((short)3,str3);
- rs.GetFieldValue((short)4,str4);
- count=atoi(str4);
- if(count<=m_count)
- {
- /*m_list.InsertItem(0,str0);
- m_list.InsertItem(1,str1);
- m_list.InsertItem(2,str4);
- m_list.InsertItem(3,str3);
- m_list.InsertItem(4,str2);
- */
- m_list.InsertItem (times,str0);//写第一列;
- m_list.SetItemText (times,1,str1);//第二列;
- m_list.SetItemText (times,2,str4);//第三列;
- m_list.SetItemText (times,3,str3);//第四列;
- m_list.SetItemText (times,4,str2);//第四列;
-
- times = times + 1;
-
- }
- rs.MoveNext();
- }
-
- }
- BOOL COosSearchDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- 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,110);
- m_list.InsertColumn(2,"商品数量",LVCFMT_LEFT,80);
- m_list.InsertColumn(3,"商品产地",LVCFMT_LEFT,120);
- m_list.InsertColumn(4,"商品单价",LVCFMT_LEFT,80);
- // TODO: Add extra initialization here
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }