DesignFrom.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. // DesignFrom.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "DesignFrom.h"
  6. #include "MyMdi.H"
  7. #include "InputPsw.h"
  8. #include "ClientDlg.h"
  9. #include "SqlDlg.h"
  10. #include "mysqldata.h"
  11. #include "ClientRequirement.h"
  12. #include "ChoosePhotoSkin2.h"
  13. #include "./helper/ffsco.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #pragma comment(lib, "Shlwapi.lib")
  20. /////////////////////////////////////////////////////////////////////////////
  21. // DesignFrom
  22. IMPLEMENT_DYNCREATE(DesignFrom, CFormView)
  23. DesignFrom::DesignFrom()
  24. : CFormView(DesignFrom::IDD)
  25. {
  26. //{{AFX_DATA_INIT(DesignFrom)
  27. m_filter = _T("");
  28. //}}AFX_DATA_INIT
  29. }
  30. DesignFrom::~DesignFrom()
  31. {
  32. }
  33. void DesignFrom::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CFormView::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(DesignFrom)
  37. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  38. DDX_Control(pDX, IDC_LIST2, m_List1);
  39. DDX_Control(pDX, IDC_STATIC1, m_static1);
  40. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(DesignFrom, CFormView)
  44. //{{AFX_MSG_MAP(DesignFrom)
  45. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  46. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  47. ON_WM_TIMER()
  48. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  49. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  50. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // DesignFrom diagnostics
  55. #ifdef _DEBUG
  56. void DesignFrom::AssertValid() const
  57. {
  58. CFormView::AssertValid();
  59. }
  60. void DesignFrom::Dump(CDumpContext& dc) const
  61. {
  62. CFormView::Dump(dc);
  63. }
  64. #endif //_DEBUG
  65. /////////////////////////////////////////////////////////////////////////////
  66. // DesignFrom message handlers
  67. void DesignFrom::OnInitialUpdate()
  68. {
  69. CFormView::OnInitialUpdate();
  70. // TODO: Add your specialized code here and/or call the base class
  71. CMyMdi Mdi;
  72. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  73. // Here we create the outbar control using the splitter as its parent
  74. // and setting its id to the first pane.
  75. CRect rc2;
  76. GetWindowRect(rc2);
  77. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  78. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  79. m_static1.SetFont (&g_titlefont);
  80. m_List1.SetHeadings("账号,100;姓名,100;号码,100;内容,100;发送时间,100;时间,100;费用,100;真实费用,100;id,0" );
  81. // m_List1.SetHeadings("账号,100;姓名,100;号码,100;时间,100;费用,100;真实费用,100" );
  82. m_List1.LoadColumnInfo (_T("119"));
  83. m_combo1.GetWindowRect (rc2);
  84. ScreenToClient(rc2);
  85. rc2.bottom +=200;
  86. m_combo1.MoveWindow (rc2);
  87. OnButton1();
  88. }
  89. void DesignFrom::FillGrid(BOOL bStatus)
  90. {
  91. m_List1.DeleteAllItems2 ();
  92. int ii=0;
  93. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  94. int count=0;
  95. if(m_filter.IsEmpty ())
  96. {
  97. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  98. {
  99. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  100. }
  101. }
  102. else
  103. {
  104. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  105. {
  106. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 \
  107. ||m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 \
  108. || m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 \
  109. || m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1\
  110. || m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 )
  111. {
  112. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  113. }
  114. }
  115. }
  116. m_List1.m_arLabels.SetSize(count, 1);
  117. ii=count;
  118. m_List1.m_LabelCount=ii;
  119. m_List1.SetItemCountEx (ii);
  120. CString str;
  121. str.Format ("项目:%d", ii);
  122. SetDlgItemText(IDC_STATIC2, str);
  123. }
  124. void DesignFrom::OnBUTclose()
  125. {
  126. // TODO: Add your control notification handler code here
  127. GetParent()->SendMessage(WM_CLOSE);
  128. }
  129. void DesignFrom::OnTimer(UINT nIDEvent)
  130. {
  131. // TODO: Add your message handler code here and/or call default
  132. KillTimer(nIDEvent);
  133. OnButton1();
  134. }
  135. BOOL DesignFrom::PreTranslateMessage(MSG* pMsg)
  136. {
  137. // TODO: Add your specialized code here and/or call the base class
  138. try
  139. {
  140. if(pMsg->message==WM_KEYDOWN)
  141. {
  142. switch (pMsg->wParam)
  143. {
  144. case VK_RETURN:
  145. OnButton1();
  146. return 1;
  147. case VK_F9:
  148. {
  149. SqlDlg dlg;
  150. dlg.DoModal ();
  151. }
  152. return 1;
  153. case 0x43: // copy
  154. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  155. {
  156. GetFocus()->SendMessage(WM_COPY);
  157. return TRUE;
  158. }
  159. break;
  160. case 0x56: //Ctrl + V:
  161. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  162. {
  163. GetFocus()->SendMessage(WM_PASTE);
  164. return TRUE;
  165. }
  166. break;
  167. case 0x58: // cut
  168. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  169. {
  170. GetFocus()->SendMessage(WM_CUT);
  171. return TRUE;
  172. }
  173. break;
  174. case 0x5A: //undo
  175. case 0x59: //redo
  176. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  177. {
  178. GetFocus()->SendMessage(WM_UNDO);
  179. return TRUE;
  180. }
  181. break;
  182. }
  183. }
  184. return CFormView::PreTranslateMessage(pMsg);
  185. }
  186. catch(...)
  187. {
  188. }
  189. }
  190. void DesignFrom::OnButton1()
  191. {
  192. // TODO: Add your control notification handler code here
  193. if(1)
  194. {
  195. MyLock lock("xiaoaccessdbmsg");
  196. CRecordset myset(&g_db);
  197. CString sql="select count(*) as cot from sendregform";
  198. myset.Open (CRecordset::forwardOnly, sql);
  199. myset.GetFieldValue ("cot", sql);
  200. myset.Close();
  201. m_List1array.SetSize(atol(sql) , 1 );
  202. RstSendRegForm rsSt;
  203. rsSt.Open();
  204. DWORD ii=0;
  205. while(!rsSt.IsEOF())
  206. {
  207. m_List1array.ElementAt (ii).RemoveAll ();
  208. m_List1array.ElementAt (ii).Add(rsSt.m_account) ;
  209. m_List1array.ElementAt (ii).Add(rsSt.m_name) ;
  210. if(rsSt.m_phones.GetLength ()>259)
  211. m_List1array.ElementAt (ii).Add(rsSt.m_phones.Left (256)+"...") ;
  212. else
  213. m_List1array.ElementAt (ii).Add(rsSt.m_phones) ;
  214. if(rsSt.m_content.GetLength ()>259)
  215. m_List1array.ElementAt (ii).Add(rsSt.m_content.Left (256)+"...") ;
  216. else
  217. m_List1array.ElementAt (ii).Add(rsSt.m_content) ;
  218. m_List1array.ElementAt (ii).Add(rsSt.m_log) ;
  219. m_List1array.ElementAt (ii).Add(rsSt.m_timestamp) ;
  220. m_List1array.ElementAt (ii).Add(rsSt.m_msgcount) ;
  221. m_List1array.ElementAt (ii).Add(rsSt.m_msgcount2) ;
  222. m_List1array.ElementAt (ii).Add(rsSt.m_id) ;
  223. ii++;
  224. rsSt.MoveNext();if(m_List1array.GetSize ()<=ii)break;
  225. }
  226. rsSt.Close();m_List1array.SetSize(ii , 1 );
  227. }
  228. UpdateData();
  229. m_filter.TrimLeft ();
  230. m_filter.TrimRight ();
  231. FillGrid();
  232. }
  233. void DesignFrom::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  234. {
  235. // TODO: Add your control notification handler code here
  236. POSITION pos;
  237. pos=m_List1.GetFirstSelectedItemPosition();
  238. if(pos==NULL)
  239. {
  240. return;
  241. }
  242. int iItem=m_List1.GetNextSelectedItem(pos);
  243. CString content=m_List1.GetItemText (iItem, 3);
  244. CString id=m_List1.GetItemText (iItem, 8);
  245. CRecordset myset(&g_db);
  246. CString sql;
  247. sql.Format("select [phones] as cot from sendreg where [autoid]=%d", atoi(id));
  248. myset.Open (CRecordset::forwardOnly, sql);
  249. myset.GetFieldValue ("cot", sql);
  250. myset.Close();
  251. CString phone=sql;
  252. SqlDlg dlg;
  253. dlg.m_sql =phone+"\r\n"+content;
  254. dlg.DoModal ();
  255. *pResult = 0;
  256. }
  257. void DesignFrom::OnBUTimportphoto()
  258. {
  259. // TODO: Add your control notification handler code here
  260. }
  261. void FillLength(CString &str, int length)
  262. {
  263. while(str.GetLength ()<length)
  264. str+=" ";
  265. }
  266. void DesignFrom::OnBUTshowphoto()
  267. {
  268. CStdioFile fp;
  269. fp.Open ("c:\\clientphone.txt", CFile::modeCreate|CFile::modeWrite);
  270. CString str;
  271. CString name,m_name1,m_name2;
  272. CString phone,m_phone1,m_phone2;
  273. CString txname,txprice,mensi;
  274. int leng1=20;
  275. int leng2=30;
  276. int leng3=30;
  277. int leng4=30;
  278. int leng5=20;
  279. name="账号";
  280. mensi="号码";
  281. phone="内容";
  282. txname="发送时间";
  283. txprice="费用";
  284. FillLength(name, leng1);
  285. FillLength(mensi, leng2);
  286. FillLength(phone, leng3);
  287. FillLength(txname, leng4);
  288. FillLength(txprice,leng5);
  289. str=name+mensi+phone+txname+txprice+"\n";
  290. fp.WriteString (str);
  291. for(int i=0; i<m_List1.GetItemCount (); i++)
  292. {
  293. name=m_List1.GetItemText (i, 0);
  294. mensi=m_List1.GetItemText (i, 2);
  295. phone=m_List1.GetItemText (i, 3);
  296. txname=m_List1.GetItemText (i, 4);
  297. txprice=m_List1.GetItemText (i, 6);
  298. if(mensi.GetLength ()>10) mensi=mensi.Left (10)+"...";
  299. if(phone.GetLength ()>10) phone=phone.Left (10)+"...";
  300. FillLength(name, leng1);
  301. FillLength(mensi, leng2);
  302. FillLength(phone, leng3);
  303. FillLength(txname, leng4);
  304. FillLength(txprice,leng5);
  305. str=name+mensi+phone+txname+txprice+"\n";
  306. fp.WriteString (str);
  307. }
  308. fp.Close ();
  309. MessageBox("电话已保存到c:\\clientphone.txt");
  310. ShellExecute(NULL, _T("open"), _T("c:\\clientphone.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  311. }