IncomeInput.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. // IncomeInput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "IncomeInput.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // IncomeInput
  14. IMPLEMENT_DYNCREATE(IncomeInput, CFormView)
  15. IncomeInput::IncomeInput()
  16. : CFormView(IncomeInput::IDD)
  17. {
  18. //{{AFX_DATA_INIT(IncomeInput)
  19. m_bz = _T("");
  20. m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  21. m_money = _T("");
  22. m_name = _T("");
  23. m_renyuan1 = _T("");
  24. m_renyuan2 = g_user.name;
  25. m_year = CTime::GetCurrentTime ().GetYear ();
  26. m_month = CTime::GetCurrentTime ().GetMonth ();
  27. m_day = CTime::GetCurrentTime ().GetDay ();
  28. m_bInit=0;
  29. //}}AFX_DATA_INIT
  30. }
  31. IncomeInput::~IncomeInput()
  32. {
  33. }
  34. void IncomeInput::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CFormView::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(IncomeInput)
  38. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  39. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  40. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  41. DDX_Control(pDX, IDC_COMBO2, m_comboren);
  42. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  43. DDX_Control(pDX, IDC_LIST2, m_List1);
  44. DDX_Control(pDX, IDC_STATIC1, m_static1);
  45. DDX_Text(pDX, IDC_EDITbz, m_bz);
  46. DDX_Text(pDX, IDC_EDITdate, m_date);
  47. DDX_Text(pDX, IDC_EDITmoney, m_money);
  48. DDX_Text(pDX, IDC_EDITname, m_name);
  49. DDX_Text(pDX, IDC_EDITrenyuan1, m_renyuan1);
  50. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  51. DDX_Text(pDX, IDC_EDITyear, m_year);
  52. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  53. DDX_Text(pDX, IDC_EDITmonth, m_month);
  54. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  55. DDX_Text(pDX, IDC_EDITday, m_day);
  56. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  57. //}}AFX_DATA_MAP
  58. }
  59. BEGIN_MESSAGE_MAP(IncomeInput, CFormView)
  60. //{{AFX_MSG_MAP(IncomeInput)
  61. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  62. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  63. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  64. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  65. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  66. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  67. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. /////////////////////////////////////////////////////////////////////////////
  71. // IncomeInput diagnostics
  72. #ifdef _DEBUG
  73. void IncomeInput::AssertValid() const
  74. {
  75. CFormView::AssertValid();
  76. }
  77. void IncomeInput::Dump(CDumpContext& dc) const
  78. {
  79. CFormView::Dump(dc);
  80. }
  81. #endif //_DEBUG
  82. /////////////////////////////////////////////////////////////////////////////
  83. // IncomeInput message handlers
  84. void IncomeInput::OnInitialUpdate()
  85. {
  86. CFormView::OnInitialUpdate();
  87. // TODO: Add your specialized code here and/or call the base class
  88. CMyMdi Mdi;
  89. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  90. // Here we create the outbar control using the splitter as its parent
  91. // and setting its id to the first pane.
  92. CRect rc2;
  93. GetWindowRect(rc2);
  94. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  95. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  96. m_static1.SetFont (&g_titlefont);
  97. m_List1.SetHeadings("id,0;项目名称, 160;金额, 100;日期, 120;付款人,100;经手人,100;开单人,100;备注,120" );
  98. m_List1.LoadColumnInfo (106);
  99. m_comboren.GetWindowRect (rc2);
  100. ScreenToClient(rc2);
  101. rc2.bottom +=400;
  102. m_comboren.MoveWindow (rc2);
  103. for(int i=0; i<g_userarray.GetSize (); i++)
  104. m_comboren.AddString (g_userarray.ElementAt (i).ElementAt (1));
  105. m_bInit=1;
  106. GetData();
  107. }
  108. void IncomeInput::FillGrid()
  109. {
  110. m_List1.DeleteAllItems2 ();
  111. int ii=0;
  112. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  113. int count=0;
  114. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  115. {
  116. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  117. }
  118. m_List1.m_arLabels.SetSize(count, 1);
  119. ii=count;
  120. m_List1.m_LabelCount=ii;
  121. m_List1.SetItemCountEx (ii);
  122. }
  123. void IncomeInput::OnBUTclose()
  124. {
  125. // TODO: Add your control notification handler code here
  126. GetParent()->SendMessage(WM_CLOSE);
  127. }
  128. void IncomeInput::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  129. {
  130. // TODO: Add your control notification handler code here
  131. ListSelChange();
  132. *pResult = 0;
  133. }
  134. void IncomeInput::ListSelChange()
  135. {
  136. POSITION pos;
  137. pos=m_List1.GetFirstSelectedItemPosition();
  138. if(pos==NULL)
  139. {
  140. ClearCtrl();
  141. return;
  142. }
  143. }
  144. void IncomeInput::OnBUTsave()
  145. {
  146. // TODO: Add your control notification handler code here
  147. UpdateData();
  148. m_name.TrimRight ();
  149. if(m_name.IsEmpty ())
  150. {
  151. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  152. return;
  153. }
  154. CString m_renyuan3;
  155. int pos=m_comboren.GetCurSel ();
  156. if(pos!=-1)
  157. {
  158. m_comboren.GetLBText (pos, m_renyuan3);
  159. }
  160. CString sql;
  161. sql.Format ("insert into singleincome([name],[money],[dat],[renyuan1],[renyuan2],[renyuan3],[bz])\
  162. values('%s','%s','%s','%s','%s','%s','%s')",m_name,m_money,m_date,m_renyuan1,m_renyuan2,m_renyuan3,m_bz);
  163. sql+=SGLIN_REF;
  164. g_sendhead.bsql=1;
  165. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  166. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  167. GetData();
  168. }
  169. void IncomeInput::OnBUTdel()
  170. {
  171. // TODO: Add your control notification handler code here
  172. POSITION pos;
  173. pos=m_List1.GetFirstSelectedItemPosition();
  174. if(pos==NULL)
  175. {
  176. return;
  177. }
  178. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  179. int iItem=m_List1.GetNextSelectedItem(pos);
  180. CString id=m_List1.GetItemText (iItem, 0);
  181. CString sql;
  182. sql.Format ("delete from singleincome where id=%d ", atoi(id));
  183. sql+=SGLIN_REF;
  184. g_sendhead.bsql=1;
  185. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  186. GetData();
  187. }
  188. void IncomeInput::GetData()
  189. {
  190. if(m_bInit==0)return;
  191. UpdateData();
  192. CString sql,strdate;
  193. strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
  194. sql.Format ("dat='"+strdate+"'");
  195. g_sendhead.bsql=0;
  196. g_sendhead.code[0]=14;
  197. g_sendhead.tabcount=1;
  198. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  199. DataToArray(&m_List1array);
  200. FillGrid();
  201. m_date=strdate;
  202. UpdateData(false);
  203. }
  204. void IncomeInput::ClearCtrl()
  205. {
  206. m_bz = _T("");
  207. m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  208. m_money = _T("");
  209. m_name = _T("");
  210. m_renyuan1 = _T("");
  211. m_renyuan2 = g_user.name;
  212. UpdateData(false);
  213. }
  214. void IncomeInput::OnChangeEDITyear()
  215. {
  216. // TODO: If this is a RICHEDIT control, the control will not
  217. // send this notification unless you override the CFormView::OnInitDialog()
  218. // function and call CRichEditCtrl().SetEventMask()
  219. // with the ENM_CHANGE flag ORed into the mask.
  220. GetData();
  221. // TODO: Add your control notification handler code here
  222. }
  223. void IncomeInput::OnChangeEDITmonth()
  224. {
  225. // TODO: If this is a RICHEDIT control, the control will not
  226. // send this notification unless you override the CFormView::OnInitDialog()
  227. // function and call CRichEditCtrl().SetEventMask()
  228. // with the ENM_CHANGE flag ORed into the mask.
  229. GetData();
  230. // TODO: Add your control notification handler code here
  231. }
  232. void IncomeInput::OnChangeEDITday()
  233. {
  234. // TODO: If this is a RICHEDIT control, the control will not
  235. // send this notification unless you override the CFormView::OnInitDialog()
  236. // function and call CRichEditCtrl().SetEventMask()
  237. // with the ENM_CHANGE flag ORed into the mask.
  238. GetData();
  239. // TODO: Add your control notification handler code here
  240. }
  241. BOOL IncomeInput::PreTranslateMessage(MSG* pMsg)
  242. {
  243. // TODO: Add your specialized code here and/or call the base class
  244. try
  245. {
  246. if(pMsg->message==WM_KEYDOWN)
  247. {
  248. switch (pMsg->wParam)
  249. {
  250. case 0x43: // copy
  251. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  252. {
  253. GetFocus()->SendMessage(WM_COPY);
  254. return TRUE;
  255. }
  256. break;
  257. case 0x56: //Ctrl + V:
  258. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  259. {
  260. GetFocus()->SendMessage(WM_PASTE);
  261. return TRUE;
  262. }
  263. break;
  264. case 0x58: // cut
  265. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  266. {
  267. GetFocus()->SendMessage(WM_CUT);
  268. return TRUE;
  269. }
  270. break;
  271. case 0x5A: //undo
  272. case 0x59: //redo
  273. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  274. {
  275. GetFocus()->SendMessage(WM_UNDO);
  276. return TRUE;
  277. }
  278. break;
  279. }
  280. }
  281. return CFormView::PreTranslateMessage(pMsg);
  282. }
  283. catch(...)
  284. {
  285. }
  286. }