InputGoods.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // InputGoods.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "InputGoods.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // InputGoods dialog
  13. InputGoods::InputGoods(CWnd* pParent /*=NULL*/)
  14. : CDialog(InputGoods::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(InputGoods)
  17. m_id = _T("");
  18. m_count = _T("");
  19. m_clerk = g_user.name;
  20. m_date = g_date;
  21. m_remark = _T("");
  22. //}}AFX_DATA_INIT
  23. m_mode = 0;
  24. }
  25. void InputGoods::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CDialog::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(InputGoods)
  29. DDX_Control(pDX, IDC_EDITcount, m_editnum);
  30. DDX_Control(pDX, IDC_COMBOname, m_comboname);
  31. DDX_Control(pDX, IDC_COMBOtype, m_combotype);
  32. DDX_Text(pDX, IDC_EDITid, m_id);
  33. DDX_Text(pDX, IDC_EDITcount, m_count);
  34. DDX_Text(pDX, IDC_EDITclerk, m_clerk);
  35. DDX_Text(pDX, IDC_EDITdate, m_date);
  36. DDX_Text(pDX, IDC_EDITremark, m_remark);
  37. DDV_MaxChars(pDX, m_remark, 1000);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(InputGoods, CDialog)
  41. //{{AFX_MSG_MAP(InputGoods)
  42. ON_CBN_SELCHANGE(IDC_COMBOtype, OnSelchangeCOMBOtype)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // InputGoods message handlers
  47. BOOL InputGoods::OnInitDialog()
  48. {
  49. CDialog::OnInitDialog();
  50. // TODO: Add extra initialization here
  51. CString sql = "select max(id) as cot from storeinfo where [date]='" + g_date + "'";
  52. if (m_mode)
  53. sql = "select max(id) as cot from storeinfo2 where [date]='" + g_date + "'";
  54. g_sendhead.bsql = 1;
  55. g_pMainWnd->ProcessChatMessageRequest2(sql);
  56. if (g_bSendOK == 0)
  57. {
  58. CDialog::OnCancel();
  59. return false;
  60. }
  61. CString date = g_date;
  62. date.Replace("-", "");
  63. if (m_mode == 0)
  64. m_id.Format("%s-(rk)%03d", date, g_ncount + 1);
  65. else
  66. {
  67. m_id.Format("%s-(ck)%03d", date, g_ncount + 1);
  68. GetDlgItem(IDC_STATIC1)->SetWindowText("出库资料");
  69. SetWindowText("出库单");
  70. }
  71. UpdateData(false);
  72. g_sendhead.bsql = 0;
  73. g_sendhead.code[0] = 8;
  74. g_sendhead.code[1] = 2;
  75. g_sendhead.tabcount = 2;
  76. CString filter = "hide<>'下架' or hide is null;";
  77. g_pMainWnd->ProcessChatMessageRequest2(filter);
  78. if (g_bSendOK == 0)
  79. {
  80. CDialog::OnCancel();
  81. return false;
  82. }
  83. DataToArray(&m_List1array, &m_List2array);
  84. for (int i = 0; i < m_List2array.GetSize(); i++)
  85. m_combotype.AddString(m_List2array.ElementAt(i).ElementAt(0));
  86. CenterWindow();
  87. return TRUE; // return TRUE unless you set the focus to a control
  88. // EXCEPTION: OCX Property Pages should return FALSE
  89. }
  90. void InputGoods::OnSelchangeCOMBOtype()
  91. {
  92. // TODO: Add your control notification handler code here
  93. int pos = m_combotype.GetCurSel();
  94. if (pos == -1)return;
  95. CString str;
  96. m_combotype.GetLBText(pos, str);
  97. m_comboname.ResetContent();
  98. for (int ii = 0; ii < m_List1array.GetSize(); ii++)
  99. {
  100. if (m_List1array.ElementAt(ii).ElementAt(4) == str)
  101. {
  102. m_comboname.AddString(m_List1array.ElementAt(ii).ElementAt(1));
  103. }
  104. }
  105. }
  106. void InputGoods::OnOK()
  107. {
  108. // TODO: Add extra validation here
  109. UpdateData();
  110. CString type, name;
  111. int pos;
  112. pos = m_combotype.GetCurSel();
  113. if (pos != -1)
  114. m_combotype.GetLBText(pos, type);
  115. pos = m_comboname.GetCurSel();
  116. if (pos != -1)
  117. m_comboname.GetLBText(pos, name);
  118. m_count.TrimLeft(); m_count.TrimRight();
  119. if (m_count.IsEmpty() || type.IsEmpty() || name.IsEmpty())
  120. {
  121. AfxMessageBox("资料不全, 打*号的项目为必填项目!");
  122. return;
  123. }
  124. CString sql;
  125. if (m_mode == 0)
  126. {
  127. sql.Format("insert into [storeinfo]([id],[type],[name],[count],[date],[clerk],[remark])values('%s','%s','%s','%s','%s','%s','%s')", m_id, type, name, m_count, m_date, m_clerk, m_remark);
  128. }
  129. else
  130. {
  131. sql.Format("insert into [storeinfo2]([id],[type],[name],[count],[date],[clerk],[remark])values('%s','%s','%s','%s','%s','%s','%s')", m_id, type, name, m_count, m_date, m_clerk, m_remark);
  132. }
  133. g_sendhead.bsql = 1;
  134. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  135. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  136. ////////////////////
  137. sql = "select max(id) as cot from storeinfo where [date]='" + g_date + "'";
  138. if (m_mode)
  139. sql = "select max(id) as cot from storeinfo2 where [date]='" + g_date + "'";
  140. g_sendhead.bsql = 1;
  141. g_pMainWnd->ProcessChatMessageRequest2(sql);
  142. if (g_bSendOK == 0)
  143. {
  144. CDialog::OnCancel();
  145. return;
  146. }
  147. CString date = g_date;
  148. date.Replace("-", "");
  149. if (m_mode == 0)
  150. m_id.Format("%s-(rk)%03d", date, g_ncount + 1);
  151. else
  152. {
  153. m_id.Format("%s-(ck)%03d", date, g_ncount + 1);
  154. }
  155. m_comboname.SetCurSel(-1);
  156. m_count = _T("");
  157. m_remark = _T("");
  158. UpdateData(false);
  159. // CDialog::OnOK();
  160. }