SelMsgContent2.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // SelMsgContent2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SelMsgContent2.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SelMsgContent2 dialog
  13. SelMsgContent2::SelMsgContent2(CWnd* pParent /*=NULL*/)
  14. : CDialog(SelMsgContent2::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SelMsgContent2)
  17. m_content = _T("");
  18. m_title = _T("");
  19. //}}AFX_DATA_INIT
  20. }
  21. void SelMsgContent2::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(SelMsgContent2)
  25. DDX_Control(pDX, IDC_LIST1, m_List1);
  26. DDX_Text(pDX, IDC_EDIT1, m_content);
  27. DDV_MaxChars(pDX, m_content, 1000);
  28. DDX_Text(pDX, IDC_EDIT2, m_title);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(SelMsgContent2, CDialog)
  32. //{{AFX_MSG_MAP(SelMsgContent2)
  33. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  34. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // SelMsgContent2 message handlers
  39. BOOL SelMsgContent2::OnInitDialog()
  40. {
  41. CDialog::OnInitDialog();
  42. // TODO: Add extra initialization here
  43. g_sendhead.bsql=0;
  44. g_sendhead.code[0]=134;
  45. g_sendhead.tabcount=1;
  46. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return false;
  47. DataToArray(&m_List1array);
  48. for(int i=0; i<m_List1array.GetSize (); i++)
  49. {
  50. m_List1.AddString (m_List1array.ElementAt (i).ElementAt (0));
  51. }
  52. return TRUE; // return TRUE unless you set the focus to a control
  53. // EXCEPTION: OCX Property Pages should return FALSE
  54. }
  55. void SelMsgContent2::OnOK()
  56. {
  57. // TODO: Add extra validation here
  58. UpdateData();
  59. if(m_title.IsEmpty ())return;
  60. for(int i=0; i<m_List1array.GetSize (); i++)
  61. {
  62. if(m_title==m_List1array.ElementAt (i).ElementAt (0))
  63. {MessageBox("已有此模板的记录");
  64. return;
  65. }
  66. }
  67. CString sql="insert into msgtemp(title,content)values('"+m_title+"','"+m_content+"')";
  68. g_sendhead.bsql=1;
  69. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  70. MessageBox("保存成功");
  71. m_List1.AddString (m_title);
  72. int size=m_List1array.GetSize ();
  73. m_List1array.SetSize(size+1, 1);
  74. m_List1array.ElementAt (size).RemoveAll ();
  75. m_List1array.ElementAt (size).Add (m_title);
  76. m_List1array.ElementAt (size).Add (m_content);
  77. }
  78. void SelMsgContent2::OnSelchangeList1()
  79. {
  80. // TODO: Add your control notification handler code here
  81. int pos=m_List1.GetCurSel ();
  82. if(pos==-1)return;
  83. m_title=m_List1array.ElementAt (pos).ElementAt (0);
  84. m_content=m_List1array.ElementAt (pos).ElementAt (1);
  85. UpdateData(false);
  86. }
  87. void SelMsgContent2::OnButton1()
  88. {
  89. // TODO: Add your control notification handler code here
  90. int pos=m_List1.GetCurSel ();
  91. if(pos==-1)return;
  92. if(AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  93. m_title=m_List1array.ElementAt (pos).ElementAt (0);
  94. m_content=m_List1array.ElementAt (pos).ElementAt (1);
  95. CString sql="delete from msgtemp where title='"+m_title+"'";
  96. g_sendhead.bsql=1;
  97. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  98. m_List1.DeleteString (pos);
  99. m_List1array.RemoveAt(pos);
  100. }