📄 opdlg.cpp
字号:
// OpDlg.cpp : implementation file
//
#include "stdafx.h"
#include "OrderDishsSys.h"
#include "OpDlg.h"
//
#include"afxtempl.h"
#include"Dish.h"
//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COpDlg dialog
//
extern CList<Dish,Dish&> MList;
extern Dish d;
COpDlg::COpDlg(CWnd* pParent /*=NULL*/)
: CDialog(COpDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COpDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void COpDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpDlg)
DDX_Control(pDX, IDC_LIST4, m_list4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COpDlg, CDialog)
//{{AFX_MSG_MAP(COpDlg)
ON_BN_CLICKED(ID_OADD, OnOadd)
ON_BN_CLICKED(ID_REFRESH, OnRefresh)
ON_BN_CLICKED(ID_OMOD, OnOmod)
ON_BN_CLICKED(ID_ODEL, OnOdel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COpDlg message handlers
BOOL COpDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_list4.SetExtendedStyle(0x21);
m_list4.SetBkColor(RGB(247,247,255));
m_list4.SetTextColor(RGB(0,0,255));
m_list4.SetTextBkColor(RGB(247,247,255));
m_list4.InsertColumn(0," 菜名",LVCFMT_CENTER,150);
m_list4.InsertColumn(1,"价格",LVCFMT_CENTER,115);
m_list4.InsertColumn(2,"数量",LVCFMT_CENTER,100);
List();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COpDlg::List()
{
m_list4.DeleteAllItems();
int k=0;
int nItem=0;
CString str;
POSITION pos = MList.GetHeadPosition();
for(int i=0;i<MList.GetCount();i++)
{
nItem=m_list4.InsertItem(0xffff,(LPCTSTR)(MList.GetAt(pos).GetName()),1);
str.Format(_T("%d"),MList.GetAt(pos).GetPrice());
m_list4.SetItemText(nItem,1,(LPCTSTR)(str));
str.Format(_T("%d"),MList.GetAt(pos).GetQuantity());
m_list4.SetItemText(nItem,2,(LPCTSTR)(str));
MList.GetNext(pos);
}
}
//
#include "Add.h"
void COpDlg::OnOadd()
{
// TODO: Add your control notification handler code here
CAdd dlg;
dlg.DoModal();
}
void COpDlg::OnRefresh()
{
// TODO: Add your control notification handler code here
List();
}
//
#include"ModCtrl.h"
void COpDlg::OnOmod()
{
// TODO: Add your control notification handler code here
POSITION pos = m_list4.GetFirstSelectedItemPosition();
CModCtrl dlg;
if(pos)
{
int nItem = m_list4.GetNextSelectedItem(pos);
dlg.m_modname=m_list4.GetItemText(nItem,0);
pos = MList.GetHeadPosition();
for(int i=0;i<MList.GetCount();i++)
{
if(dlg.m_modname==(MList.GetAt(pos).GetName()))
{
break;
}
MList.GetNext(pos);
}
dlg.pt=pos;
dlg.m_modprice=atoi(m_list4.GetItemText(nItem,1));
dlg.m_modshu=atoi(m_list4.GetItemText(nItem,2));
dlg.DoModal();
}
else
{
AfxMessageBox("请选择要修改的一行数据!");
}
}
//
#include"OpCtrl.h"
void COpDlg::OnOdel()
{
// TODO: Add your control notification handler code here
POSITION pos = m_list4.GetFirstSelectedItemPosition();
if(pos)
{
if(MessageBox("你确定要删除此记录吗?","警告",MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2)==IDYES)
{
int nItem = m_list4.GetNextSelectedItem(pos);
CString str1 =m_list4.GetItemText(nItem,0);
//AfxMessageBox(str1);
//int k=0;
COpCtrl ctrl;
ctrl.DelCtrl(str1,MList,d);
//MList.GetNext(pos);
}
}
else
{
AfxMessageBox("请选择要删除的一行数据!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -