// ModifyReg.cpp : implementation file #include "stdafx.h" #include "ylgl.h" #include "ModifyReg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // ModifyReg dialog ModifyReg::ModifyReg(CWnd* pParent /*=NULL*/) : CDialog(ModifyReg::IDD, pParent) { //{{AFX_DATA_INIT(ModifyReg) //}}AFX_DATA_INIT } void ModifyReg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(ModifyReg) DDX_Control(pDX, IDC_LIST1, m_List1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(ModifyReg, CDialog) //{{AFX_MSG_MAP(ModifyReg) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTdel, OnBUTdel) //}}AFX_MSG_MAP ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, OnCustomdrawList1) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ModifyReg message handlers BOOL ModifyReg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if (IsHasRights2new(49) == 0) GetDlgItem(IDC_BUTdel)->EnableWindow(0); m_List1.SetHeadings("单号,120;名称,150;数量,80;日期,160;经手人,120"); m_List1.LoadColumnInfo(186); GetData(); CenterWindow(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void ModifyReg::OnButton1() { // TODO: Add your control notification handler code here CDialog::OnCancel(); } void ModifyReg::OnBUTdel() { // TODO: Add your control notification handler code here if (IsHasRights2new(49) == 0)return; POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { return; } if (AfxMessageBox("删除后将不可恢复, 确认吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return; int iItem = m_List1.GetNextSelectedItem(pos); CString id = m_List1.GetItemText(iItem, 0); CString date = m_List1.GetItemText(iItem, 3); CString sql; sql.Format("delete from [dindansp2] where [id]='%s' and [date]='%s'", id, date); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; GetData(); } void ModifyReg::GetData() { CString filter = "[id]='" + m_id + "'"; g_sendhead.bsql = 0; g_sendhead.code[0] = 173; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return; DataToArray(&m_List1array); m_datearray.RemoveAll(); m_List1.DeleteAllItems2(); int ii = 0; m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1); int count = 0; for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); if (::FindArray(&m_datearray, m_List1array.ElementAt(ii).ElementAt(3)) == -1) m_datearray.Add(m_List1array.ElementAt(ii).ElementAt(3)); } m_List1.m_arLabels.SetSize(count, 1); ii = count; m_List1.m_LabelCount = ii; m_List1.SetItemCountEx(ii); } void ModifyReg::OnCustomdrawList1(NMHDR* pNMHDR, LRESULT* pResult) { NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); // Take the default processing unless we set this to something else below. *pResult = 0; // First thing - check the draw stage. If it's the control's prepaint // stage, then tell Windows we want messages for every item. if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) { *pResult = CDRF_NOTIFYITEMDRAW; } else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) { // This is the prepaint stage for an item. Here's where we set the // item's text color. Our return value will tell Windows to draw the // item itself, but it will use the new color we set here. // We'll cycle the colors through red, green, and light blue. if (::FindArray(&m_datearray, m_List1.m_arLabels.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(3)) % 2) pLVCD->clrText = RGB(220, 0, 0); else pLVCD->clrText = RGB(20, 133, 20); if (pLVCD->nmcd.dwItemSpec % 2) pLVCD->clrTextBk = g_gridcol1; else pLVCD->clrTextBk = g_gridcol2; // Store the color back in the NMLVCUSTOMDRAW struct. // Tell Windows to paint the control itself. *pResult = CDRF_DODEFAULT; } }