TakeFrom.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. // TakeFrom.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "TakeFrom.h"
  6. #include "MyMdi.H"
  7. #include "InputPsw.h"
  8. #include "SetPathDlg.h"
  9. #include "mysqldata.h"
  10. #include "InputPsw.h"
  11. #include "ShowHistoryReg.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. #pragma comment(lib, "Shlwapi.lib")
  18. /////////////////////////////////////////////////////////////////////////////
  19. // TakeFrom IDC_STATIC2
  20. int GetBalance(CString account)
  21. {
  22. CString count1="";
  23. CString count2="";
  24. CString count3="";
  25. try
  26. {
  27. CRecordset myset(&g_db);
  28. CString sql="select sum([count]) as cot from recharge where account='"+account+"'";
  29. myset.Open (CRecordset::forwardOnly, sql);
  30. if(!myset.IsEOF())
  31. myset.GetFieldValue ("cot", count1);
  32. myset.Close();
  33. sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
  34. myset.Open (CRecordset::forwardOnly, sql);
  35. if(!myset.IsEOF())
  36. myset.GetFieldValue ("cot", count2);
  37. myset.Close();
  38. sql="select sum([msgcount2]) as cot from sendreg where account='"+account+"'";
  39. myset.Open (CRecordset::forwardOnly, sql);
  40. if(!myset.IsEOF())
  41. myset.GetFieldValue ("cot", count3);
  42. myset.Close();
  43. // return atoi(count1)-min(atoi(count2),atoi(count3));
  44. return atoi(count1)-atoi(count2);
  45. }
  46. catch(...)
  47. {
  48. return -1;
  49. }
  50. }
  51. IMPLEMENT_DYNCREATE(TakeFrom, CFormView)
  52. TakeFrom::TakeFrom()
  53. : CFormView(TakeFrom::IDD)
  54. {
  55. //{{AFX_DATA_INIT(TakeFrom)
  56. m_filter = _T("");
  57. //}}AFX_DATA_INIT
  58. }
  59. TakeFrom::~TakeFrom()
  60. {
  61. }
  62. void TakeFrom::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CFormView::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(TakeFrom)
  66. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  67. DDX_Control(pDX, IDC_LIST2, m_List1);
  68. DDX_Control(pDX, IDC_STATIC1, m_static1);
  69. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  70. //}}AFX_DATA_MAP
  71. }
  72. BEGIN_MESSAGE_MAP(TakeFrom, CFormView)
  73. //{{AFX_MSG_MAP(TakeFrom)
  74. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  75. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  76. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  77. ON_WM_TIMER()
  78. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  79. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  80. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  81. ON_BN_CLICKED(IDC_BTNaddsp, OnBTNaddsp)
  82. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  83. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  84. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  85. ON_BN_CLICKED(IDC_BUTimportphoto2, OnBUTimportphoto2)
  86. //}}AFX_MSG_MAP
  87. END_MESSAGE_MAP()
  88. /////////////////////////////////////////////////////////////////////////////
  89. // TakeFrom diagnostics
  90. #ifdef _DEBUG
  91. void TakeFrom::AssertValid() const
  92. {
  93. CFormView::AssertValid();
  94. }
  95. void TakeFrom::Dump(CDumpContext& dc) const
  96. {
  97. CFormView::Dump(dc);
  98. }
  99. #endif //_DEBUG
  100. /////////////////////////////////////////////////////////////////////////////
  101. // TakeFrom message handlers
  102. void TakeFrom::OnInitialUpdate()
  103. {
  104. CFormView::OnInitialUpdate();
  105. // TODO: Add your specialized code here and/or call the base class
  106. CMyMdi Mdi;
  107. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  108. // Here we create the outbar control using the splitter as its parent
  109. // and setting its id to the first pane.
  110. CRect rc2;
  111. GetWindowRect(rc2);
  112. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  113. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  114. m_static1.SetFont (&g_titlefont);
  115. m_List1.SetHeadings("账号,100;余额(可发短信数),160;已发,100;客人姓名,100;电话,100;QQ,100;地址,100;备注,100;申请日期,100" );
  116. m_List1.LoadColumnInfo (_T("114"));
  117. m_combo1.GetWindowRect (rc2);
  118. ScreenToClient(rc2);
  119. rc2.bottom +=200;
  120. m_combo1.MoveWindow (rc2);
  121. OnButton1();
  122. }
  123. void TakeFrom::FillGrid(BOOL bStatus)
  124. {
  125. m_List1.DeleteAllItems2 ();
  126. int ii=0;
  127. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  128. int count=0;
  129. if(m_filter.IsEmpty ())
  130. {
  131. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  132. {
  133. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  134. }
  135. }
  136. else
  137. {
  138. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  139. {
  140. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 \
  141. ||m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 \
  142. || m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 \
  143. || m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1\
  144. || m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1\
  145. || m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 \
  146. || m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1\
  147. || m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 )
  148. {
  149. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  150. }
  151. }
  152. }
  153. m_List1.m_arLabels.SetSize(count, 1);
  154. ii=count;
  155. m_List1.m_LabelCount=ii;
  156. m_List1.SetItemCountEx (ii);
  157. CString str;
  158. str.Format ("客户:%d", ii);
  159. SetDlgItemText(IDC_STATIC2, str);
  160. }
  161. void TakeFrom::OnBUTclose()
  162. {
  163. // TODO: Add your control notification handler code here
  164. GetParent()->SendMessage(WM_CLOSE);
  165. }
  166. void TakeFrom::OnSelchangeCombo1()
  167. {
  168. // TODO: Add your control notification handler code here
  169. SetTimer(1, 100, NULL);
  170. }
  171. void TakeFrom::OnTimer(UINT nIDEvent)
  172. {
  173. // TODO: Add your message handler code here and/or call default
  174. KillTimer(nIDEvent);
  175. OnButton1();
  176. }
  177. BOOL TakeFrom::PreTranslateMessage(MSG* pMsg)
  178. {
  179. // TODO: Add your specialized code here and/or call the base class
  180. try
  181. {
  182. if(pMsg->message==WM_KEYDOWN)
  183. {
  184. switch (pMsg->wParam)
  185. {
  186. case VK_RETURN:
  187. OnButton1();
  188. return 1;
  189. case 0x43: // copy
  190. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  191. {
  192. GetFocus()->SendMessage(WM_COPY);
  193. return TRUE;
  194. }
  195. break;
  196. case 0x56: //Ctrl + V:
  197. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  198. {
  199. GetFocus()->SendMessage(WM_PASTE);
  200. return TRUE;
  201. }
  202. break;
  203. case 0x58: // cut
  204. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  205. {
  206. GetFocus()->SendMessage(WM_CUT);
  207. return TRUE;
  208. }
  209. break;
  210. case 0x5A: //undo
  211. case 0x59: //redo
  212. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  213. {
  214. GetFocus()->SendMessage(WM_UNDO);
  215. return TRUE;
  216. }
  217. break;
  218. }
  219. }
  220. return CFormView::PreTranslateMessage(pMsg);
  221. }
  222. catch(...)
  223. {
  224. }
  225. }
  226. extern int GetBalance(CString account);
  227. void TakeFrom::OnBUTmoney()
  228. {
  229. // TODO: Add your control notification handler code here
  230. POSITION pos;
  231. pos=m_List1.GetFirstSelectedItemPosition();
  232. if(pos==NULL)
  233. {
  234. return;
  235. }
  236. int iItem=m_List1.GetNextSelectedItem(pos);
  237. CString account=m_List1.GetItemText (iItem, 0);
  238. int balance=GetBalance(account);
  239. CString str;
  240. str.Format ("账号%s: 余额:%d", account, balance);
  241. MessageBox(str);
  242. }
  243. void TakeFrom::OnBTNaddsp()
  244. {
  245. }
  246. void TakeFrom::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  247. {
  248. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  249. // TODO: Add your control notification handler code here
  250. *pResult = 0;
  251. }
  252. extern void ConvertToPrice(CString &str);
  253. void TakeFrom::OnButton1()
  254. {
  255. // TODO: Add your control notification handler code here
  256. CRecordset myset(&g_db);
  257. CString sql="select count(*) as cot from clientinfo";
  258. myset.Open (CRecordset::forwardOnly, sql);
  259. myset.GetFieldValue ("cot", sql);
  260. myset.Close();
  261. m_List1array.SetSize(atol(sql) , 1 );
  262. CRstClientInfo rsSt;
  263. rsSt.Open();
  264. DWORD ii=0;
  265. while(!rsSt.IsEOF())
  266. {
  267. m_List1array.ElementAt (ii).RemoveAll ();
  268. m_List1array.ElementAt (ii).Add(rsSt.m_account) ;
  269. m_List1array.ElementAt (ii).Add(rsSt.m_balance) ;
  270. m_List1array.ElementAt (ii).Add(rsSt.m_name) ;
  271. m_List1array.ElementAt (ii).Add(rsSt.m_phone) ;
  272. m_List1array.ElementAt (ii).Add(rsSt.m_qq) ;
  273. m_List1array.ElementAt (ii).Add(rsSt.m_addr) ;
  274. m_List1array.ElementAt (ii).Add(rsSt.m_remark) ;
  275. m_List1array.ElementAt (ii).Add(rsSt.m_applydate) ;
  276. ii++;
  277. rsSt.MoveNext();if(m_List1array.GetSize ()<=ii)break;
  278. }
  279. rsSt.Close();m_List1array.SetSize(ii+1 , 1 );
  280. int sumcount1=0;
  281. int sumcount2=0;
  282. for(int i=0; i<m_List1array.GetSize ()-1; i++)
  283. {
  284. CString account=m_List1array.ElementAt (i).ElementAt (0);
  285. CRecordset myset(&g_db);
  286. CString sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
  287. myset.Open (CRecordset::forwardOnly, sql);
  288. if(!myset.IsEOF())
  289. myset.GetFieldValue ("cot", sql);
  290. myset.Close();
  291. ConvertToPrice(sql);
  292. if(sql.IsEmpty ())sql="0";
  293. m_List1array.ElementAt (i).InsertAt (2, sql);
  294. sumcount1+=atoi(m_List1array.ElementAt (i).ElementAt (1));
  295. sumcount2+=atoi(sql);
  296. }
  297. CString str;
  298. m_List1array.ElementAt (ii).RemoveAll ();
  299. m_List1array.ElementAt (ii).Add("") ;
  300. str.Format("%d", sumcount1);
  301. m_List1array.ElementAt (ii).Add(str) ;
  302. str.Format("%d", sumcount2);
  303. m_List1array.ElementAt (ii).Add(str) ;
  304. m_List1array.ElementAt (ii).Add("") ;
  305. m_List1array.ElementAt (ii).Add("") ;
  306. m_List1array.ElementAt (ii).Add("") ;
  307. m_List1array.ElementAt (ii).Add("") ;
  308. m_List1array.ElementAt (ii).Add("") ;
  309. m_List1array.ElementAt (ii).Add("") ;
  310. m_List1array.ElementAt (ii).Add("") ;
  311. m_List1array.ElementAt (ii).Add("") ;
  312. m_List1array.ElementAt (ii).Add("") ;
  313. m_List1array.ElementAt (ii).Add("") ;
  314. UpdateData();
  315. m_filter.TrimLeft ();
  316. m_filter.TrimRight ();
  317. FillGrid();
  318. }
  319. void TakeFrom::OnBUTshowphoto() //历史冲值
  320. {
  321. POSITION pos;
  322. pos=m_List1.GetFirstSelectedItemPosition();
  323. if(pos==NULL)
  324. {
  325. AfxMessageBox("请先选中您要查看冲值记录的客户!", MB_ICONINFORMATION);
  326. return;
  327. }
  328. int iItem=m_List1.GetNextSelectedItem(pos);
  329. CString account=m_List1.GetItemText (iItem, 0);
  330. ShowHistoryReg dlg;
  331. dlg.m_account=account;
  332. dlg.DoModal ();
  333. }
  334. void TakeFrom::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  335. {
  336. // TODO: Add your control notification handler code here
  337. POSITION pos;
  338. pos=m_List1.GetFirstSelectedItemPosition();
  339. if(pos==NULL)
  340. {
  341. return;
  342. }
  343. int iItem=m_List1.GetNextSelectedItem(pos);
  344. CString account=m_List1.GetItemText (iItem, 0);
  345. SetPathDlg dlg;
  346. dlg.m_mode =1;
  347. dlg.m_account =account;
  348. if(dlg.DoModal ()==IDOK)
  349. OnButton1();
  350. *pResult = 0;
  351. }
  352. void TakeFrom::OnBUTimportphoto() //添加客户
  353. {
  354. // TODO: Add your control notification handler code here
  355. SetPathDlg dlg;
  356. if(dlg.DoModal ()==IDOK)
  357. OnButton1();
  358. }
  359. void TakeFrom::OnBUTimportphoto2() //冲值
  360. {
  361. // TODO: Add your control notification handler code here
  362. POSITION pos;
  363. pos=m_List1.GetFirstSelectedItemPosition();
  364. if(pos==NULL)
  365. {
  366. AfxMessageBox("请先选中您要冲值的客户!", MB_ICONINFORMATION);
  367. return;
  368. }
  369. {
  370. InputPsw dlg;
  371. if(dlg.DoModal()!=IDOK)return;
  372. }
  373. int iItem=m_List1.GetNextSelectedItem(pos);
  374. CString account=m_List1.GetItemText (iItem, 0);
  375. CString name=m_List1.GetItemText (iItem, 3);
  376. // ReCharge dlg;
  377. // dlg.m_account =account;
  378. // dlg.m_name =name;
  379. // if(dlg.DoModal ()==IDOK)
  380. // OnButton1();
  381. }
  382. void TakeFrom::OnButton2()
  383. {
  384. }