123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- // SPBox.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SPBox.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SPBox dialog
- SPBox::SPBox(CWnd* pParent /*=NULL*/)
- : CDialog(SPBox::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SPBox)
- m_filter = _T("");
- //}}AFX_DATA_INIT
- m_mode = 0;
- m_badmin = 0;
- }
- void SPBox::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SPBox)
- DDX_Control(pDX, IDC_LIST1, m_listbox1);
- DDX_Control(pDX, IDC_LIST2, m_List1);
- DDX_Control(pDX, IDC_COMBOsplb, m_combosplb);
- DDX_Text(pDX, IDC_EDIT1, m_filter);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SPBox, CDialog)
- //{{AFX_MSG_MAP(SPBox)
- ON_CBN_SELCHANGE(IDC_COMBOsplb, OnSelchangeCOMBOsplb)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SPBox message handlers
- BOOL SPBox::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- // m_badmin=IsHasRights2new(49);
- if (m_badmin)
- m_List1.SetHeadings("编号,50;商品名称,150;成本价,80;销售价,80");
- else
- m_List1.SetHeadings("编号,50;商品名称,150;销售价,80");
- m_List1.LoadColumnInfo(103);
- CString filter = "hide<>'下架' or hide is null;";
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 8;
- g_sendhead.code[1] = 2;
- g_sendhead.tabcount = 2;
- g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
- DataToArray(&m_List1array, &m_List2array);
- CString strRes1;
- if (m_badmin == 0)
- {
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- m_List1array.ElementAt(i).RemoveAt(2);
- ChinesePinYin::GetFirstLetter(m_List1array.ElementAt(i).ElementAt(1), strRes1);
- m_List1array.ElementAt(i).InsertAt(3, strRes1);
- }
- }
- else
- {
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- ChinesePinYin::GetFirstLetter(m_List1array.ElementAt(i).ElementAt(1), strRes1);
- m_List1array.ElementAt(i).InsertAt(4, strRes1);
- }
- }
- if (m_mode)
- {
- m_combosplb.AddString("婚庆服务");
- }
- else
- {
- for (int i = 0; i < m_List2array.GetSize(); i++)
- m_combosplb.AddString(m_List2array.ElementAt(i).ElementAt(0));
- }
- if (m_combosplb.GetCount())
- m_combosplb.SetCurSel(0);
- OnSelchangeCOMBOsplb();
- this->CenterWindow(g_pMainWnd);
- m_combosplb.SetFocus();
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SPBox::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- }
- void SPBox::OnOK()
- {
- // TODO: Add extra validation here
- /* int pos=m_combosplb.GetCurSel ();
- if(pos==-1)return;
- m_combosplb.GetLBText (pos, m_lb);*/
- //if(m_mode==0)
- {
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中一个商品!");
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- m_spid = m_List1.GetItemText(iItem, 0);
- m_spname = m_List1.GetItemText(iItem, 1);
- }
- CDialog::OnOK();
- }
- void SPBox::OnSelchangeCOMBOsplb()
- {
- // TODO: Add your control notification handler code here
- int pos = m_combosplb.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_combosplb.GetLBText(pos, str);
- FillGrid(str);
- }
- void SPBox::FillGrid(CString str)
- {
- UpdateData();
- m_filter.MakeUpper();
- if (m_filter != "")m_combosplb.SetCurSel(-1);
- m_List1.DeleteAllItems2();
- int ii = 0;
- m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
- int count = 0;
- if (m_badmin)
- {
- if (m_filter == "")
- {
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- if (m_List1array.ElementAt(ii).ElementAt(5) == str)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- }
- }
- else
- {
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- if (m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- }
- }
- }
- else
- {
- if (m_filter == "")
- {
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- if (m_List1array.ElementAt(ii).ElementAt(4) == str)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- }
- }
- else
- {
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- if (m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
- m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- }
- }
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii = count;
- m_List1.m_LabelCount = ii;
- m_List1.SetItemCountEx(ii);
- }
- void SPBox::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- OnButton1();
- *pResult = 0;
- }
- void SPBox::OnButton1()
- {
- // TODO: Add your control notification handler code here
- /* {
- int pos=m_combosplb.GetCurSel ();
- if(pos==-1)return;
- m_combosplb.GetLBText (pos, m_lb);
- }*/
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- m_spid = m_List1.GetItemText(iItem, 0);
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- if (m_spid == m_List1array.ElementAt(i).ElementAt(0))
- {
- m_lb = m_List1array.ElementAt(i).ElementAt(4); break;
- }
- }
- m_spname = m_List1.GetItemText(iItem, 1);
- m_spidarray.Add(m_spid);
- m_spnamearray.Add(m_spname);
- m_lbarray.Add(m_lb);
- m_listbox1.AddString(m_spname);
- }
- void SPBox::OnButton2()
- {
- // TODO: Add your control notification handler code here
- int pos = m_listbox1.GetCurSel();
- if (pos == -1)return;
- m_spidarray.RemoveAt(pos);
- m_spnamearray.RemoveAt(pos);
- m_lbarray.RemoveAt(pos);
- m_listbox1.DeleteString(pos);
- if (pos == m_listbox1.GetCount() && pos)
- m_listbox1.SetCurSel(0);
- else if (m_listbox1.GetCount())
- m_listbox1.SetCurSel(pos);
- }
- void SPBox::OnButton3()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- m_filter.TrimLeft();
- m_filter.TrimRight();
- if (m_filter == "")
- {
- OnSelchangeCOMBOsplb();
- return;
- }
- FillGrid("");
- }
|