MyAccount.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // MyAccount.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "MyAccount.h"
  6. #include "mysqldata.h"
  7. #include "InputPsw.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // MyAccount IDC_STATIC2
  15. IMPLEMENT_DYNCREATE(MyAccount, CFormView)
  16. MyAccount::MyAccount()
  17. : CFormView(MyAccount::IDD)
  18. {
  19. //{{AFX_DATA_INIT(MyAccount)
  20. //}}AFX_DATA_INIT
  21. }
  22. MyAccount::~MyAccount()
  23. {
  24. }
  25. void MyAccount::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CFormView::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(MyAccount)
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(MyAccount, CFormView)
  32. //{{AFX_MSG_MAP(MyAccount)
  33. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  34. ON_WM_TIMER()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // MyAccount diagnostics
  39. #ifdef _DEBUG
  40. void MyAccount::AssertValid() const
  41. {
  42. CFormView::AssertValid();
  43. }
  44. void MyAccount::Dump(CDumpContext& dc) const
  45. {
  46. CFormView::Dump(dc);
  47. }
  48. #endif //_DEBUG
  49. /////////////////////////////////////////////////////////////////////////////
  50. // MyAccount message handlers
  51. void MyAccount::OnInitialUpdate()
  52. {
  53. CFormView::OnInitialUpdate();
  54. // TODO: Add your specialized code here and/or call the base class
  55. CMyMdi Mdi;
  56. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  57. // Here we create the outbar control using the splitter as its parent
  58. // and setting its id to the first pane.
  59. CRect rc2;
  60. GetWindowRect(rc2);
  61. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  62. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  63. OnButton2();
  64. }
  65. BOOL MyAccount::PreTranslateMessage(MSG* pMsg)
  66. {
  67. // TODO: Add your specialized code here and/or call the base class
  68. try
  69. {
  70. if(pMsg->message==WM_KEYDOWN)
  71. {
  72. switch (pMsg->wParam)
  73. {
  74. case 0x43: // copy
  75. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  76. {
  77. GetFocus()->SendMessage(WM_COPY);
  78. return TRUE;
  79. }
  80. break;
  81. case 0x56: //Ctrl + V:
  82. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  83. {
  84. GetFocus()->SendMessage(WM_PASTE);
  85. return TRUE;
  86. }
  87. break;
  88. case 0x58: // cut
  89. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  90. {
  91. GetFocus()->SendMessage(WM_CUT);
  92. return TRUE;
  93. }
  94. break;
  95. case 0x5A: //undo
  96. case 0x59: //redo
  97. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  98. {
  99. GetFocus()->SendMessage(WM_UNDO);
  100. return TRUE;
  101. }
  102. break;
  103. }
  104. }
  105. return CFormView::PreTranslateMessage(pMsg);
  106. }
  107. catch(...)
  108. {
  109. }
  110. }
  111. int g_iLeft=0;
  112. int g_iUsed=0;
  113. int g_nQuery=-1;
  114. void MyAccount::OnButton2()
  115. {
  116. // TODO: Add your control notification handler code here
  117. GetDlgItem(IDC_STATIC4)->ShowWindow(SW_SHOW);
  118. g_nQuery=1;
  119. SetTimer(1, 1000, NULL);
  120. }
  121. void MyAccount::QueryOK()
  122. {
  123. GetDlgItem(IDC_STATIC4)->ShowWindow(SW_HIDE);
  124. CString mystr;
  125. if (g_iLeft >= 0)
  126. {
  127. CRecordset myset(&g_db);
  128. CString count1="0";
  129. CString sql="select sum([balance]) as cot from clientinfo";
  130. myset.Open (CRecordset::forwardOnly, sql);
  131. if(!myset.IsEOF())
  132. {
  133. myset.GetFieldValue ("cot", count1);
  134. if(atoi(count1)>g_iLeft)
  135. AfxMessageBox("我方账户可发信息数小于客户申请的信息数, 请尽快向经销商冲值!", MB_ICONSTOP);
  136. }
  137. myset.Close();
  138. mystr.Format("查询余额成功,剩余:%d 我方客户申请数:%s",g_iLeft,count1);
  139. }
  140. else
  141. mystr.Format("查询余额失败,返回:%d",g_iLeft);
  142. GetDlgItem(IDC_STATIC2)->SetWindowText(mystr);
  143. if (g_iUsed > 0)
  144. mystr.Format("查询使用成功,已用:%d",g_iUsed);
  145. else
  146. mystr.Format("查询使用失败,返回:%d",g_iUsed);
  147. GetDlgItem(IDC_STATIC3)->SetWindowText(mystr);
  148. }
  149. void MyAccount::OnTimer(UINT nIDEvent)
  150. {
  151. // TODO: Add your message handler code here and/or call default
  152. if(nIDEvent==1)
  153. {
  154. if(g_nQuery==0)
  155. {
  156. KillTimer(1);
  157. QueryOK();
  158. }
  159. }
  160. }