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

📄 doperation.cpp

📁 物流综合管理系统
💻 CPP
字号:
// DOperation.cpp : implementation file
//

#include "stdafx.h"
#include "MyProject.h"
#include "DOperation.h"
#include "ExternDllHeader.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDOperation dialog


CDOperation::CDOperation(CWnd* pParent /*=NULL*/)
	: CDialog(CDOperation::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDOperation)
	//}}AFX_DATA_INIT
}


void CDOperation::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDOperation)
	DDX_Control(pDX, IDC_STAFRAME2, m_StaFrame);
	DDX_Control(pDX, IDC_STAGIVEMONEYVALUE, m_StaGiveMoneyValue);
	DDX_Control(pDX, IDC_STANOPAYVALUE, m_StaNoPayValue);
	DDX_Control(pDX, IDC_STAGIVEMONEY, m_StaGiveMoney);
	DDX_Control(pDX, IDC_STAPAY, m_StaPay);
	DDX_Control(pDX, IDC_STANOPAY, m_StaNoPay);
	DDX_Control(pDX, IDC_EDTPAY, m_EdtPay);
	DDX_Control(pDX, IDC_STATOTAL, m_StaTotal);
	DDX_Control(pDX, IDC_STASUMNUMBER, m_StaSumNumber);
	DDX_Control(pDX, IDC_STABIGTOTAL, m_StaBigTotal);
	DDX_Control(pDX, IDC_STADATEVALUE, m_StaDateValue);
	DDX_Control(pDX, IDC_STADATE, m_StaDate);
	DDX_Control(pDX, IDC_BUTUNDO1, m_ButUndo);
	DDX_Control(pDX, IDC_BUTSAVE1, m_ButSave);
	DDX_Control(pDX, IDC_BUTPRINT, m_ButPrint);
	DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
	DDX_Control(pDX, IDC_BUTENROL, m_ButEnrol);
	DDX_Control(pDX, IDC_GRID, m_Grid);
	DDX_Control(pDX, IDC_EDTSTORE, m_EdtStore);
	DDX_Control(pDX, IDC_EDTOPERATION, m_EdtOperation);
	DDX_Control(pDX, IDC_EDTMAN, m_EdtMan);
	DDX_Control(pDX, IDC_STAIDVALUE, m_StaIDValue);
	DDX_Control(pDX, IDC_STASTORE, m_StaStore);
	DDX_Control(pDX, IDC_STAOPERATION, m_StaOperation);
	DDX_Control(pDX, IDC_STANOTEID, m_StaNoteID);
	DDX_Control(pDX, IDC_STAMAN, m_StaMan);
	DDX_Control(pDX, IDC_STATITLE, m_StaTitle);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDOperation, CDialog)
	//{{AFX_MSG_MAP(CDOperation)
	ON_BN_CLICKED(IDC_BUTUNDO1, OnButUndo)
	ON_BN_CLICKED(IDC_BUTENROL, OnButEnrol)
	ON_BN_CLICKED(IDC_BUTSAVE1, OnButSave)
	ON_BN_CLICKED(IDC_BUTPRINT, OnButPrint)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	ON_MESSAGE(DIY_SETFOCUS,OnCellSetFocus)
	ON_MESSAGE(DIY_KILLFOCUS,OnCellKillFocus)
	ON_WM_PAINT()
	ON_NOTIFY(NM_SETFOCUS, IDC_GRID, OnSetfocusGrid)
	ON_EN_KILLFOCUS(IDC_EDTOPERATION, OnKillfocusEdtoperation)
	ON_NOTIFY(NM_RCLICK, IDC_GRID, OnRclickGrid)
	ON_COMMAND(IDM_POPDEL, OnPopdel)
	ON_EN_CHANGE(IDC_EDTPAY, OnChangeEdtpay)
	ON_EN_SETFOCUS(IDC_EDTMAN, OnSetfocusEdtman)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDOperation message handlers

void CDOperation::OnCancel() 
{
	// TODO: Add extra cleanup here
	if(this->m_ButEnrol.IsWindowEnabled()==false)
		if(MessageBox("确定不保存就退出吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
			return;
	CDialog::OnCancel();
}

void CDOperation::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

BOOL CDOperation::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CTime time;
	time=time.GetCurrentTime();
	CString sTime;
	sTime=CTimeToCString(time);
	this->m_StaDateValue.SetWindowText(sTime);
	//调用存虚函数
	this->Init();
	//调整标题区域大小
	this->m_StaTitle.SetWindowText(m_sCaption);
	
	this->SetWindowText(m_sCaption);
	COLORREF bkColor=::GetSysColor(COLOR_3DFACE);
	COLORREF TextColor=RGB(255,0,0);
	this->m_StaBigTotal.SetBkColor(bkColor);
	this->m_StaBigTotal.SetTextColor(TextColor);
	this->m_StaSumNumber.SetBkColor(bkColor);
	this->m_StaSumNumber.SetTextColor(TextColor);
	this->m_StaTotal.SetBkColor(bkColor);
	this->m_StaTotal.SetTextColor(TextColor);
	m_EdtPay.IsMoneyOnly(true);
	m_Grid.m_bReadOnly=true;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDOperation::SetCaption(CString sCaption)
{
	m_sCaption=sCaption;
}

void CDOperation::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rcWin;
	this->GetClientRect(&rcWin);
	rcWin.top=rcWin.top+11;
	rcWin.bottom=100;
	rcWin.left=rcWin.left+11;
	rcWin.right=rcWin.right-10;
	CBrush brush;
	brush.CreateSolidBrush(RGB(255,255,255));
	dc.FillRect(&rcWin,&brush);
	brush.DeleteObject();

	// Do not call CDialog::OnPaint() for painting messages
}

void CDOperation::SetStoreTitle(CString sTitle)
{
	m_StaStore.SetWindowText(sTitle);
}

void CDOperation::SetOperationTitle(CString sTitle)
{
	m_StaOperation.SetWindowText(sTitle);
}

void CDOperation::SetManTitle(CString sTitle)
{
	m_StaMan.SetWindowText(sTitle);
}

void CDOperation::SetNoteIDTitle(CString sTitle)
{
	m_StaNoteID.SetWindowText(sTitle);
}

void CDOperation::SetGridHeader(CString sHeaderNameList)
{
	int nPost=0,nOldPost=0;
	CString sHeaderName;
	int nColID=0;
	while(nPost!=-1)
	{
		nColID++;
		nOldPost=nPost;
		nPost=sHeaderNameList.Find(",",nOldPost+1);
		if(nPost!=-1)
			if(nOldPost==0)
				sHeaderName=sHeaderNameList.Mid(nOldPost,nPost);
			else
				sHeaderName=sHeaderNameList.Mid(nOldPost+1,nPost-nOldPost-1);
		else
			sHeaderName=sHeaderNameList.Mid(nOldPost+1,sHeaderNameList.GetLength());
		m_Grid.InsertColumn(nColID,sHeaderName);
	}
}

void CDOperation::PreSubclassWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CDialog::PreSubclassWindow();
}

void CDOperation::SetHeadersWidth(CString sHeadersWidthList)
{
	int nPost=0,nOldPost=0;
	CString sHeaderWidth;
	int nColID=0;
	while(nPost!=-1)
	{
		nOldPost=nPost;
		nPost=sHeadersWidthList.Find(",",nOldPost+1);
		if(nPost!=-1)
			if(nOldPost==0)
				sHeaderWidth=sHeadersWidthList.Mid(nOldPost,nPost);
			else
				sHeaderWidth=sHeadersWidthList.Mid(nOldPost+1,nPost-nOldPost-1);
		else
			sHeaderWidth=sHeadersWidthList.Mid(nOldPost+1,sHeadersWidthList.GetLength());
		m_Grid.SetColumnWidth(nColID,atoi(sHeaderWidth));
		nColID++;
	}
}

void CDOperation::OnButexit() 
{
	if(this->m_ButEnrol.IsWindowEnabled()==false)
		if(MessageBox("确定不保存就退出吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
			return;
	this->OnCancel();	
}

void CDOperation::OnSetfocusGrid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if(this->m_Grid.GetRows()<1)
	{
		this->m_Grid.InsertItem(0,"");
		this->Invalidate();
		::SendMessage(this->m_Grid.GetSafeHwnd(),WM_LBUTTONDOWN,1,1441802);
		::SendMessage(this->m_Grid.GetSafeHwnd(),WM_LBUTTONUP,1,1441802);
	}
	else
		this->m_EdtPay.SetFocus();
	*pResult = 0;
}


void CDOperation::OnKillfocusEdtoperation() 
{

}

void CDOperation::OnCellKillFocus()
{

}

void CDOperation::OnCellSetFocus()
{

}

void CDOperation::OnButPrint()
{
	m_ps.MainCaptionFontSize=400;
	m_ps.DeckCaptionFontSize=180;
	m_ps.MainCaption=m_sCaption+"单据";
	CString sMem;
	m_ps.DeckCaptionNumber=5;
	this->m_StaNoteID.GetWindowText(m_ps.DeckCaptions[0]);
	this->m_StaIDValue.GetWindowText(sMem);
	m_ps.DeckCaptions[0]=m_ps.DeckCaptions[0]+sMem;

	this->m_StaDate.GetWindowText(m_ps.DeckCaptions[1]);
	this->m_StaDateValue.GetWindowText(sMem);
	m_ps.DeckCaptions[1]=m_ps.DeckCaptions[1]+sMem;


	this->m_StaOperation.GetWindowText(m_ps.DeckCaptions[2]);
	this->m_EdtOperation.GetWindowText(sMem);
	m_ps.DeckCaptions[2]=m_ps.DeckCaptions[2]+sMem;

	this->m_StaStore.GetWindowText(m_ps.DeckCaptions[3]);
	this->m_EdtStore.GetWindowText(sMem);
	m_ps.DeckCaptions[3]=m_ps.DeckCaptions[3]+sMem;

	this->m_StaMan.GetWindowText(m_ps.DeckCaptions[4]);
	this->m_EdtMan.GetWindowText(sMem);
	m_ps.DeckCaptions[4]=m_ps.DeckCaptions[4]+sMem;
	
	if(m_StaNoPay.IsWindowVisible()==false)
		m_ps.TotalNumber=4;
	else
		m_ps.TotalNumber=7;

	this->m_StaSumNumber.GetWindowText(sMem);
	m_ps.Totals[0]="合计数量:"+sMem;
	this->m_StaTotal.GetWindowText(sMem);
	m_ps.Totals[1]="合计金额:"+sMem;
	this->m_StaBigTotal.GetWindowText(sMem);
	m_ps.Totals[2]="大    写:"+sMem;
	m_ps.Totals[3]="操 作 员:"+OP;
	this->m_EdtPay.GetWindowText(sMem);
	m_ps.Totals[4]="实付金额:"+sMem;
	this->m_StaNoPayValue.GetWindowText(sMem);
	m_ps.Totals[5]="未付金额:"+sMem;
	this->m_StaGiveMoneyValue.GetWindowText(sMem);
	m_ps.Totals[6]="找    零:"+sMem;


	m_ps.Grid=&m_Grid;
	CMyApp* theApp;
	theApp=(CMyApp*)::AfxGetApp();
	theApp->Print();	
}

void CDOperation::OnButSave()
{	
}

void CDOperation::OnButEnrol()
{
}

void CDOperation::OnButUndo()
{
	if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	this->m_EdtMan.IsShowing=true;
	this->m_EdtMan.SetWindowText("");
	this->m_EdtMan.IsShowing=false;
	this->m_EdtOperation.IsShowing=true;
	this->m_EdtOperation.SetWindowText("");
	this->m_EdtOperation.IsShowing=false;
	this->m_EdtStore.IsShowing=true;
	this->m_EdtStore.SetWindowText("");
	this->m_EdtStore.IsShowing=false;
	this->m_StaBigTotal.SetWindowText("零元");
	this->m_StaTotal.SetWindowText("0");
	this->m_StaSumNumber.SetWindowText("0");
	this->m_Grid.DeleteAllItems();
	this->Enabled(false);
	this->m_ButEnrol.SetFocus();
}

void CDOperation::Enabled(bool bEnabled)
{
	m_Grid.ReadOnly(!bEnabled);
	m_ButEnrol.EnableWindow(!bEnabled);
	m_ButPrint.EnableWindow(!bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_ButUndo.EnableWindow(bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_Grid.m_bReadOnly=!bEnabled;
}

void CDOperation::ClearRow(int RowIndex)
{
	for(int i=1;i<m_Grid.GetCols();i++)
		m_Grid.SetItemText(RowIndex,i,"");
}

void CDOperation::OnRclickGrid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if(m_Grid.GetSelectionMark()==-1)
		return;
	POINT pot;
	GetCursorPos(&pot);
	
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_POPMENU));

	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);
 
	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pot.x, pot.y,
		this);
	*pResult = 0;
}

void CDOperation::OnPopdel() 
{

	if(MessageBox("确定要删除这条信息吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
		return;
	if(m_Grid.GetSelectionMark()!=-1)
		this->m_Grid.DeleteItem(m_Grid.GetSelectionMark());
	else
		if(m_Grid.GetRow()!=-1)
			this->m_Grid.DeleteItem(m_Grid.GetRow());

}

BOOL CDOperation::PreTranslateMessage(MSG* pMsg) 
{
	if((pMsg->hwnd==m_Grid.m_Edit.GetSafeHwnd() || pMsg->hwnd==m_Grid.GetSafeHwnd())&& pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_DELETE)
		SendMessage(WM_COMMAND,IDM_POPDEL);
	return CDialog::PreTranslateMessage(pMsg);
}

void CDOperation::OnChangeEdtpay() 
{
	CString sPay,sTotal,sGiveMoney;
	this->m_EdtPay.GetWindowText(sPay);
	this->m_StaTotal.GetWindowText(sTotal);
	float fPay,fTotal,fGiveMoney;
	fPay=atof(sPay);
	fTotal=atof(sTotal);
	if(fTotal>=fPay)
	{
		fGiveMoney=fTotal-fPay;
		sGiveMoney.Format("%f",fGiveMoney);
		this->m_StaNoPayValue.SetWindowText(sGiveMoney);
		this->m_StaGiveMoneyValue.SetWindowText("0");
	}
	else
	{
		fGiveMoney=fPay-fTotal;
		sGiveMoney.Format("%f",fGiveMoney);
		this->m_StaGiveMoneyValue.SetWindowText(sGiveMoney);
		this->m_StaNoPayValue.SetWindowText("0");
	}
	this->Invalidate();
}

void CDOperation::DrawCheck(bool bDraw)
{
	this->m_StaFrame.ShowWindow(bDraw);
	this->m_StaGiveMoney.ShowWindow(bDraw);
	this->m_StaGiveMoneyValue.ShowWindow(bDraw);
	this->m_StaPay.ShowWindow(bDraw);
	this->m_EdtPay.ShowWindow(bDraw);
	this->m_StaNoPay.ShowWindow(bDraw);
	this->m_StaNoPayValue.ShowWindow(bDraw);
}


void CDOperation::OnSetfocusEdtman() 
{

}


void CDOperation::Clear()
{
	this->m_Grid.DeleteAllItems();
}

⌨️ 快捷键说明

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