ServerDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:3k
- // ServerDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "ServerDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CServerDlg dialog
- CServerDlg::CServerDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CServerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CServerDlg)
- //}}AFX_DATA_INIT
- }
- void CServerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CServerDlg)
- DDX_Control(pDX, IDC_COMBO1, m_name);
- DDX_Control(pDX, IDC_LIST1, m_list);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CServerDlg, CDialog)
- //{{AFX_MSG_MAP(CServerDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CServerDlg message handlers
- void CServerDlg::OnOK()
- {
- // TODO: Add extra validation here
- CString str,str0,str1,str2;
- m_name.GetWindowText(str);
- CDatabase dbTemp;
-
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- CRecordset rs( &dbTemp);
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 商品信息 where 商品名称='"+str+"'");
-
- rs.GetFieldValue((short)2,str0); //从商品信息表中读入商品信息
- rs.GetFieldValue((short)4,str1);
- rs.GetFieldValue((short)3,str2);
- rs.Close();
- /* m_list.InsertItem(0,str0); //显示到窗口上
- m_list.InsertItem(1,str1);
- m_list.InsertItem(2,str2);
- */
- m_list.InsertItem (0,str0);//写第一列;
- m_list.SetItemText (0,1,str1);//第二列;
- m_list.SetItemText (0,2,str2);//第三列;
- // CDialog::OnOK();
- }
- BOOL CServerDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- 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,80);
- m_list.InsertColumn(2,"产地",LVCFMT_LEFT,80);
-
- CString str;
- CDatabase dbTemp;
-
- 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)1,str);
- m_name.AddString(str);
- rs.MoveNext();
- }
- rs.Close();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }