InputCard2Dlg.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. // InputCard2Dlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "InputCard2Dlg.h"
  6. #include "MemberCardFunc2.h"
  7. #include "SelMemberCardFund.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // InputCard2Dlg dialog IDC_STATIC3
  15. InputCard2Dlg::InputCard2Dlg(CWnd* pParent /*=NULL*/) : CDialog(InputCard2Dlg::IDD, pParent)
  16. {
  17. m_name = _T("");
  18. m_no = _T("");
  19. m_card2no1 = _T("");
  20. m_card2no2 = _T("");
  21. m_card2no3 = _T("");
  22. m_card2no4 = _T("");
  23. m_card2no5 = _T("");
  24. m_mode = 0;
  25. m_bAddOne = 0;
  26. }
  27. void InputCard2Dlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. DDX_Text(pDX, IDC_EDITname, m_name);
  31. DDX_Text(pDX, IDC_EDITno, m_no);
  32. DDX_Text(pDX, IDC_EDITcard2no1, m_card2no1);
  33. DDX_Text(pDX, IDC_EDITcard2no2, m_card2no2);
  34. DDX_Text(pDX, IDC_EDITcard2no3, m_card2no3);
  35. DDX_Text(pDX, IDC_EDITcard2no4, m_card2no4);
  36. DDX_Text(pDX, IDC_EDITcard2no5, m_card2no5);
  37. }
  38. BEGIN_MESSAGE_MAP(InputCard2Dlg, CDialog)
  39. ON_BN_CLICKED(Btn_Recharge, OnBnClickedRecharge)
  40. END_MESSAGE_MAP()
  41. BOOL InputCard2Dlg::OnInitDialog()
  42. {
  43. CDialog::OnInitDialog();
  44. if (m_bAddOne)
  45. {
  46. GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  47. GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  48. GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  49. GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  50. }
  51. else
  52. {
  53. int cardnum = atoi(g_cominfoarray.ElementAt(0).ElementAt(118));
  54. switch (cardnum)
  55. {
  56. case 1:
  57. GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  58. GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  59. GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  60. GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  61. break;
  62. case 2:
  63. //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  64. GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  65. GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  66. GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  67. break;
  68. case 3:
  69. //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  70. //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  71. GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  72. GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  73. break;
  74. case 4:
  75. //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  76. //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  77. //GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  78. GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  79. break;
  80. case 5:
  81. //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0);
  82. //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0);
  83. //GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0);
  84. //GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0);
  85. break;
  86. default:
  87. break;
  88. }
  89. }
  90. return TRUE;
  91. }
  92. void InputCard2Dlg::OnOK()
  93. {
  94. UpdateData();
  95. m_card2no1.TrimLeft();
  96. m_card2no1.TrimRight();
  97. m_card2no2.TrimLeft();
  98. m_card2no2.TrimRight();
  99. m_card2no3.TrimLeft();
  100. m_card2no3.TrimRight();
  101. m_card2no4.TrimLeft();
  102. m_card2no4.TrimRight();
  103. m_card2no5.TrimLeft();
  104. m_card2no5.TrimRight();
  105. int length = atol(g_cominfoarray.ElementAt(0).ElementAt(55));
  106. if (m_mode)
  107. {
  108. if (m_bAddOne == 0)
  109. {
  110. int cardnum = atoi(g_cominfoarray.ElementAt(0).ElementAt(118));
  111. switch (cardnum)
  112. {
  113. case 1:
  114. if (m_card2no1.IsEmpty())
  115. {
  116. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION);
  117. return;
  118. }
  119. break;
  120. case 2:
  121. if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() )
  122. {
  123. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION);
  124. return;
  125. }
  126. else if (m_card2no1 == m_card2no2 )
  127. {
  128. AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return;
  129. }
  130. break;
  131. case 3:
  132. if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty())
  133. {
  134. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION);
  135. return;
  136. }
  137. else if (m_card2no1 == m_card2no2 || m_card2no1 == m_card2no3 || m_card2no2 == m_card2no3 )
  138. {
  139. AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return;
  140. }
  141. break;
  142. case 4:
  143. if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty() || m_card2no4.IsEmpty())
  144. {
  145. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION);
  146. return;
  147. }
  148. else if (m_card2no1 == m_card2no2 || m_card2no1 == m_card2no3 || m_card2no1 == m_card2no4 || m_card2no2 == m_card2no3 || m_card2no2 == m_card2no4 || m_card2no3 == m_card2no4 )
  149. {
  150. AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return;
  151. }
  152. break;
  153. case 5:
  154. if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty() || m_card2no4.IsEmpty() || m_card2no5.IsEmpty())
  155. {
  156. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION);
  157. return;
  158. }
  159. else if (m_card2no1 == m_card2no2 || m_card2no1 == m_card2no3 || m_card2no1 == m_card2no4 || m_card2no1 == m_card2no5 || m_card2no2 == m_card2no3 || m_card2no2 == m_card2no4 || m_card2no2 == m_card2no5 || m_card2no3 == m_card2no4 || m_card2no3 == m_card2no5 || m_card2no4 == m_card2no5)
  160. {
  161. AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return;
  162. }
  163. break;
  164. default:
  165. break;
  166. }
  167. }
  168. else
  169. {
  170. if (m_card2no1.IsEmpty())
  171. {
  172. AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return;
  173. }
  174. }
  175. }
  176. else
  177. {
  178. if ((m_card2no1 == m_card2no2 && m_card2no1 != "") || (m_card2no1 == m_card2no3 && m_card2no1 != "") || (m_card2no1 == m_card2no4 && m_card2no1 != "") || (m_card2no1 == m_card2no5 && m_card2no1 != "") || (m_card2no2 == m_card2no3 && m_card2no2 != "") || (m_card2no2 == m_card2no4 && m_card2no2 != "") || (m_card2no2 == m_card2no5 && m_card2no2 != "") || (m_card2no3 == m_card2no4 && m_card2no3 != "") || (m_card2no3 == m_card2no5 && m_card2no3 != "") || (m_card2no4 == m_card2no5 && m_card2no4 != ""))
  179. {
  180. AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return;
  181. }
  182. }
  183. /* if(!m_card2no1.IsEmpty ())
  184. {
  185. if(m_card2no1.GetLength ()!=length)
  186. {
  187. AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return;
  188. }
  189. }
  190. if(!m_card2no2.IsEmpty ())
  191. {
  192. if(m_card2no2.GetLength ()!=length)
  193. {
  194. AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return;
  195. }
  196. }
  197. if(!m_card2no3.IsEmpty ())
  198. {
  199. if(m_card2no3.GetLength ()!=length)
  200. {
  201. AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return;
  202. }
  203. }
  204. if(!m_card2no4.IsEmpty ())
  205. {
  206. if(m_card2no4.GetLength ()!=length)
  207. {
  208. AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return;
  209. }
  210. }
  211. if(!m_card2no5.IsEmpty ())
  212. {
  213. if(m_card2no5.GetLength ()!=length)
  214. {
  215. AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return;
  216. }
  217. }*/
  218. CString sql;
  219. if (m_mode)
  220. {
  221. sql = "select count(*) as cot from membercard2blue where ";
  222. CString temp;
  223. if (!m_card2no1.IsEmpty())
  224. temp += "or [card2no]='" + m_card2no1 + "' ";
  225. if (!m_card2no2.IsEmpty())
  226. temp += "or [card2no]='" + m_card2no2 + "' ";
  227. if (!m_card2no3.IsEmpty())
  228. temp += "or [card2no]='" + m_card2no3 + "' ";
  229. if (!m_card2no4.IsEmpty())
  230. temp += "or [card2no]='" + m_card2no4 + "' ";
  231. if (!m_card2no5.IsEmpty())
  232. temp += "or [card2no]='" + m_card2no5 + "' ";
  233. temp.TrimLeft("or");
  234. temp.TrimRight();
  235. if (temp.IsEmpty())return;
  236. sql += temp;
  237. g_sendhead.bsql = 1;
  238. g_pMainWnd->ProcessChatMessageRequest2(sql);
  239. if (g_bSendOK == 0)return;
  240. if (g_ncount)
  241. {
  242. AfxMessageBox("此副卡发出尚未收回,请重新填写副卡号!", MB_ICONINFORMATION); return;
  243. }
  244. if (!m_card2no1.IsEmpty())
  245. sql = "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no1 + "','" + g_date + "')";
  246. if (!m_card2no2.IsEmpty())
  247. sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no2 + "','" + g_date + "')";
  248. if (!m_card2no3.IsEmpty())
  249. sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no3 + "','" + g_date + "')";
  250. if (!m_card2no4.IsEmpty())
  251. sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no4 + "','" + g_date + "')";
  252. if (!m_card2no5.IsEmpty())
  253. sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no5 + "','" + g_date + "')";
  254. }
  255. else
  256. {
  257. sql = "select count(*) as cot from membercard2 where ";
  258. CString temp;
  259. if (!m_card2no1.IsEmpty())
  260. temp += "or [card2no]='" + m_card2no1 + "' ";
  261. if (!m_card2no2.IsEmpty())
  262. temp += "or [card2no]='" + m_card2no2 + "' ";
  263. if (!m_card2no3.IsEmpty())
  264. temp += "or [card2no]='" + m_card2no3 + "' ";
  265. if (!m_card2no4.IsEmpty())
  266. temp += "or [card2no]='" + m_card2no4 + "' ";
  267. if (!m_card2no5.IsEmpty())
  268. temp += "or [card2no]='" + m_card2no5 + "' ";
  269. temp.TrimLeft("or");
  270. temp.TrimRight();
  271. if (temp.IsEmpty())return;
  272. sql += temp;
  273. g_sendhead.bsql = 1;
  274. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  275. if (g_ncount)
  276. {
  277. AfxMessageBox("此副卡发出尚未收回,请重新填写副卡号!", MB_ICONINFORMATION); return;
  278. }
  279. if (!m_card2no1.IsEmpty())
  280. sql = "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no1 + "','" + g_date + "')";
  281. if (!m_card2no2.IsEmpty())
  282. sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no2 + "','" + g_date + "')";
  283. if (!m_card2no3.IsEmpty())
  284. sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no3 + "','" + g_date + "')";
  285. if (!m_card2no4.IsEmpty())
  286. sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no4 + "','" + g_date + "')";
  287. if (!m_card2no5.IsEmpty())
  288. sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no5 + "','" + g_date + "')";
  289. }
  290. sql.TrimLeft("***");
  291. g_sendhead.bsql = 1;
  292. g_pMainWnd->ProcessChatMessageRequest2(sql);
  293. if (g_bSendOK == 0)return;
  294. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  295. CDialog::OnOK();
  296. }
  297. BOOL InputCard2Dlg::PreTranslateMessage(MSG* pMsg)
  298. {
  299. if (pMsg->message == WM_KEYDOWN)
  300. {
  301. switch (pMsg->wParam)
  302. {
  303. case VK_RETURN:
  304. return 1;
  305. }
  306. }
  307. return CDialog::PreTranslateMessage(pMsg);
  308. }
  309. void InputCard2Dlg::OnBnClickedRecharge() // 充值;
  310. {
  311. // 在此添加控件通知处理程序代码;
  312. CString branch = _T("");
  313. CArray<CStringArray, CStringArray> tagAryOfData;
  314. g_sendhead.bsql = 0;
  315. g_sendhead.code[0] = 161;
  316. g_sendhead.tabcount = 1;
  317. CString strFilters = _T("");
  318. strFilters.Format(_T("memberno='%s'"), m_no);
  319. g_pMainWnd->ProcessChatMessageRequest2(strFilters);
  320. if (g_bSendOK == 0)
  321. return;
  322. DataToArray(&tagAryOfData);
  323. //////////////////////////////////////////////////////////////////////////
  324. MemberCardFunc2 dlg;
  325. CString memberno = m_no;
  326. CString m_card2no = tagAryOfData.ElementAt(0).ElementAt(7);
  327. dlg.m_branch = branch;
  328. dlg.m_memberno = memberno;
  329. if (!m_card2no.IsEmpty())
  330. {
  331. SelMemberCardFund seldlg;
  332. if (seldlg.DoModal() != IDOK)return;
  333. if (seldlg.m_radio1 == 1)
  334. {
  335. dlg.m_card2no = m_card2no;
  336. dlg.m_card2balance = tagAryOfData.ElementAt(0).ElementAt(8);
  337. }
  338. }
  339. dlg.DoModal();
  340. }