IncomeInput.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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 "DlgPaymentMethod.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(49));
  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_AryStaff.GetSize(); i++)
  115. m_comboren.AddString(DAL::GetStaffName(i));
  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. void IncomeInput::OnBUTsave()
  173. {
  174. // TODO: Add your control notification handler code here
  175. UpdateData();
  176. if (!CheckDateOK(m_date))return;
  177. if (g_nYearpos != -1)
  178. {
  179. AfxMessageBox("当前为历史数据查看状态,不能更改历史数据!", MB_ICONSTOP);
  180. return;
  181. }
  182. m_name.TrimRight();
  183. if (m_name.IsEmpty())
  184. {
  185. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  186. return;
  187. }
  188. #if 0
  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
  200. CDlgPaymentMethod dlg;
  201. if ( dlg.DoModal() != IDOK )
  202. return;
  203. CString paytype = dlg.m_strPaymentMethod;
  204. #endif
  205. CString sql;
  206. sql.Format("insert into singleincome([name],[money],[dat],[renyuan1],[renyuan2],[bz],[paytype],[time]) values('%s','%s','%s','%s','%s','%s','%s','curtimereplace')", m_name, m_money, m_date, m_renyuan1, m_renyuan2, m_bz, paytype);
  207. sql += SGLIN_REF;
  208. g_sendhead.bsql = 1;
  209. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  210. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  211. GetData();
  212. }
  213. void IncomeInput::OnBUTdel()
  214. {
  215. // TODO: Add your control notification handler code here
  216. if (IsHasRights2new(49) == 0)return;
  217. POSITION pos;
  218. pos = m_List1.GetFirstSelectedItemPosition();
  219. if (pos == NULL)
  220. {
  221. return;
  222. }
  223. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  224. int iItem = m_List1.GetNextSelectedItem(pos);
  225. CString id = m_List1.GetItemText(iItem, 0);
  226. CString bz = m_List1.GetItemText(iItem, 1);
  227. CString money = m_List1.GetItemText(iItem, 2);
  228. CString date = m_List1.GetItemText(iItem, 3);
  229. CString sql;
  230. sql.Format("delete from singleincome where id=%d ", atoi(id));
  231. sql += SGLIN_REF;
  232. g_sendhead.bsql = 1;
  233. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  234. GetData();
  235. CString str;
  236. str = "删除其它收入";
  237. str += bz;
  238. str += "金额:";
  239. str += money;
  240. str += "日期:";
  241. str += date;
  242. WriteLog(_T("普通日志"), _T("删除其他收入"), g_user.name, str);
  243. }
  244. void IncomeInput::GetData()
  245. {
  246. if (m_bInit == 0)return;
  247. m_spinyear.EnableWindow(0);
  248. m_spinmonth.EnableWindow(0);
  249. m_spinday.EnableWindow(0);
  250. UpdateData();
  251. CString sql, strdate;
  252. strdate.Format("%04d-%02d-%02d", m_year, m_month, m_day);
  253. sql.Format("dat='" + strdate + "' and sale2type='' or dat='" + strdate + "' and sale2type is null");
  254. g_sendhead.bsql = 0;
  255. g_sendhead.code[0] = 87;
  256. g_sendhead.tabcount = 1;
  257. g_pMainWnd->ProcessChatMessageRequest2(sql);
  258. if (g_bSendOK == 0)
  259. {
  260. m_spinyear.EnableWindow(1);
  261. m_spinmonth.EnableWindow(1);
  262. m_spinday.EnableWindow(1);
  263. return;
  264. }
  265. DataToArray(&m_List1array);
  266. m_List1arrayBak.SetSize(m_List1array.GetSize());
  267. for (int i = 0; i < m_List1array.GetSize(); i++)
  268. {
  269. m_List1arrayBak.ElementAt(i).Copy(m_List1array.ElementAt(i));
  270. if (m_List1array.ElementAt(i).ElementAt(6).GetLength()>256)
  271. m_List1array.ElementAt(i).SetAt(6, m_List1array.ElementAt(i).ElementAt(6).Left(256) + "..");
  272. }
  273. FillGrid();
  274. m_spinyear.EnableWindow(1);
  275. m_spinmonth.EnableWindow(1);
  276. m_spinday.EnableWindow(1);
  277. }
  278. void IncomeInput::ClearCtrl()
  279. {
  280. UpdateData();
  281. m_date = g_date;
  282. m_bz = _T("");
  283. m_money = _T("");
  284. m_name = _T("");
  285. m_renyuan1 = _T("");
  286. m_renyuan2 = g_user.name;
  287. m_comboren.SetCurSel(-1);
  288. UpdateData(false);
  289. GetDlgItem(IDC_BUTsave)->EnableWindow(1);
  290. }
  291. void IncomeInput::OnChangeEDITyear()
  292. {
  293. // TODO: If this is a RICHEDIT control, the control will not
  294. // send this notification unless you override the MyFormView::OnInitDialog()
  295. // function and call CRichEditCtrl().SetEventMask()
  296. // with the ENM_CHANGE flag ORed into the mask.
  297. GetData();
  298. // TODO: Add your control notification handler code here
  299. }
  300. void IncomeInput::OnChangeEDITmonth()
  301. {
  302. // TODO: If this is a RICHEDIT control, the control will not
  303. // send this notification unless you override the MyFormView::OnInitDialog()
  304. // function and call CRichEditCtrl().SetEventMask()
  305. // with the ENM_CHANGE flag ORed into the mask.
  306. GetData();
  307. // TODO: Add your control notification handler code here
  308. }
  309. void IncomeInput::OnChangeEDITday()
  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. BOOL IncomeInput::PreTranslateMessage(MSG* pMsg)
  319. {
  320. // TODO: Add your specialized code here and/or call the base class
  321. try
  322. {
  323. if (pMsg->message == WM_KEYDOWN)
  324. {
  325. switch (pMsg->wParam)
  326. {
  327. case 0x43: // copy
  328. if ((GetKeyState(VK_CONTROL) & 0x80))
  329. {
  330. GetFocus()->SendMessage(WM_COPY);
  331. return TRUE;
  332. }
  333. break;
  334. case 0x56: //Ctrl + V:
  335. if ((GetKeyState(VK_CONTROL) & 0x80))
  336. {
  337. GetFocus()->SendMessage(WM_PASTE);
  338. return TRUE;
  339. }
  340. break;
  341. case 0x58: // cut
  342. if ((GetKeyState(VK_CONTROL) & 0x80))
  343. {
  344. GetFocus()->SendMessage(WM_CUT);
  345. return TRUE;
  346. }
  347. break;
  348. case 0x5A: //undo
  349. case 0x59: //redo
  350. if ((GetKeyState(VK_CONTROL) & 0x80))
  351. {
  352. GetFocus()->SendMessage(WM_UNDO);
  353. return TRUE;
  354. }
  355. break;
  356. }
  357. }
  358. return MyFormView::PreTranslateMessage(pMsg);
  359. }
  360. catch (...)
  361. {
  362. }
  363. }
  364. void IncomeInput::OnBUTprint()
  365. {
  366. // TODO: Add your control notification handler code here
  367. POSITION pos;
  368. pos = m_List1.GetFirstSelectedItemPosition();
  369. if (pos == NULL)
  370. {
  371. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  372. return;
  373. }
  374. int iItem;
  375. iItem = m_List1.GetNextSelectedItem(pos);
  376. CStringArray array;
  377. array.Add("");
  378. array.Add(g_cominfoarray.ElementAt(0).ElementAt(48));
  379. array.Add("");
  380. CString str = "地址:" + g_cominfoarray.ElementAt(0).ElementAt(12);
  381. str += " 电话:" + g_cominfoarray.ElementAt(0).ElementAt(11);
  382. array.Add(str);
  383. CString name = m_List1.GetItemText(iItem, 4);
  384. array.Add("客户姓名:" + name);
  385. array.Add("");
  386. CString date;
  387. date.Format("日期:%s年%s月%s日", g_date.Mid(0, 4), g_date.Mid(5, 2), g_date.Mid(8, 2));
  388. array.Add(date);
  389. array.Add(" 收 款 项 目 ");
  390. array.Add(" 金 额 ");
  391. array.Add(" 开单人 ");
  392. int count = 0;
  393. float money = 0;
  394. // while (pos)
  395. {
  396. count++;
  397. // if(count>4)break;
  398. array.Add(m_List1.GetItemText(iItem, 1));
  399. array.Add(m_List1.GetItemText(iItem, 2));
  400. money += atof(m_List1.GetItemText(iItem, 2));
  401. array.Add("");
  402. }
  403. #ifndef ZHIAI_VERSION
  404. while (array.GetSize() < 22)
  405. array.Add("");
  406. #else
  407. while(array.GetSize ()<31)
  408. array.Add ("");
  409. #endif
  410. CString smoney;
  411. smoney.Format("%0.1f", money);
  412. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  413. {
  414. str = "付款情况 应付:" + smoney;
  415. str += " 实付:" + smoney;
  416. str += " 欠款:0";
  417. array.Add(str);
  418. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  419. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  420. }
  421. else
  422. {
  423. str = "付款情况 应付:" + smoney;
  424. str += " 实付:" + smoney;
  425. str += " 欠款:0";
  426. array.Add(str);
  427. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  428. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  429. }
  430. array.Add(str);
  431. array.Add(g_cominfoarray.ElementAt(0).ElementAt(120));
  432. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  433. array.Add("收银:" + g_user.name);
  434. else
  435. array.Add(" 收银:" + g_user.name);
  436. array.Add("顾客签名:");
  437. 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∨");
  438. g_pMainWnd->PrintReceipt(&array); // 其他收入 不使用PrintReceipt_01,不需要显示支付方式 Jeff
  439. }
  440. void IncomeInput::OnButton1()
  441. {
  442. // TODO: Add your control notification handler code here
  443. Login2 dlg;
  444. dlg.m_mode = 3;
  445. if (dlg.DoModal() != IDOK)return;
  446. if (IsHasRightsnew2(49, dlg.m_rights) == 0)return;
  447. ((CEdit*)GetDlgItem(IDC_EDITdate))->SetReadOnly(0);
  448. }