SPBox.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // SPBox.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "SPBox.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SPBox dialog
  13. SPBox::SPBox(CWnd* pParent /*=NULL*/)
  14. : CDialog(SPBox::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SPBox)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. m_mode=0;
  20. }
  21. void SPBox::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(SPBox)
  25. DDX_Control(pDX, IDC_LIST2, m_List1);
  26. DDX_Control(pDX, IDC_COMBOsplb, m_combosplb);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(SPBox, CDialog)
  30. //{{AFX_MSG_MAP(SPBox)
  31. ON_CBN_SELCHANGE(IDC_COMBOsplb, OnSelchangeCOMBOsplb)
  32. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  33. //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // SPBox message handlers
  37. BOOL SPBox::OnInitDialog()
  38. {
  39. CDialog::OnInitDialog();
  40. // TODO: Add extra initialization here
  41. m_List1.SetHeadings( "编号,50;商品名称,150;销售价,80" );
  42. m_List1.LoadColumnInfo (103);
  43. g_sendhead.bsql=0;
  44. g_sendhead.code[0]=8;
  45. g_sendhead.code[1]=2;
  46. g_sendhead.tabcount=2;
  47. g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return 1;
  48. DataToArray(&m_List1array,&m_List2array);
  49. for(int i=0; i<m_List2array.GetSize (); i++)
  50. m_combosplb.AddString (m_List2array.ElementAt (i).ElementAt (0));
  51. if(m_combosplb.GetCount ())
  52. m_combosplb.SetCurSel (0);
  53. OnSelchangeCOMBOsplb();
  54. this->CenterWindow (g_pMainWnd);
  55. m_combosplb.SetFocus();
  56. return false; // return TRUE unless you set the focus to a control
  57. // EXCEPTION: OCX Property Pages should return FALSE
  58. }
  59. void SPBox::OnCancel()
  60. {
  61. // TODO: Add extra cleanup here
  62. CDialog::OnCancel();
  63. }
  64. void SPBox::OnOK()
  65. {
  66. // TODO: Add extra validation here
  67. if(m_mode==0)
  68. {
  69. POSITION pos;
  70. pos=m_List1.GetFirstSelectedItemPosition();
  71. if(pos==NULL)
  72. {
  73. AfxMessageBox("请先选中一个商品!");
  74. return;
  75. }
  76. int iItem=m_List1.GetNextSelectedItem(pos);
  77. m_spid=m_List1.GetItemText (iItem, 0);
  78. m_spname=m_List1.GetItemText (iItem, 1);
  79. }
  80. CDialog::OnOK();
  81. }
  82. void SPBox::OnSelchangeCOMBOsplb()
  83. {
  84. // TODO: Add your control notification handler code here
  85. int pos=m_combosplb.GetCurSel ();
  86. if(pos==-1)return;
  87. CString str;
  88. m_combosplb.GetLBText (pos, str);
  89. FillGrid(str);
  90. }
  91. void SPBox::FillGrid(CString str)
  92. {
  93. m_List1.DeleteAllItems2 ();
  94. int ii=0;
  95. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  96. int count=0;
  97. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  98. {
  99. if(m_List1array.ElementAt (ii).ElementAt (3)==str)
  100. {
  101. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  102. }
  103. }
  104. m_List1.m_arLabels.SetSize(count, 1);
  105. ii=count;
  106. m_List1.m_LabelCount=ii;
  107. m_List1.SetItemCountEx (ii);
  108. }
  109. void SPBox::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  110. {
  111. // TODO: Add your control notification handler code here
  112. OnOK();
  113. *pResult = 0;
  114. }