SPLBDlg.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPLBDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "SPLBDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SPLBDlg dialog
  13. SPLBDlg::SPLBDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(SPLBDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SPLBDlg)
  17. m_edit1 = _T("");
  18. //}}AFX_DATA_INIT
  19. }
  20. void SPLBDlg::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(SPLBDlg)
  24. DDX_Control(pDX, IDC_LIST1, m_List1);
  25. DDX_Text(pDX, IDC_EDIT1, m_edit1);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(SPLBDlg, CDialog)
  29. //{{AFX_MSG_MAP(SPLBDlg)
  30. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  31. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // SPLBDlg message handlers
  36. BOOL SPLBDlg::OnInitDialog()
  37. {
  38. CDialog::OnInitDialog();
  39. // TODO: Add extra initialization here
  40. CRect rc;
  41. m_List1.GetClientRect (rc);
  42. CString strHeadings;
  43. strHeadings.Format ("商品类别名称,%d", rc.Width()-18);
  44. m_List1.SetHeadings( strHeadings );
  45. FillGrid();
  46. this->CenterWindow (g_pMainWnd);
  47. return TRUE; // return TRUE unless you set the focus to a control
  48. // EXCEPTION: OCX Property Pages should return FALSE
  49. }
  50. void SPLBDlg::FillGrid()
  51. {
  52. g_sendhead.bsql=0;
  53. g_sendhead.code[0]=2;
  54. g_sendhead.tabcount=1;
  55. g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return;
  56. DataToArray(&g_List1array);
  57. m_List1.DeleteAllItems2 ();
  58. int ii=0;
  59. {
  60. m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
  61. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  62. m_List1.m_arLabels.ElementAt (ii).Copy (g_List1array.ElementAt (ii));
  63. }
  64. m_List1.m_LabelCount=ii;
  65. m_List1.SetItemCountEx (ii);
  66. }
  67. void SPLBDlg::OnBUTadd()
  68. {
  69. // TODO: Add your control notification handler code here
  70. UpdateData();
  71. m_edit1.TrimLeft ();
  72. m_edit1.TrimRight ();
  73. if(m_edit1.IsEmpty ())
  74. {
  75. AfxMessageBox("商品类别不能为空!", MB_ICONINFORMATION);
  76. this->GetDlgItem (IDC_EDIT1)->SetFocus();
  77. return;
  78. }
  79. CString sql;
  80. sql.Format ("insert into shangpinlb (name)values('%s')", m_edit1);
  81. sql+=SPLB_REF;
  82. g_sendhead.bsql=1;
  83. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  84. FillGrid();
  85. }
  86. void SPLBDlg::OnBUTdel()
  87. {
  88. // TODO: Add your control notification handler code here
  89. POSITION pos;
  90. pos=m_List1.GetFirstSelectedItemPosition();
  91. if(pos==NULL)
  92. {
  93. AfxMessageBox("请选中您要删除的类别!", MB_ICONINFORMATION);
  94. return;
  95. }
  96. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  97. int iItem=m_List1.GetNextSelectedItem(pos);
  98. CString name=m_List1.GetItemText (iItem, 0);
  99. CString sql;
  100. sql.Format ("delete from shangpinlb where name='%s'", name);
  101. sql+=SPLB_REF;
  102. g_sendhead.bsql=1;
  103. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  104. FillGrid();
  105. }