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

📄 ddelever.cpp

📁 物流管理系统是我买的一本书上的一个系统。斑竹看看行吗?
💻 CPP
字号:
// DDelever.cpp : implementation file
//

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

/////////////////////////////////////////////////////////////////////////////
// CDDelever dialog


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


void CDDelever::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDDelever)
	DDX_Control(pDX, IDC_GRID, m_Grid);
	DDX_Control(pDX, IDC_EDTSTORE, m_EdtStore);
	DDX_Control(pDX, IDC_EDTSMANTEL, m_EdtSManTel);
	DDX_Control(pDX, IDC_EDTSMAN, m_EdtSMan);
	DDX_Control(pDX, IDC_EDTOUTPUTID, m_EdtOutPutID);
	DDX_Control(pDX, IDC_EDTNAME, m_EdtName);
	DDX_Control(pDX, IDC_EDTMAN, m_EdtMan);
	DDX_Control(pDX, IDC_EDTFMANTEL, m_EdtFManTel);
	DDX_Control(pDX, IDC_EDTID, m_EdtID);
	DDX_Control(pDX, IDC_EDTFMAN, m_EdtFMan);
	DDX_Control(pDX, IDC_EDTDATE, m_EdtDate);
	DDX_Control(pDX, IDC_EDTADDR, m_EdtAddr);
	DDX_Control(pDX, IDC_DTDATE, m_DtDate);
	DDX_Control(pDX, IDC_BUTSAVE, m_ButSave);
	DDX_Control(pDX, IDC_BUTPRINT, m_ButPrint);
	DDX_Control(pDX, IDC_BUTNEW, m_ButNew);
	DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDDelever, CDialog)
	//{{AFX_MSG_MAP(CDDelever)
	ON_BN_CLICKED(IDC_BUTNEW, OnButnew)
	ON_NOTIFY(NM_SETFOCUS, IDC_DTDATE, OnSetfocusDtdate)
	ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	ON_BN_CLICKED(IDC_BUTPRINT, OnButprint)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDDelever message handlers

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

void CDDelever::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CDDelever::Enabled(bool bEnabled)
{
	m_EdtSManTel.EnableWindow(bEnabled);
	m_EdtSMan.EnableWindow(bEnabled);
	m_EdtOutPutID.EnableWindow(bEnabled);
	m_EdtMan.EnableWindow(bEnabled);
	m_EdtFManTel.EnableWindow(bEnabled);
	m_EdtFMan.EnableWindow(bEnabled);
	m_EdtAddr.EnableWindow(bEnabled);
	m_DtDate.EnableWindow(bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_ButPrint.EnableWindow(!bEnabled);
	m_ButNew.EnableWindow(!bEnabled);
	m_ButExit.EnableWindow(!bEnabled);
}

void CDDelever::OnButnew() 
{
	Clear();
	CString NewNumber;
	RxRecordset rst;
	NewNumber=ado.AutoNumber("配送申请表","配送票号","PS",3);
	this->m_EdtID.SetWindowText(NewNumber);
	CTime Date;
	Date=Date.GetCurrentTime();
	CString sDate;
	sDate=CTimeToCString(Date);
	this->m_EdtDate.SetWindowText(sDate);
	this->m_DtDate.SetTime(&Date);
	Enabled(true);
	this->m_EdtOutPutID.SetFocus();
}

void CDDelever::Clear()
{
	m_Grid.DeleteAllItems();
	m_EdtStore.SetWindowText("");
	m_EdtSManTel.SetWindowText("");
	m_EdtSMan.SetWindowText("");
	m_EdtOutPutID.IsShowing=true;
	m_EdtOutPutID.SetWindowText("");
	m_EdtOutPutID.IsShowing=false;
	m_EdtName.SetWindowText("");

	m_EdtMan.IsShowing=true;
	m_EdtMan.SetWindowText("");
	m_EdtMan.IsShowing=false;

	m_EdtFManTel.SetWindowText("");
	m_EdtFMan.SetWindowText("");
	m_EdtAddr.SetWindowText("");

}


BOOL CDDelever::OnInitDialog() 
{
	CDialog::OnInitDialog();
	RxRecordset rst;
	CString sSQL;
	sSQL.Format("SELECT * FROM ( SELECT 出库票号,出库日期,b.姓名 AS 经手人,c.用户名 AS 操作员 FROM 出库记录表 a inner join 员工信息表 b ON a.经手人=b.编号 inner join 操作员信息表 c ON a.操作员=c.操作员编号 WHERE 审核否=1 ) DERIVEDTBL WHERE 出库票号 NOT IN( SELECT 出库票号 FROM 配送申请表)");
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()<1)
	{
		MessageBox("没有审核通过的出库记录,不允许配送!","系统提示",MB_OK|MB_ICONSTOP);
		this->OnCancel();
	}
	m_EdtOutPutID.Initialize(this->GetParent());
	m_EdtOutPutID.SetRecordset(rst);
	m_EdtOutPutID.SetSelectField("出库票号");

	rst.Open("员工信息表");
	m_EdtMan.Initialize(this->GetParent());
	m_EdtMan.SetRecordset(rst);
	m_EdtMan.SetSelectField("姓名");
	
	m_Grid.m_bReadOnly=true;	
	sSQL.Format("SELECT b.商品条形码 AS 条码,c.名称,c.规格,c.产地,b.销售数量 AS 出库数量 FROM 出库记录表 a INNER JOIN 销售明细表 b ON  a.销售票号=b.销售票号 INNER JOIN 商品信息表 c ON b.商品条形码=c.条形码");
	m_Grid.SetDataBase(sSQL,adCmdText);
	m_Grid.DeleteAllItems();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



void CDDelever::OnSetfocusDtdate(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CString sSQL,sOutputID,sClient,sStore;
	RxRecordset rst;
	this->m_EdtOutPutID.GetWindowText(sOutputID);
	sSQL.Format("select a.出库票号,a.出库日期,c.全称,d.仓库名称 from 出库记录表 a inner join 销售记录表 b ON a.销售票号=b.销售票号  inner join 往来单位信息表 c on b.客户编号=c.编号 inner join 仓库信息表 d on a.出货仓库=d.编号 WHERE 出库票号='%s'",sOutputID);
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()<1 && sOutputID.IsEmpty()==false)
	{
		MessageBox("对不起!您输入的出库票号不正确,请确认后重新输入!","系统提示",MB_OK|MB_ICONSTOP);
		this->m_EdtOutPutID.SetFocus();
	}
	else
	{
		sClient=rst.GetFieldValue("全称");
		sStore=rst.GetFieldValue("仓库名称");
		m_EdtStore.SetWindowText(sStore);
		m_EdtName.SetWindowText(sClient);
		sSQL.Format("SELECT b.商品条形码 AS 条码,c.名称,c.规格,c.产地,b.销售数量 AS 出库数量 FROM 出库记录表 a INNER JOIN 销售明细表 b ON  a.销售票号=b.销售票号 INNER JOIN 商品信息表 c ON b.商品条形码=c.条形码 WHERE a.出库票号='%s'",sOutputID);
		rst.Open(sSQL,adCmdText);
		m_Grid.AddCellValue(rst);
	}	

	*pResult = 0;
}

void CDDelever::OnButsave() 
{
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL,sStore,sSManTel,sSMan,sOutPutID,sName,sMan,sFManTel,sID,sFMan,sDate,sDate2,sAddr;
	CTime	tTime;

	//取出各编辑框中的文本
	m_EdtStore.GetWindowText(sStore);
	sStore=ado.FieldToOtherField("仓库信息表","仓库名称",sStore,"编号",1);
	m_EdtSManTel.GetWindowText(sSManTel);
	m_EdtSMan.GetWindowText(sSMan);
	m_EdtOutPutID.GetWindowText(sOutPutID);
	m_EdtName.GetWindowText(sName);
	sName=ado.FieldToOtherField("往来单位信息表","全称",sName,"编号",1);

	m_EdtMan.GetWindowText(sMan);
	sMan=ado.FieldToOtherField("员工信息表","姓名",sMan,"编号",1);

	m_EdtFManTel.GetWindowText(sFManTel); 
	m_EdtID.GetWindowText(sID); 
	m_EdtFMan.GetWindowText(sFMan); 
	m_EdtAddr.GetWindowText(sAddr);
	m_EdtDate.GetWindowText(sDate);
	
	this->m_DtDate.GetTime(tTime);
	sDate2=CTimeToCString(tTime); 
	CString sOPID=ado.FieldToOtherField("操作员信息表","用户名",OP,"操作员编号",1);
	sSQL.Format("INSERT INTO 配送申请表 VALUES('%s','%s','%s',%s,'%s','%s','%s','%s','%s','%s','%s',%s,%s,0)",sID,sDate,sName,sStore,sOutPutID,sDate2,sSMan,sSManTel,sFMan,sFManTel,sAddr,sMan,sOPID);
	RxRecordset rst;
	rst.Open(sSQL,adCmdText);
	this->Enabled(false);
}

void CDDelever::OnButexit() 
{
	this->OnCancel();	
}

void CDDelever::OnButprint() 
{

	CString sSQL,sStore,sSManTel,sSMan,sOutPutID,sName,sMan,sFManTel,sID,sFMan,sDate,sDate2,sAddr;
	CTime	tTime;

	m_ps.MainCaptionFontSize=400;
	m_ps.DeckCaptionFontSize=180;

	m_EdtStore.GetWindowText(sStore);
	m_EdtSManTel.GetWindowText(sSManTel);
	m_EdtSMan.GetWindowText(sSMan);
	m_EdtOutPutID.GetWindowText(sOutPutID);
	m_EdtName.GetWindowText(sName);
	m_EdtMan.GetWindowText(sMan);
	m_EdtFManTel.GetWindowText(sFManTel); 
	m_EdtID.GetWindowText(sID); 
	m_EdtFMan.GetWindowText(sFMan); 
	m_EdtAddr.GetWindowText(sAddr);
	m_EdtDate.GetWindowText(sDate);
	
	this->m_DtDate.GetTime(tTime);
	sDate2=CTimeToCString(tTime); 
	CString sOPID=ado.FieldToOtherField("操作员信息表","用户名",OP,"操作员编号",1);
	m_ps.MainCaption="配送单";
	m_ps.DeckCaptionNumber=1;
	m_ps.DeckCaptions[0]="配送商品详单如下:";
	m_ps.TotalNumber=11;

	m_ps.Totals[0]="配送票号:"+sID;
	m_ps.Totals[1]="客户名称:"+sName;
	m_ps.Totals[2]="仓库名称:"+sStore;
	m_ps.Totals[3]="要求到达时间:"+sDate2;
	m_ps.Totals[4]="收货人:"+sSMan;
	m_ps.Totals[5]="收货人电话:"+sSManTel;
	m_ps.Totals[6]="发货人:"+sFMan;
	m_ps.Totals[7]="发货人电话:"+sFManTel;
	m_ps.Totals[8]="卸货地点:"+sAddr;
	m_ps.Totals[9]="经手人:"+sMan;
	m_ps.Totals[10]="收货人签字:_____";

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

⌨️ 快捷键说明

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