123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- // TXSPDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LYFZIPManage.h"
- #include "TXSPDlg.h"
- #include "MyMdi.H"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // TXSPDlg
- IMPLEMENT_DYNCREATE(TXSPDlg, CFormView)
- TXSPDlg::TXSPDlg()
- : CFormView(TXSPDlg::IDD)
- {
- //{{AFX_DATA_INIT(TXSPDlg)
- m_taoxiid = _T("");
- m_taoxijiage = _T("");
- m_zs = _T("");
- //}}AFX_DATA_INIT
- }
- TXSPDlg::~TXSPDlg()
- {
- }
- void TXSPDlg::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(TXSPDlg)
- DDX_Control(pDX, IDC_LIST2, m_List2);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Control(pDX, IDC_STATIC1, m_static1);
- DDX_Control(pDX, IDC_COMBOtaoxiname, m_combotaoxiname);
- DDX_Text(pDX, IDC_EDITtaoxiid, m_taoxiid);
- DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
- DDX_Text(pDX, IDC_EDITzs, m_zs);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(TXSPDlg, CFormView)
- //{{AFX_MSG_MAP(TXSPDlg)
- ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_CBN_SELCHANGE(IDC_COMBOtaoxiname, OnSelchangeCOMBOtaoxiname)
- ON_BN_CLICKED(IDC_BUTspbox, OnBUTspbox)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_BUTsave2, OnBUTsave2)
- ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
- ON_BN_CLICKED(IDC_BUTspbox2, OnBUTspbox2)
- ON_BN_CLICKED(IDC_BUTclose2, OnBUTclose2)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // TXSPDlg diagnostics
- #ifdef _DEBUG
- void TXSPDlg::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void TXSPDlg::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // TXSPDlg message handlers
- void TXSPDlg::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- // TODO: Add your specialized code here and/or call the base class
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
-
- // Here we create the outbar control using the splitter as its parent
- // and setting its id to the first pane.
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
- m_combotaoxiname.GetWindowRect (rc2);
- ScreenToClient(rc2);
- rc2.bottom +=200;
- m_combotaoxiname.MoveWindow (rc2);
- m_static1.SetFont (&g_titlefont);
- g_sendhead.bsql=0;
- g_sendhead.code[0]=6;
- g_sendhead.code[1]=7;
- g_sendhead.code[2]=10;
- g_sendhead.code[3]=4;
- g_sendhead.tabcount=4;
- g_pMainWnd->ProcessChatMessageRequest2(6);if(g_bSendOK==0)return;
- DataToArray(&m_List1array, &m_List2array, &m_List3array, &m_sparray);
- for(int i=0; i<m_List1array.GetSize (); i++)
- m_combotaoxiname.AddString (m_List1array.ElementAt (i).ElementAt (1));
- m_List1.InitStyle();
- m_List1.InsertColumn(0,_T("编号"),LVCFMT_LEFT,80);
- m_List1.InsertColumn(1,_T("商品名称"),LVCFMT_LEFT,200);
- m_List1.InsertColumn(2,_T("数量"),LVCFMT_LEFT,60);
- m_List2.InitStyle();
- m_List2.InsertColumn(0,_T("编号"),LVCFMT_LEFT,80);
- m_List2.InsertColumn(1,_T("商品名称"),LVCFMT_LEFT,200);
- m_List2.InsertColumn(2,_T("数量"),LVCFMT_LEFT,60);
- }
- void TXSPDlg::OnSelchangeCOMBOtaoxiname()
- {
- // TODO: Add your control notification handler code here
- int pos=m_combotaoxiname.GetCurSel ();
- if(pos==-1)return;
- m_taoxiid = m_List1array.ElementAt (pos).ElementAt (0);
- m_taoxijiage = m_List1array.ElementAt (pos).ElementAt (2);
- m_zs = m_List1array.ElementAt (pos).ElementAt (3);
- UpdateData(false);
- FillGrid();
- }
- void TXSPDlg::FillGrid()
- {
- m_List1.DeleteAllItems ();
- int pos=0;
- for(int i=0; i<m_List2array.GetSize (); i++)
- {
- if(m_List2array.ElementAt (i).ElementAt (0)!=m_taoxiid)continue;
- m_List1.InsertItem(pos, m_List2array.ElementAt (i).ElementAt (1));
- m_List1.SetItemText(pos,1, GetSPNameFromId(m_List2array.ElementAt (i).ElementAt (1)));
- m_List1.SetItemText(pos,2, m_List2array.ElementAt (i).ElementAt (2));
- pos++;
- }
- //#ifndef MODERN_VERSION
- #if 0
- for( i=0; i<m_List3array.GetSize (); i++)
- {
- if(m_List3array.ElementAt (i).ElementAt (0)!=m_taoxiid)continue;
- m_List1.InsertItem(pos, m_List3array.ElementAt (i).ElementAt (1));
- m_List1.SetItemText(pos,1, GetSPNameFromId(m_List3array.ElementAt (i).ElementAt (1)));
- m_List1.SetItemText(pos,2, m_List3array.ElementAt (i).ElementAt (2));
- pos++;
- }
- #else
- m_List2.DeleteAllItems ();
- pos=0;
- for( i=0; i<m_List3array.GetSize (); i++)
- {
- if(m_List3array.ElementAt (i).ElementAt (0)!=m_taoxiid)continue;
- m_List2.InsertItem(pos, m_List3array.ElementAt (i).ElementAt (1));
- m_List2.SetItemText(pos,1, GetSPNameFromId(m_List3array.ElementAt (i).ElementAt (1)));
- m_List2.SetItemText(pos,2, m_List3array.ElementAt (i).ElementAt (2));
- pos++;
- }
- #endif
- }
- CString TXSPDlg::GetSPNameFromId(CString id)
- {
- for(int i=0; i<m_sparray.GetSize (); i++)
- {
- if(id==m_sparray.ElementAt (i).ElementAt (0))
- return m_sparray.ElementAt (i).ElementAt (1);
- }
- id.TrimLeft ("0");
- for( i=0; i<m_sparray.GetSize (); i++)
- {
- if(id==m_sparray.ElementAt (i).ElementAt (0))
- return m_sparray.ElementAt (i).ElementAt (1);
- }
- return "";
- }
- BOOL TXSPDlg::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(pMsg->message==WM_KEYDOWN)
- {
- switch( pMsg->wParam )
- {
- case 0x43: // copy
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_COPY);
- return TRUE;
- }
- break;
- case 0x56: //Ctrl + V:
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_PASTE);
- return TRUE;
- }
- break;
- case 0x58: // cut
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_CUT);
- return TRUE;
- }
- break;
- case 0x5A: //undo
- case 0x59: //redo
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_UNDO);
- return TRUE;
- }
- break;
- }
- }
- else if(pMsg->message==WM_LBUTTONDBLCLK)
- {
- {//list1
- CPoint pt;
- CRect rc,rc2;
- ::GetCursorPos (&pt);
- m_List1.GetWindowRect (rc2);
- if(rc2.PtInRect (pt)==0) goto ll;
- pt.x-=rc2.left ;
- pt.y-=rc2.top ;
- int iItem=m_List1.GetItemCount ()-1;
- if(iItem<0)
- {
- m_List1.GetHeaderCtrl()->GetItemRect (0, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- m_List1.InsertItem(m_List1.GetItemCount (), "");
- }
- }
- else
- {
- m_List1.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- if(m_List1.GetItemText (iItem, 0).IsEmpty ()&&m_List1.GetItemText (iItem, 1).IsEmpty ()&&m_List1.GetItemText (iItem, 2).IsEmpty ())
- goto ll;
- m_List1.InsertItem(m_List1.GetItemCount (), "");
- }
- }
- }
- ll: {//list2
- CPoint pt;
- CRect rc,rc2;
- ::GetCursorPos (&pt);
- m_List2.GetWindowRect (rc2);
- if(rc2.PtInRect (pt)==0) return CFormView::PreTranslateMessage(pMsg);
- pt.x-=rc2.left ;
- pt.y-=rc2.top ;
- int iItem=m_List2.GetItemCount ()-1;
- if(iItem<0)
- {
- m_List2.GetHeaderCtrl()->GetItemRect (0, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- m_List2.InsertItem(m_List2.GetItemCount (), "");
- }
- }
- else
- {
- m_List2.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- if(m_List2.GetItemText (iItem, 0).IsEmpty ()&&m_List2.GetItemText (iItem, 1).IsEmpty ()&&m_List2.GetItemText (iItem, 2).IsEmpty ())
- return CFormView::PreTranslateMessage(pMsg);
- m_List2.InsertItem(m_List2.GetItemCount (), "");
- }
- }
- }
-
- }
-
- if(pMsg->message==WM_LBUTTONDOWN)
- {
- {//list1
- CPoint pt;
- CRect rc,rc2;
- ::GetCursorPos (&pt);
- m_List1.GetWindowRect (rc2);
- if(rc2.PtInRect (pt)==0) goto mm;
- SetTimer(1, 300, NULL);
- }
- mm: {//list2
- CPoint pt;
- CRect rc,rc2;
- ::GetCursorPos (&pt);
- m_List2.GetWindowRect (rc2);
- if(rc2.PtInRect (pt)==0) return CFormView::PreTranslateMessage(pMsg);
- SetTimer(2, 300, NULL);
- }
-
- }
-
- return CFormView::PreTranslateMessage(pMsg);
- }
- void TXSPDlg::SetSPName1()
- {
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText(i,1, GetSPNameFromId(m_List1.GetItemText (i, 0)));
- }
- }
- void TXSPDlg::SetSPName2()
- {
- for(int i=0; i<m_List2.GetItemCount (); i++)
- {
- m_List2.SetItemText(i,1, GetSPNameFromId(m_List2.GetItemText (i, 0)));
- }
- }
- void TXSPDlg::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- if(nIDEvent==1)
- {
- KillTimer(nIDEvent);
- SetSPName1();
- }
- else if(nIDEvent==2)
- {
- KillTimer(nIDEvent);
- SetSPName2();
- }
- }
- void TXSPDlg::OnBUTsave()
- {
- // TODO: Add your control notification handler code here
- int pos=m_combotaoxiname.GetCurSel ();
- if(pos==-1)return;
- CArray<CStringArray, CStringArray>sparray;
- sparray.SetSize(m_List1.GetItemCount ());
- int realcount=0;
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- if(m_List1.GetItemText (i, 0).IsEmpty ())continue;
- sparray.ElementAt (realcount).Add ( m_List1array.ElementAt (pos).ElementAt (0) );
- sparray.ElementAt (realcount).Add ( m_List1.GetItemText (i, 0) );
- sparray.ElementAt (realcount).Add ( m_List1.GetItemText (i, 2) );
- realcount++;
- }
- sparray.SetSize(realcount);
- if(realcount==0)
- {
- sparray.SetSize(1);
- sparray.ElementAt (0).Add (m_List1array.ElementAt (pos).ElementAt (0));
- }
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- for(int ii=0; ii<sparray.GetSize (); ii++)
- {
- sparray.ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- int size=sparray.GetSize ();
- BYTE *pData2=new BYTE[length+sizeof(int)];
- memcpy(pData2, pData, length);
- memcpy(pData2+length, &size, sizeof(int));
- delete []pData;
- length+=sizeof(int);
- g_nSendCode=1;
- g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
- g_nSendCode=0;
- delete []pData2;
- if(g_bSendOK==0)return;
- g_sendhead.bsql=0;
- g_sendhead.code[0]=7;
- g_sendhead.code[1]=10;
- g_sendhead.tabcount=2;
- g_pMainWnd->ProcessChatMessageRequest2(7);if(g_bSendOK==0)return;
- DataToArray(&m_List2array, &m_List3array);
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- }
- void TXSPDlg::OnBUTdel()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- m_List1.DeleteItem (iItem);
- int count=m_List1.GetItemCount ();
- if(count==0)return;
- if(iItem==count)
- iItem=0;
-
- m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
- }
- void TXSPDlg::OnBUTspbox()
- {
- // TODO: Add your control notification handler code here
- SPBox dlg;
- if(dlg.DoModal ()!=IDOK)return;
- int pos=m_List1.GetItemCount ();
- if(pos)
- {
- if(m_List1.GetItemText (pos-1, 0).IsEmpty ()&&m_List1.GetItemText (pos-1, 1).IsEmpty ()&&m_List1.GetItemText (pos-1, 2).IsEmpty ())
- {
- pos--;
- m_List1.SetItemText(pos,0, dlg.m_spid);
- m_List1.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- else
- {
- m_List1.InsertItem(pos, dlg.m_spid);
- m_List1.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- }
- else
- {
- m_List1.InsertItem(pos, dlg.m_spid);
- m_List1.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- }
- void TXSPDlg::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
- void TXSPDlg::OnBUTsave2()
- {
- // TODO: Add your control notification handler code here
- int pos=m_combotaoxiname.GetCurSel ();
- if(pos==-1)return;
- CArray<CStringArray, CStringArray>sparray;
- sparray.SetSize(m_List2.GetItemCount ());
- int realcount=0;
- for(int i=0; i<m_List2.GetItemCount (); i++)
- {
- if(m_List2.GetItemText (i, 0).IsEmpty ())continue;
- sparray.ElementAt (realcount).Add ( m_List1array.ElementAt (pos).ElementAt (0) );
- sparray.ElementAt (realcount).Add ( m_List2.GetItemText (i, 0) );
- sparray.ElementAt (realcount).Add ( m_List2.GetItemText (i, 2) );
- realcount++;
- }
- sparray.SetSize(realcount);
- if(realcount==0)
- {
- sparray.SetSize(1);
- sparray.ElementAt (0).Add (m_List1array.ElementAt (pos).ElementAt (0));
- }
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- for(int ii=0; ii<sparray.GetSize (); ii++)
- {
- sparray.ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- int size=sparray.GetSize ();
- BYTE *pData2=new BYTE[length+sizeof(int)];
- memcpy(pData2, pData, length);
- memcpy(pData2+length, &size, sizeof(int));
- delete []pData;
- length+=sizeof(int);
- g_nSendCode=2;
- g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
- g_nSendCode=0;
- delete []pData2;
- if(g_bSendOK==0)return;
- g_sendhead.bsql=0;
- g_sendhead.code[0]=7;
- g_sendhead.code[1]=10;
- g_sendhead.tabcount=2;
- g_pMainWnd->ProcessChatMessageRequest2(7);if(g_bSendOK==0)return;
- DataToArray(&m_List2array, &m_List3array);
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- }
- void TXSPDlg::OnBUTdel2()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List2.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List2.GetNextSelectedItem(pos);
- m_List2.DeleteItem (iItem);
- int count=m_List2.GetItemCount ();
- if(count==0)return;
- if(iItem==count)
- iItem=0;
-
- m_List2.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
- }
- void TXSPDlg::OnBUTspbox2()
- {
- // TODO: Add your control notification handler code here
- SPBox dlg;
- if(dlg.DoModal ()!=IDOK)return;
- int pos=m_List2.GetItemCount ();
- if(pos)
- {
- if(m_List2.GetItemText (pos-1, 0).IsEmpty ()&&m_List2.GetItemText (pos-1, 1).IsEmpty ()&&m_List2.GetItemText (pos-1, 2).IsEmpty ())
- {
- pos--;
- m_List2.SetItemText(pos,0, dlg.m_spid);
- m_List2.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- else
- {
- m_List2.InsertItem(pos, dlg.m_spid);
- m_List2.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- }
- else
- {
- m_List2.InsertItem(pos, dlg.m_spid);
- m_List2.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- }
- }
- void TXSPDlg::OnBUTclose2()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
|