IncomeInput.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // IncomeInput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "IncomeInput.h"
  6. #include "MyMdi.H"
  7. #include "SelPayType.h"
  8. #include "Login2.h"
  9. #include "SelExpendType.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // IncomeInput
  17. IMPLEMENT_DYNCREATE(IncomeInput, MyFormView)
  18. IncomeInput::IncomeInput()
  19. : MyFormView(IncomeInput::IDD)
  20. {
  21. //{{AFX_DATA_INIT(IncomeInput)
  22. m_bz = _T("");
  23. m_date = g_date;
  24. m_money = _T("");
  25. m_name = _T("");
  26. m_renyuan1 = _T("");
  27. m_renyuan2 = g_user.name;
  28. m_year = atoi(g_date.Mid(0, 4));
  29. m_month = atoi(g_date.Mid(5, 2));
  30. m_day = atoi(g_date.Mid(8, 2));
  31. m_bInit = 0;
  32. //}}AFX_DATA_INIT
  33. }
  34. IncomeInput::~IncomeInput()
  35. {
  36. }
  37. void IncomeInput::DoDataExchange(CDataExchange* pDX)
  38. {
  39. MyFormView::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(IncomeInput)
  41. DDX_Control(pDX, IDC_EDITdate, m_datectrl);
  42. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  43. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  44. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  45. DDX_Control(pDX, IDC_COMBO2, m_comboren);
  46. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  47. DDX_Control(pDX, IDC_LIST2, m_List1);
  48. DDX_Control(pDX, IDC_STATIC1, m_static1);
  49. DDX_Text(pDX, IDC_EDITbz, m_bz);
  50. DDV_MaxChars(pDX, m_bz, 1000);
  51. DDX_Text(pDX, IDC_EDITdate, m_date);
  52. DDX_Text(pDX, IDC_EDITmoney, m_money);
  53. DDX_Text(pDX, IDC_EDITname, m_name);
  54. DDX_Text(pDX, IDC_EDITrenyuan1, m_renyuan1);
  55. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  56. DDX_Text(pDX, IDC_EDITyear, m_year);
  57. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  58. DDX_Text(pDX, IDC_EDITmonth, m_month);
  59. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  60. DDX_Text(pDX, IDC_EDITday, m_day);
  61. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  62. //}}AFX_DATA_MAP
  63. }
  64. BEGIN_MESSAGE_MAP(IncomeInput, MyFormView)
  65. //{{AFX_MSG_MAP(IncomeInput)
  66. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  67. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  68. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  69. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  70. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  71. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  72. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  73. ON_BN_CLICKED(IDC_BUTprint, OnBUTprint)
  74. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  75. //}}AFX_MSG_MAP
  76. END_MESSAGE_MAP()
  77. /////////////////////////////////////////////////////////////////////////////
  78. // IncomeInput diagnostics
  79. #ifdef _DEBUG
  80. void IncomeInput::AssertValid() const
  81. {
  82. MyFormView::AssertValid();
  83. }
  84. void IncomeInput::Dump(CDumpContext& dc) const
  85. {
  86. MyFormView::Dump(dc);
  87. }
  88. #endif //_DEBUG
  89. /////////////////////////////////////////////////////////////////////////////
  90. // IncomeInput message handlers
  91. void IncomeInput::OnInitialUpdate()
  92. {
  93. MyFormView::OnInitialUpdate();
  94. // TODO: Add your specialized code here and/or call the base class
  95. CMyMdi Mdi;
  96. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  97. // Here we create the outbar control using the splitter as its parent
  98. // and setting its id to the first pane.
  99. CRect rc2;
  100. GetWindowRect(rc2);
  101. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  102. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  103. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(59));
  104. m_static1.SetFont(&g_titlefont);
  105. m_List1.SetHeadings("id,0;项目名称, 160;金额, 100;日期, 120;付款人,100;经手人,100;备注,120");
  106. m_List1.LoadColumnInfo(106);
  107. m_spinyear.SetRange(1900, 3000);
  108. m_spinmonth.SetRange(1, 12);
  109. m_spinday.SetRange(1, 31);
  110. m_comboren.GetWindowRect(rc2);
  111. ScreenToClient(rc2);
  112. rc2.bottom += 400;
  113. m_comboren.MoveWindow(rc2);
  114. for (int i = 0; i < g_userarray.GetSize(); i++)
  115. m_comboren.AddString(g_userarray.ElementAt(i).ElementAt(1));
  116. m_bInit = 1;
  117. GetData();
  118. }
  119. void IncomeInput::FillGrid()
  120. {
  121. m_List1.DeleteAllItems2();
  122. int ii = 0;
  123. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  124. int count = 0;
  125. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  126. {
  127. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  128. }
  129. m_List1.m_arLabels.SetSize(count, 1);
  130. ii = count;
  131. m_List1.m_LabelCount = ii;
  132. m_List1.SetItemCountEx(ii);
  133. }
  134. void IncomeInput::OnBUTclose()
  135. {
  136. // TODO: Add your control notification handler code here
  137. GetParent()->SendMessage(WM_CLOSE);
  138. }
  139. void IncomeInput::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  140. {
  141. // TODO: Add your control notification handler code here
  142. ListSelChange();
  143. *pResult = 0;
  144. }
  145. void IncomeInput::ListSelChange()
  146. {
  147. POSITION pos;
  148. pos = m_List1.GetFirstSelectedItemPosition();
  149. if (pos == NULL)
  150. {
  151. ClearCtrl();
  152. return;
  153. }
  154. int iItem = m_List1.GetNextSelectedItem(pos);
  155. CString id = m_List1.GetItemText(iItem, 0);
  156. for (int ii = 0; ii < m_List1array.GetSize(); ii++)
  157. {
  158. if (m_List1array.ElementAt(ii).ElementAt(0) == id)
  159. {
  160. m_renyuan1 = m_List1array.ElementAt(ii).ElementAt(4);
  161. m_name = m_List1array.ElementAt(ii).ElementAt(1);
  162. m_money = m_List1array.ElementAt(ii).ElementAt(2);
  163. m_date = m_List1array.ElementAt(ii).ElementAt(3);
  164. m_renyuan2 = m_List1array.ElementAt(ii).ElementAt(5);
  165. m_bz = m_List1arrayBak.ElementAt(ii).ElementAt(6);
  166. UpdateData(false);
  167. break;
  168. }
  169. }
  170. GetDlgItem(IDC_BUTsave)->EnableWindow(0);
  171. }
  172. //保存
  173. void IncomeInput::OnBUTsave()
  174. {
  175. // TODO: Add your control notification handler code here
  176. UpdateData();
  177. if (!CheckDateOK(m_date))return;
  178. if (g_nYearpos != -1)
  179. {
  180. AfxMessageBox("当前为历史数据查看状态,不能更改历史数据!", MB_ICONSTOP);
  181. return;
  182. }
  183. m_name.TrimRight();
  184. if (m_name.IsEmpty())
  185. {
  186. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  187. return;
  188. }
  189. SelPayType seltype;
  190. seltype.m_mode = 1;
  191. if (seltype.DoModal() != IDOK)return;
  192. CString paytype;
  193. if (seltype.m_radio1 == 0)
  194. paytype = "现金";
  195. else if (seltype.m_radio1 == 1)
  196. paytype = "POS机刷卡";
  197. else if (seltype.m_radio1 == 4)
  198. paytype = "银行转账";
  199. else if ( seltype.m_radio1 == 5)
  200. paytype = "代金券";
  201. else if(seltype.m_radio1 == 6)
  202. paytype = "支付宝";
  203. else if(seltype.m_radio1 == 7)
  204. paytype = "财付通";
  205. else if(seltype.m_radio1 == 8)
  206. paytype = "微信支付";
  207. else if(seltype.m_radio1 == 9)
  208. paytype = seltype.m_strCustomPayType;
  209. CString jdd = _T("");
  210. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  211. {
  212. //设置站点
  213. SelExpendType dlg;
  214. dlg.m_mode = 3;
  215. if (dlg.DoModal() == IDOK)
  216. jdd = dlg.m_sel;
  217. else
  218. {
  219. MessageBox(_T("请选择站点"));
  220. return;
  221. }
  222. }
  223. CString sql = _T("");
  224. sql.Format("insert into singleincome([name],[money],[dat],[renyuan1],[renyuan2],[bz],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','%s','%s','curtimereplace','%s')", m_name, m_money, m_date, m_renyuan1, m_renyuan2, m_bz, paytype, jdd);
  225. sql += SGLIN_REF;
  226. g_sendhead.bsql = 1;
  227. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  228. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  229. GetData();
  230. }
  231. void IncomeInput::OnBUTdel()
  232. {
  233. // TODO: Add your control notification handler code here
  234. if (IsHasRights2new(59) == 0)return;
  235. POSITION pos;
  236. pos = m_List1.GetFirstSelectedItemPosition();
  237. if (pos == NULL)
  238. {
  239. return;
  240. }
  241. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  242. int iItem = m_List1.GetNextSelectedItem(pos);
  243. CString id = m_List1.GetItemText(iItem, 0);
  244. CString bz = m_List1.GetItemText(iItem, 1);
  245. CString money = m_List1.GetItemText(iItem, 2);
  246. CString date = m_List1.GetItemText(iItem, 3);
  247. CString sql;
  248. sql.Format("delete from singleincome where id=%d ", atoi(id));
  249. sql += SGLIN_REF;
  250. g_sendhead.bsql = 1;
  251. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  252. GetData();
  253. CString str;
  254. str = "删除其它收入";
  255. str += bz;
  256. str += "金额:";
  257. str += money;
  258. str += "日期:";
  259. str += date;
  260. WriteLog(_T("其它收入"), str);
  261. }
  262. void IncomeInput::GetData()
  263. {
  264. if (m_bInit == 0)return;
  265. m_spinyear.EnableWindow(0);
  266. m_spinmonth.EnableWindow(0);
  267. m_spinday.EnableWindow(0);
  268. UpdateData();
  269. CString sql, strdate;
  270. strdate.Format("%04d-%02d-%02d", m_year, m_month, m_day);
  271. sql.Format("dat='" + strdate + "' and sale2type='' or dat='" + strdate + "' and sale2type is null");
  272. g_sendhead.bsql = 0;
  273. g_sendhead.code[0] = 87;
  274. g_sendhead.tabcount = 1;
  275. g_pMainWnd->ProcessChatMessageRequest2(sql);
  276. if (g_bSendOK == 0)
  277. {
  278. m_spinyear.EnableWindow(1);
  279. m_spinmonth.EnableWindow(1);
  280. m_spinday.EnableWindow(1);
  281. return;
  282. }
  283. DataToArray(&m_List1array);
  284. m_List1arrayBak.SetSize(m_List1array.GetSize());
  285. for (int i = 0; i < m_List1array.GetSize(); i++)
  286. {
  287. m_List1arrayBak.ElementAt(i).Copy(m_List1array.ElementAt(i));
  288. if (m_List1array.ElementAt(i).ElementAt(6).GetLength()>256)
  289. m_List1array.ElementAt(i).SetAt(6, m_List1array.ElementAt(i).ElementAt(6).Left(256) + "..");
  290. }
  291. FillGrid();
  292. m_spinyear.EnableWindow(1);
  293. m_spinmonth.EnableWindow(1);
  294. m_spinday.EnableWindow(1);
  295. }
  296. void IncomeInput::ClearCtrl()
  297. {
  298. UpdateData();
  299. m_date = g_date;
  300. m_bz = _T("");
  301. m_money = _T("");
  302. m_name = _T("");
  303. m_renyuan1 = _T("");
  304. m_renyuan2 = g_user.name;
  305. m_comboren.SetCurSel(-1);
  306. UpdateData(false);
  307. GetDlgItem(IDC_BUTsave)->EnableWindow(1);
  308. }
  309. void IncomeInput::OnChangeEDITyear()
  310. {
  311. // TODO: If this is a RICHEDIT control, the control will not
  312. // send this notification unless you override the MyFormView::OnInitDialog()
  313. // function and call CRichEditCtrl().SetEventMask()
  314. // with the ENM_CHANGE flag ORed into the mask.
  315. GetData();
  316. // TODO: Add your control notification handler code here
  317. }
  318. void IncomeInput::OnChangeEDITmonth()
  319. {
  320. // TODO: If this is a RICHEDIT control, the control will not
  321. // send this notification unless you override the MyFormView::OnInitDialog()
  322. // function and call CRichEditCtrl().SetEventMask()
  323. // with the ENM_CHANGE flag ORed into the mask.
  324. GetData();
  325. // TODO: Add your control notification handler code here
  326. }
  327. void IncomeInput::OnChangeEDITday()
  328. {
  329. // TODO: If this is a RICHEDIT control, the control will not
  330. // send this notification unless you override the MyFormView::OnInitDialog()
  331. // function and call CRichEditCtrl().SetEventMask()
  332. // with the ENM_CHANGE flag ORed into the mask.
  333. GetData();
  334. // TODO: Add your control notification handler code here
  335. }
  336. BOOL IncomeInput::PreTranslateMessage(MSG* pMsg)
  337. {
  338. // TODO: Add your specialized code here and/or call the base class
  339. try
  340. {
  341. if (pMsg->message == WM_KEYDOWN)
  342. {
  343. switch (pMsg->wParam)
  344. {
  345. case 0x43: // copy
  346. if ((GetKeyState(VK_CONTROL) & 0x80))
  347. {
  348. GetFocus()->SendMessage(WM_COPY);
  349. return TRUE;
  350. }
  351. break;
  352. case 0x56: //Ctrl + V:
  353. if ((GetKeyState(VK_CONTROL) & 0x80))
  354. {
  355. GetFocus()->SendMessage(WM_PASTE);
  356. return TRUE;
  357. }
  358. break;
  359. case 0x58: // cut
  360. if ((GetKeyState(VK_CONTROL) & 0x80))
  361. {
  362. GetFocus()->SendMessage(WM_CUT);
  363. return TRUE;
  364. }
  365. break;
  366. case 0x5A: //undo
  367. case 0x59: //redo
  368. if ((GetKeyState(VK_CONTROL) & 0x80))
  369. {
  370. GetFocus()->SendMessage(WM_UNDO);
  371. return TRUE;
  372. }
  373. break;
  374. }
  375. }
  376. return MyFormView::PreTranslateMessage(pMsg);
  377. }
  378. catch (...)
  379. {
  380. }
  381. }
  382. void IncomeInput::OnBUTprint()
  383. {
  384. // TODO: Add your control notification handler code here
  385. POSITION pos;
  386. pos = m_List1.GetFirstSelectedItemPosition();
  387. if (pos == NULL)
  388. {
  389. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  390. return;
  391. }
  392. int iItem;
  393. iItem = m_List1.GetNextSelectedItem(pos);
  394. CStringArray array;
  395. array.Add("");
  396. array.Add(g_cominfoarray.ElementAt(0).ElementAt(48));
  397. array.Add("");
  398. CString str = "地址:" + g_cominfoarray.ElementAt(0).ElementAt(12);
  399. str += " 电话:" + g_cominfoarray.ElementAt(0).ElementAt(11);
  400. array.Add(str);
  401. CString name = m_List1.GetItemText(iItem, 4);
  402. array.Add("客户姓名:" + name);
  403. array.Add("");
  404. CString date;
  405. date.Format("日期:%s年%s月%s日", g_date.Mid(0, 4), g_date.Mid(5, 2), g_date.Mid(8, 2));
  406. array.Add(date);
  407. array.Add(" 收 款 项 目 ");
  408. array.Add(" 金 额 ");
  409. array.Add(" 开单人 ");
  410. int count = 0;
  411. float money = 0;
  412. // while (pos)
  413. {
  414. count++;
  415. // if(count>4)break;
  416. array.Add(m_List1.GetItemText(iItem, 1));
  417. array.Add(m_List1.GetItemText(iItem, 2));
  418. money += atof(m_List1.GetItemText(iItem, 2));
  419. array.Add("");
  420. }
  421. #ifndef ZHIAI_VERSION
  422. while (array.GetSize() < 22)
  423. array.Add("");
  424. #else
  425. while(array.GetSize ()<31)
  426. array.Add ("");
  427. #endif
  428. CString smoney;
  429. smoney.Format("%0.1f", money);
  430. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  431. {
  432. str = "付款情况 应付:" + smoney;
  433. str += " 实付:" + smoney;
  434. str += " 欠款:0";
  435. array.Add(str);
  436. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  437. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  438. }
  439. else
  440. {
  441. str = "付款情况 应付:" + smoney;
  442. str += " 实付:" + smoney;
  443. str += " 欠款:0";
  444. array.Add(str);
  445. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  446. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  447. }
  448. array.Add(str);
  449. array.Add(g_cominfoarray.ElementAt(0).ElementAt(120));
  450. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  451. array.Add("收银:" + g_user.name);
  452. else
  453. array.Add(" 收银:" + g_user.name);
  454. array.Add("顾客签名:");
  455. array.Add("第\r\n一\r\n联\r\n存\r\n根\r\n∧\r\n白\r\n∨\r\n第\r\n二\r\n联\r\n财\r\n务\r\n∧\r\n黄\r\n∨\r\n第\r\n三\r\n联\r\n客\r\n户\r\n∧\r\n红\r\n∨");
  456. g_pMainWnd->PrintReceipt(&array); // 其他收入 不使用PrintReceipt_01,不需要显示支付方式 Jeff
  457. }
  458. void IncomeInput::OnButton1()
  459. {
  460. // TODO: Add your control notification handler code here
  461. Login2 dlg;
  462. dlg.m_mode = 3;
  463. if (dlg.DoModal() != IDOK)return;
  464. if (IsHasRightsnew2(49, dlg.m_rights) == 0)return;
  465. ((CEdit*)GetDlgItem(IDC_EDITdate))->SetReadOnly(0);
  466. }