InputCard2Dlg.cpp 9.7 KB

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