RecvNotedlg.cpp
上传用户:hahaxixi
上传日期:2022-04-15
资源大小:1939k
文件大小:4k
源码类别:

手机短信编程

开发平台:

Visual C++

  1. // RecvNotedlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "NoteManage.h"
  5. #include "RecvNotedlg.h"
  6. #include "ADOConn.h"
  7. #include "Restoredlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CRecvNotedlg dialog
  15. CRecvNotedlg::CRecvNotedlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CRecvNotedlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CRecvNotedlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. }
  22. void CRecvNotedlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CRecvNotedlg)
  26. DDX_Control(pDX, IDC_LIST1, m_Grid);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CRecvNotedlg, CDialog)
  30. //{{AFX_MSG_MAP(CRecvNotedlg)
  31. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CRecvNotedlg message handlers
  36. BOOL CRecvNotedlg::OnInitDialog() 
  37. {
  38. CDialog::OnInitDialog();
  39. // TODO: Add extra initialization here
  40. //设置列表视图的扩展风格
  41. m_Grid.SetExtendedStyle(LVS_EX_FLATSB
  42. |LVS_EX_FULLROWSELECT
  43. |LVS_EX_HEADERDRAGDROP
  44. |LVS_EX_ONECLICKACTIVATE
  45. |LVS_EX_GRIDLINES);
  46. m_Grid.InsertColumn(0,"编号",LVCFMT_LEFT,70,0); //设置表头
  47. m_Grid.InsertColumn(1,"发送人姓名",LVCFMT_LEFT,70,1); 
  48. m_Grid.InsertColumn(2,"发送人电话",LVCFMT_LEFT,100,2);
  49. m_Grid.InsertColumn(3,"信息内容",LVCFMT_LEFT,100,3);
  50. m_Grid.InsertColumn(4,"接收时间",LVCFMT_LEFT,100,4);
  51. ADOConn m_ADOConn;
  52. m_ADOConn.OnInitADOConn();
  53. CString sql;
  54. int i = 0;
  55. sql.Format("select * from tb_recvnote order by 接收时间 desc");
  56. m_ADOConn.m_pRecordset = m_ADOConn.GetRecordSet((_bstr_t)sql);
  57. while(!m_ADOConn.m_pRecordset->adoEOF)
  58. {
  59. m_Grid.InsertItem(i,"");
  60. m_Grid.SetItemText(i,0,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("编号"));
  61. m_Grid.SetItemText(i,1,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("发送人姓名"));
  62. m_Grid.SetItemText(i,2,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("发送人电话"));
  63. m_Grid.SetItemText(i,3,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("信息内容"));
  64. m_Grid.SetItemText(i,4,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("接收时间"));
  65. m_ADOConn.m_pRecordset->MoveNext();
  66. i++;
  67. }
  68. m_ADOConn.ExitConnect();
  69. return TRUE;  // return TRUE unless you set the focus to a control
  70.               // EXCEPTION: OCX Property Pages should return FALSE
  71. }
  72. void CRecvNotedlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
  73. {
  74. // TODO: Add your control notification handler code here
  75. CRestoredlg dlg;
  76. int pos     = m_Grid.GetSelectionMark();
  77. dlg.m_Name  =  m_Grid.GetItemText(pos,1);
  78. dlg.m_Phone =  m_Grid.GetItemText(pos,2);
  79. dlg.m_Note  =  m_Grid.GetItemText(pos,3);
  80. dlg.m_Num   =  m_Grid.GetItemText(pos,0);
  81. dlg.DoModal();
  82. m_Grid.DeleteAllItems();
  83. ADOConn m_ADOConn;
  84. m_ADOConn.OnInitADOConn();
  85. CString sql;
  86. int i = 0;
  87. sql.Format("select * from tb_recvnote order by 接收时间 desc");
  88. m_ADOConn.m_pRecordset = m_ADOConn.GetRecordSet((_bstr_t)sql);
  89. while(!m_ADOConn.m_pRecordset->adoEOF)
  90. {
  91. m_Grid.InsertItem(i,"");
  92. m_Grid.SetItemText(i,0,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("编号"));
  93. m_Grid.SetItemText(i,1,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("发送人姓名"));
  94. m_Grid.SetItemText(i,2,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("发送人电话"));
  95. m_Grid.SetItemText(i,3,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("信息内容"));
  96. m_Grid.SetItemText(i,4,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("接收时间"));
  97. m_ADOConn.m_pRecordset->MoveNext();
  98. i++;
  99. }
  100. m_ADOConn.ExitConnect();
  101. *pResult = 0;
  102. }
  103. void CRecvNotedlg::OnOK()
  104. {
  105. }