// DLG_User_InportP2.cpp : implementation file // #include "stdafx.h" #include "corpsms.h" #include "DLG_User_InportP2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DLG_User_InportP2 dialog #include "FGAddress.h" #include "FPAddress.h" #include "FSAddress.h" #include "MainFrm.h" #include "DLG_AddWarning.h" #include "DLG_Send.h" #include "DLG_SendFax.h" #include "DLG_User_ModifyC.h" //#include //#include #include "DLG_SelSheet.h" #include "FBack.h" #include "FTDSet.h" #include "DLG_PLFile_Add.h" #include "DLG_QXBox_Group_Modify.h" #include "DLG_White2.h" #include "..\public\Excel\LuExcel.h" DLG_User_InportP2::DLG_User_InportP2(CWnd* pParent /*=NULL*/) : CDialog(DLG_User_InportP2::IDD, pParent) { //{{AFX_DATA_INIT(DLG_User_InportP2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT memset(&m_Field , 0 , sizeof(m_Field) ); m_lField = 0; m_lInportType = 0; m_lColCount = 0; m_lCurCol = 0; m_pFGAddress = NULL; m_pFPAddress = NULL; m_pDlgSend = NULL; m_pTDSet = NULL; m_pPLFile = NULL; m_pWhite2 = NULL; m_pParent = pParent; m_bShowProcess = false; } void DLG_User_InportP2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DLG_User_InportP2) DDX_Control(pDX, IDC_USER_INPORT_ADD0, m_B_Add0); DDX_Control(pDX, IDC_USER_INPORT_BIRTHDAY, m_B_Birthday); DDX_Control(pDX, IDC_USER_INPORT_S1, m_B_Tips); DDX_Control(pDX, IDC_USER_INPORT_REMOBILE, m_B_ReMobile); DDX_Control(pDX, IDC_USER_INPORT_LIST, m_wndList); DDX_Control(pDX, IDC_USER_INPORT_FILENAME, m_E_FileName); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DLG_User_InportP2, CDialog) //{{AFX_MSG_MAP(DLG_User_InportP2) ON_BN_CLICKED(IDC_USER_INPORT_GETFILE, OnUserInportGetfile) ON_NOTIFY(LVN_COLUMNCLICK, IDC_USER_INPORT_LIST, OnColumnclickUserInportList) //}}AFX_MSG_MAP ON_COMMAND(MENU_INPORTP_ALL,On_User_All) ON_COMMAND_RANGE(MENU_INPORTP_FIRST,MENU_INPORTP_FIRST+60,On_User_SelField) ON_BN_CLICKED(IDOK, &DLG_User_InportP2::OnBnClickedOk) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DLG_User_InportP2 message handlers void DLG_User_InportP2::SetParam(Inport_Field *pField, long lFieldCount, long lInportType) { memcpy( &m_Field , pField , sizeof(Inport_Field)*lFieldCount ); m_lField = lFieldCount; m_lInportType = lInportType; /* 3 FCAddress 2 DLG_Send 1 FGAddress 0 FPAddress */ switch ( lInportType ) { case 0: m_pFPAddress = (CFPAddress *)m_pParent; m_AdoRS.SetAdoConnection( &m_pFPAddress->m_pMainFrame->m_adoConnection ); m_strDefName = m_pFPAddress->m_pMainFrame->m_Setup.szDEF_Name; break; case 1: break; case 2: m_pDlgSend = (DLG_Send *)m_pParent; break; case 3: m_pFCAddress = (CFCAddress *)m_pParent; m_AdoRS.SetAdoConnection( &m_pFCAddress->m_pMainFrame->m_adoConnection ); m_strDefName = m_pFCAddress->m_pMainFrame->m_Setup.szDEF_Name; break; case 4: m_pFSAddress = (CFSAddress *)m_pParent; m_AdoRS.SetAdoConnection( &m_pFSAddress->m_pMainFrame->m_adoConnection ); m_strDefName = m_pFSAddress->m_pMainFrame->m_Setup.szDEF_Name; break; case 5: m_pFGAddress = (CFGAddress2 *)m_pParent; m_strDefName = m_pFGAddress->m_pMainFrame->m_Setup.szDEF_Name; break; case 6: m_pFBack = (CFBack *)m_pParent; break; case 7: m_pDlgSendFax = (DLG_SendFax *)m_pParent; break; case 8: m_pDlgSendMms = (DLG_SendMms *)m_pParent; break; case 9: m_pTDSet = (CFTDSet *)m_pParent; break; case 10: m_pPLFile = (DLG_PLFile_Add *)m_pParent; break; case 11: m_pQXBox_GroupDlg = (DLG_QXBox_Group_Modify *)m_pParent; break; case 12: m_pWhite2 = (DLG_White2 *)m_pParent; break; } } void DLG_User_InportP2::OnUserInportGetfile() { #define FILE_FILTER_TEXT \ TEXT("Excel xls 文件 (*.xls,*.xlsx)\0*.xls\0*.xlsx\0")\ TEXT("Excel csv 文件 (*.csv)\0*.csv\0")\ TEXT("txt文本文件 (*.txt)\0*.txt\0")\ TEXT("所有文件 (*.*)\0*.*;\0\0") TCHAR szFile[ 256 ]; TCHAR szFileB[ 256 ]; *szFileB = NULL; _stprintf( szFile , _T("*.xls") ); OPENFILENAME sOpen; sOpen.lStructSize = sizeof( sOpen ); sOpen.hwndOwner = this->m_hWnd ; sOpen.Flags = OFN_EXPLORER|OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY; sOpen.lpstrFilter = FILE_FILTER_TEXT; sOpen.lpstrDefExt = _T("txt"); sOpen.lpstrCustomFilter = NULL; sOpen.nMaxCustFilter = 0; sOpen.lpstrFile = szFile; sOpen.nMaxFile = sizeof( szFile ); sOpen.lpstrFileTitle = szFileB; sOpen.nMaxFileTitle = sizeof( szFileB ); sOpen.lpstrInitialDir = NULL; sOpen.lpstrTitle = _T("打开导入的文件"); if ( ::GetOpenFileName( &sOpen ) ) { CString strName = sOpen.lpstrFile; CString strTemp = strName; CString strTemp2; strTemp.MakeUpper(); //读入前10行 if ( strTemp.Find(_T(".XLS"))>0 || strTemp.Find(_T(".XLSX"))>0 ) //为Excel格式的文件 { CStringArray strAllTable; long lTabCount=0; CString strTable; CAdoConnection adoConnect; CAdoRecordSet adoRS; CAdoRecordSet rset; CLuExcel excel; long lExcelOpenType=0; //0-使用Excel控件打开,1-使用ado打开 if ( excel.Open(strName ) ) //先使用Excel打开,如果打不再,再采用数据库方式打开 { lTabCount = excel.GetSheets(strAllTable); lExcelOpenType = 0; } else { //第一步,连接到Excel数据库 if ( !adoConnect.ConnectExcel(strName) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); return ; } //查找第一个工作区 //创建QueryLog表 rset = adoConnect.OpenSchema(adSchemaColumns); while(!rset.IsEOF() && lTabCount<100) { rset.GetCollect( _T("TABLE_NAME") , strTable ); strTable.Replace( _T("$") , _T("")); strTable.Replace( _T("'") , _T("") ); if ( lTabCount>0 ) { strTemp = strAllTable.GetAt(lTabCount-1); if ( _tcscmp(strTable,strTemp) )\ { lTabCount++; strAllTable.Add(strTable); } } else { lTabCount++; strAllTable.Add(strTable); } rset.MoveNext(); } rset.Close(); lExcelOpenType = 1; //使用ado打开 } strTable = strAllTable.GetAt(0); if ( strAllTable.GetSize()>1 ) //选择多个表 { DLG_SelSheet dlg(this); dlg.SetParam(&strAllTable); if ( dlg.DoModal()==IDOK ) { strTable = dlg.m_strTable; } else { return ; } } m_strTable = strTable; //取记录数据 long lCountA = 0; if ( lExcelOpenType ==0 ) { excel.SelectSheet(m_strTable); lCountA = excel.GetRowCount(); m_lColCount = excel.GetColCount(); } else { adoRS.SetAdoConnection(&adoConnect); strTemp.Format( _T("SELECT * FROM [%s$A1:IV65536]") , strTable ); if ( !adoRS.Open(strTemp) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); return ; } lCountA = adoRS.GetRecordCount(); m_lColCount=adoRS.GetFieldsCount(); //列数 adoRS.MoveFirst(); } if ( lCountA<=0 || m_lColCount<=0) { strTemp=_T("没找到任何记录,可能是空文件,请检查!"); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); return ; } //清空列表 m_wndList.DeleteAllItems(); for ( int i=0 ; i<60 ; i++ ) m_wndList.DeleteColumn(60-i); long lLineCount=0; long lCount2 = 0; while (lCount210) break; if (lExcelOpenType ==1) //ado打开方式 { adoRS.MoveNext(); if ( adoRS.IsEOF() ) break; } } if (lExcelOpenType ==1) //ado打开方式 { adoRS.Close(); adoConnect.Close(); } m_E_FileName.SetWindowText(sOpen.lpstrFile); //清空选择 for ( i=0 ; i< m_lField ; i++ ) { m_Field[i].lDesIndex = -1; } } else { //打开文件  CFile fTalk; if ( !fTalk.Open( strName , CFile::modeRead ) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); return ; } //清空列表 m_wndList.DeleteAllItems(); for ( int i=0 ; i<60 ; i++ ) m_wndList.DeleteColumn(i); TCHAR szPNBuf[512]; TCHAR szName[512]; long lLineCount=0; m_lColCount=60; //默认有60列 BYTE * pFileReadBuf = new BYTE[1024]; //2M缓冲 long lFileReadBufLen=0; #ifdef UNICODE TCHAR szTemp[512]={0}; char szTempA[512]={0}; char szPNBuf2[512]={0}; #endif while (true) { memset( szPNBuf , 0 , sizeof( szPNBuf ) ); #ifdef UNICODE if ( ReadLine( &fTalk , "\n", szPNBuf2 , sizeof( szPNBuf2 )-5, pFileReadBuf,lFileReadBufLen) ) { _tcscpy(szPNBuf,CAdoRecordSet::Ado_A2W(szPNBuf2,szTemp)); #else if ( ReadLine( &fTalk , "\n" , szPNBuf , sizeof( szPNBuf )-5, pFileReadBuf,lFileReadBufLen ) ) //读入一行 { #endif ExChar( szPNBuf , _T("\r") ); ExChar( szPNBuf , _T("\n") ); _tcscat(szPNBuf,_T(",")); for ( i=0 ; i10) break; } fTalk.Close(); delete pFileReadBuf; } m_E_FileName.SetWindowText(sOpen.lpstrFile); //清空选择 for ( int i=0 ; i< m_lField ; i++ ) { m_Field[i].lDesIndex = -1; } return ; } } long DLG_User_InportP2::ReadLine(CFile *file, char *pSplit, char *szBuf, long lLen , BYTE * pFileBuf , long & lFileBufLen) { int i,j; int lLineCount = 0; int lSplitLen = strlen(pSplit); char c; i = 0; while ( true ) { j = file->Read( &c , 1 ); if ( j < 1 ) { szBuf[i]=0; return i; } if ( i >= lLen-1 ) { szBuf[i] = 0; return i; } szBuf[i] = c; i++; if ( !memcmp( szBuf+i-lSplitLen , pSplit , lSplitLen ) ) //换行标志 { szBuf[i] = 0; return i; } } return 0; } BOOL DLG_User_InportP2::OnInitDialog() { CDialog::OnInitDialog(); //设置成热激活形式 m_wndList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); //if ( m_lInportType != 0 && m_lInportType != 3) //不显示检查重复选项 if ( m_lInportType==0 || m_lInportType==3 ||m_lInportType==4 ) { ; } else { m_B_ReMobile.ShowWindow(SW_HIDE); m_B_Birthday.ShowWindow(SW_HIDE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DLG_User_InportP2::OnColumnclickUserInportList(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; *pResult = 0; m_lCurCol = pNMListView->iSubItem; CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu(MF_STRING , MENU_INPORTP_FIRST , _T(" 不导入 ") ); menu.AppendMenu(MF_SEPARATOR ); for ( int i=0 ;iClientToScreen( &pt); menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON,pt.x,pt.y, this, NULL); menu.DestroyMenu(); } void DLG_User_InportP2::On_User_SelField(UINT nID) { UINT nID2=MENU_INPORTP_FIRST; //先找到现在Col使用的项目 for ( int i=0 ; i< m_lField ; i++ ) { if ( m_Field[i].lDesIndex == m_lCurCol ) { m_Field[i].lDesIndex = -1; break; } } if ( nID == nID2 ) { LVCOLUMN lvcol; lvcol.mask = LVCF_TEXT; lvcol.pszText =_T(" "); m_wndList.SetColumn(m_lCurCol , &lvcol ); return ; } UINT lIndex = (nID - nID2)-1; m_Field[lIndex].lDesIndex = m_lCurCol; LVCOLUMN lvcol; lvcol.mask = LVCF_TEXT; lvcol.pszText = m_Field[lIndex].szName; m_wndList.SetColumn(m_lCurCol , &lvcol ); } void DLG_User_InportP2::On_User_All() { for ( int i=0 ; iInport(); } catch(...) { } return 0; } void DLG_User_InportP2::Inport() { CString strFileName; BOOL m_bReMobile = m_B_ReMobile.GetCheck(); BOOL m_bBirthday = m_B_Birthday.GetCheck(); BOOL m_bAdd0 = m_B_Add0.GetCheck(); m_E_FileName.GetWindowText(strFileName); if ( strFileName.GetLength() <=0 ) { MessageBox( _T("请先选择导入的文件名!"),_T("错误"),MB_ICONWARNING ); return ; } for ( int i=0 ; i< m_lField ; i++ ) { if ( m_Field[i].lDesIndex>=0 ) { break; } } if ( i>=m_lField ) { MessageBox( _T("请先在左边列表中选择相应的导入字段!"),_T("错误"),MB_ICONWARNING ); return ; } //生成序号与字段对应表 long lDYField[60]={0}; for ( int j= 0 ; j<60 ; j++ ) { lDYField[j]=-1; for ( int i=0 ; i0 || strTemp.Find(_T(".XLSX"))>0) //为Excel格式的文件 { //第一步,连接到Excel数据库 CAdoConnection adoConnect; CAdoRecordSet adoRS; CLuExcel excel; long lExcelOpenType=0; //0-使用Excel控件打开,1-使用ado打开 long lCountA=0; if ( excel.Open(strFileName ) && excel.SelectSheet(m_strTable)) //先使用Excel打开,如果打不再,再采用数据库方式打开 { lCountA = excel.GetRowCount(); m_lColCount = excel.GetColCount(); lExcelOpenType = 0; } else { if ( !adoConnect.ConnectExcel(strFileName) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strFileName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); m_DlgProcess.SetProcess( 100 , 100 ); m_bShowProcess = false; return ; } adoRS.SetAdoConnection(&adoConnect); strTemp.Format( _T("SELECT * FROM [%s$A1:IV65536]") , m_strTable ); if ( !adoRS.Open(strTemp) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strFileName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); m_DlgProcess.SetProcess( 100 , 100 ); m_bShowProcess = false; return ; } lCountA = adoRS.GetRecordCount(); m_lColCount=adoRS.GetFieldsCount(); //列数 adoRS.MoveFirst(); lExcelOpenType = 1; } if ( lCountA<=0 || m_lColCount<=0) { strTemp=_T("没找到任何记录,可能是空文件,请检查!"); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); m_DlgProcess.SetProcess( 100 , 100 ); m_bShowProcess = false; return ; } //清空列表 m_wndList.DeleteAllItems(); for ( int i=0 ; i<60 ; i++ ) m_wndList.DeleteColumn(60-i); long lLineCount=0; long lCount2 = 0; TCHAR szName[1024]={0}; long lNameCount=0; BOOL bShowReMobile = true; long lReMobileType = 0; CString str; PAddress user={0}; CKAddress Cuser={0}; CSAddress Suser={0}; Send_User Luser={0}; PLUser PLuser={0}; while (lCount20 ) { // AfxMessageBox(strTemp); strTemp.TrimLeft(); strTemp.TrimRight(); //strTemp.Replace( _T("\r") , _T("") ); //strTemp.Replace( _T("\n") , _T("") ); //strTemp.Replace( _T("\t") , _T("") ); strTemp.Replace( _T(".00000000") , _T("") ); //去掉小数点后面的位数 //strTemp.Replace( _T("'") , _T("''" )); memset(&szName,0,sizeof(szName)); _tcscpy(szName , strTemp); switch (lDYField[i]) { case 0: //姓名 switch ( m_lInportType ) { case 0: case 1: case 5: BreakChar(szName,sizeof(user.szName)-1); _tcscpy(user.szName , szName ); break; case 2: case 7: case 8: case 11: BreakChar(szName,sizeof(Luser.szName)-1); _tcscpy(Luser.szName , szName ); break; case 3: //车主 BreakChar(szName,sizeof(Cuser.szName)-1); _tcscpy(Cuser.szName , szName ); break; case 4: //客户编号 BreakChar(szName,sizeof(Suser.szBH)-1); _tcscpy(Suser.szBH , szName ); break; } break; case 1: //昵称 switch ( m_lInportType ) { case 0: case 1: case 5: BreakChar(szName,sizeof(user.szNickName)-1); _tcscpy(user.szNickName , szName ); break; case 2: BreakChar(szName,sizeof(Luser.szNickName)-1); _tcscpy(Luser.szNickName , szName ); break; case 3: //车牌 BreakChar(szName,sizeof(Cuser.szCarNum)-1); _tcscpy(Cuser.szCarNum , szName ); break; case 4: //姓 名 BreakChar(szName,sizeof(Suser.szName)-1); _tcscpy(Suser.szName , szName ); break; } break; case 2: //性别 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: //BreakChar(szName,sizeof(user.szSex)-1); BreakChar(szName,2); _tcscpy(user.szSex , szName ); break; case 3: //车型 BreakChar(szName,sizeof(Cuser.szCarType)-1); _tcscpy(Cuser.szCarType , szName ); break; case 4: //昵 称 BreakChar(szName,sizeof(Suser.szNickName)-1); _tcscpy(Suser.szNickName , szName ); break; } break; case 3: //生日 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(user.tBirthday); } } catch(...) { memset(&user.tBirthday,0,sizeof(user.tBirthday)); } break; case 3: //发动机号 BreakChar(szName,sizeof(Cuser.szFDJNum)-1); _tcscpy(Cuser.szFDJNum , szName ); break; case 4: //性 别 BreakChar(szName,sizeof(Suser.szSex)-1); _tcscpy(Suser.szSex , szName ); break; } break; case 4: //公司 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szLtd)-1); _tcscpy( user.szLtd , szName ); break; case 3: //底盘号 BreakChar(szName,sizeof(Cuser.szDPNum)-1); _tcscpy(Cuser.szDPNum , szName ); break; case 4: //生 日 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tBirthday); } } catch(...) { memset(&Suser.tBirthday,0,sizeof(Suser.tBirthday)); } break; } break; case 5: //职务 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szJob)-1); _tcscpy( user.szJob , szName ); break; case 3: //购车日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBuyDate); } } catch(...) { memset(&Cuser.tBuyDate,0,sizeof(Cuser.tBuyDate)); } break; case 4: //入会日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tInDate); } } catch(...) { memset(&Suser.tInDate,0,sizeof(Suser.tInDate)); } break; } break; case 6: //地址 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szAddress)-1); _tcscpy( user.szAddress , szName ); break; case 3: //保险日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBXDate); } } catch(...) { memset(&Cuser.tBXDate,0,sizeof(Cuser.tBXDate)); } break; case 4: //截止日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tOutDate); } } catch(...) { memset(&Suser.tOutDate,0,sizeof(Suser.tOutDate)); } break; } break; case 7: //手机 switch ( m_lInportType ) { case 0: case 1: case 5: case 6: case 9: case 12: { BreakChar(szName,sizeof(user.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") || str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") ||str==_T("16") || str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( user.szMobile , szName ); } else { _stprintf(user.szMobile , _T("0%s") , szName ); } } break; case 2: case 7: { BreakChar(szName,sizeof(Luser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") ) { _tcscpy( Luser.szMobile , szName ); } else { _stprintf(Luser.szMobile , _T("0%s") , szName ); } } break; case 8: case 11: { BreakChar(szName,sizeof(Luser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") ||str==_T("16") ||str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( Luser.szMobile , szName ); } } break; case 3: //联系人1 BreakChar(szName,sizeof(Cuser.szLXR)-1); _tcscpy(Cuser.szLXR , szName ); break; case 4: //联系电话 BreakChar(szName,sizeof(Suser.szTel)-1); _tcscpy(Suser.szTel , szName ); break; case 10: BreakChar(szName,sizeof(PLuser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") || str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") ||str==_T("16") || str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( PLuser.szMobile , szName ); } else { _stprintf(PLuser.szMobile , _T("0%s") , szName ); } break; } break; case 8: //电话 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szTel)-1); _tcscpy( user.szTel , szName ); break; case 3: //手机1 BreakChar(szName,sizeof(Cuser.szMobile)-1); _tcscpy(Cuser.szMobile , szName ); break; case 4: //手机号码 BreakChar(szName,sizeof(Suser.szMobile)-1); _tcscpy(Suser.szMobile , szName ); break; } break; case 9: //电话 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szFax)-1); _tcscpy( user.szFax , szName ); break; case 3: //电话1 BreakChar(szName,sizeof(Cuser.szTel)-1); _tcscpy(Cuser.szTel , szName ); break; case 4: //Email BreakChar(szName,sizeof(Suser.szEmail)-1); _tcscpy(Suser.szEmail , szName ); break; } break; case 10: //Email switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szEmail)-1); _tcscpy( user.szEmail , szName ); break; case 3: //地址1 BreakChar(szName,sizeof(Cuser.szAddr)-1); _tcscpy(Cuser.szAddr , szName ); break; case 4: //地址 BreakChar(szName,sizeof(Suser.szAddr)-1); _tcscpy(Suser.szAddr , szName ); break; } break; case 11: //QQ switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szQQ)-1); _tcscpy( user.szQQ , szName ); break; case 3: //邮编1 BreakChar(szName,sizeof(Cuser.szPostcode)-1); _tcscpy(Cuser.szPostcode , szName ); break; case 4: //业务员 BreakChar(szName,sizeof(Suser.szYWY)-1); _tcscpy(Suser.szYWY , szName ); break; } break; case 12: //BZ switch ( m_lInportType ) { case 0: case 1: case 5: case 6: case 9: BreakChar(szName,sizeof(user.szBZ)-1); _tcscpy( user.szBZ , szName ); break; case 2: BreakChar(szName,sizeof(Luser.szBZ)-1); _tcscpy( Luser.szBZ , szName ); break; case 3: //单位1 BreakChar(szName,sizeof(Cuser.szCorp)-1); _tcscpy(Cuser.szCorp , szName ); break; case 4: //金额 BreakChar(szName,sizeof(Suser.szPrice)-1); _tcscpy(Suser.szPrice , szName ); break; case 10: BreakChar(szName,sizeof(PLuser.szBZ)-1); _tcscpy( PLuser.szBZ , szName ); break; } break; case 13: switch ( m_lInportType ) { case 3: //生日1 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBirthday); } } catch(...) { memset(&Cuser.tBirthday,0,sizeof(Cuser.tBirthday)); } break; case 4: //备注 BreakChar(szName,sizeof(Suser.szBZ)-1); _tcscpy(Suser.szBZ , szName ); break; case 6: BreakChar(szName,sizeof(user.szTel)-1); _tcscpy( user.szTel , szName ); break; } break; case 14: switch ( m_lInportType ) { case 3: //联系人2 BreakChar(szName,sizeof(Cuser.szLXR2)-1); _tcscpy(Cuser.szLXR2 , szName ); break; } break; case 15: switch ( m_lInportType ) { case 3: //手机2 BreakChar(szName,sizeof(Cuser.szMobile2)-1); _tcscpy(Cuser.szMobile2 , szName ); break; } break; case 16: switch ( m_lInportType ) { case 3: //电话2 BreakChar(szName,sizeof(Cuser.szTel2)-1); _tcscpy(Cuser.szTel2 , szName ); break; } break; case 17: switch ( m_lInportType ) { case 3: //地址2 BreakChar(szName,sizeof(Cuser.szAddr2)-1); _tcscpy(Cuser.szAddr2 , szName ); break; } break; case 18: switch ( m_lInportType ) { case 3: //邮编2 BreakChar(szName,sizeof(Cuser.szPostcode2)-1); _tcscpy(Cuser.szPostcode2 , szName ); break; } break; case 19: switch ( m_lInportType ) { case 3: //单位2 BreakChar(szName,sizeof(Cuser.szCorp2)-1); _tcscpy(Cuser.szCorp2 , szName ); break; } break; case 20: switch ( m_lInportType ) { case 3: //生日2 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBirthday2); } } catch(...) { memset(&Cuser.tBirthday2,0,sizeof(Cuser.tBirthday2)); } break; } break; case 21: switch ( m_lInportType ) { case 3: //联系人2 BreakChar(szName,sizeof(Cuser.szBZ)-1); _tcscpy(Cuser.szBZ , szName ); break; } break; } } } BOOL bInvolid=false; switch ( m_lInportType ) { case 0: case 1: case 5: if (_tcslen(user.szName) >0 || _tcslen(user.szTel) >0 || _tcslen(user.szMobile) >0) bInvolid = true; break; case 6: case 9: case 12: ExMobileGZM(user.szMobile); //去除国际码 bInvolid = isMobileNum( user.szMobile ); //找到新号码 break; case 2: case 7: case 8: case 11: if ( _tcslen(Luser.szMobile) >0) bInvolid = true; break; case 3: //联系人2 if (_tcslen(Cuser.szName) >0 || _tcslen(Cuser.szCarNum) >0 || _tcslen(Cuser.szMobile) >0 || _tcslen(Cuser.szMobile2) >0 ) bInvolid = true; break; case 4: //联系人2 if (_tcslen(Suser.szName) >0 || _tcslen(Suser.szTel) >0 || _tcslen(Suser.szMobile) >0 ) bInvolid = true; break; case 10: ExMobileGZM(PLuser.szMobile); //去除国际码 bInvolid = isMobileNum( PLuser.szMobile ); //找到新号码 break; } if ( bInvolid ) { if (_tcslen(user.szName) <= 0) { if (m_strDefName.GetLength() <= 0) _stprintf(user.szName, _T("IP%d"), lNameCount); else _stprintf(user.szName, m_strDefName); } //添加用户 lNameCount ++; //_stprintf( szName , _T("现正处理->%d") , lNameCount ); //m_B_Tips.SetWindowText( szName ); switch ( m_lInportType ) { case 0: //私人电话本 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( user.szMobile ) > 0 ) { if ( _tcslen(m_pFPAddress->m_szGroupID)<=0) str.Format( _T("select * from paddress where Mobile='%s' and (GroupID is null or len(GroupID)=0) order by mobile ") , user.szMobile ); else str.Format( _T("select * from paddress where Mobile='%s' and GroupID='%s' order by mobile ") , user.szMobile,m_pFPAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && !m_AdoRS.IsEOF() ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , user.szName , user.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } #ifdef MOBSET_OEM_SNLD if ( _tcslen(user.szMobile)<=0 ) //仙妮雷德专版,自动从根目录读取用户手机号 { str.Format( _T("select * from paddress where Name='%s' and (GroupID is null or len(GroupID)=0)") , user.szName ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { m_AdoRS.MoveFirst(); m_AdoRS.GetCollect( _T("Mobile") , user.szMobile ); m_AdoRS.Close(); } } #endif if ( bAdd ) { _tcscpy( user.szUserType,_T("1") ); //用户类型 _tcscpy( user.szGroupID , m_pFPAddress->m_szGroupID); //用户组 m_pFPAddress->AddUser(user,false); } } break; case 1: //公用通讯录 case 5: { PAddress * pUser = new PAddress; *pUser = user; m_User.AddTail( pUser ); } break; case 2: //发送列表 { //添加用户 m_pDlgSend->AddUser(Luser , -1); } break; case 7: //发送列表 { //添加用户 m_pDlgSendFax->AddUser(Luser , -1); } break; case 8: //发送列表 { //添加用户 m_pDlgSendMms->AddUser(Luser , -1); } break; case 11: //发送列表 { //添加用户 m_pQXBox_GroupDlg->AddUser(Luser , -1); } break; case 3: //汽车通讯录 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( Cuser.szMobile ) > 0 ) { if ( _tcslen(m_pFCAddress->m_szGroupID)<=0) str.Format( _T("select * from caddress where Mobile='%s' and (GroupID is null or len(GroupID)=0)") , Cuser.szMobile ); else str.Format( _T("select * from caddress where Mobile='%s' and GroupID='%s'") , Cuser.szMobile,m_pFCAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , Cuser.szName , Cuser.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } if ( bAdd ) { _tcscpy( Cuser.szUserType,_T("1") ); //用户类型 _tcscpy( Cuser.szGroupID , m_pFCAddress->m_szGroupID); //用户组 m_pFCAddress->AddUser(Cuser,false); } } break; case 4: //证券通讯录 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( Suser.szMobile ) > 0 ) { if ( _tcslen(m_pFSAddress->m_szGroupID)<=0) str.Format( _T("select * from saddress where Mobile='%s' and (GroupID is null or len(GroupID)=0)") , Suser.szMobile ); else str.Format( _T("select * from saddress where Mobile='%s' and GroupID='%s'") , Suser.szMobile,m_pFSAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , Suser.szName , Suser.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } if ( bAdd ) { _tcscpy( Suser.szUserType,_T("1") ); //用户类型 _tcscpy( Suser.szGroupID , m_pFSAddress->m_szGroupID); //用户组 m_pFSAddress->AddUser(Suser,false); } } break; case 6: //黑名单 { //添加用户 m_pFBack->AddUser(user , -1); } break; case 9: //通道绑定 { //添加用户 m_pTDSet->AddUser(user , -1); } break; case 10: //号码文件 { //添加用户 m_pPLFile->AddUser(PLuser , -1); } break; case 12: //白名单 { //添加用户 m_pWhite2->AddUser(user , -1); } break; } } lLineCount ++; lCount2 ++; if ( m_bShowProcess ) { m_DlgProcess.SetProcess( lCountA+1,lCount2 ); if ( lCountA+1 <= lCount2 ) //如果相等就是已经结束 { m_bShowProcess = false; } } if (lExcelOpenType == 1 ) //ado方式 { adoRS.MoveNext(); if (adoRS.IsEOF() ) break; } } if (lExcelOpenType == 1 ) //ado方式 { adoRS.Close(); adoConnect.Close(); } } else { //打开文件  CFile fTalk; if ( !fTalk.Open( strFileName , CFile::modeRead ) ) { strTemp.Format(_T("打开文件:%s\n产生错误!") , strFileName ); MessageBox( strTemp , _T("错误") , MB_ICONWARNING|MB_OK ); m_DlgProcess.SetProcess( 100 , 100 ); m_bShowProcess = false; return ; } //清空列表 TCHAR szPNBuf[1024]; TCHAR szName[1024]; long lLineCount=0; long lNameCount=0; BOOL bShowReMobile = true; long lReMobileType = 0; CString str; #ifdef UNICODE TCHAR szTemp[512]={0}; char szTempA[512]={0}; char szPNBuf2[512]={0}; #endif PAddress user; CKAddress Cuser; CSAddress Suser; Send_User Luser; PLUser PLuser; //BYTE * pFileReadBuf = new BYTE[2*1024*1024]; //2M缓冲 BYTE * pFileReadBuf = new BYTE[1024]; //2M缓冲 long lFileReadBufLen=0; while (m_bShowProcess) { memset( szPNBuf , 0 , sizeof( szPNBuf ) ); #ifdef UNICODE if ( ReadLine( &fTalk , "\n", szPNBuf2 , sizeof( szPNBuf2 )-5 , pFileReadBuf,lFileReadBufLen ) ) { _tcscpy(szPNBuf,CAdoRecordSet::Ado_A2W(szPNBuf2,szTemp)); #else if ( ReadLine( &fTalk , "\n" , szPNBuf , sizeof( szPNBuf )-5 , pFileReadBuf,lFileReadBufLen ) ) //读入一行 { #endif ExChar( szPNBuf , _T("\r") ); ExChar( szPNBuf , _T("\n") ); _tcscat(szPNBuf,_T(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,")); memset(&user,0,sizeof(user)); memset(&Cuser,0,sizeof(Cuser)); memset(&Suser,0,sizeof(Suser)); memset(&Luser,0,sizeof(Luser)); memset(&PLuser,0,sizeof(PLuser)); for ( i=0 ; i0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(user.tBirthday); } } catch(...) { memset(&user.tBirthday,0,sizeof(user.tBirthday)); } break; case 3: //发动机号 BreakChar(szName,sizeof(Cuser.szFDJNum)-1); _tcscpy(Cuser.szFDJNum , szName ); break; case 4: //性 别 BreakChar(szName,sizeof(Suser.szSex)-1); _tcscpy(Suser.szSex , szName ); break; } break; case 4: //公司 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szLtd)-1); _tcscpy( user.szLtd , szName ); break; case 3: //底盘号 BreakChar(szName,sizeof(Cuser.szDPNum)-1); _tcscpy(Cuser.szDPNum , szName ); break; case 4: //生 日 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tBirthday); } } catch(...) { memset(&Suser.tBirthday,0,sizeof(Suser.tBirthday)); } break; } break; case 5: //职务 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szJob)-1); _tcscpy( user.szJob , szName ); break; case 3: //购车日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBuyDate); } } catch(...) { memset(&Cuser.tBuyDate,0,sizeof(Cuser.tBuyDate)); } break; case 4: //入会日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") ,_T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tInDate); } } catch(...) { memset(&Suser.tInDate,0,sizeof(Suser.tInDate)); } break; } break; case 6: //地址 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szAddress)-1); _tcscpy( user.szAddress , szName ); break; case 3: //保险日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBXDate); } } catch(...) { memset(&Cuser.tBXDate,0,sizeof(Cuser.tBXDate)); } break; case 4: //截止日期 try { BreakChar(szName,sizeof(user.szNickName)-1); COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Suser.tOutDate); } } catch(...) { memset(&Suser.tOutDate,0,sizeof(Suser.tOutDate)); } break; } break; case 7: //手机 switch ( m_lInportType ) { case 0: case 1: case 5: case 6: case 9: case 12: { BreakChar(szName,sizeof(user.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") || str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") || str==_T("16") ||str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( user.szMobile , szName ); } else { _stprintf(user.szMobile , _T("0%s") , szName ); } } break; case 2: case 7: { BreakChar(szName,sizeof(Luser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") ) { _tcscpy( Luser.szMobile , szName ); } else { _stprintf(Luser.szMobile , _T("0%s") , szName ); } } case 8: case 11: { BreakChar(szName,sizeof(Luser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") ||str==_T("16") ||str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( Luser.szMobile , szName ); } } break; case 3: //联系人1 BreakChar(szName,sizeof(Cuser.szLXR)-1); _tcscpy(Cuser.szLXR , szName ); break; case 4: //联系电话 BreakChar(szName,sizeof(Suser.szTel)-1); _tcscpy(Suser.szTel , szName ); break; case 10: { BreakChar(szName,sizeof(PLuser.szMobile)-1); ExMobileGZM(szName); //去除国际码 CString strTemp,str,str1; strTemp=szName; str = strTemp.Left(2); str1= strTemp.Left(1); if (!m_bAdd0 || str1==_T("0") || str == _T("12") || str == _T("13") || str == _T("14") || str==_T("15") || str==_T("16") ||str==_T("17") || str==_T("18") || str==_T("19") ) { _tcscpy( PLuser.szMobile , szName ); } else { _stprintf(PLuser.szMobile , _T("0%s") , szName ); } } break; } break; case 8: //电话 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szTel)-1); _tcscpy( user.szTel , szName ); break; case 3: //手机1 BreakChar(szName,sizeof(Cuser.szMobile)-1); _tcscpy(Cuser.szMobile , szName ); break; case 4: //手机号码 BreakChar(szName,sizeof(Suser.szMobile)-1); _tcscpy(Suser.szMobile , szName ); break; } break; case 9: //电话 switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szFax)-1); _tcscpy( user.szFax , szName ); break; case 3: //电话1 BreakChar(szName,sizeof(Cuser.szTel)-1); _tcscpy(Cuser.szTel , szName ); break; case 4: //Email BreakChar(szName,sizeof(Suser.szEmail)-1); _tcscpy(Suser.szEmail , szName ); break; } break; case 10: //Email switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szEmail)-1); _tcscpy( user.szEmail , szName ); break; case 3: //地址1 BreakChar(szName,sizeof(Cuser.szAddr)-1); _tcscpy(Cuser.szAddr , szName ); break; case 4: //地址 BreakChar(szName,sizeof(Suser.szAddr)-1); _tcscpy(Suser.szAddr , szName ); break; } break; case 11: //QQ switch ( m_lInportType ) { case 0: case 1: case 2: case 5: BreakChar(szName,sizeof(user.szQQ)-1); _tcscpy( user.szQQ , szName ); break; case 3: //邮编1 BreakChar(szName,sizeof(Cuser.szPostcode)-1); _tcscpy(Cuser.szPostcode , szName ); break; case 4: //业务员 BreakChar(szName,sizeof(Suser.szYWY)-1); _tcscpy(Suser.szYWY , szName ); break; } break; case 12: //BZ switch ( m_lInportType ) { case 0: case 1: case 5: case 6: case 9: BreakChar(szName,sizeof(user.szBZ)-1); _tcscpy( user.szBZ , szName ); break; case 2: BreakChar(szName,sizeof(Luser.szBZ)-1); _tcscpy( Luser.szBZ , szName ); break; case 3: //单位1 BreakChar(szName,sizeof(Cuser.szCorp)-1); _tcscpy(Cuser.szCorp , szName ); break; case 4: //金额 BreakChar(szName,sizeof(Suser.szPrice)-1); _tcscpy(Suser.szPrice , szName ); break; case 10: BreakChar(szName,sizeof(PLuser.szBZ)-1); _tcscpy( PLuser.szBZ , szName ); break; } break; case 13: switch ( m_lInportType ) { case 3: //生日1 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBirthday); } } catch(...) { memset(&Cuser.tBirthday,0,sizeof(Cuser.tBirthday)); } break; case 4: //备注 BreakChar(szName,sizeof(Suser.szBZ)-1); _tcscpy(Suser.szBZ , szName ); break; case 6: BreakChar(szName,sizeof(user.szTel)-1); _tcscpy( user.szTel , szName ); break; } break; case 14: switch ( m_lInportType ) { case 3: //联系人2 BreakChar(szName,sizeof(Cuser.szLXR2)-1); _tcscpy(Cuser.szLXR2 , szName ); break; } break; case 15: switch ( m_lInportType ) { case 3: //手机2 BreakChar(szName,sizeof(Cuser.szMobile2)-1); _tcscpy(Cuser.szMobile2 , szName ); break; } break; case 16: switch ( m_lInportType ) { case 3: //电话2 BreakChar(szName,sizeof(Cuser.szTel2)-1); _tcscpy(Cuser.szTel2 , szName ); break; } break; case 17: switch ( m_lInportType ) { case 3: //地址2 BreakChar(szName,sizeof(Cuser.szAddr2)-1); _tcscpy(Cuser.szAddr2 , szName ); break; } break; case 18: switch ( m_lInportType ) { case 3: //邮编2 BreakChar(szName,sizeof(Cuser.szPostcode2)-1); _tcscpy(Cuser.szPostcode2 , szName ); break; } break; case 19: switch ( m_lInportType ) { case 3: //单位2 BreakChar(szName,sizeof(Cuser.szCorp2)-1); _tcscpy(Cuser.szCorp2 , szName ); break; } break; case 20: switch ( m_lInportType ) { case 3: //生日2 BreakChar(szName,sizeof(user.szNickName)-1); if ( m_bBirthday ) { CString strSFZ=szName; //从身份证号码中导入生日 CString strBir1; CString strBir2; if ( strSFZ.GetLength() == 15 ) { strBir1 = strSFZ.Mid(6,6); strBir1 = CString(_T("19"))+strBir1; } if ( strSFZ.GetLength() == 18 ) { strBir1 = strSFZ.Mid(6,8); } if ( strBir1.GetLength()>0 ) { strBir2 = strBir1.Left(4)+CString(_T("-"))+strBir1.Mid(4,2)+CString(_T("-"))+strBir1.Right(2); _tcscpy(szName,strBir2); } } try { COleDateTime abc; CString str = szName; str.Replace( _T(".") , _T("-") ); BOOL btime = abc.ParseDateTime(str,VAR_DATEVALUEONLY); if ( abc.GetStatus() == COleDateTime::valid ) { abc.GetAsSystemTime(Cuser.tBirthday2); } } catch(...) { memset(&Cuser.tBirthday2,0,sizeof(Cuser.tBirthday2)); } break; } break; case 21: switch ( m_lInportType ) { case 3: //联系人2 BreakChar(szName,sizeof(Cuser.szBZ)-1); _tcscpy(Cuser.szBZ , szName ); break; } break; } } else { break; } } BOOL bInvolid=false; switch ( m_lInportType ) { case 0: case 1: case 5: if (_tcslen(user.szName) >0 || _tcslen(user.szTel) >0 || _tcslen(user.szMobile) >0) bInvolid = true; break; case 6: case 9: case 12: ExMobileGZM(user.szMobile); //去除国际码 bInvolid = isMobileNum( user.szMobile ); //找到新号码 break; case 2: case 7: case 8: case 11: if ( _tcslen(Luser.szMobile) >0) bInvolid = true; break; case 3: //联系人2 if (_tcslen(Cuser.szName) >0 || _tcslen(Cuser.szCarNum) >0 || _tcslen(Cuser.szMobile) >0 || _tcslen(Cuser.szMobile2) >0 ) bInvolid = true; break; case 4: //联系人2 if (_tcslen(Suser.szName) >0 || _tcslen(Suser.szTel) >0 || _tcslen(Suser.szMobile) >0 ) bInvolid = true; break; case 10: ExMobileGZM(PLuser.szMobile); //去除国际码 bInvolid = isMobileNum( PLuser.szMobile ); //找到新号码 break; } if ( bInvolid ) { if (_tcslen(user.szName) <= 0) { if (m_strDefName.GetLength() <= 0) _stprintf(user.szName, _T("IP%d"), lNameCount); else _stprintf(user.szName, m_strDefName); } //添加用户 lNameCount ++; //_stprintf( szName , _T("现正处理->%d") , lNameCount ); //m_B_Tips.SetWindowText( szName ); switch ( m_lInportType ) { case 0: //私人电话本 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( user.szMobile ) > 0 ) { if ( _tcslen(m_pFPAddress->m_szGroupID)<=0) str.Format( _T("select * from paddress where Mobile='%s' and (GroupID is null or len(GroupID)=0) order by Mobile") , user.szMobile ); else str.Format( _T("select * from paddress where Mobile='%s' and GroupID='%s' order by Mobile") , user.szMobile,m_pFPAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && !m_AdoRS.IsEOF() ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , user.szName , user.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } #ifdef MOBSET_OEM_SNLD if ( _tcslen(user.szMobile)<=0 ) //仙妮雷德专版,自动从根目录读取用户手机号 { str.Format( _T("select * from paddress where Name='%s' and (GroupID is null or len(GroupID)=0)") , user.szName ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { m_AdoRS.MoveFirst(); m_AdoRS.GetCollect( _T("Mobile") , user.szMobile ); m_AdoRS.Close(); } } #endif if ( bAdd ) { _tcscpy( user.szUserType,_T("1") ); //用户类型 _tcscpy( user.szGroupID , m_pFPAddress->m_szGroupID); //用户组 m_pFPAddress->AddUser(user,false); } } break; case 1: //公用通讯录 case 5: { PAddress * pUser = new PAddress; *pUser = user; m_User.AddTail( pUser ); } break; case 2: //发送列表 { //添加用户 m_pDlgSend->AddUser(Luser , -1); } break; case 7: //发送列表 { //添加用户 m_pDlgSendFax->AddUser(Luser , -1); } break; case 8: //发送列表 { //添加用户 m_pDlgSendMms->AddUser(Luser , -1); } break; case 11: //发送列表 { //添加用户 m_pQXBox_GroupDlg->AddUser(Luser , -1); } break; case 3: //汽车通讯录 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( Cuser.szMobile ) > 0 ) { if ( _tcslen(m_pFCAddress->m_szGroupID)<=0) str.Format( _T("select * from caddress where Mobile='%s' and (GroupID is null or len(GroupID)=0)") , Cuser.szMobile ); else str.Format( _T("select * from caddress where Mobile='%s' and GroupID='%s'") , Cuser.szMobile,m_pFCAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , Cuser.szName , Cuser.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } if ( bAdd ) { _tcscpy( Cuser.szUserType,_T("1") ); //用户类型 _tcscpy( Cuser.szGroupID , m_pFCAddress->m_szGroupID); //用户组 m_pFCAddress->AddUser(Cuser,false); } } break; case 4: //证券通讯录 { //先检测号码是否存在此组时,如果存在,提示 BOOL bAdd = true; if ( m_bReMobile && _tcslen( Suser.szMobile ) > 0 ) { if ( _tcslen(m_pFSAddress->m_szGroupID)<=0) str.Format( _T("select * from saddress where Mobile='%s' and (GroupID is null or len(GroupID)=0)") , Suser.szMobile ); else str.Format( _T("select * from saddress where Mobile='%s' and GroupID='%s'") , Suser.szMobile,m_pFSAddress->m_szGroupID ); if ( m_AdoRS.Open(str) && m_AdoRS.GetRecordCount()>0 ) { //找到记录,证明有重复的号码 m_AdoRS.Close(); if ( bShowReMobile ) { str.Format( _T("%s,%s") , Suser.szName , Suser.szMobile ); DLG_AddWarning dlg(str,this); //提示重复号码 dlg.DoModal(); bShowReMobile = dlg.m_bShowReMobile; lReMobileType = dlg.m_lReMobileType; } if ( lReMobileType == 0 ) //跳过 { bAdd = false; } } } if ( bAdd ) { _tcscpy( Suser.szUserType,_T("1") ); //用户类型 _tcscpy( Suser.szGroupID , m_pFSAddress->m_szGroupID); //用户组 m_pFSAddress->AddUser(Suser,false); } } break; case 6: //黑名单 { //添加用户 m_pFBack->AddUser(user , -1); } break; case 9: //通道绑定 { //添加用户 m_pTDSet->AddUser(user , -1); } break; case 10: //号码文件 { //添加用户 m_pPLFile->AddUser(PLuser , -1); } break; case 12: //白名单 { //添加用户 m_pWhite2->AddUser(user , -1); } break; } } lLineCount ++; if ( m_bShowProcess ) m_DlgProcess.SetProcess( 99999999,lLineCount ); } else { break; } } fTalk.Close(); delete pFileReadBuf; } if ( m_bShowProcess ) //非人工停止的 { CString str; str.Format( _T("导入成功,共用时%d秒!") , (GetTickCount()-dwBeginTime)/1000 ); m_DlgProcess.MessageBox( str , _T("提示") , MB_ICONINFORMATION ); try { //m_DlgProcess.SetTimer(1,100,NULL); //m_DlgProcess.EndDialog(IDOK); m_DlgProcess.SetProcess( 100 , 100 ); m_bShowProcess = false; } catch(...) { } } } void DLG_User_InportP2::OnBnClickedOk() { try { CString strFileName; BOOL m_bReMobile = m_B_ReMobile.GetCheck(); BOOL m_bBirthday = m_B_Birthday.GetCheck(); m_E_FileName.GetWindowText(strFileName); if ( strFileName.GetLength() <=0 ) { MessageBox( _T("请先选择导入的文件名!"),_T("错误"),MB_ICONWARNING ); return ; } for ( int i=0 ; i< m_lField ; i++ ) { if ( m_Field[i].lDesIndex>=0 ) { break; } } if ( i>=m_lField ) { MessageBox( _T("请先在左边列表中选择相应的导入字段!"),_T("错误"),MB_ICONWARNING ); return ; } m_bShowProcess = true; ::AfxBeginThread((AFX_THREADPROC)Process_T,(LPVOID)this,THREAD_PRIORITY_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/); m_DlgProcess.SetProcessTitle( _T("正在导入...")); m_DlgProcess.SetShowCount(true); if ( m_DlgProcess.DoModal() != IDOK ) //显示进度栏 { m_bShowProcess = false; //导入不成功 return ; } m_bShowProcess = false; this->EndDialog(IDOK); } catch(...) { } //CDialog::OnOK(); }