123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726 |
- // DlgScanBarCode.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "YLGL.h"
- #include "DlgScanBarCode.h"
- #include <Imm.h>
- #pragma comment(lib, "Imm32.lib")
- // CDlgScanBarCode 对话框
- //////////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNAMIC(CEnEdit, CEdit)
- CEnEdit::CEnEdit()
- {
- m_DefaultHKL = GetDefaultKbdLayout();
- m_Save_KbdLayout = 0;
- m_pParent = NULL;
- m_nLines = 0;
- m_bLockKbdLayout = TRUE;
- }
- CEnEdit::~CEnEdit()
- {
- }
- BEGIN_MESSAGE_MAP(CEnEdit, CEdit)
- //{{AFX_MSG_MAP(CEditEx)
- //}}AFX_MSG_MAP
- ON_CONTROL_REFLECT(EN_KILLFOCUS, OnEnKillfocus)
- ON_CONTROL_REFLECT(EN_SETFOCUS, OnEnSetfocus)
- //ON_WM_CHAR()
- ON_WM_CHAR()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEditEx message handlers
- void CEnEdit::OnEnKillfocus()
- {
- if(m_Save_KbdLayout) //恢复输入法;
- {
- printf("恢复输入法\n");
- if(ActivateKeyboardLayout(m_Save_KbdLayout, 0) == 0)
- printf( _T("Restore ActivateKeyboardLayout Err=%d"), GetLastError());
- m_Save_KbdLayout = 0;
- }
- }
- void CEnEdit::OnEnSetfocus()
- {
- if(m_DefaultHKL)
- {
- HKL CurKbdLayout = GetKeyboardLayout(0);
- if(CurKbdLayout != m_DefaultHKL)
- {
- m_Save_KbdLayout = CurKbdLayout; //保存输入法 ;
- if(ActivateKeyboardLayout(m_DefaultHKL, 0) == 0) //设置为默认输入法 ;
- {
- printf( _T("Set ActivateKeyboardLayout Err=%d"), GetLastError());
- }
- }
- }
- }
- HKL CEnEdit::GetDefaultKbdLayout()
- {
- HKL HKL_Ret= 0;
- int nSize = GetKeyboardLayoutList(0 , 0);
- if(nSize != 0)
- {
- printf("输入法数量:%d\n", nSize);
- HKL FAR * lpList = (HKL FAR *)new HKL[nSize];
- ZeroMemory(lpList, sizeof(HKL) * nSize);
- if(GetKeyboardLayoutList(nSize, lpList) == nSize)
- {
- for(int i=0; i<nSize; i++)
- {
- HKL Val = lpList[i];
- if(HIWORD(Val) == LOWORD(Val))
- HKL_Ret = Val;
- printf( _T("0x%08X/n"), Val);
- }
- }
- delete []lpList;
- }
- return HKL_Ret;
- }
- LRESULT CEnEdit::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- //if(WM_INPUTLANGCHANGEREQUEST == message) //输入法改变;
- //printf("==%d,%d,%d\n", message, wParam, lParam);
- if ( WM_INPUTLANGCHANGE == message || WM_INPUTLANGCHANGEREQUEST == message)
- {
- printf("输入法改变\n");
- if(m_DefaultHKL)
- {
- HKL CurKbdLayout = GetKeyboardLayout(0);
- if(CurKbdLayout != m_DefaultHKL)
- {
- printf("设置输入法\n");
- m_Save_KbdLayout = CurKbdLayout; //保存输入法 ;
- if(ActivateKeyboardLayout(m_DefaultHKL, 0) == 0) //设置为默认输入法 ;
- {
- printf( _T("Set ActivateKeyboardLayout Err=%d"), GetLastError());
- }
- }
- }
- }
- /*
- if ( message == WM_KEYDOWN && VK_RETURN == wParam)
- {
- printf("\t回车键\n");
- }
- */
- if ( WM_LBUTTONUP == message )
- {// 光标一直在最后;
- SetSel(-1);
- }
- return CEdit::WindowProc(message, wParam, lParam);
- }
- /*
- void CEnEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- printf("\t键值:%d\n", nChar);
- if ( nChar == 13 )
- {
- ((CDlgScanBarCode*)m_pParent)->DealScanBarCode(m_nLines);
- m_nLines++;
- }
-
- CEdit::OnChar(nChar, nRepCnt, nFlags);
- }
- */
- //////////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNAMIC(CDlgScanBarCode, CDialog)
- CDlgScanBarCode::CDlgScanBarCode(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgScanBarCode::IDD, pParent)
- {
- m_nScanMode = 0;
- }
- CDlgScanBarCode::~CDlgScanBarCode()
- {
- }
- void CDlgScanBarCode::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, ET_BARCODE, m_EtBarCode);
- DDX_Control(pDX, IDC_LIST1, m_ScanResult);
- }
- BEGIN_MESSAGE_MAP(CDlgScanBarCode, CDialog)
- END_MESSAGE_MAP()
- // CDlgScanBarCode 消息处理程序
- BOOL CDlgScanBarCode::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- if ( m_nScanMode == 0 )
- {
- SetWindowText(_T("请使用条码枪扫描条码来完成回件!"));
- }
- else
- {
- SetWindowText(_T("请使用条码枪扫描条码来完成取件!"));
- }
- // 获取未取件的dindanspview;同时获取shangpin;gongyingshang;dindan;dindansp;
- g_sendhead.code[0] = 239;
- g_sendhead.code[1] = 240;
- g_sendhead.tabcount = 2;
- g_sendhead.bsql = 0;
- g_pMainWnd->ProcessChatMessageRequest2("");
- if ( g_bSendOK == FALSE)
- return FALSE;
- DataToArray(&m_AryOrderItems, &m_AryOutWarehouse);
- m_EtBarCode.m_pParent = this;
- m_EtBarCode.SetFocus();
- SetWindowPos(&wndTopMost, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
- CenterWindow();
- InitSortList();
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- void CDlgScanBarCode::InitSortList()
- {
- //m_ScanResult.m_bSortSupport = TRUE;//是否启用列头重新排序;
- if ( !m_nScanMode )
- m_ScanResult.SetHeadings(CString("回件结果,100;扫描条码,100;订单号,100;商品类别,100;商品名,100;商品数量,100;完成数量,100;取件数量,100;"));
- else
- m_ScanResult.SetHeadings(CString("取件结果,100;扫描条码,100;订单号,100;商品类别,100;商品名,100;商品数量,100;完成数量,100;取件数量,100;"));
-
- m_ScanResult.LoadColumnInfo(1003);
- }
- void CDlgScanBarCode::OnOK()
- {
- // TODO: 在此添加专用代码和/或调用基类
- printf("\tOK触发\n");
- if (ET_BARCODE == GetFocus()->GetDlgCtrlID() )
- {
- printf("\t条码回车触发\n");
- DealScanBarCode(0);
- }
- //CDialog::OnOK();
- }
- void CDlgScanBarCode::DealScanBarCode(const int& nlines)
- {
- CString strText = _T("");
- UpdateData();
- #if 0
- //GetDlgItemText(ET_BARCODE, strText);
- //SetDlgItemText(ET_BARCODE,"");
- TCHAR szBuff[1024] = {0};
- m_EtBarCode.GetLine(nlines, (LPTSTR)szBuff, 1024);
- strText = szBuff;
- UpdateData();
- #else
- GetDlgItemText(ET_BARCODE, strText);
- SetDlgItemText(ET_BARCODE, _T(""));
- #endif
- int i = 0;
- CString strAutoId; // 商品的AutoId;
- CString strOrder; // 订单号;
- CString strSPID; // 商品ID;
- CString strPSName; // 商品名称;
- CString strSQL, strSQL2;
- CString strBackCot;
- int nSPCount = 0; // 商品数量;
- int nBackCot = 0; // 回件数量;
- int nPickupCot = 0; // 取件数量;
- int nIndex = -1; // #位置;
- int nIndex2 = -1; // \r\n位置;
- //CString strTemp;
- strText.TrimLeft(_T("#"));
- strText.TrimRight(_T("\r"));
- // 包含在#和\r\n之间的符号,才是条形码;
- OrderItems tagItems;
- OrderItems tagOldItem;
- OutWarehouse tagOutWarehouse;
- OutWarehouse tagOldOutWarehouse;
- CTime tm = CTime::GetCurrentTime();
- printf("商品AutoId = %s\n", strText);
- BOOL bGet = FALSE;
- int nListRow = 0;
- BOOL bFind = FALSE;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {
- if ( strText.CompareNoCase(m_AryOrderItems.ElementAt(i).ElementAt(1)) == 0 )
- { // 找出订单号和商品ID、商品名称;
- strOrder = m_AryOrderItems.ElementAt(i).ElementAt(0);
- strSPID = m_AryOrderItems.ElementAt(i).ElementAt(2);
- strPSName = m_AryOrderItems.ElementAt(i).ElementAt(3);
-
- tagItems.nIndex = i;
- tagItems.strOrder = m_AryOrderItems.ElementAt(i).ElementAt(0);
- tagItems.strAutoId = m_AryOrderItems.ElementAt(i).ElementAt(1);
- tagItems.strSPId = m_AryOrderItems.ElementAt(i).ElementAt(2);
- tagItems.strSPName = m_AryOrderItems.ElementAt(i).ElementAt(3);
- tagItems.strSPLb = m_AryOrderItems.ElementAt(i).ElementAt(4);
- tagItems.strBackStatus = m_AryOrderItems.ElementAt(i).ElementAt(5);
- tagItems.strPickupStatus = m_AryOrderItems.ElementAt(i).ElementAt(6);
- tagItems.strShuliang = m_AryOrderItems.ElementAt(i).ElementAt(7);
- tagItems.strBackCot = m_AryOrderItems.ElementAt(i).ElementAt(8);
- tagItems.strPickupCot = m_AryOrderItems.ElementAt(i).ElementAt(9);
- tagOldItem = tagItems;
- bFind = TRUE;
- break;
- }
- }
- if ( !bFind )
- {// 没找到产品;
- bGet = FALSE;
- for ( i = 0; i < m_AryWithOut.GetSize(); i++ )
- {
- if ( strText.CompareNoCase(m_AryWithOut.ElementAt(i)) == 0 )
- {
- bGet = TRUE;
- break;
- }
- }
- if ( !bGet )
- {
- m_AryWithOut.Add(strText);
- m_ScanResult.AddItem(_T("未找到该产品条码"),strText, "", "", "", "", "","" );
- }
- return;
- }
- bGet = FALSE;
- int nCurItemIndex = 0;
- if ( m_nScanMode == 0 )
- {// 扫描回件;
- // 登记完成状态;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {
- if ( strText.CompareNoCase(m_AryOrderItems.ElementAt(i).ElementAt(1)) == 0 )
- {
- if ( m_AryOrderItems.ElementAt(i).ElementAt(5).CompareNoCase("OK") != 0 )
- {
- tagItems.nIndex = i;
- tagOldItem.nIndex = i;
- // 完成数量 + 1 == 商品数量 ==> 更新完成状态;
- if ( (atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)) - atoi(m_AryOrderItems.ElementAt(i).ElementAt(8))) == 1)
- {
- strSQL.Format(_T("update dindansp set status1 = 'OK', [name3] = '%s', [date3] = '%s', [BackItemsCot] = '%s' where autoid = %s "), g_user.name, tm.Format("%Y-%m-%d"), m_AryOrderItems.ElementAt(i).ElementAt(7), strText);
- m_AryOrderItems.ElementAt(i).SetAt(8, m_AryOrderItems.ElementAt(i).ElementAt(7));
- m_AryOrderItems.ElementAt(i).SetAt(5, "OK");
- tagItems.strBackCot = m_AryOrderItems.ElementAt(i).ElementAt(7);
- tagItems.strBackStatus = _T("OK");
- }
- else if ( atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)) > atoi(m_AryOrderItems.ElementAt(i).ElementAt(8)) )
- {
- strSQL.Format(_T("update dindansp set [name3] = '%s', [date3] = '%s', [BackItemsCot] = '%d' where autoid = %s "), g_user.name, tm.Format("%Y-%m-%d"), atoi(m_AryOrderItems.ElementAt(i).ElementAt(8)) + 1, strText);
- strBackCot.Format(_T("%d"), atoi(m_AryOrderItems.ElementAt(i).ElementAt(8)) + 1);
- m_AryOrderItems.ElementAt(i).SetAt(8, strBackCot);
- tagItems.strBackCot = strBackCot;
- }
- vector<WithIn>::iterator it = m_vtWithIn.begin();
- for ( ; it != m_vtWithIn.end(); it++ )
- {
- if ( strText.CompareNoCase(it->strBarCode) == 0 )
- {
- bGet = TRUE;
- break;
- }
- }
- if ( !bGet )
- {
- WithIn tagWithIn;
-
- tagWithIn.strBarCode = strText;
- tagWithIn.nIndex = m_ScanResult.AddItem(tagItems.strBackStatus, strText, tagItems.strOrder, tagItems.strSPLb, tagItems.strSPName, tagItems.strShuliang, tagItems.strBackCot, tagItems.strPickupCot );
- nCurItemIndex = tagWithIn.nIndex;
- //tagItems.nIndex = nCurItemIndex;
- //tagOldItem.nIndex = nCurItemIndex;
- m_vtWithIn.push_back(tagWithIn);
- }
- else
- {
- nCurItemIndex = it->nIndex;
- //tagItems.nIndex = nCurItemIndex;
- //tagOldItem.nIndex = nCurItemIndex;
- m_ScanResult.SetItemText(it->nIndex, 0, tagItems.strBackStatus); // 回件状态;
- m_ScanResult.SetItemText(it->nIndex, 6, tagItems.strBackCot); // 完成数量;
- }
- //////////////////////////////////////////////////////////////////////////
- // 是否要出库;
- if ( atoi(g_cominfoarray.ElementAt(0).ElementAt(99)) == 0 )
- {
- nSPCount = 0;
- //BOOL bHasOutWarehouse = FALSE;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {// 查找该商品在订单目录下的数量;
- if ( m_AryOrderItems.ElementAt(i).ElementAt(0).CompareNoCase(strOrder) == 0 && m_AryOrderItems.ElementAt(i).ElementAt(2).CompareNoCase(strSPID) == 0 )
- {
- nSPCount += atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)); // 商品数量;
- nBackCot += atoi(m_AryOrderItems.ElementAt(i).ElementAt(8)); // 完成数量;
- nPickupCot += atoi(m_AryOrderItems.ElementAt(i).ElementAt(9)); // 取件数量;
- }
- }// for;
- // 获取出库数量;
- int nOutWarehouseCount = 0;
- for ( i = 0; i < m_AryOutWarehouse.GetSize(); i++ )
- {
- if ( m_AryOutWarehouse.ElementAt(i).ElementAt(0).CompareNoCase(strOrder + _T("(订单使用)")) == 0 && m_AryOutWarehouse.ElementAt(i).ElementAt(2).CompareNoCase(strPSName) == 0 )
- {
- //bHasOutWarehouse = TRUE;
- nOutWarehouseCount += atoi(m_AryOutWarehouse.ElementAt(i).ElementAt(3));
- tagOutWarehouse.nIndex = i;
- tagOutWarehouse.strOrder = m_AryOutWarehouse.ElementAt(i).ElementAt(0);
- tagOutWarehouse.strSPLB = m_AryOutWarehouse.ElementAt(i).ElementAt(1);
- tagOutWarehouse.strSPName = m_AryOutWarehouse.ElementAt(i).ElementAt(2);
- tagOutWarehouse.strCount = m_AryOutWarehouse.ElementAt(i).ElementAt(3);
- tagOutWarehouse.strDate = m_AryOutWarehouse.ElementAt(i).ElementAt(4);
- tagOutWarehouse.strClerk = m_AryOutWarehouse.ElementAt(i).ElementAt(5);
- tagOutWarehouse.strRemark = m_AryOutWarehouse.ElementAt(i).ElementAt(6);
- tagOldOutWarehouse = tagOutWarehouse;
- break;
- }
- }// for;
- if ( nOutWarehouseCount == 0 )
- {
- strSQL2.Format(_T("insert into storeinfo2([id],[type],[name],[count],[date],[clerk])values('%s','%s','%s','%s','%s','%s')"),
- strOrder + _T("(订单使用)"),
- tagItems.strSPLb,
- tagItems.strSPName,
- "1",
- tm.Format("%Y-%m-%d"),
- g_user.name);
- strSQL += _T("***") + strSQL2;
- // 添加记录;
- int nSize = m_AryOutWarehouse.GetSize() + 1;
- m_AryOutWarehouse.SetSize(nSize, 1);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(strOrder+_T("(订单使用)"));
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tagItems.strSPLb);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tagItems.strSPName);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add("1");
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tm.Format("%Y-%m-%d"));
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(g_user.name);
- tagOutWarehouse.nIndex = -1;
- tagOutWarehouse.strOrder = strOrder+_T("(订单使用)");
- tagOutWarehouse.strSPLB = tagItems.strSPLb;
- tagOutWarehouse.strSPName = tagItems.strSPName;
- tagOutWarehouse.strCount = "1";
- tagOutWarehouse.strDate = tm.Format("%Y-%m-%d");
- tagOutWarehouse.strClerk = g_user.name;
- tagOutWarehouse.strRemark = _T("");
- }
- else if ( nOutWarehouseCount < ( nBackCot >= nPickupCot ? nBackCot : nPickupCot) )
- {
- strBackCot.Format(_T("%d"), ( nBackCot >= nPickupCot ? nBackCot : nPickupCot));
- strSQL2.Format(_T("update storeinfo2 set [count] = '%s',[date] = '%s', [clerk] = '%s' where id = '%s' and name = '%s'"),
- strBackCot,
- tm.Format("%Y-%m-%d"),
- g_user.name,
- strOrder + _T("(订单使用)"),
- strPSName
- );
- //tagOutWarehouse.strOrder = strOrder+_T("(订单使用)");
- //tagOutWarehouse.strSPLB = tagItems.strSPLb;
- //tagOutWarehouse.strSPName = tagItems.strSPName;
- tagOutWarehouse.strCount = strBackCot;
- tagOutWarehouse.strDate = tm.Format("%Y-%m-%d");
- tagOutWarehouse.strClerk = g_user.name;
- //tagOutWarehouse.strRemark = _T("");
- printf("m_AryOutWarehouse = %d\n", m_AryOutWarehouse.GetSize());
- m_AryOutWarehouse.ElementAt(i).SetAt(3, strBackCot);
- strSQL += _T("***") + strSQL2;
- }
- break;
- }
- }
- }
- } // for;
- }
- else
- {// 扫描取件;
- // 登记取件状态;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {
- if ( strText.CompareNoCase(m_AryOrderItems.ElementAt(i).ElementAt(1)) == 0 )
- {
- if ( m_AryOrderItems.ElementAt(i).ElementAt(6).CompareNoCase("OK") != 0 )
- {
- tagItems.nIndex = i;
- tagOldItem.nIndex = i;
- // 取件数量 + 1 == 商品数量 ==> 更新完成状态;
- if ( (atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)) - atoi(m_AryOrderItems.ElementAt(i).ElementAt(9))) == 1)
- {
- strSQL.Format(_T("update dindansp set status2 = 'OK', [name4] = '%s', [date4] = '%s', [PickupItemsCot] = '%s' where autoid = %s "), g_user.name, tm.Format("%Y-%m-%d"), m_AryOrderItems.ElementAt(i).ElementAt(7), strText);
- m_AryOrderItems.ElementAt(i).SetAt(9, m_AryOrderItems.ElementAt(i).ElementAt(7));
- m_AryOrderItems.ElementAt(i).SetAt(6, "OK");
- tagItems.strPickupCot = m_AryOrderItems.ElementAt(i).ElementAt(7);
- tagItems.strPickupStatus = _T("OK");
- }
- else if (atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)) > atoi(m_AryOrderItems.ElementAt(i).ElementAt(9)))
- {
- strSQL.Format(_T("update dindansp set [name4] = '%s', [date4] = '%s', [PickupItemsCot] = '%d' where autoid = %s "), g_user.name, tm.Format("%Y-%m-%d"), atoi(m_AryOrderItems.ElementAt(i).ElementAt(9)) + 1, strText);
- strBackCot.Format(_T("%d"), atoi(m_AryOrderItems.ElementAt(i).ElementAt(9)) + 1);
- m_AryOrderItems.ElementAt(i).SetAt(9, strBackCot);
- tagItems.strPickupCot = strBackCot;
- }
- vector<WithIn>::iterator it = m_vtWithIn.begin();
- for ( ; it != m_vtWithIn.end(); it++ )
- {
- if ( strText.CompareNoCase(it->strBarCode) == 0 )
- {
- bGet = TRUE;
- break;
- }
- }
- if ( !bGet )
- {
- WithIn tagWithIn;
-
- tagWithIn.strBarCode = strText;
- tagWithIn.nIndex = m_ScanResult.AddItem(tagItems.strPickupStatus, strText, tagItems.strOrder, tagItems.strSPLb, tagItems.strSPName, tagItems.strShuliang, tagItems.strBackCot, tagItems.strPickupCot );
- nCurItemIndex = tagWithIn.nIndex;
-
- //tagItems.nIndex = nCurItemIndex;
- //tagOldItem.nIndex = nCurItemIndex;
- m_vtWithIn.push_back(tagWithIn);
- }
- else
- {
- nCurItemIndex = it->nIndex;
- //tagItems.nIndex = nCurItemIndex;
- //tagOldItem.nIndex = nCurItemIndex;
- m_ScanResult.SetItemText(it->nIndex, 0, tagItems.strPickupStatus); // 取件状态;
- m_ScanResult.SetItemText(it->nIndex, 7, tagItems.strPickupCot); // 取件数量;
- }
- //////////////////////////////////////////////////////////////////////////
- // 全部取走,更新订单取件状态;
- BOOL bPickupAll = TRUE;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {
- if ( strOrder == m_AryOrderItems.ElementAt(i).ElementAt(0) )
- {
- if ( m_AryOrderItems.ElementAt(i).ElementAt(6) != "OK")
- {
- bPickupAll = FALSE;
- break;
- }
- }
- }
- if ( bPickupAll )
- {
- strSQL2.Format(_T("update dindan set status3='OK', time5='%s', datetime5 = '%s' where id = '%s'"),tm.Format("%Y-%m-%d"), tm.Format("%H:%M"), strOrder);
- strSQL += _T("***") + strSQL2;
- }
- //////////////////////////////////////////////////////////////////////////
- // 是否要出库;
- if ( atoi(g_cominfoarray.ElementAt(0).ElementAt(99)) == 0 )
- {
- nSPCount = 0;
- for ( i = 0; i < m_AryOrderItems.GetSize(); i++ )
- {// 查找该商品在订单目录下的数量;
- if ( m_AryOrderItems.ElementAt(i).ElementAt(0).CompareNoCase(strOrder) == 0 && m_AryOrderItems.ElementAt(i).ElementAt(2).CompareNoCase(strSPID) == 0 )
- {
- nSPCount += atoi(m_AryOrderItems.ElementAt(i).ElementAt(7)); // 商品数量;
- nBackCot += atoi(m_AryOrderItems.ElementAt(i).ElementAt(8)); // 完成数量;
- nPickupCot += atoi(m_AryOrderItems.ElementAt(i).ElementAt(9)); // 取件数量;
- }
- }// for;
- // 获取出库数量;
- int nOutWarehouseCount = 0;
- for ( i = 0; i < m_AryOutWarehouse.GetSize(); i++ )
- {
- if ( m_AryOutWarehouse.ElementAt(i).ElementAt(0).CompareNoCase(strOrder + _T("(订单使用)")) == 0 && m_AryOutWarehouse.ElementAt(i).ElementAt(2).CompareNoCase(strPSName) == 0 )
- {
- nOutWarehouseCount += atoi(m_AryOutWarehouse.ElementAt(i).ElementAt(3));
- tagOutWarehouse.nIndex = i;
- tagOutWarehouse.strOrder = m_AryOutWarehouse.ElementAt(i).ElementAt(0);
- tagOutWarehouse.strSPLB = m_AryOutWarehouse.ElementAt(i).ElementAt(1);
- tagOutWarehouse.strSPName = m_AryOutWarehouse.ElementAt(i).ElementAt(2);
- tagOutWarehouse.strCount = m_AryOutWarehouse.ElementAt(i).ElementAt(3);
- tagOutWarehouse.strDate = m_AryOutWarehouse.ElementAt(i).ElementAt(4);
- tagOutWarehouse.strClerk = m_AryOutWarehouse.ElementAt(i).ElementAt(5);
- tagOutWarehouse.strRemark = m_AryOutWarehouse.ElementAt(i).ElementAt(6);
- tagOldOutWarehouse = tagOutWarehouse;
- break;
- }
- }// for;
- if ( nOutWarehouseCount == 0 )
- {
- strSQL2.Format(_T("insert into storeinfo2([id],[type],[name],[count],[date],[clerk])values('%s','%s','%s','%s','%s','%s')"),
- strOrder + _T("(订单使用)"),
- tagItems.strSPLb,
- tagItems.strSPName,
- "1",
- tm.Format("%Y-%m-%d"),
- g_user.name);
- strSQL += _T("***") + strSQL2;
- // 添加记录;
- int nSize = m_AryOutWarehouse.GetSize() + 1;
- m_AryOutWarehouse.SetSize(nSize, 1);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(strOrder+_T("(订单使用)"));
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tagItems.strSPLb);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tagItems.strSPName);
- m_AryOutWarehouse.ElementAt(nSize - 1).Add("1");
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(tm.Format("%Y-%m-%d"));
- m_AryOutWarehouse.ElementAt(nSize - 1).Add(g_user.name);
- tagOutWarehouse.nIndex = -1;
- tagOutWarehouse.strOrder = strOrder+_T("(订单使用)");
- tagOutWarehouse.strSPLB = tagItems.strSPLb;
- tagOutWarehouse.strSPName = tagItems.strSPName;
- tagOutWarehouse.strCount = "1";
- tagOutWarehouse.strDate = tm.Format("%Y-%m-%d");
- tagOutWarehouse.strClerk = g_user.name;
- tagOutWarehouse.strRemark = _T("");
- }
- else if ( nOutWarehouseCount < ( nBackCot >= nPickupCot ? nBackCot : nPickupCot) )
- {
- strBackCot.Format(_T("%d"), ( nBackCot >= nPickupCot ? nBackCot : nPickupCot));
- strSQL2.Format(_T("update storeinfo2 set [count] = '%s',[date] = '%s', [clerk] = '%s' where id = '%s' and name = '%s'"),
- strBackCot,
- tm.Format("%Y-%m-%d"),
- g_user.name,
- strOrder + _T("(订单使用)"),
- strPSName
- );
- strSQL += _T("***") + strSQL2;
- m_AryOutWarehouse.ElementAt(i).SetAt(3, strBackCot);
- //tagOutWarehouse.strOrder = strOrder+_T("(订单使用)");
- //tagOutWarehouse.strSPLB = tagItems.strSPLb;
- //tagOutWarehouse.strSPName = tagItems.strSPName;
- tagOutWarehouse.strCount = strBackCot;
- tagOutWarehouse.strDate = tm.Format("%Y-%m-%d");
- tagOutWarehouse.strClerk = g_user.name;
- //tagOutWarehouse.strRemark = _T("");
- }
- break;
- }
- }
- }
- }
- }
- if ( !strSQL.IsEmpty() )
- {
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQL);
- if ( !g_bSendOK )
- {// 更新失败;
- if ( m_nScanMode )
- {
- m_ScanResult.SetItemText(nCurItemIndex, 0, _T("更新取件失败"));
- m_ScanResult.SetItemText(nCurItemIndex, 7, tagOldItem.strPickupCot);
- // 是否要出库;
- if ( atoi(g_cominfoarray.ElementAt(0).ElementAt(99)) == 0 )
- {
- if ( tagOutWarehouse.nIndex == -1 && !tagOutWarehouse.strOrder.IsEmpty() )
- {// 新元素;
- m_AryOutWarehouse.RemoveAt(m_AryOutWarehouse.GetSize() - 1);
- }
- else
- {
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(3, tagOldOutWarehouse.strCount);
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(4, tagOldOutWarehouse.strDate);
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(5, tagOldOutWarehouse.strClerk);
- }
- }
- m_AryOrderItems.ElementAt(tagOldItem.nIndex).SetAt(6, tagOldItem.strPickupStatus); // 取件状态;
- m_AryOrderItems.ElementAt(tagOldItem.nIndex).SetAt(9, tagOldItem.strPickupCot); // 取件数量;
- }
- else
- {
- m_ScanResult.SetItemText(nCurItemIndex, 0, _T("更新回件失败"));
- m_ScanResult.SetItemText(nCurItemIndex, 6, tagOldItem.strBackCot);
- // 是否要出库;
- if ( atoi(g_cominfoarray.ElementAt(0).ElementAt(99)) == 0 )
- {
- if ( tagOutWarehouse.nIndex == -1 && !tagOutWarehouse.strOrder.IsEmpty() )
- {// 新元素;
- m_AryOutWarehouse.RemoveAt(m_AryOutWarehouse.GetSize() - 1);
- }
- else
- {
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(3, tagOldOutWarehouse.strCount);
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(4, tagOldOutWarehouse.strDate);
- m_AryOutWarehouse.ElementAt(tagOutWarehouse.nIndex).SetAt(5, tagOldOutWarehouse.strClerk);
- }
- }
- m_AryOrderItems.ElementAt(tagOldItem.nIndex).SetAt(5, tagOldItem.strBackStatus); // 回件状态;
- m_AryOrderItems.ElementAt(tagOldItem.nIndex).SetAt(8, tagOldItem.strBackCot); // 回件数量;
- }
- }
- printf("SQL:%s\n", strSQL);
- }
- }
- void CDlgScanBarCode::OnCancel()
- {
- // 退出扫描时,进行出入库及订单商品状态更新;
- CDialog::OnCancel();
- }
|