📄 双星台球厅计时收费系统view.cpp
字号:
// 双星台球厅计时收费系统View.cpp : implementation of the CMyView class
//
#include "stdafx.h"
#include "双星台球厅计时收费系统.h"
#include "双星台球厅计时收费系统Doc.h"
#include "双星台球厅计时收费系统View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CFormView)
BEGIN_MESSAGE_MAP(CMyView, CFormView)
//{{AFX_MSG_MAP(CMyView)
ON_WM_PAINT()
ON_WM_TIMER()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo_ShowYear)
ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo_ShowMonth)
ON_CBN_SELCHANGE(IDC_COMBO3, OnSelchangeCombo_ShowData)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction
CMyView::CMyView()
: CFormView(CMyView::IDD)
{
//{{AFX_DATA_INIT(CMyView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CMyView::~CMyView()
{
}
void CMyView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyView)
DDX_Control(pDX, IDC_COMBO3, m_ShowData);
DDX_Control(pDX, IDC_COMBO2, m_ShowMonth);
DDX_Control(pDX, IDC_COMBO1, m_ShowYear);
DDX_Control(pDX, IDC_EDIT10, m_TongJi_YouHuiTimeLength);
DDX_Control(pDX, IDC_EDIT9, m_TongJi_YouHuiFeiYong);
DDX_Control(pDX, IDC_EDIT8, m_TongJi_ShiJiFeiYong);
DDX_Control(pDX, IDC_EDIT7, m_TongJi_FeiYong);
DDX_Control(pDX, IDC_EDIT6, m_TongJi_TimeLength);
DDX_Control(pDX, IDC_EDIT5, m_TongJi_Number);
DDX_Control(pDX, IDC_EDIT4, m_TaloeFeiYong);
DDX_Control(pDX, IDC_EDIT3, m_TimeLength);
DDX_Control(pDX, IDC_EDIT2, m_UnUserNumber);
DDX_Control(pDX, IDC_EDIT1, m_UserNumber);
DDX_Control(pDX, IDC_LIST2, m_TongJiInformation);
DDX_Control(pDX, IDC_LIST1, m_UserInformation);
//}}AFX_DATA_MAP
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CMyView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->OnMyViewIndex(this);
for(int i=0;i<=5;i++)
{
m_TongJiMarkCount[i]=0;
}
CTime m_Time;
CString str_T;
int m_61=m_Time.GetCurrentTime().GetYear();
int m_62=m_Time.GetCurrentTime().GetMonth();
int m_63=m_Time.GetCurrentTime().GetDay();
str_T.Format("%d",m_61);
m_ShowYear.AddString(str_T);
for(i=1;i<=31;i++)
{
str_T.Format("%d",i);
if(str_T.GetLength()==1)
{
str_T="0"+str_T;
}
if(i<=12)
{
m_ShowMonth.AddString(str_T);
}
m_ShowData.AddString(str_T);
}
m_ShowYear.SetCurSel(0);
m_ShowMonth.SetCurSel(m_62-1);
m_ShowData.SetCurSel(m_63-1);
m_UserInformation.InsertColumn(0,"桌号",LVCFMT_LEFT,40);
m_UserInformation.InsertColumn(1,"地理位置",LVCFMT_LEFT,120);
m_UserInformation.InsertColumn(2,"价格",LVCFMT_LEFT,80);
m_UserInformation.InsertColumn(3,"使用标志",LVCFMT_LEFT,75);
m_UserInformation.InsertColumn(4,"使用人",LVCFMT_LEFT,60);
m_UserInformation.InsertColumn(5,"使用日期",LVCFMT_LEFT,100);
m_UserInformation.InsertColumn(6,"开始时间",LVCFMT_LEFT,90);
m_UserInformation.InsertColumn(7,"使用时长",LVCFMT_LEFT,90);
m_UserInformation.InsertColumn(8,"当前计费金额",LVCFMT_LEFT,100);
m_UserInformation.InsertColumn(9,"备注",LVCFMT_LEFT,100);
CString str_1,str_2;
_variant_t var;
int m_MarkCount=0;
m_TongJiInformation.InsertColumn(0,"序号",LVCFMT_LEFT,40);
m_TongJiInformation.InsertColumn(1,"使用桌号",LVCFMT_LEFT,80);
m_TongJiInformation.InsertColumn(2,"使用人",LVCFMT_LEFT,80);
m_TongJiInformation.InsertColumn(3,"使用日期",LVCFMT_LEFT,90);
m_TongJiInformation.InsertColumn(4,"开始时间",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(5,"结束时间",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(6,"使用时长",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(7,"计算费用",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(8,"优惠时长",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(9,"优惠费用",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(10,"优惠后费用",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(11,"实际收费",LVCFMT_LEFT,100);
m_TongJiInformation.InsertColumn(12,"价格",LVCFMT_LEFT,100);
OnAddListCtrlExStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_MarkCount_1=FALSE;
m_SetTimeMark=SetTimer(1,1000,NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CMyView printing
BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CMyView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics
#ifdef _DEBUG
void CMyView::AssertValid() const
{
CFormView::AssertValid();
}
void CMyView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
void CMyView::OnPaint()
{
CPaintDC dc(this);
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
if(pFrame->ShowWindow(SW_SHOWMAXIMIZED)!=TRUE)
{
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
}
}
void CMyView::OnAddListCtrlExStyle(DWORD dwNewStyle)
{
DWORD dwStyle = ::SendMessage (m_UserInformation.m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
dwStyle |= dwNewStyle;
::SendMessage (m_UserInformation.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
dwStyle = ::SendMessage (m_TongJiInformation.m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
dwStyle |= dwNewStyle;
::SendMessage (m_TongJiInformation.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
}
void CMyView::OnTimer(UINT nIDEvent)
{
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
if(m_MarkCount_1==FALSE)
{
m_UserInformation.DeleteAllItems();
m_MarkCount_1=TRUE;
CString str_1,str_2;
_variant_t var;
int m_MarkCount=0;
try
{
pFrame->f_MyApp->m_pRecordset->Open("SELECT *FROM TaiQiuZheUserInformationRecond",
pFrame->f_MyApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(!pFrame->f_MyApp->m_pRecordset->BOF)
{
pFrame->f_MyApp->m_pRecordset->MoveFirst();
}
while(!pFrame->f_MyApp->m_pRecordset->adoEOF)
{
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserNumber");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.InsertItem(m_MarkCount,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserWeiZhi");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,1,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserJiaGe");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,2,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserMark");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,3,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserPeople");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,4,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserData");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,5,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("BeginTime");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,6,str_1);
}
var=pFrame->f_MyApp->m_pRecordset->GetCollect("Mark");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
m_UserInformation.SetItemText(m_MarkCount,9,str_1);
}
m_MarkCount++;
pFrame->f_MyApp->m_pRecordset->MoveNext();
}
pFrame->f_MyApp->m_pRecordset->Close();
}
catch(_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
On_AddOldDataToListShow(1);
}
_variant_t RecordsAffected;
pFrame->f_MyApp->m_pRecordset=pFrame->f_MyApp->m_pConnection->Execute("SELECT COUNT(*) FROM TaiQiuZheUserInformationRecond",
&RecordsAffected,adCmdText);
_variant_t vIndex=(long)0;
_variant_t vCount=pFrame->f_MyApp->m_pRecordset->GetCollect(vIndex);
pFrame->f_MyApp->m_pRecordset->Close();
CString str_10=(LPCSTR)_bstr_t(vCount);
int m_RecordCount=atoi(str_10);
int m_UserNumber_1=0;
int m_UserNumber_2=0;
int m_TimeLength_1=0;
double m_TatolFeiYong_1=0;
for(int i=1;i<=m_RecordCount;i++)
{
CTime m_Time;
CString str[4];
int m_1=m_Time.GetCurrentTime().GetHour();
int m_2=m_Time.GetCurrentTime().GetMinute();
int m_3=m_Time.GetCurrentTime().GetSecond();
int m_61=m_Time.GetCurrentTime().GetYear();
int m_62=m_Time.GetCurrentTime().GetMonth();
int m_63=m_Time.GetCurrentTime().GetDay();
char chrTemp[255] = {'\0'};
m_UserInformation.GetItemText(i-1,3,chrTemp,sizeof(char[255]));
CString str_20=chrTemp;
if(str_20=="正在使用")
{
m_UserNumber_1++;
m_UserInformation.GetItemText(i-1,5,chrTemp,sizeof(char[255]));
CString str_50=chrTemp;
str_50.Replace("-","");
CString str_51=str_50.Mid(0,4);
CString str_52=str_50.Mid(4,2);
CString str_53=str_50.Mid(6,2);
int m_51=atoi(str_51);
int m_52=atoi(str_52);
int m_53=atoi(str_53);
m_UserInformation.GetItemText(i-1,6,chrTemp,sizeof(char[255]));
CString str_1=chrTemp;
str_1.Replace(":","");
CString str_2=str_1.Mid(0,2);
CString str_3=str_1.Mid(2,2);
CString str_4=str_1.Mid(4,2);
int m_4=atoi(str_2);
int m_5=atoi(str_3);
int m_6=atoi(str_4);
int m_70,m_71,m_72,m_73;
int m_9;
if(m_52!=m_62)
{
if((m_52==1)||(m_52==3)||(m_52==5)||(m_52==7)||(m_52==8)||(m_52==10)||(m_52==12))
{
m_70=31-m_53;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -