📄 dlgmodifygoodssite.cpp
字号:
// DlgModifyGoodsSite.cpp : implementation file
//
#include "stdafx.h"
#include "Manage_WH.h"
#include "DlgModifyGoodsSite.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgModifyGoodsSite dialog
CDlgModifyGoodsSite::CDlgModifyGoodsSite(CWnd* pParent /*=NULL*/)
: CDialog(CDlgModifyGoodsSite::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgModifyGoodsSite)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDI_MYICON);
}
void CDlgModifyGoodsSite::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgModifyGoodsSite)
DDX_Control(pDX, IDC_LIST, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgModifyGoodsSite, CDialog)
//{{AFX_MSG_MAP(CDlgModifyGoodsSite)
ON_BN_CLICKED(IDC_READ, OnRead)
ON_BN_CLICKED(IDC_CHANGE, OnChange)
ON_BN_CLICKED(IDC_SETNULL, OnSetnull)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_RESUME, OnResume)
ON_BN_CLICKED(IDC_WRITE, OnWrite)
ON_BN_CLICKED(IDC_UNDO, OnUndo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgModifyGoodsSite message handlers
BOOL CDlgModifyGoodsSite::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN &&(pMsg->wParam==13 || pMsg->wParam==27))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CDlgModifyGoodsSite::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon,TRUE);
m_list.InsertColumn(0,"商品编码列表");
RECT rect;
m_list.GetWindowRect(&rect);
int wid = rect.right - rect.left - 20;
m_list.SetColumnWidth(0,wid);
//填充货位索引下拉列表
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX)),"T_Goods_Site_Manage","F_SiteIndex");
CString sVal;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
//填充托盘索引下拉列表
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->ResetContent();
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->AddString("");
rs.Open("select * from T_Salver_Manage where F_State='正常'",adCmdText);
while(!rs.IsEOF())
{
rs.GetCollect("F_Index",sVal);
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->AddString(sVal);
rs.MoveNext();
}
rs.Close();
cn.Close();
//填充商品名称
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME)),"T_Products","F_Name");
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->AddString("杂色商品");
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->AddString("空货箱");
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->AddString("单空托盘");
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->AddString("托盘垛");
//填充客户名称
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER)),"T_Customers","F_CompanyName");
//填充货位状态
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE)),"T_Site_State","F_Name");
return TRUE;
}
void CDlgModifyGoodsSite::OnRead()
{
CString sSiteIndex;
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX))->GetWindowText(sSiteIndex);
if (!sSiteIndex.IsEmpty())
{
int iCount(0),row(0);
CString sTrayIndex,sGoodsCode,sCustomer,sCount,sGoodsName,s,sField;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from V_GoodsSiteInfo where F_Site='"+sSiteIndex+"'",adCmdText);
if (rs.GetRecordCount() != 0)
{
rs.MoveFirst();
rs.GetCollect("F_Tray",sTrayIndex);
rs.GetCollect("F_Name",sGoodsName);
rs.GetCollect("F_GoodsCount",iCount);
rs.GetCollect("F_CustomerName",sCustomer);
rs.GetCollect("F_State",m_sStatus);
sCount.Format("%d",iCount);
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->SetCurSel(static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->FindString(-1,sTrayIndex));
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->SetCurSel(static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->FindString(-1,sGoodsName));
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->SetCurSel(static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->FindString(-1,m_sStatus));
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->SetCurSel(static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->FindString(-1,sCustomer));
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_COUNT))->SetWindowText(sCount);
m_list.DeleteAllItems();
m_sGoodsCodeArray.RemoveAll();
for (int i=1;i<9;i++)
{
s.Format("%d",i);
sField = "F_Index"+s+"";
rs.GetCollect(sField,sGoodsCode);
if (!sGoodsCode.IsEmpty())
{
row = m_list.InsertItem(row,"");
m_list.SetItemText(row,0,sGoodsCode);
m_sGoodsCodeArray.Add(sGoodsCode);
row++;
}
}
}
rs.Close();
cn.Close();
static_cast<CButton *>(GetDlgItem(IDC_CHANGE))->EnableWindow(TRUE);
if (m_sStatus != "空")
static_cast<CButton *>(GetDlgItem(IDC_SETNULL))->EnableWindow(TRUE);
else
static_cast<CButton *>(GetDlgItem(IDC_SETNULL))->EnableWindow(FALSE);
}
}
void CDlgModifyGoodsSite::OnChange()
{
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX))->EnableWindow(FALSE);
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->EnableWindow(TRUE);
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->EnableWindow(TRUE);
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->EnableWindow(TRUE);
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->EnableWindow(TRUE);
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_CODE))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_ADD))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_DEL))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_RESUME))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_WRITE))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_UNDO))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_READ))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_CHANGE))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_SETNULL))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDCANCEL))->EnableWindow(FALSE);
//修改货位状态
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->ResetContent();
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->AddString("空");
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->AddString("有货");
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->AddString("禁用");
}
void CDlgModifyGoodsSite::OnSetnull()
{
CString sSiteIndex;
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX))->GetWindowText(sSiteIndex);
if (MessageBox("是否置空货位["+sSiteIndex+"]?","系统提示",MB_ICONWARNING|MB_YESNO) == IDNO)
return;
CAdoConnection cn;
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("UPDATE T_Goods_Site_Manage SET F_TrayIndex='',F_Index1='',F_Index2='',F_Index3='',F_Index4='',F_Index5='',\
F_Index6='',F_Index7='',F_Index8='',F_GoodsKind=0,F_GoodsCount=0,F_CustomerName='',F_IfRight='Y',\
F_SiteState=0,F_InLibTime='1972-12-03 21:00:00' WHERE F_SiteIndex='"+sSiteIndex+"'",adCmdText);
cn.Close();
AddLog("置空货位:["+sSiteIndex+"]");
OnUndo();
}
void CDlgModifyGoodsSite::OnAdd()
{
CString sGoodsCode;
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_CODE))->GetWindowText(sGoodsCode);
if (!sGoodsCode.IsEmpty())
{
if (m_list.GetItemCount() == 8)
{
MessageBox("托盘最多放置商品数量为8!","系统提示",MB_ICONSTOP|MB_OK);
return;
}
int bz(0);
for (int i=0;i<m_list.GetItemCount();i++)
{
if (sGoodsCode == m_list.GetItemText(i,0))
bz = 1;
}
if (bz == 1)
{
MessageBox("商品["+sGoodsCode+"]已存在!","系统提示",MB_ICONSTOP|MB_OK);
return;
}
int row;
row = m_list.GetItemCount();
row = m_list.InsertItem(row,"");
m_list.SetItemText(row,0,sGoodsCode);
CString sGoodsCount;
sGoodsCount.Format("%d",m_list.GetItemCount());
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_COUNT))->SetWindowText(sGoodsCount);
}
}
void CDlgModifyGoodsSite::OnDel()
{
for (int i=0;i<m_list.GetItemCount();i++)
{
if (m_list.GetItemState(i,LVIS_SELECTED) == LVIS_SELECTED)
{
m_list.DeleteItem(i);
CString sGoodsCount;
sGoodsCount.Format("%d",m_list.GetItemCount());
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_COUNT))->SetWindowText(sGoodsCount);
}
}
}
void CDlgModifyGoodsSite::OnResume()
{
m_list.DeleteAllItems();
int row(0);
for (int i=0;i<m_sGoodsCodeArray.GetSize();i++)
{
row = m_list.InsertItem(row,"");
m_list.SetItemText(row,0,m_sGoodsCodeArray[i]);
row++;
}
CString sGoodsCount;
sGoodsCount.Format("%d",m_list.GetItemCount());
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_COUNT))->SetWindowText(sGoodsCount);
}
void CDlgModifyGoodsSite::OnWrite()
{
CString sSiteIndex,sTrayIndex,sGoodsName,sSiteState,sCustomer,sInTime,sWarning,sSQL,sCount;
int iCount(0),iGoodsKind(0);
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX))->GetWindowText(sSiteIndex);
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->GetWindowText(sTrayIndex);
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->GetWindowText(sGoodsName);
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->GetWindowText(sSiteState);
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->GetWindowText(sCustomer);
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_COUNT))->GetWindowText(sCount);
iCount = atoi(sCount);
if (!sGoodsName.IsEmpty())
{
if (sGoodsName == "杂色商品") iGoodsKind=100;
else if (sGoodsName=="空货箱") iGoodsKind=101;
else if (sGoodsName=="单空托盘") iGoodsKind=102;
else if (sGoodsName=="托盘垛") iGoodsKind=103;
else iGoodsKind=gfGetGoodsKind(sGoodsName);
}
if (sSiteState.IsEmpty())
{
MessageBox("请选择要更改的货位的状态!","系统提示",MB_ICONSTOP|MB_OK);
return;
}
if (MessageBox("是否修改货位["+sSiteIndex+"]","系统提示",MB_ICONINFORMATION|MB_YESNO)==IDNO)
return;
CAdoConnection cn;
CAdoRecordSet rs;
if (sSiteState == "空")
{
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("UPDATE T_Goods_Site_Manage SET F_TrayIndex='',F_Index1='',F_Index2='',F_Index3='',F_Index4='',F_Index5='',\
F_Index6='',F_Index7='',F_Index8='',F_GoodsKind=0,F_GoodsCount=0,F_CustomerName='',F_IfRight='Y',\
F_SiteState=0,F_InLibTime='1972-12-03 21:00:00' WHERE F_SiteIndex='"+sSiteIndex+"'",adCmdText);
cn.Close();
AddLog("将货位["+sSiteIndex+"]置空");
}
else if (sSiteState=="有货")
{
if (sTrayIndex.IsEmpty()) sWarning = "托盘索引不能为空,请输入!";
else if (sGoodsName.IsEmpty()) sWarning = "商品类型不能为空,请输入!";
else if (sGoodsName!="空货箱" && sGoodsName!="单空托盘" && sGoodsName!="托盘垛" && iCount==0)
sWarning = "请在列表中添加商品条形码!";
if (!sWarning.IsEmpty())
{
MessageBox(sWarning,"系统提示",MB_ICONSTOP|MB_OK);
return;
}
CString s,sTemp;
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("UPDATE T_Goods_Site_Manage SET F_Index1='',F_Index2='',F_Index3='',F_Index4='',F_Index5='',\
F_Index6='',F_Index7='',F_Index8='' WHERE F_SiteIndex='"+sSiteIndex+"'",adCmdText);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Goods_Site_Manage where F_SiteIndex='"+sSiteIndex+"'",adCmdText);
rs.PutCollect("F_TrayIndex",sTrayIndex);
for (int i=0;i<iCount;i++)
{
s.Format("%d",i+1);
s = "F_Index"+s+"";
rs.PutCollect(s,m_list.GetItemText(i,0));
}
rs.PutCollect("F_GoodsKind",iGoodsKind);
rs.PutCollect("F_GoodsCount",iCount);
rs.PutCollect("F_CustomerName",sCustomer);
s="Y";
rs.PutCollect("F_IfRight",s);
rs.PutCollect("F_SiteState",1);
if (m_sStatus=="空" || m_sStatus=="无货占用" || m_sStatus=="禁用")
{
CString sInLibTime;
sInLibTime = GetDate(2);
rs.PutCollect("F_InLibTime",sInLibTime);
}
rs.Update();
rs.Close();
cn.Close();
AddLog("修改货位["+sSiteIndex+"]信息");
}
else if (sSiteState == "禁用")
{
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("UPDATE T_Goods_Site_Manage SET F_SiteState=4 WHERE F_SiteIndex='"+sSiteIndex+"'",adCmdText);
cn.Close();
AddLog("将货位["+sSiteIndex+"]置为禁用");
}
OnUndo();
}
void CDlgModifyGoodsSite::OnUndo()
{
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_INDEX))->EnableWindow(TRUE);
static_cast<CComboBox *>(GetDlgItem(IDC_TRAY_INDEX))->EnableWindow(FALSE);
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS_NAME))->EnableWindow(FALSE);
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->EnableWindow(FALSE);
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->EnableWindow(FALSE);
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_CODE))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_ADD))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_DEL))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_RESUME))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_WRITE))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_UNDO))->EnableWindow(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_READ))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_CHANGE))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDC_SETNULL))->EnableWindow(TRUE);
static_cast<CButton *>(GetDlgItem(IDCANCEL))->EnableWindow(TRUE);
static_cast<CEdit *>(GetDlgItem(IDC_GOODS_CODE))->SetWindowText("");
static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE))->ResetContent();
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_SITE_STATE)),"T_Site_State","F_Name");
OnRead();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -