SendInsideMsg.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // SendInsideMsg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SendInsideMsg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SendInsideMsg dialog
  13. SendInsideMsg::SendInsideMsg(CWnd* pParent /*=NULL*/)
  14. : CDialog(SendInsideMsg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SendInsideMsg)
  17. m_strRecvMobi = _T("");
  18. m_count = 0;
  19. m_content = _T("");
  20. //}}AFX_DATA_INIT
  21. }
  22. void SendInsideMsg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(SendInsideMsg)
  26. DDX_Control(pDX, IDC_COMBO1, m_combobm);
  27. DDX_Control(pDX, IDC_LIST1, m_List1);
  28. DDX_Text(pDX, IDC_EDT_RECV_MOBI, m_strRecvMobi);
  29. DDV_MaxChars(pDX, m_strRecvMobi, 4000);
  30. DDX_Text(pDX, IDC_EDT_NUM, m_count);
  31. DDX_Text(pDX, IDC_EDT_SMS, m_content);
  32. DDV_MaxChars(pDX, m_content, 4000);
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(SendInsideMsg, CDialog)
  36. //{{AFX_MSG_MAP(SendInsideMsg)
  37. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  38. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  39. ON_BN_CLICKED(IDC_BTN_SEND, OnBtnSend)
  40. ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // SendInsideMsg message handlers
  45. BOOL SendInsideMsg::OnInitDialog()
  46. {
  47. CDialog::OnInitDialog();
  48. // TODO: Add extra initialization here
  49. CString filter="[dimission]='在职';";
  50. g_sendhead.bsql=0;
  51. g_sendhead.code[0]=5;
  52. g_sendhead.code[1]=3;
  53. g_sendhead.tabcount=2;
  54. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return false;
  55. DataToArray(&m_List1array, &g_List1array);
  56. m_combobm.AddString ("全部");
  57. for(int i=0; i<g_List1array.GetSize (); i++)
  58. m_combobm.AddString (g_List1array.ElementAt (i).ElementAt (0));
  59. CenterWindow();
  60. m_combobm.SetCurSel (0);
  61. OnSelchangeCombo1();
  62. return TRUE; // return TRUE unless you set the focus to a control
  63. // EXCEPTION: OCX Property Pages should return FALSE
  64. }
  65. void SendInsideMsg::OnSelchangeCombo1()
  66. {
  67. // TODO: Add your control notification handler code here
  68. int pos=m_combobm.GetCurSel ();
  69. if(pos==-1)return;
  70. CString bm;
  71. m_combobm.GetLBText (pos, bm);
  72. m_List1.ResetContent ();
  73. int aa=0;
  74. for(int i=0; i<m_List1array.GetSize(); i++)
  75. {
  76. if(bm=="全部" || bm==m_List1array.ElementAt (i).ElementAt (2))
  77. {
  78. if(m_List1.GetCount()%2)
  79. m_List1.AddEntry( m_List1array.ElementAt (i).ElementAt (1) , g_gridcol1, m_List1.GetCount());
  80. else
  81. m_List1.AddEntry( m_List1array.ElementAt (i).ElementAt (1) , g_gridcol2, m_List1.GetCount());
  82. m_List1.SetSel (aa);aa++;
  83. }
  84. }
  85. m_List1.Invalidate ();
  86. OnSelchangeList1();
  87. }
  88. void SendInsideMsg::OnSelchangeList1()
  89. {
  90. // TODO: Add your control notification handler code here
  91. UpdateData();
  92. int count= m_List1.GetSelCount() ;
  93. if(count==0)return;
  94. int *pIndex=new int[count];
  95. m_List1.GetSelItems(count, pIndex);
  96. m_strRecvMobi = _T("");
  97. CString str,temp;
  98. int pos;
  99. m_count=0;
  100. for(int i=0; i<count; i++)
  101. {
  102. m_List1.GetText (pIndex[i], str);
  103. m_strRecvMobi+=str;
  104. m_strRecvMobi+=",";
  105. m_count++;
  106. }
  107. m_strRecvMobi.TrimRight (",");
  108. UpdateData(false);
  109. delete []pIndex;
  110. }
  111. void SendInsideMsg::OnBtnSend()
  112. {
  113. // TODO: Add your control notification handler code here
  114. UpdateData();
  115. if(m_strRecvMobi.IsEmpty ())
  116. {
  117. AfxMessageBox("接收人员不能为空!");return;
  118. }
  119. if(m_content.IsEmpty ())
  120. {
  121. AfxMessageBox("内容不能为空!");return;
  122. }
  123. if(m_strRecvMobi.GetLength ()>1000)
  124. {
  125. AfxMessageBox("接收人太多!");return;
  126. }
  127. if(m_content.GetLength ()>1000)
  128. {
  129. AfxMessageBox("内容太长!");return;
  130. }
  131. CString timestamp=g_date+" curtimereplace";
  132. CString sql="insert into insidemsg([content],[timestamp],[sender],[receiver]) values('"+m_content+"','"+timestamp+"','"+g_user.name+"','"+m_strRecvMobi+"')";
  133. g_sendhead.bsql=1;
  134. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  135. AfxMessageBox("发送成功!", MB_ICONINFORMATION);
  136. }
  137. void SendInsideMsg::OnEditchangeCombo1()
  138. {
  139. // TODO: Add your control notification handler code here
  140. OnSelchangeCombo1();
  141. }