FinanceForm.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. // FinanceForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "FinanceForm.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #include "TakeMoney2.h"
  10. #include "TakeMoney3.h"
  11. #include "SelMoneyType.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. // FinanceForm
  20. IMPLEMENT_DYNCREATE(FinanceForm, MyFormView)
  21. FinanceForm::FinanceForm() : MyFormView(FinanceForm::IDD)
  22. {
  23. m_filter = _T("");
  24. }
  25. FinanceForm::~FinanceForm()
  26. {
  27. }
  28. void FinanceForm::DoDataExchange(CDataExchange* pDX)
  29. {
  30. MyFormView::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(FinanceForm)
  32. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  33. DDX_Control(pDX, IDC_LIST2, m_List1);
  34. DDX_Control(pDX, IDC_STATIC1, m_static1);
  35. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(FinanceForm, MyFormView)
  39. //{{AFX_MSG_MAP(FinanceForm)
  40. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  41. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  42. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  43. ON_WM_TIMER()
  44. ON_BN_CLICKED(IDC_BUTprint, OnBUTprint)
  45. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  46. ON_BN_CLICKED(IDC_BUTMoney2, OnBUTMoney2)
  47. ON_BN_CLICKED(IDC_BUTmoney3, OnBUTmoney3)
  48. ON_BN_CLICKED(IDC_BUTmoney4, OnBUTmoney4)
  49. ON_BN_CLICKED(IDC_BTNaddsp, OnBTNaddsp)
  50. ON_BN_CLICKED(IDC_BTNaddsp2, OnBTNaddsp2)
  51. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  52. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  53. //}}AFX_MSG_MAP
  54. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  55. END_MESSAGE_MAP()
  56. #ifdef _DEBUG
  57. void FinanceForm::AssertValid() const
  58. {
  59. MyFormView::AssertValid();
  60. }
  61. void FinanceForm::Dump(CDumpContext& dc) const
  62. {
  63. MyFormView::Dump(dc);
  64. }
  65. #endif //_DEBUG
  66. void FinanceForm::OnInitialUpdate()
  67. {
  68. MyFormView::OnInitialUpdate();
  69. CMyMdi Mdi;
  70. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  71. CRect rc2;
  72. GetWindowRect(rc2);
  73. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  74. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  75. m_static1.SetFont(&g_titlefont);
  76. #ifdef CHILD_VERSION
  77. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;是否取件,100;应付,100;前期,100;后期,100;已付,100;欠款,100;门市,100;套系名称,100;套系价格,100;手机,100;固定电话,100");
  78. #else
  79. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;是否取件,100;应付,100;前期,100;后期,100;已付,100;欠款,100;门市,100;套系名称,100;套系价格,100;男宾电话,100;女宾电话,100" );
  80. #endif
  81. m_List1.LoadColumnInfo(126);
  82. GetData();
  83. m_combo1.GetWindowRect(rc2);
  84. ScreenToClient(rc2);
  85. rc2.bottom += 200;
  86. m_combo1.MoveWindow(rc2);
  87. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  88. SetComboHei(&m_combo1, rc2.Height());
  89. GetDlgItem(IDC_BUTmoney)->EnableWindow(IsHasRights2new(16));
  90. GetDlgItem(IDC_BUTMoney2)->EnableWindow(IsHasRights2new(16));
  91. GetDlgItem(IDC_BUTmoney4)->EnableWindow(IsHasRights2new(16));
  92. }
  93. void FinanceForm::FillGrid()
  94. {
  95. m_List1.DeleteAllItems2();
  96. int ii = 0;
  97. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  98. int count = 0;
  99. if (m_filter.IsEmpty())
  100. {
  101. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  102. {
  103. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  104. }
  105. }
  106. else
  107. {
  108. int type = GetType(m_filter);
  109. if (type == 1)//电话
  110. {
  111. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  112. {
  113. if (m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1 || \
  114. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  115. {
  116. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  117. }
  118. }
  119. }
  120. else if (type == 2)//拼音
  121. {
  122. m_filter.MakeUpper();
  123. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  124. {
  125. if (m_List1array.ElementAt(ii).ElementAt(15).Find(m_filter) != -1 || \
  126. m_List1array.ElementAt(ii).ElementAt(14).Find(m_filter) != -1)
  127. {
  128. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  129. }
  130. }
  131. }
  132. else
  133. {
  134. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  135. {
  136. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  137. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  138. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  139. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  140. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  141. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  142. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1 || \
  143. m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  144. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1 || \
  145. m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1)
  146. {
  147. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  148. }
  149. }
  150. }
  151. }
  152. m_List1.m_arLabels.SetSize(count, 1);
  153. ii = count;
  154. m_List1.m_LabelCount = ii;
  155. m_List1.SetItemCountEx(ii);
  156. CString str;
  157. str.Format("单数:%d", ii);
  158. SetDlgItemText(IDC_STATIC2, str);
  159. if (!g_id.IsEmpty())
  160. {
  161. for (int i = 0; i < m_List1.GetItemCount(); i++)
  162. {
  163. if (g_id == m_List1.GetItemText(i, 0))
  164. {
  165. m_List1.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  166. m_List1.EnsureVisible(i, FALSE);
  167. break;
  168. }
  169. }
  170. }
  171. }
  172. void FinanceForm::OnBUTclose()
  173. {
  174. GetParent()->SendMessage(WM_CLOSE);
  175. }
  176. void FinanceForm::OnButton1()
  177. {
  178. UpdateData();
  179. m_filter.TrimLeft();
  180. m_filter.TrimRight();
  181. FillGrid();
  182. }
  183. void FinanceForm::OnSelchangeCombo1()
  184. {
  185. SetTimer(1, 100, NULL);
  186. }
  187. void FinanceForm::OnTimer(UINT nIDEvent)
  188. {
  189. KillTimer(nIDEvent);
  190. OnButton1();
  191. }
  192. BOOL FinanceForm::PreTranslateMessage(MSG* pMsg)
  193. {
  194. try
  195. {
  196. if (pMsg->message == WM_KEYDOWN)
  197. {
  198. switch (pMsg->wParam)
  199. {
  200. case VK_RETURN:
  201. OnButton1();
  202. return 1;
  203. case 0x43: // copy
  204. if ((GetKeyState(VK_CONTROL) & 0x80))
  205. {
  206. GetFocus()->SendMessage(WM_COPY);
  207. return TRUE;
  208. }
  209. break;
  210. case 0x56: //Ctrl + V:
  211. if ((GetKeyState(VK_CONTROL) & 0x80))
  212. {
  213. GetFocus()->SendMessage(WM_PASTE);
  214. return TRUE;
  215. }
  216. break;
  217. case 0x58: // cut
  218. if ((GetKeyState(VK_CONTROL) & 0x80))
  219. {
  220. GetFocus()->SendMessage(WM_CUT);
  221. return TRUE;
  222. }
  223. break;
  224. case 0x5A: //undo
  225. case 0x59: //redo
  226. if ((GetKeyState(VK_CONTROL) & 0x80))
  227. {
  228. GetFocus()->SendMessage(WM_UNDO);
  229. return TRUE;
  230. }
  231. break;
  232. }
  233. }
  234. return MyFormView::PreTranslateMessage(pMsg);
  235. }
  236. catch (...)
  237. {
  238. }
  239. }
  240. void FinanceForm::OnBUTprint()
  241. {
  242. }
  243. void FinanceForm::OnBUTmoney()//预约收款**
  244. {
  245. if (IsHasRights2new(16) == 0)return;
  246. UpdateData();
  247. POSITION pos;
  248. pos = m_List1.GetFirstSelectedItemPosition();
  249. if (pos == NULL)
  250. {
  251. AfxMessageBox("请先选中您要收款的定单!", MB_ICONINFORMATION);
  252. return;
  253. }
  254. int iItem = m_List1.GetNextSelectedItem(pos);
  255. CString id = m_List1.GetItemText(iItem, 0);
  256. CString ren = m_List1.GetItemText(iItem, 9);
  257. CString str;
  258. TakeMoney2 dlg;
  259. dlg.m_mode = 3;
  260. dlg.m_strOrderNumber = id;
  261. dlg.m_ren = ren;
  262. dlg.m_name1 = m_List1.GetItemText(iItem, 1);
  263. dlg.m_name2 = m_List1.GetItemText(iItem, 2);
  264. dlg.m_phone1 = m_List1.GetItemText(iItem, 12);
  265. dlg.m_phone2 = m_List1.GetItemText(iItem, 13);
  266. dlg.DoModal();
  267. GetData();
  268. }
  269. void FinanceForm::OnBUTMoney2() //预约补款**
  270. {
  271. if (IsHasRights2new(16) == 0)return;
  272. UpdateData();
  273. POSITION pos;
  274. pos = m_List1.GetFirstSelectedItemPosition();
  275. if (pos == NULL)
  276. {
  277. AfxMessageBox("请先选中您要收款的定单!", MB_ICONINFORMATION);
  278. return;
  279. }
  280. int iItem = m_List1.GetNextSelectedItem(pos);
  281. CString id = m_List1.GetItemText(iItem, 0);
  282. CString ren = m_List1.GetItemText(iItem, 9);
  283. CString str;
  284. TakeMoney2 dlg;
  285. dlg.m_mode = 2;
  286. dlg.m_strOrderNumber = id;
  287. dlg.m_ren = ren;
  288. dlg.m_name1 = m_List1.GetItemText(iItem, 1);
  289. dlg.m_name2 = m_List1.GetItemText(iItem, 2);
  290. dlg.m_phone1 = m_List1.GetItemText(iItem, 12);
  291. dlg.m_phone2 = m_List1.GetItemText(iItem, 13);
  292. dlg.DoModal();
  293. GetData();
  294. }
  295. void FinanceForm::OnBUTmoney3() //拍照补款
  296. {
  297. }
  298. void FinanceForm::OnBUTmoney4() //后期补款**
  299. {
  300. if (IsHasRights2new(16) == 0)return;
  301. UpdateData();
  302. POSITION pos;
  303. pos = m_List1.GetFirstSelectedItemPosition();
  304. if (pos == NULL)
  305. {
  306. AfxMessageBox("请先选中您要收款的定单!", MB_ICONINFORMATION);
  307. return;
  308. }
  309. int iItem = m_List1.GetNextSelectedItem(pos);
  310. CString id = m_List1.GetItemText(iItem, 0);
  311. CString ren = m_List1.GetItemText(iItem, 9);
  312. CString str;
  313. TakeMoney3 dlg;
  314. dlg.m_mode = 1;
  315. dlg.m_strOrderNumber = id;
  316. dlg.m_ren = ren;
  317. dlg.m_name1 = m_List1.GetItemText(iItem, 1);
  318. dlg.m_name2 = m_List1.GetItemText(iItem, 2);
  319. dlg.m_phone1 = m_List1.GetItemText(iItem, 12);
  320. dlg.m_phone2 = m_List1.GetItemText(iItem, 13);
  321. dlg.DoModal();
  322. GetData();
  323. }
  324. void FinanceForm::OnBTNaddsp()
  325. {
  326. }
  327. void FinanceForm::OnBTNaddsp2()
  328. {
  329. }
  330. void FinanceForm::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  331. {
  332. SelMoneyType dlg;
  333. if (dlg.DoModal() == IDOK)
  334. {
  335. if (dlg.m_type == 0)OnBUTmoney();
  336. else if (dlg.m_type == 1)OnBUTMoney2();
  337. else if (dlg.m_type == 2)OnBUTmoney4();
  338. }
  339. *pResult = 0;
  340. }
  341. void FinanceForm::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
  342. {
  343. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
  344. *pResult = 0;
  345. if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
  346. {
  347. *pResult = CDRF_NOTIFYITEMDRAW;
  348. }
  349. else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
  350. {
  351. if (m_List1.m_arLabels.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(8) != "0")
  352. pLVCD->clrText = RGB(220, 0, 0);
  353. else
  354. pLVCD->clrText = RGB(20, 133, 20);
  355. if (pLVCD->nmcd.dwItemSpec % 2)
  356. pLVCD->clrTextBk = g_gridcol1;
  357. else
  358. pLVCD->clrTextBk = g_gridcol2;
  359. *pResult = CDRF_DODEFAULT;
  360. }
  361. }
  362. void FinanceForm::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  363. {
  364. POSITION pos;
  365. pos = m_List1.GetFirstSelectedItemPosition();
  366. if (pos == NULL)return;
  367. int iItem = m_List1.GetNextSelectedItem(pos);
  368. g_id = m_List1.GetItemText(iItem, 0);
  369. *pResult = 0;
  370. }
  371. void FinanceForm::GetData()
  372. {
  373. if (g_bShowOK == 0)
  374. {
  375. #ifdef LKAY_VERSION
  376. CString filter="status3='未取' and (dindantype<>'意向客户' or dindantype is null)";
  377. #else
  378. CString filter = "status3='未取'";
  379. #endif
  380. g_sendhead.bsql = 0;
  381. g_sendhead.code[0] = 62;
  382. g_sendhead.tabcount = 1;
  383. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return;
  384. }
  385. else
  386. {
  387. g_sendhead.bsql = 0;
  388. g_sendhead.code[0] = 62;
  389. g_sendhead.tabcount = 1;
  390. #ifdef LKAY_VERSION
  391. CString filter="dindantype<>'意向客户' or dindantype is null";
  392. g_pMainWnd->ProcessChatMessageRequest2(filter);
  393. #else
  394. g_pMainWnd->ProcessChatMessageRequest2(1);
  395. #endif
  396. if (g_bSendOK == 0)return;
  397. }
  398. DataToArray(&m_List1array);
  399. FillGrid();
  400. }