📄 winfeeview.cpp
字号:
// WinFeeView.cpp : implementation file
//
#include "stdafx.h"
#include "PressManagerDoc.h"
#include "WinFeeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DialogChargeReport.h"
/////////////////////////////////////////////////////////////////////////////
// CWinFeeView
IMPLEMENT_DYNCREATE(CWinFeeView, CFormView)
CWinFeeView::CWinFeeView()
: CFormView(CWinFeeView::IDD)
{
//{{AFX_DATA_INIT(CWinFeeView)
m_strLastMoney = _T("");
m_strShouldFee = _T("");
m_strInfactFee = _T("");
m_strAllMoney = _T("");
m_strClientAddress = _T("");
m_strClientName = _T("");
m_strLeftFee = _T("");
m_strSerial = _T("");
m_strRemark = _T("");
//}}AFX_DATA_INIT
pages = 0;
}
CWinFeeView::~CWinFeeView()
{
}
void CWinFeeView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWinFeeView)
DDX_Control(pDX, IDC_LIST, m_List);
DDX_Control(pDX, ID_FILE_PRINT, m_ctrlPrint);
DDX_Control(pDX, IDC_EDIT_SERIAL, m_EditSerial);
DDX_Control(pDX, IDC_EDIT_INFACT_FEE, m_ctrlEditInFactFee);
DDX_Text(pDX, IDC_EDIT_LAST_MONEY, m_strLastMoney);
DDX_Text(pDX, IDC_EDIT_SHOULD_FEE, m_strShouldFee);
DDX_Text(pDX, IDC_EDIT_INFACT_FEE, m_strInfactFee);
DDX_Text(pDX, IDC_STATIC_ALLFEE, m_strAllMoney);
DDX_Text(pDX, IDC_EDIT_CLIENT_ADDRESS, m_strClientAddress);
DDX_Text(pDX, IDC_EDIT_CLIENT_NAME, m_strClientName);
DDX_Text(pDX, IDC_EDIT_LEFT_FEE, m_strLeftFee);
DDX_Text(pDX, IDC_EDIT_SERIAL, m_strSerial);
DDX_Text(pDX, IDC_EDIT_REMARKS, m_strRemark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWinFeeView, CFormView)
//{{AFX_MSG_MAP(CWinFeeView)
ON_BN_CLICKED(IDC_BUTTON_WINDOW_FEE, OnButtonWindowFee)
ON_BN_CLICKED(ID_BUTTON_ACCOUNT_INCOME_REPORT, OnButtonChargeReport)
ON_WM_CTLCOLOR()
ON_EN_KILLFOCUS(IDC_EDIT_SERIAL, OnKillfocusEditSerial)
ON_BN_CLICKED(ID_BUTTON_FINISH_FEE, OnButtonFinishFee)
ON_BN_CLICKED(ID_BUTTON_FEE_LIST, OnButtonFeeList)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEWBillSysView printing
BOOL CWinFeeView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
if(m_strSerial.IsEmpty())
return FALSE;
UpdateData();
if(m_bAlreadyFee == 0)
return FALSE;
return DoPreparePrinting(pInfo);
}
void CWinFeeView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
// CWinFeeView diagnostics
#ifdef _DEBUG
void CWinFeeView::AssertValid() const
{
CFormView::AssertValid();
}
void CWinFeeView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CPressManagerDoc* CWinFeeView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPressManagerDoc)));
return (CPressManagerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWinFeeView message handlers
void CWinFeeView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_pFeeSet = &GetDocument()->m_FeeSet;
m_pProduceClientSet = &GetDocument()->m_ProduceClientSet;
m_pProductWareSet = &GetDocument()->m_ProductWareSet;
m_pWarePurposeSet = &GetDocument()->m_WarePurposeSet;
m_pWareTypeSet = &GetDocument()->m_WareTypeSet;
m_pWareModeSet = &GetDocument()->m_WareModeSet;
m_pOperatorSet = &GetDocument()->m_OperatorSet;
m_pMoneySumSet = &GetDocument()->m_MoneySumSet;
m_strOperatorId = GetDocument()->m_strOperatorId;
m_List.SetExtendedStyle
(m_List.GetExtendedStyle()|LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_List.InsertColumn(0,"任务Id",LVCFMT_LEFT,60,-1);
m_List.InsertColumn(1,"稿件",LVCFMT_LEFT,80,-1);
m_List.InsertColumn(2,"稿件尺寸",LVCFMT_LEFT,90,-1);
m_List.InsertColumn(3,"计量单位",LVCFMT_LEFT,70,-1);
m_List.InsertColumn(4,"印刷数量",LVCFMT_LEFT,80,-1);
m_List.InsertColumn(5,"印刷单价",LVCFMT_LEFT,90,-1);
m_List.InsertColumn(6,"生产类别",LVCFMT_LEFT,80,-1);
m_List.InsertColumn(7,"原材料种类",LVCFMT_LEFT,80,-1);
m_List.InsertColumn(8,"物品名",LVCFMT_LEFT,90,-1);
m_List.InsertColumn(9,"物品型号",LVCFMT_LEFT,70,-1);
m_List.InsertColumn(10,"计量单位",LVCFMT_LEFT,70,-1);
m_List.InsertColumn(11,"物品数量",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(12,"拼后尺寸",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(13,"拼板数量",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(14,"板类",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(15,"打印色数",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(16,"打印机台",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(17,"单色车数",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(18,"消耗车数",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(19,"钉丝",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(20,"上胶",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(21,"包壳",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(22,"成品数",LVCFMT_LEFT,100,-1);
m_List.InsertColumn(23,"状态",LVCFMT_LEFT,100,-1);
m_bluecolor = RGB(116,236,6); // red
m_redcolor = RGB(238,249,162); // blue
m_staticcolor = RGB(168,217,242); // static
m_textcolor = RGB(0,0,0); // text
m_redbrush.CreateSolidBrush(m_redcolor); // red background
m_bluebrush.CreateSolidBrush(m_bluecolor); // blue background
m_staticbrush.CreateSolidBrush(m_staticcolor); // static background
}
void CWinFeeView::OnFeeCalculate()
{
// TODO: Add your control notification handler code here
double efee = 0;
for(int i = 0; i < m_List.GetItemCount(); i++)
efee += atof(m_List.GetItemText(i, 4)) * atof(m_List.GetItemText(i, 5));
m_strShouldFee.Format("%.2f",efee);
m_strLeftFee.Format("%.2f", atof(m_strInfactFee) + atof(m_strLastMoney) - efee);
}
void CWinFeeView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
if(m_strSerial.IsEmpty())
return;
UpdateData();
if(m_bAlreadyFee == 0)
return;
pDC->SetMapMode(MM_LOENGLISH);
LOGFONT logFont;
logFont.lfWidth = 0;
logFont.lfEscapement = 0;
logFont.lfOrientation = 0;
logFont.lfWeight = FW_NORMAL;
logFont.lfItalic = 0;
logFont.lfUnderline = 0;
logFont.lfStrikeOut = 0;
logFont.lfCharSet = ANSI_CHARSET;
logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont.lfQuality = PROOF_QUALITY;
logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
strcpy(logFont.lfFaceName, "Times New Roman");
CFont font;
// CFont* oldFont;
CString strSql;
CString str1, str2;
// int i;
/* int yn = -60;
int xx[11] = {0,45,25,48,60,60,55,43,52,52,52};
for(i = 1; i < 11; i++)
xx[i] += xx[i -1];
if(m_pProduceClientSet->m_LastLine == 0)
{
logFont.lfHeight = 20;
font.CreateFontIndirect(&logFont);
oldFont = pDC->SelectObject(&font);
int xn = 40;
CString str[10] = {"日期","类","单价","上次","本次","金额","滞纳","实交","余额","卫生费"};
CString str3[10] = {"","号","","表数","表数","(元)","金","(元)","(元)","(元)"};
str1.Format("用户号:%d", m_pProduceClientSet->m_Id);
pDC->TextOut(xn, yn, str1);
str1.Format("用户名:%s", m_pProduceClientSet->m_Name);
pDC->TextOut(xn + 180, yn, str1);
yn -= 40;
pDC->TextOut(xn, yn, "表ID号");
pDC->TextOut(xn + 120, yn, "电表变比");
pDC->TextOut(xn + 240, yn, "安装地址");
font.DeleteObject();
logFont.lfHeight = 18;
font.CreateFontIndirect(&logFont);
pDC->SelectObject(&font);
yn -= 4;
if(!(m_pWProductWareSet->IsEOF() && m_pWProductWareSet->IsBOF()))
{
m_pWProductWareSet->MoveFirst();
while(!m_pWProductWareSet->IsEOF())
{
m_pInstallAddressSet->MoveFirst();
while(!m_pInstallAddressSet->IsEOF())
{
if(m_pInstallAddressSet->m_Id == m_pWProductWareSet->m_InstallAddressId)
break;
m_pInstallAddressSet->MoveNext();
}
str1.Format("水表%d", m_pWProductWareSet->m_Id);
yn -= 22;
pDC->TextOut(xn, yn, str1);
str1.Format("%s%s", m_pInstallAddressSet->m_InstallAddress, m_pWProductWareSet->m_DoorPlate);
pDC->TextOut(xn + 240, yn, str1);
m_pWProductWareSet->MoveNext();
}
}
if(!(m_pProductWareSet->IsEOF() && m_pProductWareSet->IsBOF()))
{
m_pProductWareSet->MoveFirst();
while(!m_pProductWareSet->IsEOF())
{
m_pInstallAddressSet->MoveFirst();
while(!m_pInstallAddressSet->IsEOF())
{
if(m_pInstallAddressSet->m_Id == m_pProductWareSet->m_InstallAddressId)
break;
m_pInstallAddressSet->MoveNext();
}
str1.Format("电表%d", m_pProductWareSet->m_Id);
yn -= 22;
pDC->TextOut(xn, yn, str1);
str1.Format("%d", m_pProductWareSet->m_RateValue);
pDC->TextOut(xn + 120, yn, str1);
str1.Format("%s%s", m_pInstallAddressSet->m_InstallAddress, m_pProductWareSet->m_DoorPlate);
pDC->TextOut(xn + 240, yn, str1);
m_pProductWareSet->MoveNext();
}
}
yn = -335;
for(i = 0; i < 10; i++)
{
pDC->TextOut(xx[i] + 2, yn - 2, str[i]);
pDC->TextOut(xx[i] + 2, -366, str3[i]);
}
yn = -390;
}
else
{
logFont.lfHeight = 18;
font.CreateFontIndirect(&logFont);
oldFont = pDC->SelectObject(&font);
yn = m_pProduceClientSet->m_LastLine;
}
font.DeleteObject();
logFont.lfHeight = 14;
font.CreateFontIndirect(&logFont);
pDC->SelectObject(&font);
for(i = 0; i < 11; i++)
xx[i] += 2;
//////////////////////////////////
CString fromtime;
CString totime;
CString m_strPrintTime;
#if !defined(_ACCESS_DB)
m_strPrintTime.Format("'%d/%d/%d %d:%d:%d'", m_PrintTime.GetMonth(), m_PrintTime.GetDay(), m_PrintTime.GetYear(), m_PrintTime.GetHour(), m_PrintTime.GetMinute(), m_PrintTime.GetSecond());
#endif
#if defined(_ACCESS_DB)
m_strPrintTime.Format("#%d/%d/%d %d:%d:%d#", m_PrintTime.GetYear(), m_PrintTime.GetMonth(), m_PrintTime.GetDay(), m_PrintTime.GetHour(), m_PrintTime.GetMinute(), m_PrintTime.GetSecond());
#endif
strSql.Format("select * from [Fee] where [ProduceClientId] = %s and [BillDate] >= %s", m_strSerial, m_strPrintTime);
if(m_pFeeSet->IsOpen())
m_pFeeSet->Close();
m_pFeeSet->Open(CRecordset::snapshot, strSql);
while(!m_pFeeSet->IsEOF())
{
str1.Format("%d/%d/%d", m_pFeeSet->m_BillDate.GetYear(), m_pFeeSet->m_BillDate.GetMonth(), m_pFeeSet->m_BillDate.GetDay());
str1.Delete(0,2);
pDC->TextOut(xx[0], yn, str1);
str1.Format("%.2f", atof(m_pFeeSet->m_LateBillFee));
pDC->TextOut(xx[6], yn, str1);
str1.Format("%.2f", atof(m_pFeeSet->m_InfactBillMoney));
pDC->TextOut(xx[7], yn, str1);
str1.Format("%.2f", atof(m_pFeeSet->m_SurplusMoney));
pDC->TextOut(xx[8], yn, str1);
str1.Format("%.2f", atof(m_pFeeSet->m_SalinityFee));
pDC->TextOut(xx[9], yn, str1);
i = 0;
#if !defined(_ACCESS_DB)
fromtime.Format("%d/%d/%d",m_pFeeSet->m_BillDate.GetMonth(),m_pFeeSet->m_BillDate.GetDay(),m_pFeeSet->m_BillDate.GetYear());
totime = fromtime + " 23:59:59";
strSql.Format("select * from [ProductWareMonthRec] where [ProduceClientId] = %s and [FeeDate] between '%s' and '%s'", m_strSerial, fromtime, totime);
#endif
#if defined(_ACCESS_DB)
fromtime.Format("#%d/%d/%d#",m_pFeeSet->m_BillDate.GetMonth(),m_pFeeSet->m_BillDate.GetDay(),m_pFeeSet->m_BillDate.GetYear());
totime.Format("#%d/%d/%d 23:59:59#",m_pFeeSet->m_BillDate.GetMonth(),m_pFeeSet->m_BillDate.GetDay(),m_pFeeSet->m_BillDate.GetYear());
strSql.Format("select * from [ProductWareMonthRec] where [ProduceClientId] = %s and [FeeDate] between %s and %s", m_strSerial, fromtime, totime);
#endif
if(m_pProductWareMonthRecSet->IsOpen())
m_pProductWareMonthRecSet->Close();
m_pProductWareMonthRecSet->Open(CRecordset::snapshot, strSql);
while(!m_pProductWareMonthRecSet->IsEOF())
{
if(m_pProductWareMonthRecSet->m_ProductWareType == 0 && atof(m_pFeeSet->m_WaterFee) != 0)
{
i++;
pDC->TextOut(xx[1], yn, "水");
str1.Format("%.3f", atof(m_pProductWareMonthRecSet->m_PurposeFee));
pDC->TextOut(xx[2], yn, str1);
str1.Format("%.1f", m_pProductWareMonthRecSet->m_PrevRecValue);
pDC->TextOut(xx[3], yn, str1);
str1.Format("%.1f", m_pProductWareMonthRecSet->m_RecValue);
pDC->TextOut(xx[4], yn, str1);
str2.Format("%.2f", (m_pProductWareMonthRecSet->m_RecResult) * (atof(m_pProductWareMonthRecSet->m_PurposeFee) + m_pProductWareMonthRecSet->m_RateValue));
pDC->TextOut(xx[5], yn, str2);
yn -= 20;
if((yn - 20) % 322 > -20)
yn -= 20;
}
else if(m_pProductWareMonthRecSet->m_ProductWareType == 1 && atof(m_pFeeSet->m_ElectriFee) != 0)
{
i++;
pDC->TextOut(xx[1], yn, "电");
str1.Format("%.3f", atof(m_pProductWareMonthRecSet->m_PurposeFee));
pDC->TextOut(xx[2], yn, str1);
str1.Format("%.1f", m_pProductWareMonthRecSet->m_PrevRecValue);
pDC->TextOut(xx[3], yn, str1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -