SelMsgContent3.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // SelMsgContent3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SelMsgContent3.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SelMsgContent3 dialog
  13. SelMsgContent3::SelMsgContent3(CWnd* pParent /*=NULL*/)
  14. : CDialog(SelMsgContent3::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SelMsgContent3)
  17. m_check1 = FALSE;
  18. m_check2 = FALSE;
  19. m_name = _T("");
  20. m_content1 = _T("");
  21. m_content2 = _T("");
  22. m_point = _T("");
  23. //}}AFX_DATA_INIT
  24. }
  25. void SelMsgContent3::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CDialog::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(SelMsgContent3)
  29. DDX_Control(pDX, IDC_EDIT3, m_editnum1);
  30. DDX_Control(pDX, IDC_LIST1, m_List1);
  31. DDX_Check(pDX, IDC_CHECK1, m_check1);
  32. DDX_Check(pDX, IDC_CHECK2, m_check2);
  33. DDX_Text(pDX, IDC_EDIT2, m_name);
  34. DDX_Text(pDX, IDC_EDIT1, m_content1);
  35. DDX_Text(pDX, IDC_EDIT8, m_content2);
  36. DDX_Text(pDX, IDC_EDIT3, m_point);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(SelMsgContent3, CDialog)
  40. //{{AFX_MSG_MAP(SelMsgContent3)
  41. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  42. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  43. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  44. ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
  45. ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // SelMsgContent3 message handlers
  50. int __cdecl CompareByLabel6( const void *elem1, const void *elem2)
  51. {
  52. CStringArray *p1 = (CStringArray*)elem1;
  53. CStringArray *p2 = (CStringArray*)elem2;
  54. return atoi( p1->ElementAt (5))>atoi(p2->ElementAt (5) ) ;
  55. }
  56. BOOL SelMsgContent3::OnInitDialog()
  57. {
  58. CDialog::OnInitDialog();
  59. // TODO: Add extra initialization here
  60. g_sendhead.bsql=0;
  61. g_sendhead.code[0]=170;
  62. g_sendhead.tabcount=1;
  63. g_pMainWnd->ProcessChatMessageRequest2(1);
  64. if(g_bSendOK==0)
  65. return false;
  66. DataToArray(&m_List1array);
  67. if ( m_List1array.GetSize() > 0 )
  68. {
  69. qsort( static_cast<void*>(&m_List1array[0]), m_List1array.GetSize(), sizeof(m_List1array[0]), CompareByLabel6 );
  70. for(int i=0; i<m_List1array.GetSize(); i++)
  71. {
  72. m_List1.AddString(m_List1array.ElementAt(i).ElementAt(0));
  73. }
  74. }
  75. CenterWindow();
  76. return TRUE;
  77. }
  78. void SelMsgContent3::OnOK()
  79. {
  80. // TODO: Add extra validation here
  81. UpdateData();
  82. if(m_name.IsEmpty ())return;
  83. if(atoi(m_point)<1)return;
  84. for(int i=0; i<m_List1array.GetSize (); i++)
  85. {
  86. if(m_name==m_List1array.ElementAt (i).ElementAt (0))
  87. {
  88. MessageBox("已有此规则的记录");
  89. return;
  90. }
  91. }
  92. if(CheckBadWords(m_content1)==0 || CheckBadWords2(m_content2)==0)
  93. {
  94. AfxMessageBox("信息服务商禁止的非法字符:("+g_temp+")希望您谅解!");
  95. return;
  96. }
  97. CString check1,check2;
  98. check1.Format ("%d", m_check1);
  99. check2.Format ("%d", m_check2);
  100. CString sql="insert into msgtemp2(name,point,content1,content2,check1,check2)values('"+m_name+"','"+m_point+"','"+m_content1+"','"+m_content2+"','"+check1+"','"+check2+"')";
  101. g_sendhead.bsql=1;
  102. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  103. MessageBox("保存成功");
  104. m_List1.AddString (m_name);
  105. int size=m_List1array.GetSize ();
  106. m_List1array.SetSize(size+1, 1);
  107. m_List1array.ElementAt (size).RemoveAll ();
  108. m_List1array.ElementAt (size).Add (m_name);
  109. m_List1array.ElementAt (size).Add (m_content1);
  110. m_List1array.ElementAt (size).Add (m_content2);
  111. m_List1array.ElementAt (size).Add (check1);
  112. m_List1array.ElementAt (size).Add (check2);
  113. m_List1array.ElementAt (size).Add (m_point);
  114. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  115. }
  116. void SelMsgContent3::OnSelchangeList1()
  117. {
  118. // TODO: Add your control notification handler code here
  119. int pos=m_List1.GetCurSel ();
  120. if(pos==-1)
  121. {
  122. m_oldname.Empty (); GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  123. return;
  124. }
  125. m_name=m_List1array.ElementAt (pos).ElementAt (0);
  126. m_content1=m_List1array.ElementAt (pos).ElementAt (1);
  127. m_content2=m_List1array.ElementAt (pos).ElementAt (2);
  128. CString check1,check2;
  129. check1=m_List1array.ElementAt (pos).ElementAt (3);
  130. check2=m_List1array.ElementAt (pos).ElementAt (4);
  131. m_point=m_List1array.ElementAt (pos).ElementAt (5);
  132. m_check1=atoi(check1);
  133. m_check2=atoi(check2);
  134. m_oldname=m_name;
  135. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  136. // if(m_content1.IsEmpty())m_content1="xxx先生/女士";
  137. // if(m_content2.IsEmpty())m_content2="xxx先生/女士";
  138. UpdateData(false);
  139. }
  140. void SelMsgContent3::OnButton1()
  141. {
  142. // TODO: Add your control notification handler code here
  143. int pos=m_List1.GetCurSel ();
  144. if(pos==-1)return;
  145. if(AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  146. m_name=m_List1array.ElementAt (pos).ElementAt (0);
  147. m_content1=m_List1array.ElementAt (pos).ElementAt (1);
  148. CString sql="delete from msgtemp2 where name='"+m_name+"'";
  149. g_sendhead.bsql=1;
  150. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  151. m_List1.DeleteString (pos);
  152. m_List1array.RemoveAt(pos);
  153. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  154. }
  155. void SelMsgContent3::OnButton2()
  156. {
  157. // TODO: Add your control notification handler code here
  158. UpdateData();
  159. if(m_oldname.IsEmpty ())return;
  160. if(m_name.IsEmpty ())return;
  161. if(atoi(m_point)<1)return;
  162. /* if(m_content1.Find ("xxx先生/女士")==-1)
  163. {
  164. m_content1="xxx先生/女士"+m_content1;
  165. AfxMessageBox("祝福语不合规范!");
  166. UpdateData(false);
  167. return;
  168. }
  169. if(m_content2.Find ("xxx先生/女士")==-1)
  170. {
  171. m_content2="xxx先生/女士"+m_content2;
  172. AfxMessageBox("祝福语不合规范!");
  173. UpdateData(false);
  174. return;
  175. }*/
  176. int i = 0;
  177. int oldpos=-1;
  178. for( i=0; i<m_List1array.GetSize (); i++)
  179. {
  180. if(m_oldname==m_List1array.ElementAt (i).ElementAt (0))
  181. {
  182. oldpos=i;
  183. break;
  184. }
  185. }
  186. if(CheckBadWords(m_content1)==0 || CheckBadWords2(m_content2)==0)
  187. {
  188. AfxMessageBox("信息服务商禁止的非法字符:("+g_temp+")希望您谅解!");
  189. return;
  190. }
  191. if(oldpos==-1)return;
  192. CString check1,check2;
  193. check1.Format ("%d", m_check1);
  194. check2.Format ("%d", m_check2);
  195. CString sql="update msgtemp2 set name='"+m_name+"',point='"+m_point+"',content1='"+m_content1+"',content2='"+m_content2+"',check1='"+check1+"',check2='"+check2+"' where name='"+m_oldname+"'";
  196. g_sendhead.bsql=1;
  197. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  198. MessageBox("保存成功");
  199. m_List1array.ElementAt (oldpos).SetAt (0, m_name);
  200. m_List1array.ElementAt (oldpos).SetAt (1, m_content1);
  201. m_List1array.ElementAt (oldpos).SetAt (2, m_content2);
  202. m_List1array.ElementAt (oldpos).SetAt (3, check1);
  203. m_List1array.ElementAt (oldpos).SetAt (4, check2);
  204. m_List1array.ElementAt (oldpos).SetAt (5, m_point);
  205. m_List1.ResetContent ();
  206. for( i=0; i<m_List1array.GetSize (); i++)
  207. {
  208. m_List1.AddString (m_List1array.ElementAt (i).ElementAt (0));
  209. }
  210. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  211. }
  212. void SelMsgContent3::OnChangeEdit1()
  213. {
  214. // TODO: If this is a RICHEDIT control, the control will not
  215. // send this notification unless you override the CDialog::OnInitDialog()
  216. // function and call CRichEditCtrl().SetEventMask()
  217. // with the ENM_CHANGE flag ORed into the mask.
  218. UpdateData();
  219. /* if(m_content1.Find ("xxx先生/女士")==-1)
  220. {
  221. m_content1="xxx先生/女士"+m_content1;
  222. UpdateData(false);
  223. return;
  224. }*/
  225. m_content1.Replace ("'", "'");
  226. m_content1.Replace ("(", "(");
  227. m_content1.Replace (")", ")");
  228. UpdateData(false);
  229. CString str;
  230. int count=0;
  231. int leng=GetLengthEx(m_content1)-3;
  232. count+=(leng/MSG_LENGTH);
  233. if(leng%MSG_LENGTH)
  234. count+=1;
  235. str.Format ("%d字/条,现%d字,共%d条)", MSG_LENGTH,leng,count);
  236. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  237. // TODO: Add your control notification handler code here
  238. }
  239. void SelMsgContent3::OnChangeEdit8()
  240. {
  241. // TODO: If this is a RICHEDIT control, the control will not
  242. // send this notification unless you override the CDialog::OnInitDialog()
  243. // function and call CRichEditCtrl().SetEventMask()
  244. // with the ENM_CHANGE flag ORed into the mask.
  245. UpdateData();
  246. /* if(m_content2.Find ("xxx先生/女士")==-1)
  247. {
  248. m_content2="xxx先生/女士"+m_content2;
  249. UpdateData(false);
  250. return;
  251. }*/
  252. m_content2.Replace ("'", "'");
  253. m_content2.Replace ("(", "(");
  254. m_content2.Replace (")", ")");
  255. UpdateData(false);
  256. CString str;
  257. int count=0;
  258. int leng=GetLengthEx(m_content2)-3;
  259. count+=(leng/MSG_LENGTH);
  260. if(leng%MSG_LENGTH)
  261. count+=1;
  262. str.Format ("%d字/条,现%d字,共%d条)", MSG_LENGTH, leng,count);
  263. GetDlgItem(IDC_STATIC2)->SetWindowText(str);
  264. // TODO: Add your control notification handler code here
  265. }
  266. //没有此域名的记录