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

📄 dlgdiaobo.cpp

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

#include "stdafx.h"
#include "falcon_jxc.h"
#include "DlgDiaobo.h"
#include "mainfrm.h"
#include "FALCON_JXCView.h"
#include "message.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgDiaobo dialog


CDlgDiaobo::CDlgDiaobo(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgDiaobo::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgDiaobo)
	m_sChuhuobumen = _T("");
	m_sRiqi = _T("");
	m_sShouhuobumen = _T("");
	m_sSonghuodanhao = _T("");
	m_sZhidanren = _T("");
	//}}AFX_DATA_INIT
	m_iSelectRow = 0;
	m_bSave = FALSE;
}


void CDlgDiaobo::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgDiaobo)
	DDX_Control(pDX, IDC_SHOUHUOBUMEN, m_ctrShouhuobumen);
	DDX_Control(pDX, IDC_CHUHUOBUMEN, m_ctrChuhuobumen);
	DDX_CBString(pDX, IDC_CHUHUOBUMEN, m_sChuhuobumen);
	DDX_Control(pDX, IDC_MSFLEXGRID1, m_ctrMSFlexGrid);
	DDX_Text(pDX, IDC_RIQI, m_sRiqi);
	DDX_CBString(pDX, IDC_SHOUHUOBUMEN, m_sShouhuobumen);
	DDX_Text(pDX, IDC_SONGHUODANBIANHAO, m_sSonghuodanhao);
	DDX_Text(pDX, IDC_ZHIDANREN, m_sZhidanren);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgDiaobo, CDialog)
	//{{AFX_MSG_MAP(CDlgDiaobo)
	ON_BN_CLICKED(IDC_CHAXUN, OnChaxun)
	ON_BN_CLICKED(IDC_SHANCHU, OnShanchu)
	ON_BN_CLICKED(IDC_QUEDING, OnQueding)
	ON_BN_CLICKED(IDC_TUICHU, OnTuichu)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgDiaobo message handlers

BOOL CDlgDiaobo::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_ctrChuhuobumen.AddString("库房");
	m_ctrChuhuobumen.AddString("南洋");
	m_ctrChuhuobumen.AddString("欧典");
	m_ctrChuhuobumen.AddString("圣地亚");
	m_ctrChuhuobumen.SetCurSel(0);
	m_ctrShouhuobumen.AddString("南洋");
	m_ctrShouhuobumen.AddString("欧典");
	m_ctrShouhuobumen.AddString("圣地亚");
	m_ctrShouhuobumen.SetCurSel(0);

	m_ctrMSFlexGrid.SetTextMatrix(0,0,"商品编码");
	m_ctrMSFlexGrid.SetTextMatrix(0,1,"名称");
	m_ctrMSFlexGrid.SetTextMatrix(0,2,"规格");
	m_ctrMSFlexGrid.SetTextMatrix(0,3,"单位");
	m_ctrMSFlexGrid.SetTextMatrix(0,4,"数量");
	m_ctrMSFlexGrid.SetTextMatrix(0,5,"商品所在地");
	m_ctrMSFlexGrid.SetTextMatrix(0,6,"备注");

	CTime time=CTime::GetCurrentTime();
	CString str;
	int yy,mm,dd;
	yy=time.GetYear();
	mm=time.GetMonth();
	dd=time.GetDay();
	str.Format("%d-%d-%d",yy,mm,dd);
	m_sRiqi = str;
	UpdateData(FALSE);
	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgDiaobo::OnChaxun() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_sSonghuodanhao == "")
	{
		AfxMessageBox("请输入送货单号!");
		return;
	}
	CMainFrame* pwnd=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	CFALCON_JXCView* pView=(CFALCON_JXCView*)pwnd->GetActiveView();
	CFALCON_JXCDoc* pDoc = pView->GetDocument();
	int i,j;
	for(i = 1; i < 5; i++)
	{
		for(j = 0; j < 7; j++)
		{
			m_ctrMSFlexGrid.SetTextMatrix(i,j,"");
		}
	}
	
	if(pDoc->ConnectToServer())
	{

		pDoc->SendMsg(m_sSonghuodanhao,1313);
	}
	else
		return;

a: 
	if(pDoc->m_b2313)
	{
		if(pDoc->m_pMsg->ShortMessage != "")
		{
			int n = 0;
			CString str;
			int iRows = 1;
			for(i = 1; i < 5; i++)
			{
				if(pDoc->m_StrArray[5+n] != "展场")
				{
					for(j = 0; j < 6; j++)
					{
						str = pDoc->m_StrArray[j+n];
						m_ctrMSFlexGrid.SetTextMatrix(iRows,j,str);
					}
					if(m_ctrMSFlexGrid.GetTextMatrix(iRows,0) != "")
					{
						m_ctrMSFlexGrid.SetTextMatrix(iRows,6,"销售");
					}

					iRows++;
				}
				n += 6;
			}

			UpdateData(FALSE);
		}
		else
		{
			AfxMessageBox("未查到相符记录!");
		}
		pDoc->m_b2313 = FALSE;
	}
	else
	{
		pDoc->ProcessReadMessage();
		goto a;
	}
	
}

BEGIN_EVENTSINK_MAP(CDlgDiaobo, CDialog)
    //{{AFX_EVENTSINK_MAP(CDlgDiaobo)
	ON_EVENT(CDlgDiaobo, IDC_MSFLEXGRID1, -600 /* Click */, OnClickMsflexgrid1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CDlgDiaobo::OnClickMsflexgrid1() 
{
	// TODO: Add your control notification handler code here
	m_iSelectRow = m_ctrMSFlexGrid.GetRow();
	
}

void CDlgDiaobo::OnShanchu() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
//	if(m_iSelectRow == 0)
//	{
//		AfxMessageBox("请选择要删除的条目!");
//		return;
//	}


	CString str;
	if (m_iSelectRow >0)
	{		
		if ( m_ctrMSFlexGrid.GetTextMatrix(m_iSelectRow,0) == "")
		{
			return;
		}
		else
		{
			str.Format("是否删除第%d条记录?",m_iSelectRow);
			if(AfxMessageBox(str,MB_YESNO) == IDYES)
			{
				m_ctrMSFlexGrid.RemoveItem(m_iSelectRow);
				m_ctrMSFlexGrid.SetRows(5);
				m_ctrMSFlexGrid.Refresh();
			}
			m_iSelectRow=0;
		}
	}
	else 
	{
		AfxMessageBox("请选择要删除的记录!");
		return;
	}
	
}

void CDlgDiaobo::OnQueding() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	
	if(m_ctrMSFlexGrid.GetTextMatrix(1,0) == "")
	{
		AfxMessageBox("无调拨货品!");
		return;
	}
	
	CMainFrame* pwnd=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	CFALCON_JXCView* pView=(CFALCON_JXCView*)pwnd->GetActiveView();
	CFALCON_JXCDoc* pDoc = pView->GetDocument();
	if(pDoc->ConnectToServer())
	{

		pDoc->SendMsg("",1340);
	}
	else
		return;

a: 
	if(pDoc->m_b2340)
	{
	   m_sDbdbh=pDoc->m_pMsg->ShortMessage;
	   pDoc->m_b2340 = FALSE;
	}
	else
	{
		pDoc->ProcessReadMessage();
		goto a;
	}


//	CMainFrame* pwnd=(CMainFrame*)AfxGetApp()->m_pMainWnd;
//	CFALCON_JXCView* pView=(CFALCON_JXCView*)pwnd->GetActiveView();
//	CFALCON_JXCDoc* pDoc=	pView->GetDocument();
	CString strInsert,strtemp,str;
	int i,j,tmp = 0;
	for(i = 1; i < 5; i++)
	{
		if(m_ctrMSFlexGrid.GetTextMatrix(i,0) == "")
		{
			tmp++;
		}
	}
	if(tmp == 4)
	{
		OnOK();
		return;
	}
	
	int iTemp = atoi(m_sDbdbh);
	iTemp++;
	m_sDbdbh.Format("%d",iTemp);
	strInsert = m_sDbdbh;
	strInsert+=CHARFLAG;

	///////////////////////////////////转换日期格式
	int len = m_sRiqi.GetLength();
	int Index = m_sRiqi.Find("-");
	strtemp = m_sRiqi.Mid(0,Index);
	str = m_sRiqi.GetAt(Index+2);
	if(str == "-")
	{
		CString sMonth;
		sMonth = m_sRiqi.GetAt(Index+1);
		int month = atoi(sMonth);
		sMonth.Format("0%d",month);
		strtemp += sMonth;
	}
	else
	{
		strtemp += m_sRiqi.Mid(Index+1,2);
	}
	str = m_sRiqi.GetAt(len-2);
	if(str == "-")
	{
		CString sDay;
		sDay = m_sRiqi.GetAt(len-1);
		int day = atoi(sDay);
		sDay.Format("0%d",day);
		strtemp += sDay;
	}
	else
	{
		strtemp += m_sRiqi.Mid(len-2,2);
	}
	m_sRiqi = strtemp;
	/////////////////////////////////////////////

	strInsert+=m_sRiqi;
	strInsert+=CHARFLAG;
	strInsert+=m_sSonghuodanhao;
	strInsert+=CHARFLAG;
	strInsert+=m_sChuhuobumen;
	strInsert+=CHARFLAG;
	strInsert+=m_sShouhuobumen;
	strInsert+=CHARFLAG;
	for(i=1;i<5;i++)
	{
		for(j=0;j<5;j++)
		{
			strInsert+=m_ctrMSFlexGrid.GetTextMatrix(i,j);
			strInsert+=CHARFLAG;
		}
		strInsert+=m_ctrMSFlexGrid.GetTextMatrix(i,6);
		strInsert+=CHARFLAG;
	}
	strInsert+=m_sZhidanren;
	strInsert+=CHARFLAG;

	if(pDoc->ConnectToServer())
	{

		pDoc->SendMsg(strInsert,1341);
	}
	else
		return;

	/*/////////////////////
	添加打印函数
	*/////////////////////
	m_bSave = TRUE;

	for(i=1;i<5;i++)
	{
		for(j=0;j<7;j++)
		{
			m_ctrMSFlexGrid.SetTextMatrix(i,j,"");
		}
	}
//	OnOK();
	
}

void CDlgDiaobo::OnTuichu() 
{
	// TODO: Add your control notification handler code here
	if (m_bSave == FALSE && AfxMessageBox("尚未出单!是否退出?", MB_YESNO | MB_ICONQUESTION) == IDNO)
	{
		return;
	}
	else
	{
		CDialog::OnOK();

	}	
}

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

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

⌨️ 快捷键说明

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