InfoLookDialog.cpp
资源名称:酒店管理系统源代码.rar [点击查看]
上传用户:czfddz
上传日期:2013-03-20
资源大小:1517k
文件大小:14k
源码类别:
酒店行业
开发平台:
C/C++
- // InfoLookDialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "qq.h"
- #include "InfoLookDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define AW_CENTER 0x00000010
- /////////////////////////////////////////////////////////////////////////////
- // CInfoLookDialog dialog
- CInfoLookDialog::CInfoLookDialog(CWnd* pParent /*=NULL*/)
- : CDialog(CInfoLookDialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CInfoLookDialog)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CInfoLookDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CInfoLookDialog)
- DDX_Control(pDX, IDC_EDIT_SHOWTEXT, m_EditTextShow);
- DDX_Control(pDX, IDC_LIST_CTRL_MODE,m_cTabListMode );
- DDX_Control(pDX, IDC_LIST_CTRL, m_cListCtrl);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CInfoLookDialog, CDialog)
- //{{AFX_MSG_MAP(CInfoLookDialog)
- ON_NOTIFY(TCN_SELCHANGE, IDC_LIST_CTRL_MODE, OnSelchangeListCtrlMode)
- ON_NOTIFY(NM_CLICK, IDC_LIST_CTRL, OnClickListCtrl)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CInfoLookDialog message handlers
- BOOL CInfoLookDialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- // Initial extended style for the list control on this dialog
- /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- 动态显示对话框
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
- this->CenterWindow();
- // HINSTANCE m_hInst=LoadLibrary("user32.dll");
- // typedef BOOL(WINAPI* LPANIMATEWND)(HWND,DWORD,DWORD);
- // LPANIMATEWND m_aniwnd=(LPANIMATEWND)GetProcAddress(m_hInst,"AnimateWindow");
- // m_aniwnd(this->GetSafeHwnd(),650,AW_CENTER);
- /*----------------------------------------------------------------*/
- DWORD dwStyle = m_cListCtrl.GetExtendedStyle();
- dwStyle |= LVS_EX_FULLROWSELECT;
- m_cListCtrl.SetExtendedStyle(dwStyle);
- m_cListCtrl.ModifyStyle(0, LVS_REPORT);
- // Setup the tab header
- InitTabCtrl();
- // Setup the column headings
- SetListCtrlColsNames(0);
- // Create the image list that is attached to the list control
- InitImageList();
- // Insert the default dummy items
- //set the edit text
- m_EditTextShow.SetWindowText("");
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CInfoLookDialog::InitTabCtrl()
- {//设置表头的名字
- m_cTabListMode.InsertItem(0, _T("客人"));
- m_cTabListMode.InsertItem(1, _T("房间"));
- m_cTabListMode.InsertItem(2, _T("帐单"));
- m_cTabListMode.InsertItem(3, _T("服务"));
- m_cTabListMode.InsertItem(4, _T("食物"));
- m_cTabListMode.InsertItem(5, _T("职员"));
- }
- void CInfoLookDialog::SetListCtrlColsNames(int nTabMode)
- {//根据不同的表头设置不同的标题
- // Insert some columns
- CRect rect;
- m_cListCtrl.GetClientRect(&rect);
- int nColInterval = rect.Width();//设置单位宽度
- CHeaderCtrl* pHdr=m_cListCtrl.GetHeaderCtrl();
- int n=pHdr->GetItemCount();
- switch(nTabMode)
- {
- case 0/*客人模式*/:
- m_cListCtrl.InsertColumn(0,_T("HandCode"),LVCFMT_LEFT,nColInterval/6+30);
- m_cListCtrl.InsertColumn(1,_T("Name"),LVCFMT_LEFT,nColInterval/6+10);
- m_cListCtrl.InsertColumn(2,_T("GuestType"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(3,_T("Sex"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(4,_T("Certificate"),LVCFMT_LEFT,nColInterval/6+5);
- m_cListCtrl.InsertColumn(5,_T("CertifyCode"),LVCFMT_LEFT,nColInterval/6+10);
- m_cListCtrl.InsertColumn(6,_T("IsMember"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(7,_T("IsMaster"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(8,_T("GroupID"),LVCFMT_LEFT,nColInterval/6+5);
- m_cListCtrl.InsertColumn(9,_T("GuestNum"),LVCFMT_LEFT,nColInterval/6+5);
- m_cListCtrl.InsertColumn(10,_T("RoomNum"),LVCFMT_LEFT,nColInterval/6+5);
- m_cListCtrl.InsertColumn(11,_T("RoomCode"),LVCFMT_LEFT,nColInterval/6+5);
- break;
- case 1:
- m_cListCtrl.InsertColumn(0,_T("RoomCode"),LVCFMT_LEFT,nColInterval/3);
- m_cListCtrl.InsertColumn(1,_T("RoomType"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(2,_T("Floor"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(3,_T("Phone"),LVCFMT_LEFT,nColInterval/3);
- m_cListCtrl.InsertColumn(4,_T("RoomStatus"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(5,_T("PriceType"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(6,_T("Price"),LVCFMT_LEFT,nColInterval/6);
- break;
- case 2:
- m_cListCtrl.InsertColumn(0,_T("帐单码"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(1,_T("手牌号码"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(2,_T("总数"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(3,_T("实付数"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(4,_T("折扣率"),LVCFMT_LEFT,nColInterval/6);
- m_cListCtrl.InsertColumn(5,_T("是/否已付"),LVCFMT_LEFT,nColInterval/6);
- break;
- case 3:
- m_cListCtrl.InsertColumn(0,_T("服务名称"),LVCFMT_LEFT,nColInterval/2);
- m_cListCtrl.InsertColumn(1,_T("服务价格"),LVCFMT_LEFT,nColInterval/2);
- break;
- case 4:
- m_cListCtrl.InsertColumn(0,_T("食物名称"),LVCFMT_LEFT,nColInterval/2);
- m_cListCtrl.InsertColumn(1,_T("食物价格"),LVCFMT_LEFT,nColInterval/2);
- break;
- case 5:
- m_cListCtrl.InsertColumn(0,_T("员工编号"),LVCFMT_LEFT,nColInterval/3);
- m_cListCtrl.InsertColumn(1,_T("员工名字"),LVCFMT_LEFT,nColInterval/3);
- m_cListCtrl.InsertColumn(2,_T("所属部们"),LVCFMT_LEFT,nColInterval/3);
- break;
- }
- }
- void CInfoLookDialog::InitImageList()
- {
- // Create 256 color image lists
- HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 |ILC_MASK , 8, 1);
- m_cImageListNormal.Attach(hList);
- hList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 1);
- m_cImageListSmall.Attach(hList);
- // Load the large icons
- CBitmap cBmp;
- cBmp.LoadBitmap(IDB_IMAGES_NORMAL);
- m_cImageListNormal.Add(&cBmp, RGB(255,0, 255));
- cBmp.DeleteObject();
- // Load the small icons
- cBmp.LoadBitmap(IDB_IMAGES_SMALL);
- m_cImageListSmall.Add(&cBmp, RGB(255,0, 255));
- // Attach them
- m_cListCtrl.SetImageList(&m_cImageListNormal, LVSIL_NORMAL);
- m_cListCtrl.SetImageList(&m_cImageListSmall, LVSIL_SMALL);
- }
- void CInfoLookDialog::InsertItems(int nTab)
- {//插入全部子项目
- //删除所有的项目
- m_cListCtrl.DeleteAllItems();//清空
- CString psztext[6][100][12];
- int i=0,j=0,k=0;
- for(i=0;i<6;i++)
- {
- for(j=0;j<100;j++)
- {
- for(k=0;k<12;k++)
- {
- psztext[i][j][k]=m_Page1.pszText[i][j][k];//拷贝字符
- }
- }
- }
- LVITEM lvi;
- //根据nTab的值画不同的项目表
- switch(nTab)
- {
- case 0://客人
- for(i=0;i<m_Page1.nTablesItems[0];i++)
- {
- //插入第一个头
- lvi.mask = LVIF_IMAGE | LVIF_TEXT;;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[0][i][0].GetBuffer(psztext[0][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<12;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText = psztext[0][i][j].GetBuffer(psztext[0][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- case 1://房间信息显示
- for(i=0;i<m_Page1.nTablesItems[1];i++)
- {
- //插入第一个头
- lvi.mask = LVIF_IMAGE | LVIF_TEXT;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[1][i][0].GetBuffer(psztext[1][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<7;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText = psztext[1][i][j].GetBuffer(psztext[1][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- case 2://帐单
- for(i=0;i<m_Page1.nTablesItems[2];i++)
- {
- //插入第一个头
- lvi.mask =LVIF_IMAGE | LVIF_TEXT;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[2][i][0].GetBuffer(psztext[2][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<6;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText = psztext[2][i][j].GetBuffer(psztext[2][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- case 3:
- for(i=0;i<m_Page1.nTablesItems[3];i++)
- {
- //插入第一个头
- lvi.mask =LVIF_IMAGE | LVIF_TEXT;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[3][i][0].GetBuffer(psztext[3][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<2;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText = psztext[3][i][j].GetBuffer(psztext[3][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- case 4:
- for(i=0;i<m_Page1.nTablesItems[4];i++)
- {
- //插入第一个头
- lvi.mask =LVIF_IMAGE | LVIF_TEXT;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[4][i][0].GetBuffer(psztext[4][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<2;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText = psztext[4][i][j].GetBuffer(psztext[4][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- case 5:
- for(i=0;i<m_Page1.nTablesItems[5];i++)
- {
- //插入第一个头
- lvi.mask =LVIF_IMAGE | LVIF_TEXT;
- lvi.iItem = i;
- lvi.iSubItem = 0;
- lvi.pszText = psztext[5][i][0].GetBuffer(psztext[5][i][0].GetLength());
- lvi.iImage = i%8; // There are 8 images in the image list
- m_cListCtrl.InsertItem(&lvi);
- for(j=1;j<3;j++)
- {//插入后面的项目
- lvi.iSubItem =j;
- lvi.pszText =psztext[5][i][j].GetBuffer(psztext[5][i][j].GetLength());
- m_cListCtrl.SetItem(&lvi);
- }
- }
- break;
- }
- }
- void CInfoLookDialog::OnSelchangeListCtrlMode(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- // Get the current data and don't redraw while we decide what to do.
- UpdateData(TRUE);
- m_cListCtrl.SetRedraw(FALSE);
- // Remove whatever style is there currently
- m_cListCtrl.ModifyStyle(0, LVS_REPORT);
- int i=0;
- // Switch the tab mode
- switch (m_cTabListMode.GetCurSel())//draw the listctrl there is a bug!!!!
- {
- case 0: // Guest
- SetListCtrlColsNames(0);
- InsertItems(0);
- break;
- case 1: // Room
- // ClearHeaderCtrl();
- SetListCtrlColsNames(1);
- InsertItems(1);
- break;
- case 2: // Bill
- SetListCtrlColsNames(2);
- InsertItems(2);
- break;
- case 3: // Server
- // ClearHeaderCtrl();
- SetListCtrlColsNames(3);
- InsertItems(3);
- break;
- case 4: // Food
- // ClearHeaderCtrl();
- SetListCtrlColsNames(4);
- InsertItems(4);
- break;
- case 5: // Employer
- // ClearHeaderCtrl();
- SetListCtrlColsNames(5);
- InsertItems(5);
- break;
- }
- // Fill the list control
- m_cListCtrl.SetRedraw(TRUE);
- *pResult = 0;
- }
- void CInfoLookDialog::OnOK()
- {
- // TODO: Add extra validation here
- CDialog::OnOK();
- }
- void CInfoLookDialog::OnCancel()
- {
- // TODO: Add extra cleanup here
- // SendMessage(WM_COMMAND,WM_SETPOS,0);
- // m_Page1.m_CoolProgress.SetPos(0);
- CDialog::OnCancel();
- }
- void CInfoLookDialog::OnClickListCtrl(NMHDR* pNMHDR, LRESULT* pResult)
- {//选择了listctrl中的一个项目
- // TODO: Add your control notification handler code here
- m_EditTextShow.SetWindowText("");//清空
- CRect rect;
- m_EditTextShow.GetClientRect(&rect);
- POSITION pos=m_cListCtrl.GetFirstSelectedItemPosition();
- while (pos)
- {
- int nSel=m_cListCtrl.GetNextSelectedItem(pos);
- CString str=_T("");
- int nMode=m_cTabListMode.GetCurSel();
- int i=0;
- //get the CHeaderCtrl pointer
- CHeaderCtrl* pHeader=(CHeaderCtrl*)m_cListCtrl.GetHeaderCtrl();
- HDITEM Hditem;
- TCHAR lpBuffer[256];
- Hditem.mask=HDI_TEXT;
- Hditem.pszText=lpBuffer;
- Hditem.cchTextMax=256;
- switch(nMode)
- {
- case 0://Guest
- for(i=0;i<12;i++)
- {//there is a bug!
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.GetScrollBarCtrl(SB_VERT)->SetScrollPos(0,TRUE);
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- // m_EditTextShow.ScrollWindow(0,-m_EditTextShow.GetScrollPos(SB_VERT),NULL,NULL);
- // m_EditTextShow.UpdateWindow();
- break;
- case 1://Room
- for(i=0;i<7;i++)
- {//there is a bug!打印出来的结果排列不整齐
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- break;
- case 2://Bill
- for(i=0;i<6;i++)
- {//there is a bug!
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- break;
- case 3://Server
- for(i=0;i<2;i++)
- {//there is a bug!
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- break;
- case 4://Food
- for(i=0;i<2;i++)
- {//there is a bug!
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- break;
- case 5://Employer
- for(i=0;i<3;i++)
- {//there is a bug!
- pHeader->GetItem(i,&Hditem);//get the header item
- str=lpBuffer;
- str+=":";
- // str=str+":t"+m_cListCtrl.GetItemText(nSel,i);
- m_EditTextShow.AppendString(str,m_cListCtrl.GetItemText(nSel,i),rect);
- }
- // m_EditTextShow.SetScrollPos(SB_VERT,0,TRUE);
- break;
- }
- }
- *pResult = 0;
- }