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

📄 winfeeview.cpp

📁 以前给一个印刷厂开发的业务管理软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				str1.Format("%.1f", m_pProductWareMonthRecSet->m_RecValue);
				pDC->TextOut(xx[4], yn, str1);
				str2.Format("%.2f", (m_pProductWareMonthRecSet->m_RecResult) * (m_pProductWareMonthRecSet->m_RateValue) * (atof(m_pProductWareMonthRecSet->m_PurposeFee)));
				pDC->TextOut(xx[5], yn, str2);

				yn -= 20;
//					if((yn - 20) % 322 > -20)
//						yn -= 20;
			}
			m_pProductWareMonthRecSet->MoveNext();
		}
		if(i == 0)
		{
			yn -= 20;
//				if((yn - 20) % 322 > -20)
//					yn -= 20;
		}
		m_pFeeSet->MoveNext();
	}

#if !defined(_ACCESS_DB)
	strSql.Format("update [ProduceClient] set [LastLine] = %d, [LastPrintTime]=getdate() where [Id] = %s", yn, m_strSerial);
#endif
#if defined(_ACCESS_DB)
	strSql.Format("update [ProduceClient] set [LastLine] = %d, [LastPrintTime]=date()+time() where [Id] = %s", yn, m_strSerial);
#endif
	TRY
	{
		m_pProduceClientSet->m_pDatabase->ExecuteSQL(strSql);
	}
	CATCH_ALL(e)
	{
		;
	}	
	END_CATCH_ALL;

    pDC->SelectObject(oldFont);
	font.DeleteObject();
*/

	CFormView::OnPrint(pDC, pInfo);
}

void CWinFeeView::SetProduceClientInfo()
{
	m_strLastMoney = "";
	m_strShouldFee = "";
	m_strInfactFee = "";
	m_strLeftFee = "";
	m_strRemark = "";

	m_strClientAddress = m_pProduceClientSet->m_ClientAddress;
	m_strClientName = m_pProduceClientSet->m_ClientName;

	CString strSql;
	strSql.Format("select sum([Fee]) from [Fee] where [ProduceClientSerial] = '%s'", m_strSerial);
	if(m_pMoneySumSet->IsOpen())
		m_pMoneySumSet->Close();
	m_pMoneySumSet->Open(CRecordset::snapshot, strSql);
	m_strLastMoney.Format("%.2f", atof(m_pMoneySumSet->m_MoneySum));
	UpdateData(FALSE);

	strSql.Format("select * from [ProductWare] where [ProduceClientSerial] = '%s'", m_strSerial);
	if(m_pProductWareSet->IsOpen())
		m_pProductWareSet->Close();
	m_pProductWareSet->Open(CRecordset::snapshot, strSql);

	SetProductWareInfo();
	OnFeeCalculate();

}

void CWinFeeView::SetProductWareInfo()
{
	if(m_strSerial.IsEmpty())
		return;

	m_bAlreadyFee = 0;
	m_List.DeleteAllItems();

	int i = 0;
	CString strSql;
	while(!m_pProductWareSet->IsEOF())
	{
		m_pWarePurposeSet->MoveFirst();
		while(!m_pWarePurposeSet->IsEOF())
		{
			if(m_pWarePurposeSet->m_Id == m_pProductWareSet->m_WarePurposeId)
				break;

			m_pWarePurposeSet->MoveNext();
		}
		m_pWareTypeSet->MoveFirst();
		while(!m_pWareTypeSet->IsEOF())
		{
			if(m_pWareTypeSet->m_Id == m_pProductWareSet->m_WareTypeId)
				break;

			m_pWareTypeSet->MoveNext();
		}
		m_pWareModeSet->MoveFirst();
		while(!m_pWareModeSet->IsEOF())
		{
			if(m_pWareModeSet->m_Id == m_pProductWareSet->m_WareModeId)
				break;

			m_pWareModeSet->MoveNext();
		}

		strSql.Format("%d",m_pProductWareSet->m_Id);
		m_List.InsertItem(i, strSql);
		m_List.SetItemText(i, 1, 	m_pProductWareSet->m_Draft );
		m_List.SetItemText(i, 2, 	m_pProductWareSet->m_Size );
		m_List.SetItemText(i, 3, 	m_pProductWareSet->m_Unit );
		strSql.Format("%.2f",	m_pProductWareSet->m_Number);
		m_List.SetItemText(i, 4, 	strSql );
		strSql.Format("%.2f",	atof(m_pProductWareSet->m_Price));
		m_List.SetItemText(i, 5, 	strSql );
		m_List.SetItemText(i, 6, 	m_pProductWareSet->m_ProduceType );
		m_List.SetItemText(i, 7, m_pWarePurposeSet->m_WarePurpose);
		m_List.SetItemText(i, 8, m_pWareTypeSet->m_WareType );
		m_List.SetItemText(i, 9, m_pWareModeSet->m_WareMode );
		m_List.SetItemText(i, 10, m_pWareTypeSet->m_Unit );
		strSql.Format("%.2f",	m_pProductWareSet->m_WareNumber);
		m_List.SetItemText(i, 11, 	strSql );
		m_List.SetItemText(i, 12, 	m_pProductWareSet->m_PinHouSize );
		strSql.Format("%d",	m_pProductWareSet->m_PinBanNumber);
		m_List.SetItemText(i, 13, 	strSql );
		m_List.SetItemText(i, 14, 	m_pProductWareSet->m_BanLei );
		m_List.SetItemText(i, 15, 	m_pProductWareSet->m_PrintColorNumber );
		m_List.SetItemText(i, 16, 	m_pProductWareSet->m_PrintJiTai );
		m_List.SetItemText(i, 17, 	m_pProductWareSet->m_DanSeCheSu );
		m_List.SetItemText(i, 18, 	m_pProductWareSet->m_XiaoHaoCheSu );
		m_List.SetItemText(i, 19, 	m_pProductWareSet->m_DingSi );
		m_List.SetItemText(i, 20, 	m_pProductWareSet->m_ShangJiao );
		m_List.SetItemText(i, 21, 	m_pProductWareSet->m_BaoKe );
		m_List.SetItemText(i, 22, 	m_pProductWareSet->m_ChengPingShu );

		if(m_pProduceClientSet->m_State == 0)
			m_List.SetItemText(i, 23, "生产中" );
		else
			m_List.SetItemText(i, 23, "完成" );

		m_pProductWareSet->MoveNext();
		i++;
	}
}

void CWinFeeView::OnButtonWindowFee() 
{
	// TODO: Add your control notification handler code here
	if(m_strSerial.IsEmpty())
	{
		return;
	}

	if(	m_bAlreadyFee == 1)
	{
		MessageBox("用户已收过费");
		return;
	}
	int i = MessageBox("确认用户交费?", "确认交费", MB_OKCANCEL);
	if(i != IDOK)
		return;

	UpdateData();
	OnFeeCalculate();

	if(atof(m_strShouldFee) == 0 && atof(m_strInfactFee) == 0)
	{
		MessageBox("用户合计应交、实交金额都为0,不能交费");
		return;
	}
	if(atof(m_strLastMoney) + atof(m_strInfactFee) < 0)
	{
		MessageBox("缴费差额不能为负");
		return;
	}

	CWaitCursor cursor; // this will automatically display a wait cursor
	CString strSql;

	//交费记录
	if(!m_pFeeSet->IsOpen())
		m_pFeeSet->Open();
	m_pFeeSet->AddNew();
	m_pFeeSet->m_ProduceClientSerial = m_strSerial;
	m_pFeeSet->m_ClientName = m_strClientName;
	m_pFeeSet->m_ClientAddress = m_strClientAddress;
	m_pFeeSet->m_Fee = m_strInfactFee;
	m_pFeeSet->m_Remark = m_strRemark;
	m_pFeeSet->m_OperatorId = m_strOperatorId;
	TRY
	{
		m_pFeeSet->Update();
	}
	CATCH_ALL(e)
	{
		MessageBox("数据加入失败。收款失败!");
		return;
	}
	END_CATCH_ALL;

	strSql.Format("Update [ProduceClient] set Fee = %f where [Serial] = '%s'" ,atof(m_strInfactFee) + atof(m_strLastMoney), m_strSerial);
	TRY
	{
		m_pProduceClientSet->m_pDatabase->ExecuteSQL(strSql);
	}
	CATCH_ALL(e)
	{
		MessageBox("ProduceClient数据更新失败!");
		return;
	}
	END_CATCH_ALL;

	m_bAlreadyFee = 1;
	m_ctrlPrint.SetFocus();
	m_ctrlEditInFactFee.SetReadOnly();
	MessageBox("用户收费成功,请按打印按钮打印收费单");

	CTime t = CTime::GetCurrentTime();
	CString fromtime;
#if !defined(_ACCESS_DB)
	fromtime.Format("'%d/%d/%d 0:0:0'",t.GetMonth(),t.GetDay(),t.GetYear());
#endif
#if defined(_ACCESS_DB)
	fromtime.Format("#%d/%d/%d 0:0:0#",t.GetYear(),t.GetMonth(),t.GetDay());
#endif
	strSql.Format("select sum([Fee]) from [Fee] where [OperatorId] = '%s' and [UpdateDate] > %s", m_strOperatorId, fromtime);
	if(m_pMoneySumSet->IsOpen())
		m_pMoneySumSet->Close();
	m_pMoneySumSet->Open(CRecordset::snapshot, strSql);

	strSql.Format("时间:%d月%d日 收款总额:%.2f元" ,t.GetMonth(),t.GetDay(), atof(m_pMoneySumSet->m_MoneySum));
	m_strAllMoney = strSql;

	UpdateData(FALSE);
}

void CWinFeeView::OnButtonChargeReport() 
{
	// TODO: Add your control notification handler code here
	CPressManagerDoc* doc = GetDocument();

	CDialogChargeReport dlg;
	dlg.m_pFeeSet = &doc->m_FeeSet;
	dlg.m_pOperatorSet = &doc->m_OperatorSet;
	dlg.m_strOperatorId = doc->m_strOperatorId;
	dlg.DoModal();		
}

void CWinFeeView::OnKillfocusEditSerial() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if(m_strSerial.IsEmpty())
	{
		m_strSerial.Empty();
		return;
	}

	CString strSql;
	strSql.Format("select * from [ProduceClient] where [Serial] = '%s' and FeeDate is null" , m_strSerial);
	if(m_pProduceClientSet->IsOpen())
		m_pProduceClientSet->Close();
	m_pProduceClientSet->Open(CRecordset::snapshot, strSql);
	if(!m_pProduceClientSet->IsEOF())
	{
		SetProduceClientInfo();
		m_ctrlEditInFactFee.SetReadOnly(FALSE);
	}
	else
	{
		m_strSerial.Empty();
		MessageBox("生产单号错误或已完成缴费");
	}

	UpdateData(FALSE);
}

HBRUSH CWinFeeView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
	// TODO: Change any attributes of the DC here
	if(nCtlColor == CTLCOLOR_EDIT) 
	{ 
	  // process my edit controls by ID.
		switch(pWnd->GetDlgCtrlID())
		{     
	  // first CEdit control ID
		case IDC_EDIT_SERIAL:         // put your own CONTROL ID
			if(m_EditSerial.m_focus == 1)
			{
			  pDC->SetBkColor(m_bluecolor);    // change the background
			  pDC->SetTextColor(m_textcolor);  // change the text color
			  hbr = (HBRUSH) m_bluebrush;    // apply the blue brush
			}
			else
			{
			  pDC->SetBkMode(m_redcolor);   // make background
			  pDC->SetTextColor(m_textcolor);  // change the text color
			  hbr = (HBRUSH) m_redbrush;     // apply the red brush
			}
		    break;
		case IDC_EDIT_INFACT_FEE:         // make the TEXT transparent,
			if(m_ctrlEditInFactFee.m_focus == 1)
			{
			  pDC->SetBkColor(m_bluecolor);    // change the background
			  pDC->SetTextColor(m_textcolor);  // change the text color
			  hbr = (HBRUSH) m_bluebrush;    // apply the blue brush
			}
			else
			{
			  pDC->SetBkMode(m_redcolor);   // make background
			  pDC->SetTextColor(m_textcolor);  // change the text color
			  hbr = (HBRUSH) m_redbrush;     // apply the red brush
			}
		    break;
	  }
	}
	else if(nCtlColor == CTLCOLOR_STATIC) 
	{ 
		switch(pWnd->GetDlgCtrlID())
		{     
		case IDC_EDIT_CLIENT_ADDRESS:
		case IDC_EDIT_CLIENT_NAME:
		  pDC->SetBkMode(m_staticcolor);   // make background
		  pDC->SetTextColor(m_textcolor);  // change the text color
		  hbr = (HBRUSH) m_staticbrush;     // apply the red brush
		  break;
		}
	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

void CWinFeeView::OnButtonFinishFee() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_strSerial.IsEmpty())
	{
		m_strSerial.Empty();
		return;
	}

	CString strSql;
	#if !defined(_ACCESS_DB)
		strSql.Format("Update [ProduceClient] set FeeDate = getdate() where [Serial] = '%s'" , m_strSerial);
	#endif
	#if defined(_ACCESS_DB)
		strSql.Format("Update [ProduceClient] set FeeDate = date()+time() where [Serial] = '%s'" , m_strSerial);
	#endif
	TRY
	{
		m_pProduceClientSet->m_pDatabase->ExecuteSQL(strSql);
	}
	CATCH_ALL(e)
	{
		MessageBox("ProduceClient数据更新失败!");
		return;
	}
	END_CATCH_ALL;
	
	MessageBox("用户已完成缴费!");
}

void CWinFeeView::OnButtonFeeList() 
{
	// TODO: Add your control notification handler code here
	CPressManagerDoc* doc = GetDocument();

	CDialogChargeReport dlg;
	dlg.m_pFeeSet = &doc->m_FeeSet;
	dlg.m_pOperatorSet = &doc->m_OperatorSet;
	dlg.m_strOperatorId = doc->m_strOperatorId;
	dlg.m_strSerial = m_strSerial;
	dlg.m_timeFrom = 0;
	dlg.DoModal();			
}

⌨️ 快捷键说明

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