📄 rptdlgspzddh.cpp
字号:
// RptDlgSpzddh.cpp : implementation file
//
#include "stdafx.h"
#include "falcon_jxc.h"
#include "RptDlgSpzddh.h"
#include "FALCON_JXCView.h"
#include "message.h"
#include "DinghuoMx.h"
#include "DinghuoMx_ZDDH.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpzddh dialog
CRptDlgSpzddh::CRptDlgSpzddh(CWnd* pParent /*=NULL*/)
: CDialog(CRptDlgSpzddh::IDD, pParent)
{
//{{AFX_DATA_INIT(CRptDlgSpzddh)
m_strBaobiaomingcheng = _T("");
m_strBumen = _T("");
m_strZhibiaoren = _T("");
m_strZhibiaoriqi = _T("");
//}}AFX_DATA_INIT
//Andrew--------------------------------------------------
m_pView = NULL;
m_iRow = 1;
m_iSelectRow = 0;
m_bSave = FALSE;
}
CRptDlgSpzddh::CRptDlgSpzddh(CFALCON_JXCView * pView)
{
m_pView = pView;
m_iRow = 1;
m_iSelectRow = 0;
m_bSave = FALSE;
}
BOOL CRptDlgSpzddh::Create()
{
return CDialog::Create(CRptDlgSpzddh::IDD);
}
//----------------------------------------------------------
void CRptDlgSpzddh::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRptDlgSpzddh)
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(CRptDlgSpzddh, CDialog)
//{{AFX_MSG_MAP(CRptDlgSpzddh)
ON_BN_CLICKED(IDC_BAOCUN, OnBaocun)
ON_BN_CLICKED(IDC_PRT_PRINT, OnPrtPrint)
ON_BN_CLICKED(IDC_TUICHU, OnTuichu)
ON_BN_CLICKED(IDC_dinghuo, OnDinghuo)
ON_BN_CLICKED(IDC_XIUGAI, OnXiugai)
ON_CBN_KILLFOCUS(IDC_COMBO_BUMEN, OnKillfocusComboBumen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRptDlgSpzddh message handlers
BOOL CRptDlgSpzddh::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_CMSFlexGrid.SetRows(1);
m_CMSFlexGrid.SetCols(12);
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_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 CRptDlgSpzddh::OnBaocun()
{
// TODO: Add your control notification handler code here
CFALCON_JXCDoc* pDoc = m_pView->GetDocument();
UpdateData();
if (m_bSave)
{
AfxMessageBox("所列商品订货信息已保存!");
// m_iRow = 1;
// OnInitDialog();
return;
}
if(m_iRow == 1)
{
AfxMessageBox("没有需保存的订货数据!");
return;
}
if(m_CMSFlexGrid.GetTextMatrix(1,0) == "")
{
AfxMessageBox("无订货!");
return;
}
if(pDoc->ConnectToServer())
{
pDoc->SendMsg("",1110);
}
else
return;
a:
if(pDoc->m_b2110)
{
m_sDingdanhao = pDoc->m_pMsg->ShortMessage;
pDoc->m_b2110 = FALSE;
}
else
{
pDoc->ProcessReadMessage();
goto a;
}
int iTemp = atoi(m_sDingdanhao);
iTemp++;
m_sDingdanhao.Format("%d",iTemp);
CString strInsert="",strtemp="",str;
int i,j;
str.Format("%d",m_iRow-1);
strInsert += str;
strInsert += CHARFLAG;
str.Format("%d",16);
strInsert += str;
strInsert += CHARFLAG;
///////////////////////////////////转换日期格式
int len = m_strZhibiaoriqi.GetLength();
int Index = m_strZhibiaoriqi.Find("-");
strtemp = m_strZhibiaoriqi.Mid(0,Index);
str = m_strZhibiaoriqi.GetAt(Index+2);
if(str == "-")
{
CString sMonth;
sMonth = m_strZhibiaoriqi.GetAt(Index+1);
int month = atoi(sMonth);
sMonth.Format("0%d",month);
strtemp += sMonth;
}
else
{
strtemp += m_strZhibiaoriqi.Mid(Index+1,2);
}
str = m_strZhibiaoriqi.GetAt(len-2);
if(str == "-")
{
CString sDay;
sDay = m_strZhibiaoriqi.GetAt(len-1);
int day = atoi(sDay);
sDay.Format("0%d",day);
strtemp += sDay;
}
else
{
strtemp += m_strZhibiaoriqi.Mid(len-2,2);
}
m_strZhibiaoriqi = strtemp;
/////////////////////////////////////////////
for(i = 1 ; i < m_iRow; i++)
{
strInsert += m_sDingdanhao;
strInsert += CHARFLAG;
strInsert += m_strBumen;
strInsert += CHARFLAG;
for(j = 0; j < 12; j++)
{
strInsert += m_CMSFlexGrid.GetTextMatrix(i,j);
strInsert += CHARFLAG;
}
strInsert+=m_strZhibiaoriqi;
strInsert+=CHARFLAG;
strInsert+=m_strZhibiaoren;
strInsert+=CHARFLAG;
}
if(pDoc->ConnectToServer())
{
pDoc->SendMsg(strInsert,1111);//发送存储"订货单"请求
}
else
return;
b: if (pDoc->m_b2111)
{
pDoc->m_b2111 = FALSE;
m_bSave = TRUE;
}
else
{
pDoc->ProcessReadMessage();
goto b;
}
}
void CRptDlgSpzddh::OnPrtPrint()
{
// TODO: Add your control notification handler code here
UpdateData();
CFALCON_JXCDoc* pDoc = m_pView->GetDocument();
if(!m_bSave)
{
AfxMessageBox("请先保存订货信息!");
return;
}
if (m_CMSFlexGrid.GetTextMatrix(1,0) == "")
{
AfxMessageBox("无可打印数据!");
return ;
}
OnColSata(); //统计每列的最长字节串
SendMessage(WM_COMMAND,ID_FILE_PRINT_PREVIEW);
// m_strBumen = "";
// m_strZhibiaoren = "";
// for(int i=1;i<m_iRow;i++)
// {
// for(int j=0;j<12;j++)
// {
// m_CMSFlexGrid.SetTextMatrix(i,j,"");
// }
// }
// UpdateData(FALSE);
}
void CRptDlgSpzddh::OnTuichu()
{
// TODO: Add your control notification handler code here
if (m_bSave == FALSE && AfxMessageBox("尚未保存!是否退出?", MB_YESNO | MB_ICONQUESTION) == IDNO)
{
return;
}
else if(m_pView != NULL)
{
m_pView->m_iPrtItem = -1;
DestroyWindow();
}
else
{
CDialog::OnOK();
}
}
void CRptDlgSpzddh::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 = "";
//
// 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 = "";
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 CRptDlgSpzddh::OnOK()
{
//Dummy OnOk function!
}
void CRptDlgSpzddh::OnCancel()
{
//Dummy OnCancel function!
}
void CRptDlgSpzddh::OnDinghuo()
{
// TODO: Add your control notification handler code here
CFALCON_JXCDoc* pDoc = m_pView->GetDocument();
UpdateData();
if (m_bSave)
{
m_iRow = 1;
OnInitDialog();
}
if(pDoc->ConnectToServer())
{
pDoc->SendMsg(m_strBumen,1120);
}
else
return;
a:
if(pDoc->m_b2120)
{
if(pDoc->m_pMsg->ShortMessage != "")
{
int i,j;
m_iRow = pDoc->m_iRow+1;
m_CMSFlexGrid.SetRows(m_iRow);
for(i = 0; i < pDoc->m_iRow; i++)
{
for(j = 0; j < 7; j++)
{
m_CMSFlexGrid.SetTextMatrix(i+1,j,pDoc->m_StrArray.GetAt(j+i*pDoc->m_iCol));
}
m_CMSFlexGrid.SetTextMatrix(i+1,10,pDoc->m_StrArray.GetAt(7+i*pDoc->m_iCol));
m_CMSFlexGrid.SetTextMatrix(i+1,11,pDoc->m_StrArray.GetAt(8+i*pDoc->m_iCol));
}
m_bSave = FALSE;
}
else
{
AfxMessageBox("没有需要订货的商品!");
m_iRow = 1;
m_CMSFlexGrid.SetRows(m_iRow);
}
pDoc->m_b2120 = FALSE;
}
else
{
pDoc->ProcessReadMessage();
goto a;
}
}
void CRptDlgSpzddh::OnXiugai()
{
// TODO: Add your control notification handler code here
UpdateData();
if (m_bSave)
{
AfxMessageBox("商品订货信息已保存,不能再修改!");
m_iRow = 1;
OnInitDialog();
return;
}
CDinghuoMx_ZDDH dlg;
CString str;
if(m_iSelectRow != 0)
{
dlg.m_strBianma = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,0);
dlg.m_strMingcheng = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,1);
dlg.m_strDanwei = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,2);
dlg.m_strGuige = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,3);
dlg.m_strXinghao = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,4);
dlg.m_strGonghuoshang = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,5);
dlg.m_strShengchanchangshang = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,6);
dlg.m_strDangqiankucun = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,10);
dlg.m_strZuixiaokucun = m_CMSFlexGrid.GetTextMatrix(m_iSelectRow,11);
if (dlg.DoModal() == IDOK)
{
str.Format("%.2f",dlg.m_fDinghuojia);
m_CMSFlexGrid.SetTextMatrix(m_iSelectRow,7,str);
str.Format("%d",dlg.m_iDinghuoshuliang);
m_CMSFlexGrid.SetTextMatrix(m_iSelectRow,8,str);
str.Format("%.2f",dlg.m_fDinghuojia*dlg.m_iDinghuoshuliang);
m_CMSFlexGrid.SetTextMatrix(m_iSelectRow,9,str);
m_bSave = FALSE;
}
}
}
BEGIN_EVENTSINK_MAP(CRptDlgSpzddh, CDialog)
//{{AFX_EVENTSINK_MAP(CRptDlgSpzddh)
ON_EVENT(CRptDlgSpzddh, IDC_MSFLEXGRID1, -600 /* Click */, OnClickMsflexgrid1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CRptDlgSpzddh::OnClickMsflexgrid1()
{
// TODO: Add your control notification handler code here
m_iSelectRow = m_CMSFlexGrid.GetRow();
}
void CRptDlgSpzddh::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 + -