ModifyReg.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // ModifyReg.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "ylgl.h"
  4. #include "ModifyReg.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // ModifyReg dialog
  12. ModifyReg::ModifyReg(CWnd* pParent /*=NULL*/)
  13. : CDialog(ModifyReg::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(ModifyReg)
  16. //}}AFX_DATA_INIT
  17. }
  18. void ModifyReg::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialog::DoDataExchange(pDX);
  21. //{{AFX_DATA_MAP(ModifyReg)
  22. DDX_Control(pDX, IDC_LIST1, m_List1);
  23. //}}AFX_DATA_MAP
  24. }
  25. BEGIN_MESSAGE_MAP(ModifyReg, CDialog)
  26. //{{AFX_MSG_MAP(ModifyReg)
  27. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  28. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  29. //}}AFX_MSG_MAP
  30. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, OnCustomdrawList1)
  31. END_MESSAGE_MAP()
  32. /////////////////////////////////////////////////////////////////////////////
  33. // ModifyReg message handlers
  34. BOOL ModifyReg::OnInitDialog()
  35. {
  36. CDialog::OnInitDialog();
  37. // TODO: Add extra initialization here
  38. if (IsHasRights2new(49) == 0) GetDlgItem(IDC_BUTdel)->EnableWindow(0);
  39. m_List1.SetHeadings("单号,120;名称,150;数量,80;日期,160;经手人,120");
  40. m_List1.LoadColumnInfo(186);
  41. GetData();
  42. CenterWindow();
  43. return TRUE; // return TRUE unless you set the focus to a control
  44. // EXCEPTION: OCX Property Pages should return FALSE
  45. }
  46. void ModifyReg::OnButton1()
  47. {
  48. // TODO: Add your control notification handler code here
  49. CDialog::OnCancel();
  50. }
  51. void ModifyReg::OnBUTdel()
  52. {
  53. // TODO: Add your control notification handler code here
  54. if (IsHasRights2new(49) == 0)return;
  55. POSITION pos;
  56. pos = m_List1.GetFirstSelectedItemPosition();
  57. if (pos == NULL)
  58. {
  59. return;
  60. }
  61. if (AfxMessageBox("删除后将不可恢复, 确认吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  62. int iItem = m_List1.GetNextSelectedItem(pos);
  63. CString id = m_List1.GetItemText(iItem, 0);
  64. CString date = m_List1.GetItemText(iItem, 3);
  65. CString sql;
  66. sql.Format("delete from [dindansp2] where [id]='%s' and [date]='%s'", id, date);
  67. g_sendhead.bsql = 1;
  68. g_pMainWnd->ProcessChatMessageRequest2(sql);
  69. if (g_bSendOK == 0)return;
  70. GetData();
  71. }
  72. void ModifyReg::GetData()
  73. {
  74. CString filter = "[id]='" + m_id + "'";
  75. g_sendhead.bsql = 0;
  76. g_sendhead.code[0] = 173;
  77. g_sendhead.tabcount = 1;
  78. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return;
  79. DataToArray(&m_List1array);
  80. m_datearray.RemoveAll();
  81. m_List1.DeleteAllItems2();
  82. int ii = 0;
  83. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  84. int count = 0;
  85. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  86. {
  87. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  88. if (::FindArray(&m_datearray, m_List1array.ElementAt(ii).ElementAt(3)) == -1)
  89. m_datearray.Add(m_List1array.ElementAt(ii).ElementAt(3));
  90. }
  91. m_List1.m_arLabels.SetSize(count, 1);
  92. ii = count;
  93. m_List1.m_LabelCount = ii;
  94. m_List1.SetItemCountEx(ii);
  95. }
  96. void ModifyReg::OnCustomdrawList1(NMHDR* pNMHDR, LRESULT* pResult)
  97. {
  98. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
  99. // Take the default processing unless we set this to something else below.
  100. *pResult = 0;
  101. // First thing - check the draw stage. If it's the control's prepaint
  102. // stage, then tell Windows we want messages for every item.
  103. if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
  104. {
  105. *pResult = CDRF_NOTIFYITEMDRAW;
  106. }
  107. else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
  108. {
  109. // This is the prepaint stage for an item. Here's where we set the
  110. // item's text color. Our return value will tell Windows to draw the
  111. // item itself, but it will use the new color we set here.
  112. // We'll cycle the colors through red, green, and light blue.
  113. if (::FindArray(&m_datearray, m_List1.m_arLabels.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(3)) % 2)
  114. pLVCD->clrText = RGB(220, 0, 0);
  115. else
  116. pLVCD->clrText = RGB(20, 133, 20);
  117. if (pLVCD->nmcd.dwItemSpec % 2)
  118. pLVCD->clrTextBk = g_gridcol1;
  119. else
  120. pLVCD->clrTextBk = g_gridcol2;
  121. // Store the color back in the NMLVCUSTOMDRAW struct.
  122. // Tell Windows to paint the control itself.
  123. *pResult = CDRF_DODEFAULT;
  124. }
  125. }