?? ddelever.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 經(jīng)手人,c.用戶名 AS 操作員 FROM 出庫記錄表 a inner join 員工信息表 b ON a.經(jīng)手人=b.編號 inner join 操作員信息表 c ON a.操作員=c.操作員編號 WHERE 審核否=1 ) DERIVEDTBL WHERE 出庫票號 NOT IN( SELECT 出庫票號 FROM 配送申請表)");
rst.Open(sSQL,adCmdText);
if(rst.GetRecordCount()<1)
{
MessageBox("沒有審核通過的出庫記錄,不允許配送!","系統(tǒng)提示",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.規(guī)格,c.產(chǎn)地,b.銷售數(shù)量 AS 出庫數(shù)量 FROM 出庫記錄表 a INNER JOIN 銷售明細(xì)表 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("對不起!您輸入的出庫票號不正確,請確認(rèn)后重新輸入!","系統(tǒng)提示",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.規(guī)格,c.產(chǎn)地,b.銷售數(shù)量 AS 出庫數(shù)量 FROM 出庫記錄表 a INNER JOIN 銷售明細(xì)表 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("確定要保存記錄嗎?","系統(tǒng)提示",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]="要求到達(dá)時間:"+sDate2;
m_ps.Totals[4]="收貨人:"+sSMan;
m_ps.Totals[5]="收貨人電話:"+sSManTel;
m_ps.Totals[6]="發(fā)貨人:"+sFMan;
m_ps.Totals[7]="發(fā)貨人電話:"+sFManTel;
m_ps.Totals[8]="卸貨地點:"+sAddr;
m_ps.Totals[9]="經(jīng)手人:"+sMan;
m_ps.Totals[10]="收貨人簽字:_____";
m_ps.Grid=&m_Grid;
CMyApp* theApp;
theApp=(CMyApp*)::AfxGetApp();
theApp->Print();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -