FinanceForm.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 "TakeMoney3.h"
  9. #include "TakeMoney2.h"
  10. #include "SelMoneyType.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. #pragma comment(lib, "Shlwapi.lib")
  17. /////////////////////////////////////////////////////////////////////////////
  18. // FinanceForm
  19. IMPLEMENT_DYNCREATE(FinanceForm, MyFormView)
  20. FinanceForm::FinanceForm() : MyFormView(FinanceForm::IDD)
  21. {
  22. m_filter = _T("");
  23. }
  24. FinanceForm::~FinanceForm()
  25. {
  26. }
  27. void FinanceForm::DoDataExchange(CDataExchange* pDX)
  28. {
  29. MyFormView::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(FinanceForm)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List1);
  33. DDX_Control(pDX, IDC_STATIC1, m_static1);
  34. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(FinanceForm, MyFormView)
  38. //{{AFX_MSG_MAP(FinanceForm)
  39. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  40. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  41. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  42. ON_WM_TIMER()
  43. ON_BN_CLICKED(IDC_BUTprint, OnBUTprint)
  44. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  45. ON_BN_CLICKED(IDC_BUTMoney2, OnBUTMoney2)
  46. ON_BN_CLICKED(IDC_BUTmoney3, OnBUTmoney3)
  47. ON_BN_CLICKED(IDC_BUTmoney4, OnBUTmoney4)
  48. ON_BN_CLICKED(IDC_BTNaddsp, OnBTNaddsp)
  49. ON_BN_CLICKED(IDC_BTNaddsp2, OnBTNaddsp2)
  50. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  51. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  52. //}}AFX_MSG_MAP
  53. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  54. END_MESSAGE_MAP()
  55. #ifdef _DEBUG
  56. void FinanceForm::AssertValid() const
  57. {
  58. MyFormView::AssertValid();
  59. }
  60. void FinanceForm::Dump(CDumpContext& dc) const
  61. {
  62. MyFormView::Dump(dc);
  63. }
  64. #endif //_DEBUG
  65. void FinanceForm::OnInitialUpdate()
  66. {
  67. MyFormView::OnInitialUpdate();
  68. CMyMdi Mdi;
  69. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  70. CRect rc2;
  71. GetWindowRect(rc2);
  72. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  73. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  74. m_static1.SetFont(&g_titlefont);
  75. #ifdef CHILD_VERSION
  76. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;是否取件,100;应付,100;前期,100;后期,100;已付,100;欠款,100;门市,100;套系名称,100;套系价格,100;手机,100;固定电话,100");
  77. #else
  78. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;是否取件,100;应付,100;前期,100;后期,100;已付,100;欠款,100;门市,100;套系名称,100;套系价格,100;男宾电话,100;女宾电话,100" );
  79. #endif
  80. m_List1.LoadColumnInfo(126);
  81. GetData();
  82. m_combo1.GetWindowRect(rc2);
  83. ScreenToClient(rc2);
  84. rc2.bottom += 200;
  85. m_combo1.MoveWindow(rc2);
  86. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  87. SetComboHei(&m_combo1, rc2.Height());
  88. GetDlgItem(IDC_BUTmoney)->EnableWindow(IsHasRights2new(16));
  89. GetDlgItem(IDC_BUTMoney2)->EnableWindow(IsHasRights2new(16));
  90. GetDlgItem(IDC_BUTmoney4)->EnableWindow(IsHasRights2new(16));
  91. }
  92. void FinanceForm::FillGrid()
  93. {
  94. m_List1.DeleteAllItems2();
  95. int ii = 0;
  96. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  97. int count = 0;
  98. if (m_filter.IsEmpty())
  99. {
  100. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  101. {
  102. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  103. }
  104. }
  105. else
  106. {
  107. int type = GetType(m_filter);
  108. if (type == 1)//电话
  109. {
  110. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  111. {
  112. if (m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1 || \
  113. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  114. {
  115. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  116. }
  117. }
  118. }
  119. else if (type == 2)//拼音
  120. {
  121. m_filter.MakeUpper();
  122. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  123. {
  124. if (m_List1array.ElementAt(ii).ElementAt(15).Find(m_filter) != -1 || \
  125. m_List1array.ElementAt(ii).ElementAt(14).Find(m_filter) != -1)
  126. {
  127. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  128. }
  129. }
  130. }
  131. else
  132. {
  133. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  134. {
  135. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  136. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  137. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  138. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  139. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  140. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  141. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1 || \
  142. m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  143. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1 || \
  144. m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1)
  145. {
  146. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  147. }
  148. }
  149. }
  150. }
  151. m_List1.m_arLabels.SetSize(count, 1);
  152. ii = count;
  153. m_List1.m_LabelCount = ii;
  154. m_List1.SetItemCountEx(ii);
  155. CString str;
  156. str.Format("单数:%d", ii);
  157. SetDlgItemText(IDC_STATIC2, str);
  158. if (!g_id.IsEmpty())
  159. {
  160. for (int i = 0; i < m_List1.GetItemCount(); i++)
  161. {
  162. if (g_id == m_List1.GetItemText(i, 0))
  163. {
  164. m_List1.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  165. m_List1.EnsureVisible(i, FALSE);
  166. break;
  167. }
  168. }
  169. }
  170. }
  171. void FinanceForm::OnBUTclose()
  172. {
  173. GetParent()->SendMessage(WM_CLOSE);
  174. }
  175. void FinanceForm::OnButton1()
  176. {
  177. UpdateData();
  178. m_filter.TrimLeft();
  179. m_filter.TrimRight();
  180. FillGrid();
  181. }
  182. void FinanceForm::OnSelchangeCombo1()
  183. {
  184. SetTimer(1, 100, NULL);
  185. }
  186. void FinanceForm::OnTimer(UINT nIDEvent)
  187. {
  188. KillTimer(nIDEvent);
  189. OnButton1();
  190. }
  191. BOOL FinanceForm::PreTranslateMessage(MSG* pMsg)
  192. {
  193. try
  194. {
  195. if (pMsg->message == WM_KEYDOWN)
  196. {
  197. switch (pMsg->wParam)
  198. {
  199. case VK_RETURN:
  200. OnButton1();
  201. return 1;
  202. case 0x43: // copy
  203. if ((GetKeyState(VK_CONTROL) & 0x80))
  204. {
  205. GetFocus()->SendMessage(WM_COPY);
  206. return TRUE;
  207. }
  208. break;
  209. case 0x56: //Ctrl + V:
  210. if ((GetKeyState(VK_CONTROL) & 0x80))
  211. {
  212. GetFocus()->SendMessage(WM_PASTE);
  213. return TRUE;
  214. }
  215. break;
  216. case 0x58: // cut
  217. if ((GetKeyState(VK_CONTROL) & 0x80))
  218. {
  219. GetFocus()->SendMessage(WM_CUT);
  220. return TRUE;
  221. }
  222. break;
  223. case 0x5A: //undo
  224. case 0x59: //redo
  225. if ((GetKeyState(VK_CONTROL) & 0x80))
  226. {
  227. GetFocus()->SendMessage(WM_UNDO);
  228. return TRUE;
  229. }
  230. break;
  231. }
  232. }
  233. return MyFormView::PreTranslateMessage(pMsg);
  234. }
  235. catch (...)
  236. {
  237. }
  238. return TRUE;
  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. }