IncomeInput.cpp 13 KB

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