?? dinput.cpp
字號:
// DInput.cpp : implementation file
//
#include "stdafx.h"
#include "qpglxt.h"
#include "DInput.h"
#include "externDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CQpglxtApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDInput dialog
CDInput::CDInput(CWnd* pParent /*=NULL*/)
: CDialog(CDInput::IDD, pParent)
{
//{{AFX_DATA_INIT(CDInput)
//}}AFX_DATA_INIT
}
void CDInput::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDInput)
DDX_Control(pDX, IDC_STASFJE, m_StaSfje);
DDX_Control(pDX, IDC_STAWFJE, m_StaWfje);
DDX_Control(pDX, IDC_STABLOCK, m_staBlock);
DDX_Control(pDX, IDC_INPUT_EDTSTORE, m_EdtStore);
DDX_Control(pDX, IDC_INPUT_STASUMNUMBER, m_StaSumNumber);
DDX_Control(pDX, IDC_INPUT_STASUMMONEY, m_StaSumMoney);
DDX_Control(pDX, IDC_INPUT_STASUMMONEY2, m_StaBigSumMoney);
DDX_Control(pDX, IDC_INPUT_EDTPAY, m_EdtPay);
DDX_Control(pDX, IDC_INPUT_EDTNOPAY, m_EdtNoPay);
DDX_Control(pDX, IDC_INPUT_EDTGIVECHANGE, m_EdtGiveChange);
DDX_Control(pDX, IDC_INPUT_STAID, m_StaID);
DDX_Control(pDX, IDC_INPUT_STADATE, m_StaDate);
DDX_Control(pDX, IDC_INPUT_BUTBOOKIN, m_ButBookIn);
DDX_Control(pDX, IDC_INPUT_BUTUNDO, m_ButUndo);
DDX_Control(pDX, IDC_INPUT_BUTSAVE, m_ButSave);
DDX_Control(pDX, IDC_INPUT_BUTPRINT, m_ButPrint);
DDX_Control(pDX, IDC_INPUT_BUTEXIT, m_ButExit);
DDX_Control(pDX, IDC_INPUT_STAOP, m_StaOP);
DDX_Control(pDX, IDC_INPUT_GRID, m_Grid);
DDX_Control(pDX, IDC_INPUT_EDTPROVIDE, m_EdtProvide);
DDX_Control(pDX, IDC_INPUT_EDTDEAR, m_EdtDear);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDInput, CDialog)
//{{AFX_MSG_MAP(CDInput)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_INPUT_BUTBOOKIN, OnInputButbookin)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_INPUT_BUTEXIT, OnInputButexit)
ON_BN_CLICKED(IDC_INPUT_BUTSAVE, OnInputButsave)
ON_EN_CHANGE(IDC_INPUT_EDTPAY, OnChangeInputEdtpay)
ON_BN_CLICKED(IDC_INPUT_BUTUNDO, OnInputButundo)
ON_BN_CLICKED(IDC_INPUT_BUTPRINT, OnInputButprint)
ON_EN_KILLFOCUS(IDC_INPUT_EDTDEAR, OnKillfocusInputEdtdear)
//}}AFX_MSG_MAP
ON_MESSAGE(DIY_SETFOCUS,OnCellSetFocus)
ON_MESSAGE(DIY_KILLFOCUS,OnCellKillFocus)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDInput message handlers
void CDInput::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDInput::OnPaint()
{
CPaintDC pDC(this); // device context for painting
CBitmap bit;
CDC memDC;
CRect rect;
this->GetClientRect(&rect);
if(m_Caption=="進貨管理")
bit.LoadBitmap(IDB_INPUT);
if(m_Caption=="退貨返廠管理")
bit.LoadBitmap(IDB_BACKF);
if(m_Caption=="銷售管理")
bit.LoadBitmap(IDB_SELL);
if(m_Caption=="銷售退貨管理")
bit.LoadBitmap(IDB_SELLBACK);
if(m_Caption=="商品調撥管理")
bit.LoadBitmap(IDB_DH);
memDC.CreateCompatibleDC(&pDC);
memDC.SelectObject(&bit);
pDC.BitBlt(22,23,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memDC.DeleteDC();
::DeleteObject(&bit);
}
BOOL CDInput::OnInitDialog()
{
CDialog::OnInitDialog();
this->SetWindowText(m_Caption);
m_StaDate.SetTextColor(RGB(0,0,0));
m_StaID.SetTextColor(RGB(0,0,0));
CString sSQL;
if(m_Caption!="銷售管理"&&m_Caption!="銷售退貨管理"&&m_Caption!="商品調撥管理")
sSQL.Format("SELECT 編號,名稱,簡稱 FROM 往來單位信息表 WHERE 類型=0");
else
if(m_Caption=="商品調撥管理")
{
sSQL.Format("SELECT * FROM 倉庫信息查詢");
this->m_staBlock.ShowWindow(SW_SHOW);
}
else
sSQL.Format("SELECT 編號,名稱,簡稱 FROM 往來單位信息表 WHERE 類型=1");
rst.Open(sSQL,adCmdText);
m_EdtProvide.Initialize(this->GetParent());
m_EdtProvide.StartUpAssciation=true;
m_EdtProvide.SetRecordset(rst);
m_EdtProvide.SetSelectField("名稱");
m_StaOP.SetWindowText(OP);
sSQL.Format("SELECT 編號,姓名 FROM 員工信息表");
rst.Open(sSQL,adCmdText);
m_EdtDear.Initialize(this->GetParent());
m_EdtDear.SetRecordset(rst);
m_EdtDear.SetSelectField("姓名");
rst.Open("倉庫信息查詢");
m_EdtStore.Initialize(this->GetParent());
m_EdtStore.SetRecordset(rst);
m_EdtStore.SetSelectField("名稱");
CString Fields[]={"配件名稱","適用車型","規格","產地","計量單位","進貨數量","價格","合計"};
if(m_Caption=="銷售管理")
{
Fields[5]="銷售數量";
this->m_StaSfje.SetWindowText("實收金額:");
this->m_StaWfje.SetWindowText("未收金額:");
}
if(m_Caption=="退貨返廠管理")
{
Fields[5]="退貨數量";
this->m_StaSfje.SetWindowText("實返金額:");
this->m_StaWfje.SetWindowText("未返金額:");
}
if(m_Caption=="銷售退貨管理")
{
Fields[5]="退貨數量";
this->m_StaSfje.SetWindowText("實返金額:");
this->m_StaWfje.SetWindowText("未返金額:");
}
if(m_Caption=="商品調撥管理")
{
Fields[5]="調撥數量";
this->m_StaSfje.EnableWindow(false);
this->m_StaWfje.EnableWindow(false);
}
int ColWidth[]={130,60,100,130,60,60,60,78};
for(int m=0;m<8;m++)
{
m_Grid.InsertColumn(m,Fields[m]);
m_Grid.SetColumnWidth(m,ColWidth[m]);
}
m_Grid.m_Edit.Initialize(this->GetParent());
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDInput::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->hwnd==m_EdtDear.GetSafeHwnd() && pMsg->message==WM_KEYDOWN && pMsg->wParam==9)
{
this->m_Grid.InsertItem(0,"");
this->m_Grid.SetRow(0);
this->m_Grid.SetCol(0);
this->m_Grid.BeginEdit(0,0);
this->m_Grid.m_Edit.SetFocus();
pMsg->wParam=VK_CONTROL ;
}
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_ESCAPE)
{
pMsg->wParam=VK_CONTROL ;
this->OnInputButexit();
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDInput::OnInputButbookin()
{
CTime time;
CString cTime,NewID;
if(m_Caption=="進貨管理")
NewID=ado.AutoNumber("進貨信息表","票號","JH",3);
if(m_Caption=="退貨返廠管理")
NewID=ado.AutoNumber("退貨返廠表","票號","RT",3);
if(m_Caption=="銷售管理")
NewID=ado.AutoNumber("銷售信息表","票號","XS",3);
if(m_Caption=="銷售退貨管理")
NewID=ado.AutoNumber("銷售退貨信息表","票號","XT",3);
if(m_Caption=="商品調撥管理")
NewID=ado.AutoNumber("調貨信息表","票號","DB",3);
NewID=NewID+" ";
this->m_StaID.SetWindowText(NewID);
time=time.GetCurrentTime();
cTime=CTimeToCString(time);
cTime=cTime+" ";
this->m_StaDate.SetWindowText(cTime);
this->m_EdtProvide.SetFocus();
this->Enabled(false);
this->Clear();
}
HBRUSH CDInput::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd==&this->m_StaDate|| pWnd==&this->m_StaID)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CDInput::Enabled(bool bEnabled)
{
this->m_Grid.ReadOnly(bEnabled);
this->m_ButBookIn.EnableWindow(bEnabled);
if(m_Caption!="商品調撥管理")
this->m_EdtPay.EnableWindow(!bEnabled);
this->m_ButExit.EnableWindow(bEnabled);
this->m_ButPrint.EnableWindow(bEnabled);
this->m_ButSave.EnableWindow(!bEnabled);
this->m_ButUndo.EnableWindow(!bEnabled);
}
void CDInput::OnCellSetFocus()
{
CString sSQL, sName,sType,sSpec,sAddr;
switch(m_Grid.GetCol())
{
case 0:
m_Grid.m_Edit.NumberOnly(false);
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.ClearAll();
rst.Open("SELECT DISTINCT 名稱,簡稱 from 商品信息表",adCmdText);
m_Grid.m_Edit.StartUpAssciation=true;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("名稱");
m_Grid.m_Edit.AutoPosition();
break;
case 1:
m_Grid.m_Edit.NumberOnly(false);
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.ClearAll();
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sSQL.Format("SELECT DISTINCT 名稱,適用車型 from 商品信息查詢 WHERE 名稱='%s'",sName);
rst.Open(sSQL,adCmdText);
m_Grid.m_Edit.StartUpAssciation=false;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("適用車型");
m_Grid.m_Edit.AutoPosition();
break;
case 2:
m_Grid.m_Edit.NumberOnly(false);
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.ClearAll();
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sType=m_Grid.GetItemText(m_Grid.GetRow(),1);
sSQL.Format("SELECT DISTINCT 名稱,規格 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s'",sName,sType);
rst.Open(sSQL,adCmdText);
m_Grid.m_Edit.StartUpAssciation=false;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("規格");
m_Grid.m_Edit.AutoPosition();
break;
case 3:
m_Grid.m_Edit.NumberOnly(false);
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.ClearAll();
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sType=m_Grid.GetItemText(m_Grid.GetRow(),1);
sSpec=m_Grid.GetItemText(m_Grid.GetRow(),2);
sSQL.Format("SELECT DISTINCT 名稱,產地 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s' AND 規格='%s'",sName,sType,sSpec);
rst.Open(sSQL,adCmdText);
m_Grid.m_Edit.StartUpAssciation=false;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("產地");
m_Grid.m_Edit.AutoPosition();
break;
case 4:
m_Grid.m_Edit.NumberOnly(false);
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.ClearAll();
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sType=m_Grid.GetItemText(m_Grid.GetRow(),1);
sSpec=m_Grid.GetItemText(m_Grid.GetRow(),2);
sAddr=m_Grid.GetItemText(m_Grid.GetRow(),3);
sSQL.Format("SELECT DISTINCT 名稱,計量單位 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s' AND 規格='%s' AND 產地='%s'",sName,sType,sSpec,sAddr);
rst.Open(sSQL,adCmdText);
m_Grid.m_Edit.StartUpAssciation=false;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("計量單位");
m_Grid.m_Edit.AutoPosition();
break;
case 5:
m_Grid.m_Edit.PopHide=true;
m_Grid.m_Edit.NumberOnly(true);
m_Grid.m_Edit.HideGrid();
break;
case 6:
m_Grid.m_Edit.PopHide=false;
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.ClearAll();
m_Grid.m_Edit.NumberOnly(true);
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sType=m_Grid.GetItemText(m_Grid.GetRow(),1);
sSpec=m_Grid.GetItemText(m_Grid.GetRow(),2);
sAddr=m_Grid.GetItemText(m_Grid.GetRow(),3);
if(m_Caption=="銷售管理" || m_Caption=="銷售退貨管理")
sSQL.Format("SELECT DISTINCT 名稱,銷售價格 as 價格 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s' AND 規格='%s' AND 產地='%s'",sName,sType,sSpec,sAddr);
else
sSQL.Format("SELECT DISTINCT 名稱,進價 as 價格 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s' AND 規格='%s' AND 產地='%s'",sName,sType,sSpec,sAddr);
rst.Open(sSQL,adCmdText);
m_Grid.m_Edit.StartUpAssciation=false;
m_Grid.m_Edit.SetRecordset(rst);
m_Grid.m_Edit.SetSelectField("價格");
m_Grid.m_Edit.AutoPosition();
m_Grid.m_Edit.ShowGrid();
break;
case 7:
m_Grid.m_Edit.EnterNumber=0;
m_Grid.m_Edit.PopHide=true;
m_Grid.m_Edit.NumberOnly(true);
m_Grid.m_Edit.HideGrid();
break;
}
}
void CDInput::OnCellKillFocus()
{
RxRecordset rst;
CString sNumber,sMoney,sTotal,sSumNumber,sSumMoney;
float fTotal,fNumber,fSumNumber=0,fSumMoney=0;
if(m_Grid.GetCol()==5)
{
sNumber=m_Grid.GetItemText(m_Grid.GetRow(),5);
if(sNumber.IsEmpty())
{
m_Grid.m_Edit.EnterNumber=0;
m_Grid.SetCol(5);
m_Grid.BeginEdit(this->m_Grid.GetRow(),5);
m_Grid.m_Edit.SetFocus();
}
else
{
if(m_Caption=="銷售管理"||m_Caption=="退貨返廠管理")
{
CString sSQL,sID,sName,sType,sSpec,sAddr,sStore;
sName=m_Grid.GetItemText(m_Grid.GetRow(),0);
sType=m_Grid.GetItemText(m_Grid.GetRow(),1);
sSpec=m_Grid.GetItemText(m_Grid.GetRow(),2);
sAddr=m_Grid.GetItemText(m_Grid.GetRow(),3);
sSQL.Format("SELECT 編號 from 商品信息查詢 WHERE 名稱='%s' AND 適用車型='%s' AND 規格='%s' AND 產地='%s'",sName,sType,sSpec,sAddr);
rst.Open(sSQL,adCmdText);
sID=rst.GetFieldValue("編號");
m_EdtStore.GetWindowText(sStore);
CString sStoreID=ado.FieldToOtherField("倉庫信息查詢","名稱",sStore,"編號",1);
sSQL.Format("SELECT * FROM 庫存信息表 WHERE 商品編號 ='%s' AND 倉庫 =%s",sID,sStoreID);
rst.Open(sSQL,adCmdText);
CString sStoreNumber;
if(rst.GetRecordCount()<1)
sStoreNumber="0";
else
sStoreNumber=rst.GetFieldValue("庫存數量");
if(atoi(sNumber)>atoi(sStoreNumber)|| sStoreNumber=="0")
{
m_Grid.SetItemText(m_Grid.GetRow(),m_Grid.GetCol(),sStoreNumber);
}
}
}
}
if(m_Grid.GetCol()==6)
{
sNumber=m_Grid.GetItemText(m_Grid.GetRow(),5);
sMoney=m_Grid.GetItemText(m_Grid.GetRow(),6);
fTotal=atof(sNumber)*atof(sMoney);
sTotal.Format("%f",fTotal);
m_Grid.SetItemText(m_Grid.GetRow(),7,sTotal);
for(int i=0;i<m_Grid.GetRows();i++)
{
sNumber=m_Grid.GetItemText(i,5);
sMoney=m_Grid.GetItemText(i,6);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -