📄 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.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);
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 + -