123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- // SPLBDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LYFZIPManage.h"
- #include "SPLBDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SPLBDlg dialog
- SPLBDlg::SPLBDlg(CWnd* pParent /*=NULL*/)
- : CDialog(SPLBDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SPLBDlg)
- m_edit1 = _T("");
- //}}AFX_DATA_INIT
- }
- void SPLBDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SPLBDlg)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Text(pDX, IDC_EDIT1, m_edit1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SPLBDlg, CDialog)
- //{{AFX_MSG_MAP(SPLBDlg)
- ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SPLBDlg message handlers
- BOOL SPLBDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CRect rc;
- m_List1.GetClientRect (rc);
- CString strHeadings;
- strHeadings.Format ("商品类别名称,%d", rc.Width()-18);
- m_List1.SetHeadings( strHeadings );
-
- FillGrid();
- this->CenterWindow (g_pMainWnd);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SPLBDlg::FillGrid()
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=2;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return;
- DataToArray(&g_List1array);
- m_List1.DeleteAllItems2 ();
- int ii=0;
- {
- m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- m_List1.m_arLabels.ElementAt (ii).Copy (g_List1array.ElementAt (ii));
- }
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void SPLBDlg::OnBUTadd()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- m_edit1.TrimLeft ();
- m_edit1.TrimRight ();
- if(m_edit1.IsEmpty ())
- {
- AfxMessageBox("商品类别不能为空!", MB_ICONINFORMATION);
- this->GetDlgItem (IDC_EDIT1)->SetFocus();
- return;
- }
- CString sql;
- sql.Format ("insert into shangpinlb (name)values('%s')", m_edit1);
- sql+=SPLB_REF;
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- FillGrid();
- }
- void SPLBDlg::OnBUTdel()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请选中您要删除的类别!", MB_ICONINFORMATION);
- return;
- }
- if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString name=m_List1.GetItemText (iItem, 0);
-
- CString sql;
- sql.Format ("delete from shangpinlb where name='%s'", name);
- sql+=SPLB_REF;
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- FillGrid();
- }
|