📄 rptdlgspdhhz.cpp
字号:
// RptDlgSpdhhz.cpp : implementation file
//
#include "stdafx.h"
#include "falcon_jxc.h"
#include "RptDlgSpdhhz.h"
#include "FALCON_JXCView.h"
#include "message.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpdhhz dialog
CRptDlgSpdhhz::CRptDlgSpdhhz(CWnd* pParent /*=NULL*/)
: CDialog(CRptDlgSpdhhz::IDD, pParent)
{
//{{AFX_DATA_INIT(CRptDlgSpdhhz)
m_strBaobiaomingcheng = _T("");
m_strBumen = _T("");
m_strZhibiaoren = _T("");
m_strZhibiaoriqi = _T("");
//}}AFX_DATA_INIT
//Andrew--------------------------------------------------
m_pView = NULL;
}
CRptDlgSpdhhz::CRptDlgSpdhhz(CFALCON_JXCView * pView)
{
m_pView = pView;
}
BOOL CRptDlgSpdhhz::Create()
{
return CDialog::Create(CRptDlgSpdhhz::IDD);
}
//----------------------------------------------------------
void CRptDlgSpdhhz::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRptDlgSpdhhz)
DDX_Control(pDX, IDC_DATE_ZHI, m_ctrTimeZhi);
DDX_Control(pDX, IDC_DATE_QI, m_ctrTimeQi);
DDX_Control(pDX, IDC_COMBO_BUMEN, m_ctrBumen);
DDX_Text(pDX, IDC_BAOBIAOMINGCHENG, m_strBaobiaomingcheng);
DDX_CBString(pDX, IDC_COMBO_BUMEN, m_strBumen);
DDX_Control(pDX, IDC_MSFLEXGRID1, m_CMSFlexGrid);
DDX_Text(pDX, IDC_ZHIBIAOREN, m_strZhibiaoren);
DDX_Text(pDX, IDC_ZHIBIAORIQI, m_strZhibiaoriqi);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRptDlgSpdhhz, CDialog)
//{{AFX_MSG_MAP(CRptDlgSpdhhz)
ON_BN_CLICKED(IDC_TONGJI, OnTongji)
ON_BN_CLICKED(IDC_PRT_PRINT, OnPrtPrint)
ON_BN_CLICKED(IDC_TUICHU, OnTuichu)
ON_CBN_KILLFOCUS(IDC_COMBO_BUMEN, OnKillfocusComboBumen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpdhhz message handlers
BOOL CRptDlgSpdhhz::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_CMSFlexGrid.SetRows(1);
m_CMSFlexGrid.SetCols(16);
m_CMSFlexGrid.SetTextMatrix(0,0,"订单号");
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,"订货价");
m_CMSFlexGrid.SetTextMatrix(0,10,"订货数量");
m_CMSFlexGrid.SetTextMatrix(0,11,"订货金额");
m_CMSFlexGrid.SetTextMatrix(0,12,"当前库存");
m_CMSFlexGrid.SetTextMatrix(0,13,"最小库存");
m_CMSFlexGrid.SetTextMatrix(0,14,"制单日期");
m_CMSFlexGrid.SetTextMatrix(0,15,"制单人");
m_ctrBumen.AddString("圣地亚");
m_ctrBumen.AddString("欧典");
m_ctrBumen.AddString("南洋");
m_ctrBumen.AddString("库房");
m_ctrBumen.AddString("所有部门");
m_ctrBumen.SetCurSel(0);
int yy,mm,dd;
CTime time=CTime::GetCurrentTime();
CString str;
yy=time.GetYear();
mm=time.GetMonth();
dd=time.GetDay();
str.Format("%d-%d-%d",yy,mm,dd);
UpdateData();
m_strZhibiaoriqi = str;
GetWindowText(m_strBaobiaomingcheng);
m_strBaobiaomingcheng = m_strBumen + "-" + m_strBaobiaomingcheng;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRptDlgSpdhhz::OnTongji()
{
// TODO: Add your control notification handler code here
CFALCON_JXCDoc* pDoc = m_pView->GetDocument();
ASSERT_VALID(pDoc);
UpdateData();
CTime timeQi,timeZhi;
m_ctrTimeQi.GetTime(timeQi);
m_ctrTimeZhi.GetTime(timeZhi);
CString strtemp,str;
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_sTimeqi;
strRequest += CHARFLAG;
strRequest += m_sTimezhi;
strRequest += CHARFLAG;
strRequest += m_strBumen;
strRequest += CHARFLAG;
if(pDoc->ConnectToServer())
{
pDoc->SendMsg(strRequest,1410);//发送查询"订货单"请求
}
else
return;
a:
if(pDoc->m_b2410)
{
if(pDoc->m_pMsg->ShortMessage != "")
{
m_CMSFlexGrid.SetRows(pDoc->m_iRow+1);
for(int i = 1; i < pDoc->m_iRow+1; i++)
{
for (int j=0; j<pDoc->m_iCol; j++)
{
str = pDoc->m_StrArray[(i-1)*pDoc->m_iCol+j];
m_CMSFlexGrid.SetTextMatrix(i,j,str);
}
}
m_CMSFlexGrid.Refresh();
}
else
{
m_CMSFlexGrid.SetRows(2);
for (int j=0; j<16;j++)
{
m_CMSFlexGrid.SetTextMatrix(1,j,"");
}
m_CMSFlexGrid.Refresh();
}
pDoc->m_b2410 = FALSE;
}
else
{
pDoc->ProcessReadMessage();
goto a;
}
}
void CRptDlgSpdhhz::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 CRptDlgSpdhhz::OnTuichu()
{
// TODO: Add your control notification handler code here
m_pView->m_iPrtItem = -1;
if (m_pView != NULL)
{
DestroyWindow();
}
else
{
CDialog::OnOK();
}
}
void CRptDlgSpdhhz::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 CRptDlgSpdhhz::OnOK()
{
//Dummy OnOk function!
}
void CRptDlgSpdhhz::OnCancel()
{
//Dummy OnCancel function!
}
void CRptDlgSpdhhz::OnKillfocusComboBumen()
{
// TODO: Add your control notification handler code here
UpdateData();
GetWindowText(m_strBaobiaomingcheng);
m_strBaobiaomingcheng = m_strBumen + "-" + m_strBaobiaomingcheng;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -