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

📄 rptdlgspkcpd.cpp

📁 面向软件工程的Visual C++网络程序开发
💻 CPP
字号:
// RptDlgSpkcpd.cpp : implementation file
//

#include "stdafx.h"
#include "falcon_jxc.h"
#include "RptDlgSpkcpd.h"
#include "FALCON_JXCView.h"
#include "message.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpkcpd dialog


CRptDlgSpkcpd::CRptDlgSpkcpd(CWnd* pParent /*=NULL*/)
	: CDialog(CRptDlgSpkcpd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CRptDlgSpkcpd)
	m_strZhibiaoren = _T("");
	m_strZhibiaoriqi = _T("");
	m_strBaobiaomingcheng = _T("");
	m_strBumen = _T("");
	//}}AFX_DATA_INIT
//Andrew--------------------------------------------------
	m_pView = NULL;
}

CRptDlgSpkcpd::CRptDlgSpkcpd(CFALCON_JXCView * pView)
{
	m_pView = pView;
}

BOOL CRptDlgSpkcpd::Create()
{
	return CDialog::Create(CRptDlgSpkcpd::IDD);
}
//----------------------------------------------------------


void CRptDlgSpkcpd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRptDlgSpkcpd)
	DDX_Control(pDX, IDC_BUMENCOM, m_ctrBumen);
	DDX_Control(pDX, IDC_DATE_QI, m_ctrTimeQi);
	DDX_Control(pDX, IDC_DATE_ZHI, m_ctrTimeZhi);
	DDX_Control(pDX, IDC_MSFLEXGRID1, m_CMSFlexGrid);
	DDX_Text(pDX, IDC_ZHIBIAOREN, m_strZhibiaoren);
	DDX_Text(pDX, IDC_ZHIBIAORIQI, m_strZhibiaoriqi);
	DDX_Text(pDX, IDC_BAOBIAOMINGCHENG, m_strBaobiaomingcheng);
	DDX_CBString(pDX, IDC_BUMENCOM, m_strBumen);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRptDlgSpkcpd, CDialog)
	//{{AFX_MSG_MAP(CRptDlgSpkcpd)
	ON_BN_CLICKED(IDC_TONGJI, OnTongji)
	ON_BN_CLICKED(IDC_PRT_PRINT, OnPrtPrint)
	ON_BN_CLICKED(IDC_TUICHU, OnTuichu)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpkcpd message handlers

BOOL CRptDlgSpkcpd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_CMSFlexGrid.SetCols(10);
	m_CMSFlexGrid.SetTextMatrix(0,1,"商品编码");
	m_CMSFlexGrid.SetTextMatrix(0,2,"名称");
	m_CMSFlexGrid.SetTextMatrix(0,3,"单位");
 	m_CMSFlexGrid.SetTextMatrix(0,4,"规格");	
	m_CMSFlexGrid.SetTextMatrix(0,5,"型号");	
	m_CMSFlexGrid.SetTextMatrix(0,6,"库存量");	
	m_CMSFlexGrid.SetTextMatrix(0,7,"供货商");		
	m_CMSFlexGrid.SetTextMatrix(0,8,"生产厂商");	
	m_CMSFlexGrid.SetTextMatrix(0,9,"存货部门");	

	CTime time=CTime::GetCurrentTime();
	m_ctrTimeQi.SetTime(&time);
	m_ctrTimeZhi.SetTime(&time);
	int yy,mm,dd;
	CString str;	
	yy=time.GetYear();
	mm=time.GetMonth();
	dd=time.GetDay();
	str.Format("%d-%d-%d",yy,mm,dd);
	m_strZhibiaoriqi = str;
	GetWindowText(m_strBaobiaomingcheng);

	m_ctrBumen.AddString("所有部门");
	m_ctrBumen.AddString("库房");
	m_ctrBumen.AddString("圣地亚");
	m_ctrBumen.AddString("欧典");
	m_ctrBumen.AddString("南洋");
	m_ctrBumen.SetCurSel(1);
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CRptDlgSpkcpd::OnTongji() 
{
	// TODO: Add your control notification handler code here
	CFALCON_JXCDoc* pDoc = m_pView->GetDocument();
	ASSERT_VALID(pDoc);

	UpdateData();

	if (m_strBumen =="")
	{
		AfxMessageBox("请选择盘点部门!");
		return;
	}

	CString strtemp,str;
/*
	CTime timeQi,timeZhi;
	m_ctrTimeQi.GetTime(timeQi);
	m_ctrTimeZhi.GetTime(timeZhi);
	int yy,mm,dd;
	yy = timeQi.GetYear();
	str.Format("%d",yy);
	m_sTimeqi = str;
	mm = timeQi.GetMonth();
	if(mm < 10)
	{
		str.Format("0%d",mm);
		m_sTimeqi += str;
	}
	else
	{
		str.Format("%d",mm);
		m_sTimeqi += str;
	}

	dd = timeQi.GetDay();
	if(dd < 10)
	{
		str.Format("0%d",dd);
		m_sTimeqi += str;
	}
	else
	{
		str.Format("%d",dd);
		m_sTimeqi += str;
	}
		
	yy = timeZhi.GetYear();
	str.Format("%d",yy);
	m_sTimezhi = str;
	mm = timeZhi.GetMonth();
	if(mm < 10)
	{
		str.Format("0%d",mm);
		m_sTimezhi += str;
	}
	else
	{
		str.Format("%d",mm);
		m_sTimezhi += str;
	}

	dd = timeZhi.GetDay();
	if(dd < 10)
	{
		str.Format("0%d",dd);
		m_sTimezhi += str;
	}
	else
	{
		str.Format("%d",dd);
		m_sTimezhi += str;
	}*/


	CString strRequest;
	strRequest = m_strBumen;
	
	if(pDoc->ConnectToServer())
	{

		pDoc->SendMsg(strRequest,1517);//发送查询"验收单"请求
	}
	else
		return;

a: 
	if(pDoc->m_b2517)
	{
		if(pDoc->m_pMsg->ShortMessage != "")
		{
			m_CMSFlexGrid.SetRows(pDoc->m_iRow+1);
			for(int i = 1; i < pDoc->m_iRow+1; i++)
			{
				str.Format("%d",i);
				m_CMSFlexGrid.SetTextMatrix(i,0,str);
				for (int j=0; j<9; j++)
				{
					str = pDoc->m_StrArray[(i-1)*9+j];
					m_CMSFlexGrid.SetTextMatrix(i,j+1,str);
				}
			}
			m_CMSFlexGrid.Refresh();
		}
		else
		{
			AfxMessageBox("未查到相符记录!");
			m_CMSFlexGrid.SetRows(2);
			for (int j=0; j<10;j++)
			{
				m_CMSFlexGrid.SetTextMatrix(1,j,"");
			}
			m_CMSFlexGrid.Refresh();
		}
		pDoc->m_b2517 = FALSE;
	}
	else
	{
		pDoc->ProcessReadMessage();
		goto a;
	}	
}

void CRptDlgSpkcpd::OnPrtPrint() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_CMSFlexGrid.GetTextMatrix(1,0) == "")
	{
		AfxMessageBox("无可打印数据!");
		return ;
	}


	OnColSata();	//统计每列的最长字节串

	SendMessage(WM_COMMAND,ID_FILE_PRINT_PREVIEW);
	
}

void CRptDlgSpkcpd::OnTuichu() 
{
	// TODO: Add your control notification handler code here
	m_pView->m_iPrtItem = -1;
	if (m_pView != NULL)
	{
		DestroyWindow();
	}
	else
	{
		CDialog::OnOK();
 	}
}

void CRptDlgSpkcpd::OnColSata()	
{
	//Rows
	int iRows = m_CMSFlexGrid.GetRows()-1;
	if (iRows%20 != 0)
	{
		m_pView->m_iPageNum = int(iRows/20.0 + 1.0);	
	}
	else
	{
		m_pView->m_iPageNum = iRows/20;
	}
	
	//ColWidths
	m_pView->m_iAColWidth.RemoveAll();
	m_pView->m_iAColWidth.SetSize(m_CMSFlexGrid.GetCols());
	for (int i=0; i<m_CMSFlexGrid.GetCols(); i++)
	{
		int iMaxLen = 0;
		for (int j=0; j<m_CMSFlexGrid.GetRows(); j++)
		{
			int iLen = strlen(m_CMSFlexGrid.GetTextMatrix(j,i));
			iMaxLen = iMaxLen > iLen ? iMaxLen : iLen;
		}
			m_pView->m_iAColWidth.SetAt(i,iMaxLen);
	}	
//表格内容及字串	
	CTime time;
	int yy,mm,dd;
	CString str;
	
	m_ctrTimeQi.GetTime(time);	
	yy =time.GetYear();
	mm =time.GetMonth();
	dd =time.GetDay();	
	str.Format("%d-%d-%d",yy,mm,dd);
	m_pView->m_strTimeQi = str;

	m_ctrTimeZhi.GetTime(time);
	yy =time.GetYear();
	mm =time.GetMonth();
	dd =time.GetDay();	
	str.Format("%d-%d-%d",yy,mm,dd);
	m_pView->m_strTimeZhi = str;

	m_pView->m_strBaobiaomingcheng = m_strBaobiaomingcheng;
	m_pView->m_strZhibiaoriqi = m_strZhibiaoriqi;
	m_pView->m_strZhibiaoren = m_strZhibiaoren;
	m_pView->m_CMSFlexGrid = &m_CMSFlexGrid;
}

void CRptDlgSpkcpd::OnOK() 
{
	//Dummy OnOk function!
}

void CRptDlgSpkcpd::OnCancel() 
{
	//Dummy OnCancel function!
}

⌨️ 快捷键说明

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