📄 dadjust.cpp
字号:
// DAdjust.cpp : implementation file
//
#include "stdafx.h"
#include "MyProject.h"
#include "DAdjust.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDAdjust dialog
int AdjustButton::Nums=0;
int AdjustButton::Rows=0;
CDAdjust::CDAdjust(CWnd* pParent /*=NULL*/)
: CDialog(CDAdjust::IDD, pParent)
{
//{{AFX_DATA_INIT(CDAdjust)
//}}AFX_DATA_INIT
m_OldRow=0;
m_OldNum=0;
m_NewRow=0;
m_NewNum=0;
}
void CDAdjust::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDAdjust)
DDX_Control(pDX, IDC_STAFRM, m_StaFrm);
DDX_Control(pDX, IDC_LIST1, m_List);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDAdjust, CDialog)
//{{AFX_MSG_MAP(CDAdjust)
ON_MESSAGE(DIY_BUTTONDOWN,OnButtonDown)
ON_MESSAGE(DIY_BUTTONUP,OnButtonUp)
ON_MESSAGE(DIY_RBUTTONDOWN,OnRButtonDown)
ON_MESSAGE(DIY_RBUTTONUP,OnRButtonUp)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList)
ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDAdjust message handlers
void CDAdjust::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDAdjust::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CDAdjust::OnInitDialog()
{
CDialog::OnInitDialog();
this->ShowWindow(SW_MAXIMIZE);
//AddButtons("");
RxRecordset rst;
CString sText;
textDlg.Create(IDD_TOOLTEXT,this);
rst.Open("仓库信息表");
if(rst.GetRecordCount()<1)
return true;
else
{
for(int i=0;i<rst.GetRecordCount();i++)
{
rst.Move(i);
sText=rst.GetFieldValue("仓库名称");
m_List.AddString(sText);
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDAdjust::OnButtonDown()
{
CPoint pos;
::GetCursorPos(&pos);
FindButton(false,pos);
}
void CDAdjust::OnButtonUp()
{
CPoint pos;
::GetCursorPos(&pos);
FindButton(true,pos);
RxRecordset rst;
CString sSQL;
sSQL.Format("SELECT * FROM 库存信息表 WHERE 货位_排=%d AND 货位_号=%d AND 仓库编号=%s",m_NewRow,m_NewNum,m_StoreID);
rst.Open(sSQL,adCmdText);
if(rst.GetRecordCount()<1)
{
sSQL.Format("UPDATE 库存信息表 SET 货位_排=%d,货位_号=%d WHERE 货位_排=%d AND 货位_号=%d AND 仓库编号=%s",m_NewRow,m_NewNum,m_OldRow,m_OldNum,m_StoreID);
rst.Open(sSQL,adCmdText);
this->UpDate();
this->Invalidate();
}
else
MessageBox("新货位已放置商品,请将其调整到其他货位!","系统提示",MB_OK|MB_ICONSTOP);
}
CDAdjust::FindButton(bool bNew,CPoint pos)
{
CRect rcButton;
for(int i=0;i<AdjustButton::Rows;i++)
{
for(int n=0;n<AdjustButton::Nums;n++)
{
m_Button[i][n].GetWindowRect(&rcButton);
if(rcButton.PtInRect(pos)==true)
{
if(bNew==false)
{
m_OldRow=i+1;
m_OldNum=n+1;
}
else
{
m_NewRow=i+1;
m_NewNum=n+1;
}
break;
}
}
}
}
void CDAdjust::UpDate()
{
int nAspect,nStyle;
CString sSQL;
RxRecordset rst;
for(int i=0;i<AdjustButton::Rows;i++)
{
if(i%2!=0)
nAspect=0;
else
nAspect=1;
for(int n=0;n<AdjustButton::Nums;n++)
{
sSQL.Format("SELECT * FROM 库存信息表 WHERE 货位_排=%d AND 货位_号=%d AND 仓库编号=%s",i+1,n+1,m_StoreID);
rst.Open(sSQL,adCmdText);
if( rst.GetRecordCount()<1)
nStyle=0;
else
nStyle=1;
m_Button[i][n].SetStyle(nStyle,nAspect);
}
}
}
void CDAdjust::OnRButtonDown()
{
CPoint pos;
::GetCursorPos(&pos);
FindButton(true,pos);
RxRecordset rst;
CString sSQL,sText;
sSQL.Format("SELECT b.名称 FROM 库存信息表 a INNER JOIN 商品信息表 b ON a.商品条形码=b.条形码 WHERE 货位_排=%d AND 货位_号=%d AND 仓库编号=%s",m_NewRow,m_NewNum,m_StoreID);
rst.Open(sSQL,adCmdText);
if(rst.GetRecordCount()<1)
return;
else
{
sText=rst.GetFieldValue("名称");
textDlg.Show(sText);
}
}
void CDAdjust::OnRButtonUp()
{
textDlg.ShowWindow(SW_HIDE);
}
void CDAdjust::AddButtons(CString sID)
{
CRect rect;
this->m_StaFrm.GetWindowRect(&rect);
//取出当前所选仓库的信息
CString sSQL,sName;
sSQL.Format("SELECT * FROM 仓库信息表 WHERE 编号 = %s",sID);
RxRecordset rst;
rst.Open(sSQL,adCmdText);
if(rst.GetRecordCount()<1)
return;
CString sRow=rst.GetFieldValue("仓库排数");
CString sNum=rst.GetFieldValue("每排号数");
AdjustButton::Nums=atoi(sNum);
AdjustButton::Rows=atoi(sRow);
CRect rcBut(0,0,0,0);
int nStyle,nAspect;
rcBut.left=rect.left+2;
rcBut.right=rcBut.left+rect.Width()/atoi(sRow)-2;
rcBut.top=rect.top-14;
rcBut.bottom=rcBut.top+rect.Height()/atoi(sNum);
CString si,sn;
for(int i=0;i<atoi(sRow);i++)
{
if(i%2!=0)
nAspect=0;
else
nAspect=1;
for(int n=0;n<atoi(sNum);n++)
{
sSQL.Format("SELECT * FROM 库存信息表 WHERE 货位_排=%d AND 货位_号=%d AND 仓库编号=%s",i+1,n+1,sID);
rst.Open(sSQL,adCmdText);
if( rst.GetRecordCount()<1)
nStyle=0;
else
nStyle=1;
si.Format("%d",i+1);
sn.Format("%d",n+1);
sName.Format("%s-%s",si,sn);
m_Button[i][n].Create(sName,WS_CHILD|BS_OWNERDRAW,rcBut,this,WM_USER+801);
m_Button[i][n].ShowWindow(SW_SHOW);
m_Button[i][n].SetStyle(nStyle,nAspect);
rcBut.top=rcBut.bottom;
rcBut.bottom=rcBut.top+rect.Height()/atoi(sNum);
}
rcBut.top=rect.top-14;
rcBut.bottom=rcBut.top+rect.Height()/atoi(sNum);
rcBut.left=rcBut.right;
rcBut.right=rcBut.left+rect.Width()/atoi(sRow)-2;
}
}
void CDAdjust::DeleButtons()
{
for(int i=0;i<AdjustButton::Rows;i++)
{
for(int n=0;n<AdjustButton::Nums;n++)
m_Button[i][n].DestroyWindow();
}
}
void CDAdjust::OnSelchangeList()
{
CString sText;
this->m_List.GetText(m_List.GetCurSel(),sText);
m_StoreID=ado.FieldToOtherField("仓库信息表","仓库名称",sText,"编号",1);
DeleButtons();
AddButtons(m_StoreID);
}
void CDAdjust::OnButexit()
{
this->OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -