TakeFrom.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. // TakeFrom.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZSendMsg.h"
  5. #include "TakeFrom.h"
  6. #include "MyMdi.H"
  7. #include "InputPsw.h"
  8. #include "InputPsw2.h"
  9. #include "SetPathDlg.h"
  10. #include "mysqldata.h"
  11. #include "InputPsw.h"
  12. #include "ReCharge.h"
  13. #include "ShowHistoryReg.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. // TakeFrom IDC_STATIC2
  22. IMPLEMENT_DYNCREATE(TakeFrom, CFormView)
  23. TakeFrom::TakeFrom()
  24. : CFormView(TakeFrom::IDD)
  25. {
  26. //{{AFX_DATA_INIT(TakeFrom)
  27. m_filter = _T("");
  28. //}}AFX_DATA_INIT
  29. }
  30. TakeFrom::~TakeFrom()
  31. {
  32. }
  33. void TakeFrom::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CFormView::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(TakeFrom)
  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(TakeFrom, CFormView)
  44. //{{AFX_MSG_MAP(TakeFrom)
  45. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  46. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  47. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  48. ON_WM_TIMER()
  49. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  50. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  51. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  52. ON_BN_CLICKED(IDC_BTNaddsp, OnBTNaddsp)
  53. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  54. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  55. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  56. ON_BN_CLICKED(IDC_BUTimportphoto2, OnBUTimportphoto2)
  57. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  58. ON_BN_CLICKED(IDC_BTNaddsp2, OnBTNaddsp2)
  59. ON_BN_CLICKED(IDC_BTNaddsp3, OnBTNaddsp3)
  60. ON_BN_CLICKED(IDC_BTNaddsp4, OnBTNaddsp4)
  61. ON_BN_CLICKED(IDC_BUTimportphoto4, OnBnClickedButimportphoto4)
  62. //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64. /////////////////////////////////////////////////////////////////////////////
  65. // TakeFrom diagnostics
  66. #ifdef _DEBUG
  67. void TakeFrom::AssertValid() const
  68. {
  69. CFormView::AssertValid();
  70. }
  71. void TakeFrom::Dump(CDumpContext& dc) const
  72. {
  73. CFormView::Dump(dc);
  74. }
  75. #endif //_DEBUG
  76. /////////////////////////////////////////////////////////////////////////////
  77. // TakeFrom message handlers
  78. void TakeFrom::OnInitialUpdate()
  79. {
  80. CFormView::OnInitialUpdate();
  81. // TODO: Add your specialized code here and/or call the base class
  82. CMyMdi Mdi;
  83. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  84. // Here we create the outbar control using the splitter as its parent
  85. // and setting its id to the first pane.
  86. CRect rc2;
  87. GetWindowRect(rc2);
  88. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  89. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  90. m_static1.SetFont (&g_titlefont);
  91. m_List1.SetHeadings("账号,100;余额(可发短信数),160;已发,100;客人姓名,100;电话,100;QQ,100;地址,100;备注,100;申请日期,100;签名,100;通道2,100;签名长度,100" );
  92. m_List1.LoadColumnInfo ("114");
  93. m_combo1.GetWindowRect (rc2);
  94. ScreenToClient(rc2);
  95. rc2.bottom +=200;
  96. m_combo1.MoveWindow (rc2);
  97. OnButton1();
  98. }
  99. void TakeFrom::FillGrid(BOOL bStatus)
  100. {
  101. m_List1.DeleteAllItems2 ();
  102. int ii=0;
  103. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  104. int count=0;
  105. if(bStatus)
  106. {
  107. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  108. {
  109. if(atoi(m_List1array.ElementAt (ii).ElementAt (11))>6)
  110. {
  111. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  112. }
  113. }
  114. }
  115. else
  116. {
  117. if(m_filter.IsEmpty ())
  118. {
  119. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  120. {
  121. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  122. }
  123. }
  124. else
  125. {
  126. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  127. {
  128. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 \
  129. ||m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 \
  130. || m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 \
  131. || m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1\
  132. || m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1\
  133. || m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 \
  134. || m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1\
  135. || m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 )
  136. {
  137. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  138. }
  139. }
  140. }
  141. }
  142. m_List1.m_arLabels.SetSize(count, 1);
  143. ii=count;
  144. m_List1.m_LabelCount=ii;
  145. m_List1.SetItemCountEx (ii);
  146. CString str;
  147. str.Format ("客户:%d", ii);
  148. SetDlgItemText(IDC_STATIC2, str);
  149. }
  150. void TakeFrom::OnBUTclose()
  151. {
  152. // TODO: Add your control notification handler code here
  153. GetParent()->SendMessage(WM_CLOSE);
  154. }
  155. void TakeFrom::OnSelchangeCombo1()
  156. {
  157. // TODO: Add your control notification handler code here
  158. SetTimer(1, 100, NULL);
  159. }
  160. void TakeFrom::OnTimer(UINT nIDEvent)
  161. {
  162. // TODO: Add your message handler code here and/or call default
  163. KillTimer(nIDEvent);
  164. OnButton1();
  165. }
  166. BOOL TakeFrom::PreTranslateMessage(MSG* pMsg)
  167. {
  168. // TODO: Add your specialized code here and/or call the base class
  169. try
  170. {
  171. if(pMsg->message==WM_KEYDOWN)
  172. {
  173. switch (pMsg->wParam)
  174. {
  175. case VK_RETURN:
  176. OnButton1();
  177. return 1;
  178. case 0x43: // copy
  179. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  180. {
  181. GetFocus()->SendMessage(WM_COPY);
  182. return TRUE;
  183. }
  184. break;
  185. case 0x56: //Ctrl + V:
  186. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  187. {
  188. GetFocus()->SendMessage(WM_PASTE);
  189. return TRUE;
  190. }
  191. break;
  192. case 0x58: // cut
  193. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  194. {
  195. GetFocus()->SendMessage(WM_CUT);
  196. return TRUE;
  197. }
  198. break;
  199. case 0x5A: //undo
  200. case 0x59: //redo
  201. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  202. {
  203. GetFocus()->SendMessage(WM_UNDO);
  204. return TRUE;
  205. }
  206. break;
  207. }
  208. }
  209. return CFormView::PreTranslateMessage(pMsg);
  210. }
  211. catch(...)
  212. {
  213. }
  214. }
  215. extern int GetBalance(CString account);
  216. void TakeFrom::OnBUTmoney()
  217. {
  218. // TODO: Add your control notification handler code here
  219. POSITION pos;
  220. pos=m_List1.GetFirstSelectedItemPosition();
  221. if(pos==NULL)
  222. {
  223. return;
  224. }
  225. int iItem=m_List1.GetNextSelectedItem(pos);
  226. CString account=m_List1.GetItemText (iItem, 0);
  227. int balance=GetBalance(account);
  228. CString str;
  229. str.Format ("账号%s: 余额:%d", account, balance);
  230. MessageBox(str);
  231. }
  232. void TakeFrom::OnBTNaddsp()
  233. {
  234. InputPsw2 dlg;
  235. if(dlg.DoModal()!=IDOK)return;
  236. g_db.SetQueryTimeout(60*10);
  237. for(int i=0; i<m_List1.GetItemCount (); i++)
  238. {
  239. CString account=m_List1.GetItemText (i, 0);
  240. if(account.GetLength ()!=6)continue;
  241. CString count2="";
  242. CRecordset myset(&g_db);
  243. #ifdef SQLSERVER_VERSION
  244. CString sql="select sum(cast([msgcount] as float)) as cot from sendreg where account='"+account+"' ";
  245. #else
  246. CString sql="select sum([msgcount]) as cot from sendreg where account='"+account+"' ";
  247. #endif
  248. myset.Open (CRecordset::forwardOnly, sql);
  249. if(!myset.IsEOF())
  250. myset.GetFieldValue ("cot", count2);
  251. myset.Close();
  252. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  253. sql="delete from sendreg where [account]='"+account+"' ";
  254. MyExecuteSQL(&g_db, sql);
  255. sql=count2;
  256. count2.Format ("%d", atoi(sql));
  257. if(atoi(count2))
  258. {
  259. sql="insert into sendreg([account],[phones],[content],[timestamp],[log],[msgcount],[msgcount2]) values\
  260. ('"+account+"','汇总','汇总','"+timestamp+"','"+timestamp+"','"+count2+"','"+count2+"')";
  261. MyExecuteSQL(&g_db, sql);
  262. }
  263. } g_db.SetQueryTimeout(60*2);
  264. }
  265. void TakeFrom::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  266. {
  267. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  268. // TODO: Add your control notification handler code here
  269. *pResult = 0;
  270. }
  271. extern void ConvertToPrice(CString &str);
  272. CString GetLengthEx(CString str)
  273. {
  274. wchar_t wstr[500];
  275. int k = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, strlen(str), wstr, 500);
  276. str.Format ("%d", k-2);
  277. return str;
  278. }
  279. void TakeFrom::OnButton1()
  280. {
  281. // TODO: Add your control notification handler code here
  282. DWORD ii=0;
  283. if(1)
  284. {
  285. MyLock lock("xiaoaccessdbmsg");
  286. CRecordset myset(&g_db);
  287. CString sql="select count(*) as cot from clientinfo";
  288. myset.Open (CRecordset::forwardOnly, sql);
  289. myset.GetFieldValue ("cot", sql);
  290. myset.Close();
  291. m_List1array.SetSize(atol(sql) , 1 );
  292. CRstClientInfo rsSt;
  293. rsSt.Open();
  294. while(!rsSt.IsEOF())
  295. {
  296. m_List1array.ElementAt (ii).RemoveAll ();
  297. m_List1array.ElementAt (ii).Add(rsSt.m_account) ;
  298. m_List1array.ElementAt (ii).Add(rsSt.m_balance) ;
  299. m_List1array.ElementAt (ii).Add(rsSt.m_name) ;
  300. m_List1array.ElementAt (ii).Add(rsSt.m_phone) ;
  301. m_List1array.ElementAt (ii).Add(rsSt.m_qq) ;
  302. m_List1array.ElementAt (ii).Add(rsSt.m_addr) ;
  303. m_List1array.ElementAt (ii).Add(rsSt.m_remark) ;
  304. m_List1array.ElementAt (ii).Add(rsSt.m_applydate) ;
  305. m_List1array.ElementAt (ii).Add(rsSt.m_signname) ;
  306. m_List1array.ElementAt (ii).Add(rsSt.m_road) ;
  307. m_List1array.ElementAt (ii).Add(GetLengthEx(rsSt.m_signname)) ;
  308. ii++;
  309. rsSt.MoveNext();if(m_List1array.GetSize ()<=ii)break;
  310. }
  311. rsSt.Close();m_List1array.SetSize(ii+1 , 1 );
  312. }
  313. int sumcount1=0;
  314. int sumcount2=0;
  315. for(int i=0; i<m_List1array.GetSize ()-1; i++)
  316. {
  317. /* CString account=m_List1array.ElementAt (i).ElementAt (0);
  318. CRecordset myset(&g_db);
  319. CString sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
  320. myset.Open (CRecordset::forwardOnly, sql);
  321. if(!myset.IsEOF())
  322. myset.GetFieldValue ("cot", sql);
  323. myset.Close();
  324. ConvertToPrice(sql);
  325. if(sql.IsEmpty ())sql="0";*/
  326. m_List1array.ElementAt (i).InsertAt (2, "");
  327. sumcount1+=atoi(m_List1array.ElementAt (i).ElementAt (1));
  328. // sumcount2+=atoi(sql);
  329. sumcount2+=0;
  330. }
  331. CString str;
  332. m_List1array.ElementAt (ii).RemoveAll ();
  333. m_List1array.ElementAt (ii).Add("") ;
  334. str.Format("%d", sumcount1);
  335. m_List1array.ElementAt (ii).Add(str) ;
  336. str.Format("%d", sumcount2);
  337. m_List1array.ElementAt (ii).Add(str) ;
  338. m_List1array.ElementAt (ii).Add("") ;
  339. m_List1array.ElementAt (ii).Add("") ;
  340. m_List1array.ElementAt (ii).Add("") ;
  341. m_List1array.ElementAt (ii).Add("") ;
  342. m_List1array.ElementAt (ii).Add("") ;
  343. m_List1array.ElementAt (ii).Add("") ;
  344. m_List1array.ElementAt (ii).Add("") ;
  345. m_List1array.ElementAt (ii).Add("") ;
  346. m_List1array.ElementAt (ii).Add("") ;
  347. m_List1array.ElementAt (ii).Add("") ;
  348. m_List1array.ElementAt (ii).Add("") ;
  349. m_List1array.ElementAt (ii).Add("") ;
  350. UpdateData();
  351. m_filter.TrimLeft ();
  352. m_filter.TrimRight ();
  353. FillGrid();
  354. }
  355. void TakeFrom::OnBUTshowphoto() //历史冲值
  356. {
  357. POSITION pos;
  358. pos=m_List1.GetFirstSelectedItemPosition();
  359. if(pos==NULL)
  360. {
  361. AfxMessageBox("请先选中您要查看冲值记录的客户!", MB_ICONINFORMATION);
  362. return;
  363. }
  364. int iItem=m_List1.GetNextSelectedItem(pos);
  365. CString account=m_List1.GetItemText (iItem, 0);
  366. ShowHistoryReg dlg;
  367. dlg.m_account=account;
  368. dlg.DoModal ();
  369. }
  370. void TakeFrom::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  371. {
  372. // TODO: Add your control notification handler code here
  373. POSITION pos;
  374. pos=m_List1.GetFirstSelectedItemPosition();
  375. if(pos==NULL)
  376. {
  377. return;
  378. }
  379. int iItem=m_List1.GetNextSelectedItem(pos);
  380. CString account=m_List1.GetItemText (iItem, 0);
  381. SetPathDlg dlg;
  382. dlg.m_mode =1;
  383. dlg.m_account =account;
  384. if(dlg.DoModal ()==IDOK)
  385. {
  386. MessageBox("修改成功,请手动刷新数据");
  387. // OnButton1();
  388. }
  389. *pResult = 0;
  390. }
  391. void TakeFrom::OnBUTimportphoto() //添加客户
  392. {
  393. // TODO: Add your control notification handler code here
  394. InputPsw dlg2;
  395. if(dlg2.DoModal()!=IDOK)return;
  396. SetPathDlg dlg;
  397. if(dlg.DoModal ()==IDOK)
  398. OnButton1();
  399. }
  400. void TakeFrom::OnBUTimportphoto2() //冲值
  401. {
  402. // TODO: Add your control notification handler code here
  403. POSITION pos;
  404. pos=m_List1.GetFirstSelectedItemPosition();
  405. if(pos==NULL)
  406. {
  407. AfxMessageBox("请先选中您要冲值的客户!", MB_ICONINFORMATION);
  408. return;
  409. }
  410. {
  411. InputPsw dlg;
  412. if(dlg.DoModal()!=IDOK)return;
  413. }
  414. int iItem=m_List1.GetNextSelectedItem(pos);
  415. CString account=m_List1.GetItemText (iItem, 0);
  416. CString name=m_List1.GetItemText (iItem, 3);
  417. ReCharge dlg;
  418. dlg.m_account =account;
  419. dlg.m_name =name;
  420. if(dlg.DoModal ()==IDOK)
  421. OnButton1();
  422. }
  423. void TakeFrom::OnButton2()
  424. {
  425. POSITION pos;
  426. pos=m_List1.GetFirstSelectedItemPosition();
  427. if(pos==NULL)
  428. {
  429. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  430. return;
  431. }
  432. if(AfxMessageBox("警告:删除后将不可恢复, 继续吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  433. InputPsw dlg;
  434. if(dlg.DoModal()!=IDOK)return;
  435. int iItem=m_List1.GetNextSelectedItem(pos);
  436. CString account=m_List1.GetItemText (iItem, 0);
  437. CString sql;
  438. sql= "delete from clientinfo where [account]='"+account+"'";
  439. MyExecuteSQL(&g_db, sql);
  440. OnButton1();
  441. }
  442. void TakeFrom::OnButton3()
  443. {
  444. // TODO: Add your control notification handler code here
  445. DWORD ii=0;
  446. if(1)
  447. {
  448. MyLock lock("xiaoaccessdbmsg");
  449. CRecordset myset(&g_db);
  450. CString sql="select count(*) as cot from clientinfo";
  451. myset.Open (CRecordset::forwardOnly, sql);
  452. myset.GetFieldValue ("cot", sql);
  453. myset.Close();
  454. m_List1array.SetSize(atol(sql) , 1 );
  455. CRstClientInfo rsSt;
  456. rsSt.Open();
  457. while(!rsSt.IsEOF())
  458. {
  459. m_List1array.ElementAt (ii).RemoveAll ();
  460. m_List1array.ElementAt (ii).Add(rsSt.m_account) ;
  461. m_List1array.ElementAt (ii).Add(rsSt.m_balance) ;
  462. m_List1array.ElementAt (ii).Add(rsSt.m_name) ;
  463. m_List1array.ElementAt (ii).Add(rsSt.m_phone) ;
  464. m_List1array.ElementAt (ii).Add(rsSt.m_qq) ;
  465. m_List1array.ElementAt (ii).Add(rsSt.m_addr) ;
  466. m_List1array.ElementAt (ii).Add(rsSt.m_remark) ;
  467. m_List1array.ElementAt (ii).Add(rsSt.m_applydate) ;
  468. m_List1array.ElementAt (ii).Add(rsSt.m_signname) ;
  469. m_List1array.ElementAt (ii).Add(rsSt.m_road) ;
  470. m_List1array.ElementAt (ii).Add(GetLengthEx(rsSt.m_signname)) ;
  471. ii++;
  472. rsSt.MoveNext();if(m_List1array.GetSize ()<=ii)break;
  473. }
  474. rsSt.Close();m_List1array.SetSize(ii+1 , 1 );
  475. }
  476. int sumcount1=0;
  477. int sumcount2=0;
  478. if(1)
  479. {
  480. MyLock lock("xiaoaccessdbmsg");
  481. for(int i=0; i<m_List1array.GetSize ()-1; i++)
  482. {
  483. CString account=m_List1array.ElementAt (i).ElementAt (0);
  484. CRecordset myset(&g_db);
  485. #ifdef SQLSERVER_VERSION
  486. CString sql="select sum(cast([msgcount] as float)) as cot from sendreg where account='"+account+"'";
  487. #else
  488. CString sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
  489. #endif
  490. myset.Open (CRecordset::forwardOnly, sql);
  491. if(!myset.IsEOF())
  492. myset.GetFieldValue ("cot", sql);
  493. myset.Close();
  494. ConvertToPrice(sql);
  495. if(sql.IsEmpty ())sql="0";
  496. m_List1array.ElementAt (i).InsertAt (2, sql);
  497. sumcount1+=atoi(m_List1array.ElementAt (i).ElementAt (1));
  498. sumcount2+=atoi(sql);
  499. }
  500. }
  501. CString str;
  502. m_List1array.ElementAt (ii).RemoveAll ();
  503. m_List1array.ElementAt (ii).Add("") ;
  504. str.Format("%d", sumcount1);
  505. m_List1array.ElementAt (ii).Add(str) ;
  506. str.Format("%d", sumcount2);
  507. m_List1array.ElementAt (ii).Add(str) ;
  508. m_List1array.ElementAt (ii).Add("") ;
  509. m_List1array.ElementAt (ii).Add("") ;
  510. m_List1array.ElementAt (ii).Add("") ;
  511. m_List1array.ElementAt (ii).Add("") ;
  512. m_List1array.ElementAt (ii).Add("") ;
  513. m_List1array.ElementAt (ii).Add("") ;
  514. m_List1array.ElementAt (ii).Add("") ;
  515. m_List1array.ElementAt (ii).Add("") ;
  516. m_List1array.ElementAt (ii).Add("") ;
  517. m_List1array.ElementAt (ii).Add("") ;
  518. m_List1array.ElementAt (ii).Add("") ;
  519. m_List1array.ElementAt (ii).Add("") ;
  520. UpdateData();
  521. m_filter.TrimLeft ();
  522. m_filter.TrimRight ();
  523. FillGrid();
  524. }
  525. extern void FillLength(CString &str, int length);
  526. extern int CheckPhoneType(CString phoneno);
  527. void TakeFrom::OnBTNaddsp2()
  528. {
  529. // TODO: Add your control notification handler code here
  530. CStdioFile fp;
  531. fp.Open ("c:\\短信欠费客户.txt", CFile::modeCreate|CFile::modeWrite);
  532. CString str;
  533. CString name,balance,taked,phone;
  534. int leng1=45;
  535. int leng2=18;
  536. int leng3=18;
  537. int leng4=18;
  538. name="客人姓名";
  539. balance="余额";
  540. taked="已发";
  541. phone="电话";
  542. FillLength(name, leng1);
  543. FillLength(balance, leng2);
  544. FillLength(taked, leng3);
  545. FillLength(phone, leng4);
  546. str=name+balance+taked+phone+"\n";
  547. fp.WriteString (str);
  548. CString phones;
  549. int newline=0;
  550. for(int i=0; i<m_List1.GetItemCount (); i++)
  551. {
  552. name=m_List1.GetItemText (i, 3);
  553. balance=m_List1.GetItemText (i, 1);
  554. taked=m_List1.GetItemText (i, 2);
  555. phone=m_List1.GetItemText (i, 4);
  556. if(name.IsEmpty ())continue;
  557. if(atoi(taked)<200)continue;
  558. if(atoi(balance)>200)continue;
  559. if(CheckPhoneType(phone)!=-1)
  560. {
  561. newline++;
  562. phones+=phone; phones+=",";
  563. if(newline==5)
  564. {
  565. newline=0; phones+="\n";
  566. }
  567. }
  568. FillLength(name, leng1);
  569. FillLength(balance, leng2);
  570. FillLength(taked, leng3);
  571. FillLength(phone, leng4);
  572. str=name+balance+taked+phone+"\n";
  573. fp.WriteString (str);
  574. }
  575. fp.WriteString ("\n");fp.WriteString ("\n");fp.WriteString ("\n");fp.WriteString ("\n");fp.WriteString ("\n");
  576. phones.TrimRight (",");
  577. fp.WriteString ("全部手机,用于群发通知短信:\n");
  578. fp.WriteString (phones);
  579. fp.Close ();
  580. MessageBox("客户已保存到c:\\短信欠费客户.txt");
  581. ShellExecute(NULL, _T("open"), _T("c:\\短信欠费客户.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  582. }
  583. CString TakeFrom::GetName(CString m_account)
  584. {
  585. for(int i=0; i<m_List1.GetItemCount (); i++)
  586. {
  587. if(m_account==m_List1.GetItemText (i, 0))
  588. return m_List1.GetItemText (i, 3);
  589. }
  590. return "";
  591. }
  592. void TakeFrom::OnBTNaddsp3()
  593. {
  594. // TODO: Add your control notification handler code here
  595. CStdioFile fp;
  596. fp.Open ("c:\\上月充值客户.txt", CFile::modeCreate|CFile::modeWrite);
  597. CString str;
  598. CString name,date,recharge,money;
  599. int leng1=45;
  600. int leng2=18;
  601. int leng3=18;
  602. int leng4=18;
  603. name="客人姓名";
  604. date="日期";
  605. recharge="充值";
  606. money="金额";
  607. FillLength(name, leng1);
  608. FillLength(date, leng2);
  609. FillLength(recharge, leng3);
  610. FillLength(money, leng4);
  611. str=name+date+recharge+money+"\n";
  612. fp.WriteString (str);
  613. CString strdate1,strdate2;
  614. int month=CTime::GetCurrentTime ().GetMonth ()-1;
  615. if(month==0)
  616. {
  617. strdate1.Format ("%04d-%02d-%02d", CTime::GetCurrentTime ().GetYear ()-1, 12, 1);
  618. strdate2.Format ("%04d-%02d-%02d", CTime::GetCurrentTime ().GetYear ()-1, 12, 31);
  619. }
  620. else
  621. {
  622. strdate1.Format ("%04d-%02d-%02d", CTime::GetCurrentTime ().GetYear (), month, 1);
  623. strdate2.Format ("%04d-%02d-%02d", CTime::GetCurrentTime ().GetYear (), month, 31);
  624. }
  625. RstReCharge rsSt;
  626. rsSt.m_strFilter ="timestamp>='"+strdate1+"' and timestamp<='"+strdate2+"'";
  627. rsSt.Open();
  628. while(!rsSt.IsEOF())
  629. {
  630. if(atoi(rsSt.m_count)>100)
  631. {
  632. name=GetName(rsSt.m_account);
  633. recharge.Format ("%d", atoi(rsSt.m_count) );
  634. money.Format ("%d", atoi(rsSt.m_money) );
  635. date=rsSt.m_timestamp;
  636. FillLength(name, leng1);
  637. FillLength(date, leng2);
  638. FillLength(recharge, leng3);
  639. FillLength(money, leng4);
  640. str=name+date+recharge+money+"\n";
  641. fp.WriteString (str);
  642. }
  643. rsSt.MoveNext();
  644. }
  645. rsSt.Close();
  646. fp.Close ();
  647. MessageBox("客户已保存到c:\\上月充值客户.txt");
  648. ShellExecute(NULL, _T("open"), _T("c:\\上月充值客户.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  649. }
  650. void TakeFrom::OnBTNaddsp4()
  651. {
  652. // TODO: Add your control notification handler code here
  653. CStdioFile fp;
  654. fp.Open ("c:\\短信平台客户.txt", CFile::modeCreate|CFile::modeWrite);
  655. CString str;
  656. CString filed1,filed2,filed3,filed4,filed5,filed6;
  657. int leng1=40;
  658. int leng2=15;
  659. int leng3=10;
  660. int leng4=10;
  661. int leng5=10;
  662. int leng6=18;
  663. filed1="影楼名称";
  664. filed2="电话";
  665. filed3="账号";
  666. filed4="余额";
  667. filed5="已发";
  668. filed6="签名";
  669. FillLength(filed1, leng1);
  670. FillLength(filed2, leng2);
  671. FillLength(filed3, leng3);
  672. FillLength(filed4, leng4);
  673. FillLength(filed5, leng5);
  674. FillLength(filed6, leng6);
  675. str=filed1+filed2+filed3+filed4+filed5+filed6+"\n";
  676. fp.WriteString (str);
  677. for(int i=0; i<m_List1.GetItemCount (); i++)
  678. {
  679. filed1=m_List1.GetItemText (i, 3);
  680. filed2=m_List1.GetItemText (i, 4);
  681. filed3=m_List1.GetItemText (i, 0);
  682. filed4=m_List1.GetItemText (i, 1);
  683. filed5=m_List1.GetItemText (i, 2);
  684. filed6=m_List1.GetItemText (i, 9);
  685. FillLength(filed1, leng1);
  686. FillLength(filed2, leng2);
  687. FillLength(filed3, leng3);
  688. FillLength(filed4, leng4);
  689. FillLength(filed5, leng5);
  690. FillLength(filed6, leng6);
  691. str=filed1+filed2+filed3+filed4+filed5+filed6+"\n";
  692. fp.WriteString (str);
  693. }
  694. fp.Close ();
  695. MessageBox("客户已保存到c:\\短信平台客户.txt");
  696. ShellExecute(NULL, _T("open"), _T("c:\\短信平台客户.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  697. }
  698. void TakeFrom::OnBnClickedButimportphoto4()//签名超长
  699. {
  700. // TODO: 在此添加控件通知处理程序代码
  701. FillGrid(1);
  702. }