// InputCard2Dlg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "InputCard2Dlg.h" #include "MemberCardFunc2.h" #include "SelMemberCardFund.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // InputCard2Dlg dialog IDC_STATIC3 InputCard2Dlg::InputCard2Dlg(CWnd* pParent /*=NULL*/) : CDialog(InputCard2Dlg::IDD, pParent) { m_name = _T(""); m_no = _T(""); m_card2no1 = _T(""); m_card2no2 = _T(""); m_card2no3 = _T(""); m_card2no4 = _T(""); m_card2no5 = _T(""); m_mode = 0; m_bAddOne = 0; } void InputCard2Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDITname, m_name); DDX_Text(pDX, IDC_EDITno, m_no); DDX_Text(pDX, IDC_EDITcard2no1, m_card2no1); DDX_Text(pDX, IDC_EDITcard2no2, m_card2no2); DDX_Text(pDX, IDC_EDITcard2no3, m_card2no3); DDX_Text(pDX, IDC_EDITcard2no4, m_card2no4); DDX_Text(pDX, IDC_EDITcard2no5, m_card2no5); } BEGIN_MESSAGE_MAP(InputCard2Dlg, CDialog) ON_BN_CLICKED(Btn_Recharge, OnBnClickedRecharge) END_MESSAGE_MAP() BOOL InputCard2Dlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_bAddOne) { GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); } else { int cardnum = atoi(g_cominfoarray.ElementAt(0).ElementAt(118)); switch (cardnum) { case 1: GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); break; case 2: //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); break; case 3: //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); break; case 4: //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); break; case 5: //GetDlgItem(IDC_EDITcard2no2)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no3)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no4)->EnableWindow(0); //GetDlgItem(IDC_EDITcard2no5)->EnableWindow(0); break; default: break; } } return TRUE; } void InputCard2Dlg::OnOK() { UpdateData(); m_card2no1.TrimLeft(); m_card2no1.TrimRight(); m_card2no2.TrimLeft(); m_card2no2.TrimRight(); m_card2no3.TrimLeft(); m_card2no3.TrimRight(); m_card2no4.TrimLeft(); m_card2no4.TrimRight(); m_card2no5.TrimLeft(); m_card2no5.TrimRight(); int length = atol(g_cominfoarray.ElementAt(0).ElementAt(55)); if (m_mode) { if (m_bAddOne == 0) { int cardnum = atoi(g_cominfoarray.ElementAt(0).ElementAt(118)); switch (cardnum) { case 1: if (m_card2no1.IsEmpty()) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } break; case 2: if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() ) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } else if (m_card2no1 == m_card2no2 ) { AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return; } break; case 3: if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty()) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } else if (m_card2no1 == m_card2no2 || m_card2no1 == m_card2no3 || m_card2no2 == m_card2no3 ) { AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return; } break; case 4: if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty() || m_card2no4.IsEmpty()) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } 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 ) { AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return; } break; case 5: if (m_card2no1.IsEmpty() || m_card2no2.IsEmpty() || m_card2no3.IsEmpty() || m_card2no4.IsEmpty() || m_card2no5.IsEmpty()) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } 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) { AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return; } break; default: break; } } else { if (m_card2no1.IsEmpty()) { AfxMessageBox("副卡号不能为空!", MB_ICONINFORMATION); return; } } } else { 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 != "")) { AfxMessageBox("副卡号不能相同!", MB_ICONINFORMATION); return; } } /* if(!m_card2no1.IsEmpty ()) { if(m_card2no1.GetLength ()!=length) { AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return; } } if(!m_card2no2.IsEmpty ()) { if(m_card2no2.GetLength ()!=length) { AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return; } } if(!m_card2no3.IsEmpty ()) { if(m_card2no3.GetLength ()!=length) { AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return; } } if(!m_card2no4.IsEmpty ()) { if(m_card2no4.GetLength ()!=length) { AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return; } } if(!m_card2no5.IsEmpty ()) { if(m_card2no5.GetLength ()!=length) { AfxMessageBox("卡号长度不对!", MB_ICONINFORMATION);return; } }*/ CString sql; if (m_mode) { sql = "select count(*) as cot from membercard2blue where "; CString temp; if (!m_card2no1.IsEmpty()) temp += "or [card2no]='" + m_card2no1 + "' "; if (!m_card2no2.IsEmpty()) temp += "or [card2no]='" + m_card2no2 + "' "; if (!m_card2no3.IsEmpty()) temp += "or [card2no]='" + m_card2no3 + "' "; if (!m_card2no4.IsEmpty()) temp += "or [card2no]='" + m_card2no4 + "' "; if (!m_card2no5.IsEmpty()) temp += "or [card2no]='" + m_card2no5 + "' "; temp.TrimLeft("or"); temp.TrimRight(); if (temp.IsEmpty())return; sql += temp; g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; if (g_ncount) { AfxMessageBox("此副卡发出尚未收回,请重新填写副卡号!", MB_ICONINFORMATION); return; } if (!m_card2no1.IsEmpty()) sql = "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no1 + "','" + g_date + "')"; if (!m_card2no2.IsEmpty()) sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no2 + "','" + g_date + "')"; if (!m_card2no3.IsEmpty()) sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no3 + "','" + g_date + "')"; if (!m_card2no4.IsEmpty()) sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no4 + "','" + g_date + "')"; if (!m_card2no5.IsEmpty()) sql += "***insert into membercard2blue([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no5 + "','" + g_date + "')"; } else { sql = "select count(*) as cot from membercard2 where "; CString temp; if (!m_card2no1.IsEmpty()) temp += "or [card2no]='" + m_card2no1 + "' "; if (!m_card2no2.IsEmpty()) temp += "or [card2no]='" + m_card2no2 + "' "; if (!m_card2no3.IsEmpty()) temp += "or [card2no]='" + m_card2no3 + "' "; if (!m_card2no4.IsEmpty()) temp += "or [card2no]='" + m_card2no4 + "' "; if (!m_card2no5.IsEmpty()) temp += "or [card2no]='" + m_card2no5 + "' "; temp.TrimLeft("or"); temp.TrimRight(); if (temp.IsEmpty())return; sql += temp; g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; if (g_ncount) { AfxMessageBox("此副卡发出尚未收回,请重新填写副卡号!", MB_ICONINFORMATION); return; } if (!m_card2no1.IsEmpty()) sql = "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no1 + "','" + g_date + "')"; if (!m_card2no2.IsEmpty()) sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no2 + "','" + g_date + "')"; if (!m_card2no3.IsEmpty()) sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no3 + "','" + g_date + "')"; if (!m_card2no4.IsEmpty()) sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no4 + "','" + g_date + "')"; if (!m_card2no5.IsEmpty()) sql += "***insert into membercard2([memberno],[card2no],[date])values('" + m_no + "','" + m_card2no5 + "','" + g_date + "')"; } sql.TrimLeft("***"); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); CDialog::OnOK(); } BOOL InputCard2Dlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: return 1; } } return CDialog::PreTranslateMessage(pMsg); } void InputCard2Dlg::OnBnClickedRecharge() // 充值; { // 在此添加控件通知处理程序代码; CString branch = _T(""); CArray tagAryOfData; g_sendhead.bsql = 0; g_sendhead.code[0] = 161; g_sendhead.tabcount = 1; CString strFilters = _T(""); strFilters.Format(_T("memberno='%s'"), m_no); g_pMainWnd->ProcessChatMessageRequest2(strFilters); if (g_bSendOK == 0) return; DataToArray(&tagAryOfData); ////////////////////////////////////////////////////////////////////////// MemberCardFunc2 dlg; CString memberno = m_no; CString m_card2no = tagAryOfData.ElementAt(0).ElementAt(7); dlg.m_branch = branch; dlg.m_memberno = memberno; if (!m_card2no.IsEmpty()) { SelMemberCardFund seldlg; if (seldlg.DoModal() != IDOK)return; if (seldlg.m_radio1 == 1) { dlg.m_card2no = m_card2no; dlg.m_card2balance = tagAryOfData.ElementAt(0).ElementAt(8); } } dlg.DoModal(); }