⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chyudlg.cpp

📁 wince无线点菜软件,具备常规点菜的所有功能,可直接使用
💻 CPP
字号:
// chyuDlg.cpp : implementation file
//

#include "stdafx.h"
#include "chyu.h"
#include "chyuDlg.h"
#include "Denglu.h"
#include "Zhuantai.h"
#include "Bingtai.h"
#include "Kaitai.h"
#include "Mingxi.h"
#include "Weihu.h"
#include "database.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChyuDlg dialog

CChyuDlg::CChyuDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CChyuDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CChyuDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CChyuDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChyuDlg)
	DDX_Control(pDX, IDC_LIST_TAIWEI, m_list);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CChyuDlg, CDialog)
	//{{AFX_MSG_MAP(CChyuDlg)
	ON_BN_CLICKED(IDC_BUTTON_ZHUANTAI, OnButtonZhuantai)
	ON_BN_CLICKED(IDC_BUTTON_BINGTAI, OnButtonBingtai)
	ON_BN_CLICKED(IDC_BUTTON_DIANCAI, OnButtonDiancai)
	ON_BN_CLICKED(IDC_BUTTON_WEIHU, OnButtonWeihu)
	ON_BN_CLICKED(IDC_BUTTON_KAITAI, OnButtonKaitai)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChyuDlg message handlers

BOOL CChyuDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	HKEY hkey;
	WCHAR no[50];
	DWORD length=49;
	DWORD type=REG_BINARY;
	if (RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\chyu\\no",0,KEY_READ,&hkey)!=ERROR_SUCCESS)
	{
		MessageBox(L"您的软件没有经过软件厂商授权,请您及时跟软件厂商联系!");
		EndDialog(IDCANCEL);
		return TRUE;
	}
	if (RegQueryValueEx(hkey,L"no",0,&type,(BYTE *)no,&length)!=ERROR_SUCCESS)
	{
		MessageBox(L"您的软件没有经过软件厂商授权,请您及时跟软件厂商联系!");
		EndDialog(IDCANCEL);
		return TRUE;
	}
	RegCloseKey(hkey);

	HANDLE hFile;
	unsigned long len;
	int i;
	char number1[50],number2[50];
	DWORD filelen;

	hFile = CreateFile(L"system.dat", GENERIC_READ, FILE_SHARE_READ,
         NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile==NULL)
	{
		MessageBox(L"您的软件没有经过软件厂商授权,请您及时跟软件厂商联系!");
		EndDialog(IDCANCEL);
		return TRUE;
	}
	i=0;
	filelen=GetFileSize(hFile,NULL);
	while (1)
	{
		SetFilePointer(hFile,128,0,FILE_CURRENT);
		if (ReadFile(hFile,number1+i,1,&len,NULL)!=1) break;
		i++;
		if ((unsigned int)i*129>=filelen) break;
	}
	number1[i]=0;
	CloseHandle(hFile);
	WideCharToMultiByte(CP_ACP,0,no,-1,number2,49,NULL,NULL);
//swprintf(no,L"%d,%d,%d",strlen(number1),strlen(number2),filelen);
//MessageBox(no);
	if (strcmp(number1,number2)!=0)
	{
		MessageBox(L"您的软件没有经过软件厂商授权,请您及时跟软件厂商联系!");
		EndDialog(IDCANCEL);
		return TRUE;
	}
	CDenglu dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
		EndDialog(IDCANCEL);
	}
	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	m_list.InsertColumn(0,(LPCTSTR)TEXT("编号"),LVCFMT_LEFT,60,0);
	m_list.InsertColumn(1,(LPCTSTR)TEXT("台名"),LVCFMT_LEFT,120,1);
	m_list.InsertColumn(2,(LPCTSTR)TEXT("状态"),LVCFMT_LEFT,60,2);
	m_list.InsertColumn(3,(LPCTSTR)TEXT("楼层"),LVCFMT_LEFT,120,3);
	m_list.InsertColumn(4,(LPCTSTR)TEXT("流水号"),LVCFMT_LEFT,80,4);
	m_list.InsertColumn(5,(LPCTSTR)TEXT("时间"),LVCFMT_LEFT,140,5);
	UpData();
	//'ShellExecute(NULL,"close","osk.exe",NULL,NULL,0);   
	//SHSipPreference();
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CChyuDlg::OnButtonZhuantai() 
{
	CZhuantai dlg;
 	int nResponse = dlg.DoModal();
}

void CChyuDlg::OnButtonBingtai() 
{
	CBingtai dlg;
 	int nResponse = dlg.DoModal();
}

void CChyuDlg::OnButtonDiancai() 
{
	CMingxi dlg(this);
	CString str;
	POSITION pos= m_list.GetFirstSelectedItemPosition();
	if (pos==NULL) 
	{
		MessageBox(L"请先选择台位!");
		return;
	}
	int i=m_list.GetNextSelectedItem(pos);
	dlg.m_liushuihao=m_list.GetItemText(i,4);
	dlg.m_taihao=m_list.GetItemText(i,0);
	if (dlg.m_liushuihao.GetLength()==0)
	{
		MessageBox(L"请先开台!");
		return;
	}
	if (dlg.m_taihao.GetLength()==0)
	{
		MessageBox(L"开台号不能为空!");
		return;
	}
 	dlg.DoModal();
}

void CChyuDlg::OnButtonWeihu() 
{
	CWeihu dlg(this);
	CString str;
	POSITION pos= m_list.GetFirstSelectedItemPosition();
	int i=m_list.GetNextSelectedItem(pos);
	dlg.m_taiweibianhao=m_list.GetItemText(i,0);
	dlg.DoModal();
	UpData();
}

void CChyuDlg::UpData()
{
	char RecordBuf[257],*ptchar,field[257];
 	WCHAR wcCode[257];
	HANDLE hFile;
	int i,j;

	hFile = CreateFile(DB_TAIWEI, GENERIC_READ, FILE_SHARE_READ,
          NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 	if (hFile==INVALID_HANDLE_VALUE) return;
	i=0;
	m_list.DeleteAllItems();
 	while(fGetRecord(hFile,RecordBuf))
 	{
		m_list.InsertItem(LVIF_TEXT|LVIF_STATE, i, L"",0, LVIS_SELECTED,0,0);
		ptchar=RecordBuf;
		ptchar=fGetaField(ptchar,field);
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,0, wcCode);
		ptchar=fGetaField(ptchar,field);
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,1, wcCode);
		ptchar=fGetaField(ptchar,field);
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,2, wcCode);
		ptchar=fGetaField(ptchar,field);
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,3, wcCode);
		ptchar=fGetaField(ptchar,field);
		j=0;
		while(j<10)
		{
			if((unsigned char)field[j]==0xff) break;
			j++;
		}
		field[j]=0;
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,4, wcCode);
		ptchar=fGetaField(ptchar,field);
		j=0;
		while(j<20)
		{
			if((unsigned char)field[j]==0xff) break;
			j++;
		}
		field[j]=0;
 		MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
		m_list.SetItemText(i,5, wcCode);
		m_list.Update(i);
		i++;
 	}
	CloseHandle(hFile);
}

void CChyuDlg::OnButtonKaitai() 
{
	CKaitai dlg(this);
	POSITION pos= m_list.GetFirstSelectedItemPosition();
	if (pos==NULL) 
	{
		MessageBox(L"请先选择台位!");
		return;
	}
	int i=m_list.GetNextSelectedItem(pos);
	dlg.m_bianhao=m_list.GetItemText(i,0);
	dlg.m_taiming=m_list.GetItemText(i,1);
	dlg.m_louceng=m_list.GetItemText(i,3);
	dlg.DoModal();
	UpData();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -