void CBlokRtf::GetStdPWS(CString strBuf, CStdioFile &inF, CStdioFile &otF, CString strFnd, int &curPrv, CString &strOut) { int tPos,iCnt; CString strWrt,s; inF.ReadString(strBuf); if((tPos = strBuf.Find(strFnd))!=-1){ strWrt = strBuf.Left(tPos); //Считал для записи в цел. файл iCnt = strWrt.GetLength(); // s.Format("после читки curPrv = %i",curPrv); // AfxMessageBox("GetStdPWt "+strFnd+'\n'+"strWrt = "+strWrt +'\n'+ s+'\n'+"strBuf = "+strBuf); // AfxMessageBox(strWrt); strOut+=strWrt; curPrv+=iCnt; //Перемещаю указатель на новою позицию от нач.файла !!! inF.Seek(curPrv,CFile::begin); curPrv = inF.GetPosition(); // s.Format(" после смещения Seek curPrv = %i назад на iCnt = %i",curPrv,iCnt); // AfxMessageBox(s); return;// curPos; } else{ // Не нашёл, можно читать дальше //AfxMessageBox("Не нашёл \n"+strBuf); // otF.WriteString(strBuf); // Записал strOut+=strBuf; curPrv = inF.GetPosition(); GetStdPWS(strBuf, inF, otF, strFnd,curPrv,strOut); return; } }
void COTDKView::gAddDiaInTest(CString csNameNode, CString csBuf, int iCountDT) { LPTSTR p=NULL; DWORD dwPosSch = 0, dwPosO2 = 0; char buf[2]; CString csS, csW, csNameOfFind; CStdioFile Fl; int iCycle = 0; int j = 0, x = 0; int i=1, k=0; COTDKDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // открываем файл диаг.теста для соответствующ. узла Fl.Open(csNameNode + ".dia", CFile::modeReadWrite); //itoa - перевод числа в строку // выбираем # теста itoa(iCountDT,buf,10); csNameOfFind = "ИмяТеста"; csNameOfFind += buf; csNameOfFind.AnsiToOem(); // переводим в OEM стандарт dwPosSch = pDoc->gGetPosString(0, csNameOfFind, &Fl); /*// выбираем место задания количества циклов в тесте csNameOfFind = "ЧислоЦиклов"; csNameOfFind.AnsiToOem(); dwPosSch = pDoc->gGetPosString(dwPosSch, csNameOfFind, &Fl); //выбираем число циклов Fl.Seek((LONG)dwPosSch+10,CFile::begin); Fl.Read(buf, 2); iCycle = atoi(buf);*/ // ищем вхождение первого входного слова = о1 dwPosSch = pDoc->gGetPosString(dwPosSch, "o1=signatura", &Fl); // а в нем ищем вхождение шаблона ffff Fl.ReadString(csS); Fl.ReadString(csS); dwPosSch = Fl.GetPosition(); dwPosO2 = pDoc->gGetPosString(dwPosSch, "o2=counter", &Fl); Fl.ReadString(csS); Fl.ReadString(csS); dwPosO2 = Fl.GetPosition(); // здесь будет часть выбирающая номер цикла и передающая что вставить //dwPosSch = (DWORD)Fl.Seek((LONG)1, CFile::current); iCycle = (int)csBuf.GetLength()/12; while(i <= iCycle) { // берем что писать //j = j + 4; csS = csBuf.Mid(j,4); // берем номер цикла j = j + 4; csW = csBuf.Mid(j,2); j = j + 2; if (csW.Find("0a") == 0) csW = "10"; else if (csW.Find("0b") == 0) csW = "11"; else if (csW.Find("0c") == 0) csW = "12"; else if (csW.Find("0d") == 0) csW = "13"; else if (csW.Find("0e") == 0) csW = "14"; else if (csW.Find("0f") == 0) csW = "15"; x = atoi(csW.GetBuffer(2)); if (i == x + 1) { if (k == 0) { Fl.Seek((LONG)dwPosSch+x*6, CFile::begin); if (i < iCycle) csS+="\n\r"; p = csS.GetBuffer(6); k = 1; } else { Fl.Seek((LONG)dwPosO2+x*6, CFile::begin); if (i < iCycle) csS+="\n\r"; p = csS.GetBuffer(6); k = 0; i++; } Fl.WriteString(p); //Write(p,4); } else while (i < x + 1) i++; }// while i Fl.Close(); }
void CDlgSaveFootprint::OnBnClickedOk() { // update name and other strings // check folder name m_edit_folder.GetWindowText( m_folder_name ); if( *m_folder->GetFullPath() != m_folder_name ) { // folder was changed without browsing, regenerate library int ret = chdir( m_folder_name ); if( ret == -1 ) { // folder doesn't exist CString mess = "Folder \"" + m_folder_name + "\" doesn't exist\n"; mess += "Create it ?"; ret = AfxMessageBox( mess, MB_YESNO ); if( ret == IDNO ) return; // create it ret = mkdir( m_folder_name ); if( ret == -1 ) { // can't create folder CString mess = "Unable to create folder \""; mess += m_folder_name; AfxMessageBox( mess ); return; } } // index folder CFootLibFolder * new_folder = new CFootLibFolder; CString mess; mess.Format( "Indexing library folder \"%s\"\r\n", m_folder_name ); m_dlg_log->AddLine( mess ); new_folder->IndexAllLibs( &m_folder_name, m_dlg_log ); m_dlg_log->AddLine( "\r\n" ); m_foldermap->AddFolder( &m_folder_name, new_folder ); m_folder = m_foldermap->GetFolder( &m_folder_name, m_dlg_log ); m_foldermap->SetLastFolder( &m_folder_name ); InitFileList(); } m_edit_name.GetWindowText( m_name ); m_name.Replace( '\"', '\'' ); // replace any " with ' if( m_name.GetLength() > CShape::MAX_NAME_SIZE ) { CString mess; mess.Format( "Name too long, can't exceed %d characters", CShape::MAX_NAME_SIZE ); AfxMessageBox( mess ); return; } m_footprint->m_units = m_units; m_footprint->m_name = m_name; m_edit_author.GetWindowText( m_author ); m_author.Replace( '\"', '\'' ); m_footprint->m_author = m_author.Trim(); m_edit_source.GetWindowText( m_source ); m_source.Replace( '\"', '\'' ); m_footprint->m_source = m_source.Trim(); m_edit_desc.GetWindowText( m_desc ); m_desc.Replace( '\"', '\'' ); m_footprint->m_desc = m_desc.Trim(); // get footprint name, file name CString file_name; m_combo_lib.GetWindowText( file_name ); CString file_path = *m_folder->GetFullPath() + "\\" + file_name; // save file name and folder gLastFileName = file_name; gLastFolderName = *m_folder->GetFullPath(); // now check for duplication of existing footprint int ilib; int offset; int ifootprint; int next_offset; CString fn; BOOL footprint_exists = m_folder->GetFootprintInfo( &m_name, &file_path, &ilib, &ifootprint, &fn, &offset, &next_offset ); BOOL same_file = ( fn == file_path ); BOOL replace = FALSE; if( footprint_exists && same_file ) { // footprint name already exists in this file CString mess; mess.Format( "Footprint \"%s\" already exists in file \"%s\"\nOverwrite ?", m_name, fn ); int ret = AfxMessageBox( mess, MB_OKCANCEL ); if( ret == IDOK ) { replace = TRUE; } else return; } else if( footprint_exists && !same_file ) { // footprint name already exists in another file CString mess; mess.Format( "Footprint \"%s\" already exists in another library file \"%s\"\nDo you want to change the name?", m_name, fn ); int ret = AfxMessageBox( mess, MB_YESNO ); if( ret == IDYES ) { return; } } // OK, save it BOOL file_exists = ( m_folder->SearchFileName( &file_path ) != -1 ); if( !file_exists ) { // new library file, create it and write footprint CStdioFile f; BOOL ok = f.Open( file_path, CFile::modeCreate | CFile::modeWrite ); if( !ok ) { AfxMessageBox( "Unable to open file " + file_path ); return; } m_footprint->WriteFootprint( &f ); f.Close(); } else if( file_exists && !replace ) { // existing library file, insert new footprint int offset; // no heading, insert ahead of first footprint or heading in file CStdioFile * fin = new CStdioFile( file_path, CFile::modeRead ); CStdioFile * fout = new CStdioFile( "temp.txt", CFile::modeCreate | CFile::modeWrite ); CString in_str; BOOL bInserted = FALSE; // now loop through all lines in file while( fin->ReadString( in_str ) ) { in_str.Trim(); if( !bInserted && (in_str[0] == '[' || in_str.Left(5) == "name:") ) { // insert footprint m_footprint->WriteFootprint( fout ); // now copy last line read from source fout->WriteString( in_str + "\n" ); bInserted = TRUE; } else { // write line fout->WriteString( in_str + "\n" ); } } delete fin; delete fout; int err = remove( file_path ); if( err ) { CString str = "File system error: Unable to modify library file\n"; str += "File could be read-only or you don't have permission to modify it\n"; str += "The modified file has been saved as \"temp.txt\""; AfxMessageBox( str ); return; } else { err = rename( "temp.txt", file_path ); if( err ) { CString str = "File system error: Unable to modify library file\n"; str += "The original file has been deleted but can't be rewritten\n"; str += "The modified file has been saved as \"temp.txt\""; AfxMessageBox( str ); return; } } } else { // replace existing footprint CStdioFile * fin = new CStdioFile( file_path, CFile::modeRead ); CStdioFile * fout = new CStdioFile( "temp.txt", CFile::modeCreate | CFile::modeWrite ); CString in_str; BOOL bDeleted = FALSE; BOOL bInserted = FALSE; // now loop through all lines in file while( fin->ReadString( in_str ) ) { in_str.Trim(); if( !bDeleted && fin->GetPosition() <= offset ) { // haven't reached footprint, write line fout->WriteString( in_str + "\n" ); } else if( !bDeleted && next_offset<0 ) { // reached footprint, this is the last footprint in the file bDeleted = TRUE; } else if( !bDeleted && fin->GetPosition() < next_offset ) { // reached footprint, skip lines to next footprint } else if( !bInserted ) { // we have deleted the original footprint, insert replacement bDeleted = TRUE; m_footprint->WriteFootprint( fout ); // if this was the last footprint in the file, we are done if( next_offset < 0 ) break; // otherwise, copy last line read from source fout->WriteString( in_str + "\n" ); bInserted = TRUE; } else { // finished inserting, this was no the last footprint // copy subsequent lines fout->WriteString( in_str + "\n" ); } } delete fin; delete fout; int err = remove( file_path ); if( err ) { CString str = "File system error: Unable to modify library file\n"; str += "File could be read-only or you don't have permission to modify it\n"; str += "The modified file has been saved as \"temp.txt\""; AfxMessageBox( str ); return; } else { err = rename( "temp.txt", file_path ); if( err ) { CString str = "File system error: Unable to modify library file\n"; str += "The original file has been deleted but can't be rewritten\n"; str += "The modified file has been saved as \"temp.txt\""; AfxMessageBox( str ); return; } } } // now index the file m_folder->IndexLib( &file_name ); OnOK(); }
BOOL CFraseSPSToXML::read_file_rec(CString strPath) { CString str1,str2; CString str_header_type; CString str_line ; CString str_point; CString str_type; int m_list = 0; int flag = 0; m_icnt_rec = 0; double intvl = 0; m_vecLine.clear(); CStdioFile file; memset(&rec_file[0], 0, ARRAY_SIZE*sizeof(rec_file_struct)); if (FALSE == file.Open(strPath, CFile::modeRead)) { return FALSE; } while (file.GetPosition()<file.GetLength()) { file.ReadString(str1); str2 = str1.GetAt(0); if (str2 == FLAG_R) { str_line = _T(""); str_point = _T(""); str_type = _T(""); str_line = readbyte(1, 17, str1); if (_tstoi(str_line) != rec_file[m_icnt_rec].lineName) //如果测线号有变,则数组位置递增(起始位置为1),测点号为下限 { m_vecLine.push_back(0); m_icnt_rec++; rec_file[m_icnt_rec].lineName = _tstoi(str_line); rec_file[m_icnt_rec].type = _tstoi(readbyte(27, 28, str1)); str_point = readbyte(17, 25, str1); rec_file[m_icnt_rec].point_lower = _tstof(str_point); } else //否则测点号上限不断更新 { str_point = readbyte(17, 25, str1); if (rec_file[m_icnt_rec].point_upper == 0) //该测线上第二个点,计算间隔 { rec_file[m_icnt_rec].interval = _tstof(str_point) - rec_file[m_icnt_rec].point_lower; rec_file[m_icnt_rec].point_upper = _tstof(str_point); } else { intvl = _tstof(str_point) - rec_file[m_icnt_rec].point_upper; //同测线上,间隔不等 if (intvl != rec_file[m_icnt_rec].interval) { m_icnt_rec++; rec_file[m_icnt_rec].lineName = _tstoi(str_line); rec_file[m_icnt_rec].type = _tstoi(readbyte(27, 28, str1)); rec_file[m_icnt_rec].point_lower = _tstof(str_point); } else rec_file[m_icnt_rec].point_upper = _tstof(str_point); } } rec_file[m_icnt_rec].count++; m_vecLine[m_icnt_rec - 1] = rec_file[m_icnt_rec].count; } else if (str2 == _T('H')) { str_header_type = _T(""); str_header_type = readbyte(1, 4, str1); if (str_header_type == HEADER_INSTRUMENT_TYPE) { m_str_instr_type = _T(""); m_str_instr_type = readbyte(32, 33, str1); } else if (str_header_type == HEADER_REC_TYPE) { m_str_rec_type = _T(""); m_str_rec_type = readbyte(32, 34, str1); } if (str_header_type == HEADER_SHOT_TYPE) { m_str_shot_type = _T(""); m_str_shot_type = readbyte(32, 34, str1); } } else break; } return TRUE; }
BOOL CFraseSPSToXML::read_file_comm(CString strPath) { CStdioFile file; CString str1, str2, str_header_type; double shot_line; double shot_point; m_icnt_comm = 0; memset(&comm_file[0], 0, ARRAY_SIZE*sizeof(comm_file_struct)); if (FALSE == file.Open(strPath, CFile::modeRead)) { return FALSE; } while (file.GetPosition()<file.GetLength()) { file.ReadString(str1); str2 = str1.GetAt(0); if (str2 == FLAG_X) { shot_line = _tstoi(readbyte(13, 29, str1)); shot_point = _tstof(readbyte(29, 37, str1)); if (comm_file[m_icnt_comm].shot_lineName!=0 && comm_file[m_icnt_comm].shot_point!=0) { if (comm_file[m_icnt_comm].shot_lineName != shot_line || comm_file[m_icnt_comm].shot_point != shot_point) { m_icnt_comm++; comm_file[m_icnt_comm].shot_lineName = shot_line; comm_file[m_icnt_comm].shot_point = shot_point; } } else { m_icnt_comm++; comm_file[m_icnt_comm].shot_lineName = shot_line; comm_file[m_icnt_comm].shot_point = shot_point; } comm_file[m_icnt_comm].rec_line_num ++; comm_file[m_icnt_comm].rec_point_index[comm_file[m_icnt_comm].rec_line_num-1]= _tstoi(readbyte(37, 38, str1)); comm_file[m_icnt_comm].record_channel_lower[comm_file[m_icnt_comm].rec_line_num-1] = _tstoi(readbyte(38, 42, str1)); comm_file[m_icnt_comm].record_channel_upper[comm_file[m_icnt_comm].rec_line_num-1] = _tstoi(readbyte(42, 46, str1)); comm_file[m_icnt_comm].record_channel_interval[comm_file[m_icnt_comm].rec_line_num-1] = _tstoi(readbyte(46, 47, str1)); comm_file[m_icnt_comm].rec_lineName[comm_file[m_icnt_comm].rec_line_num-1] = _tstoi(readbyte(47, 63, str1)); comm_file[m_icnt_comm].rec_point_lower[comm_file[m_icnt_comm].rec_line_num-1] = _tstof(readbyte(63, 71, str1)); comm_file[m_icnt_comm].rec_point_upper[comm_file[m_icnt_comm].rec_line_num-1] = _tstof(readbyte(71, 79, str1)); comm_file[m_icnt_comm].channel_lower[comm_file[m_icnt_comm].rec_line_num-1] = (int)((comm_file[m_icnt_comm].rec_point_lower[comm_file[m_icnt_comm].rec_line_num-1] - rec_file[comm_file[m_icnt_comm].rec_line_num].point_lower)/rec_file[comm_file[m_icnt_comm].rec_line_num].interval + 1); comm_file[m_icnt_comm].channel_upper[comm_file[m_icnt_comm].rec_line_num-1] = (int)((comm_file[m_icnt_comm].rec_point_upper[comm_file[m_icnt_comm].rec_line_num-1] - rec_file[comm_file[m_icnt_comm].rec_line_num].point_lower)/rec_file[comm_file[m_icnt_comm].rec_line_num].interval + 1); } else if (str2 == _T('H')) { str_header_type = _T(""); str_header_type = readbyte(1, 4, str1); if (str_header_type == HEADER_INSTRUMENT_TYPE) { m_str_instr_type = _T(""); m_str_instr_type = readbyte(32, 33, str1); } else if (str_header_type == HEADER_REC_TYPE) { m_str_rec_type = _T(""); m_str_rec_type = readbyte(32, 34, str1); } if (str_header_type == HEADER_SHOT_TYPE) { m_str_shot_type = _T(""); m_str_shot_type = readbyte(32, 34, str1); } } else break; } return TRUE; }
extern "C" _declspec(dllexport) BOOL startRprCmdTsk(CString strNT, _ConnectionPtr ptrCon, char* strCd, char* strPthOt, char* strAc, WCHAR* strNZ){ // HINSTANCE hInstResClnt; // hInstResClnt = AfxGetResourceHandle(); //AfxMessageBox(_T("startRprCmdTsk")); AfxSetResourceHandle(::GetModuleHandle("RprCmdTsk.dll")); // char* sANZ; CStringArray strANZ; strANZ.SetSize(1); for(int n=0;n<1;n++){ strANZ.SetAt(n,_T("")); } CString curStr,strTmp,m_strNZ; CString strCod,strAcc,strPathOut; m_strNZ = _T(""); strCod = strCd; strCod.TrimLeft(); strCod.TrimRight(); strPathOut = strPthOt; strPathOut.TrimLeft(); strPathOut.TrimRight(); strAcc = strAc; strAcc.TrimLeft(); strAcc.TrimRight(); CString strCur,strSql,strCSls; CString m_strNT; CString m_strCR; //Код грузополучателя CString m_strCRAdr; //Код адреса доставки CString m_strCSA; //Код расч.сч. продовца CString m_strCREm; //Код e-mail // bPrint =false; //CCmdTarget c; //c.BeginWaitCursor(); _variant_t m_vNULL; _RecordsetPtr ptrRs1; _CommandPtr ptrCmd1; _ConnectionPtr ptrCnn; COleVariant vC; CBlokRtf m_Blk; CWords m_W; ptrCnn = ptrCon; //Соединение CRecSetProc* pR=NULL; CString m_strNum,m_strDate,m_strDecDate,sEnd,strCopy; CString s,sPrv,m_strNumDec,strSls; CString m_strWe1,m_strWe2,m_strInd,m_strOKOHX,m_strOKOH; CString m_strVnd,m_strIndVnd,m_strOKOHXV,m_strOKOHV; // CString m_strBN; // char* m_bsConn; int k=0; //Число складов для наряд заданий bool m_bBN; int iFind,iNum,i; // № нак iFind=strCod.Find('~'); m_strNum = strCod.Left(iFind); m_strNumDec = m_strNum; // дата iNum = strCod.Find('~',iFind+1); m_strDecDate = strCod.Mid(iFind+1,iNum-iFind-1); iFind = iNum; // код продовца iNum = strCod.Find('~',iFind+1); strSls = strCod.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iFind = strCod.ReverseFind('~'); m_strDate = strCod.Mid(iFind+1); m_strNT = strNT; // Имена исходящих файлов CString strFlNmCmdTsk; CString strPath; strPath = _T(""); //_T("D:\\MyProjects\\Strg\\Debug\\"); s = m_strDate; s.Remove('-'); //AfxMessageBox(strAcc); iFind=strAcc.Find('~'); // код грузополучателя m_strCR = strAcc.Left(iFind); iNum = strAcc.Find('~',iFind+1); // Код адреса доставки m_strCRAdr = strAcc.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iNum = strAcc.Find('~',iFind+1); // Код расч.сч. продовца m_strCSA = strAcc.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iFind = strAcc.ReverseFind('~'); // Код e-mail m_strCREm = strAcc.Mid(iFind+1); // Входящие шаблоны CStdioFile inCmdTsk; //Наряд-Задание // Исходящий файл CStdioFile otCmdTsk; const int iMAX = 1024; const int iMIN = 512; m_vNULL.vt = VT_ERROR; m_vNULL.scode = DISP_E_PARAMNOTFOUND; ptrCmd1 = NULL; ptrRs1 = NULL; ptrCmd1.CreateInstance(__uuidof(Command)); ptrCmd1->ActiveConnection = ptrCnn; ptrCmd1->CommandType = adCmdText; ptrRs1.CreateInstance(__uuidof(Recordset)); ptrRs1->CursorLocation = adUseClient; ptrRs1->PutRefSource(ptrCmd1); CStringArray aHd; int iRpl = 6; // строки которые будут меняться (на 1 больше) aHd.SetSize(iRpl); for(i=0;i<iRpl;i++){ aHd.SetAt(i,_T("")); } strCur = m_strNum + _T(",'"); strCur+= m_strDate + _T("'"); aHd.SetAt(1,m_strNumDec+_T(" ")+m_strDecDate); strSql = _T("RT24NCmdTsk "); strSql+=strCur; //AfxMessageBox(strSql); ptrCmd1->CommandText = (_bstr_t)strSql; try{ if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText); if(!pR->IsEmptyRec(ptrRs1)){ i=4; //Основание vC=pR->GetValueRec(ptrRs1,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; aHd.SetAt(4,s); // Основание //AfxMessageBox(s); i = 9; vC = pR->GetValueRec(ptrRs1,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; aHd.SetAt(3,s); // Покупатель // bsCmd = _T("RT38 "); //Они // bsCmd+= (_bstr_t)s + _T(",2"); //AfxMessageBox(bsCmd); // if(rsWe->State==adStateOpen) rsWe->Close(); // // rsWe->Open(bsCmd,cn->ConnectionString,adOpenKeyset,adLockReadOnly,adCmdText);//adCmdStoredProc // if(!pR->IsEmptyRec(rsWe)){ CString strAdr; int Num =ptrRs1->GetRecordCount(); typedef CArray<int,int&> aRec; //Сколько записей //по складу ptrRs1->MoveFirst(); vC = pR->GetValueRec(ptrRs1,5); // № Склада vC.ChangeType(VT_BSTR); sPrv = vC.bstrVal; aRec aRecSt; int r=1; aRecSt.Add(r); s=_T(""); for(i=2;i<=Num;i++){ ptrRs1->MoveNext(); vC = pR->GetValueRec(ptrRs1,5); vC.ChangeType(VT_BSTR); s = vC.bstrVal; if(sPrv!=s){ k++; r=1; aRecSt.Add(r); sPrv=s; } else{ r++; aRecSt.SetAt(k,r); // s.Format("k = %i, r = %i",k,r); //AfxMessageBox(s); } } k = aRecSt.GetSize(); //s.Format("k = %i",k); //AfxMessageBox(s); i=0; ptrRs1->MoveFirst(); while(i<k){ CString strNum=_T(""); CString strStg = _T(""); vC = pR->GetValueRec(ptrRs1,5); // № Склада vC.ChangeType(VT_BSTR); strStg = vC.bstrVal; aHd.SetAt(2,strStg); //********************************* Работа с файлами int curPos = 0; CString strBuf = _T(""); s = m_strDate; s.Remove('-'); strFlNmCmdTsk = strPathOut; strFlNmCmdTsk+= _T("НЗ_"); strFlNmCmdTsk+= m_strNumDec + _T("_"); strFlNmCmdTsk+= s + _T("_"); strFlNmCmdTsk+= strStg + _T(".rtf"); if(strANZ.GetAt(0)==_T("")){ strANZ.SetAt(0,strFlNmCmdTsk); } else{ strANZ.Add(strFlNmCmdTsk); } //AfxMessageBox((LPCTSTR)strNZ.GetAt(i)); try{ // strFlNmCmdTsk+= s + _T(".rtf"); //AfxMessageBox(strFlNmCmdTsk); otCmdTsk.Open(strFlNmCmdTsk,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText); s = strPath + _T("CmdTsk.rtf"); inCmdTsk.Open(s,CFile::modeRead|CFile::shareDenyNone); //AfxMessageBox(s); CString strBuf=_T(""); CString strRpl=_T(""); int j=1; CString strFnd; bool theEnd=true; //---------------------------Заполняю Шаку strFnd.Format("~%i~",j); while(theEnd){ inCmdTsk.ReadString(strBuf); //s=strBuf; strFnd.Format("~%i~",j); m_Blk.SetRplStrR(strBuf,strFnd,j,aHd); curPos = inCmdTsk.GetPosition(); //AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd); otCmdTsk.WriteString(strBuf); if(j==5){ theEnd = false; } } //------------------------------------ Конец Шапки //{\cell } m_Blk.GetStdPWt(strBuf,inCmdTsk,otCmdTsk, _T("{\\cell }"),curPos); // m_Blk.Control(inCmdTsk,300); CString strSrc=_T(""); m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc); curPos++; inCmdTsk.Seek(curPos,CFile::begin); strSrc+=_T("\\"); m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc); // s.Format("Поиск strSrc После GetStdPWS curPos = %i",curPos); //AfxMessageBox(s+'\n'+"strSrc = "+strSrc); // m_Blk.Control(inCmdTsk,100); CString strPst=_T(""); m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\trowd"),curPos,strPst); curPos++; inCmdTsk.Seek(curPos,CFile::begin); strPst+=_T("\\"); m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\trowd"),curPos,strPst); // s.Format("Поиск strPst После GetStdPWS curPos = %i",curPos); //AfxMessageBox(s+'\n'+"strPst = "+strPst); // m_Blk.Control(inCmdTsk,100); // s.Format("i =%i",aRecSt.GetAt(i)); //AfxMessageBox(s); int i5=0; CString strNew=_T(""); for(int x=1;x<=aRecSt.GetAt(i);x++){ strNew = pR->OnFillRow(ptrRs1,strSrc,5,x,i5); //AfxMessageBox(_T("strSrc = ")+'\n'+strSrc+'\n'+_T("strNew = ")+'\n'+strNew); otCmdTsk.WriteString(strNew); otCmdTsk.WriteString(strPst); ptrRs1->MoveNext(); // s.Format("x = %i",x); //AfxMessageBox(s); } m_Blk.GetStdPWt(strBuf,inCmdTsk,otCmdTsk, _T("\\cell }\\pard"),curPos); // m_Blk.Control(inCmdTsk,300); CString strSrc2=_T(""); m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc2); // s.Format("Поиск strSrc2 После GetStdPWS curPos = %i",curPos); // AfxMessageBox(s+'\n'+"strSrc2 = "+strSrc2); // m_Blk.Control(inCmdTsk,100); CString strNew2=_T(""); strNew2 = pR->OnFillTtl(strSrc2,i5,1); // AfxMessageBox("strNew2 = "+'\n'+strNew2); otCmdTsk.WriteString(strNew2); s = m_W.GetWords(i5,false,false,true); aHd.SetAt(5,s); // Общее кол-во // while(inCmdTsk.ReadString(strBuf)){ // otCmdTsk.WriteString(strBuf); // } while(inCmdTsk.ReadString(strBuf)){ // s= strBuf; strFnd.Format("~%i~",j); m_Blk.SetRplStrR(strBuf,strFnd,j,aHd); //AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd); otCmdTsk.WriteString(strBuf); } otCmdTsk.Close(); } catch(CFileException* fx){ TCHAR buf[255]; fx->GetErrorMessage(buf,255); // AfxMessageBox(buf); fx->Delete(); } i++; inCmdTsk.Close(); //s.Format("i = %i",i); //AfxMessageBox(s); // } } /*AfxMessageBox(_T("Begin")); for(int c=0;c<strNZ.GetSize();c++){ s.Format(_T("c=%i Size = %i"),c,strNZ.GetSize()); AfxMessageBox(s); AfxMessageBox((LPCTSTR)strNZ.GetAt(c)); AfxMessageBox(s); } AfxMessageBox(_T("End"));*/ } } catch(_com_error& e){ AfxMessageBox(e.ErrorMessage()); if(ptrRs1->State == adStateOpen) ptrRs1->Close(); ptrRs1 = NULL; } //c.EndWaitCursor(); // AfxSetResourceHandle(hInstResClnt); if(ptrRs1->State == adStateOpen) ptrRs1->Close(); ptrRs1 = NULL; i = 0; while(i<k){ if(i==0){ m_strNZ =strANZ.GetAt(i); } else{ m_strNZ+= _T("~")+strANZ.GetAt(i); } i++; } //AfxMessageBox(m_strNZ); //strNZ = m_strNZ.GetBufferSetLength(m_strNZ.GetLength()); int lw; lw = MultiByteToWideChar(CP_ACP,0,m_strNZ,-1,NULL,0); // s.Format(_T("lw = %i"),lw); // AfxMessageBox(s); WCHAR* strW = new WCHAR[lw]; MultiByteToWideChar(CP_ACP,0,m_strNZ,-1,strW,lw); // strNZ = m_strNZ; wcscpy_s(strNZ,lw,strW); // strNZ=strW; //AfxMessageBox("exit from RprCmdTs"); //AfxMessageBox(strNZ); delete strW; return TRUE; }
extern "C" _declspec(dllexport) BOOL startRprBill(CString strNT, _ConnectionPtr ptrCon, char* strCd, char* strPthOt, char* strAc, WCHAR* strWDoc){ // HINSTANCE hInstResClnt; //hInstResClnt = AfxGetResourceHandle(); AfxSetResourceHandle(::GetModuleHandle("RprBill.dll")); CString curStr,strTmp; CString strCod,strAcc,strPathOut; strCod = strCd; strCod.TrimLeft(); strCod.TrimRight(); strPathOut = strPthOt; strPathOut.TrimLeft(); strPathOut.TrimRight(); strAcc = strAc; strAcc.TrimLeft(); strAcc.TrimRight(); /*AfxMessageBox(strCod); AfxMessageBox(strPathOut); AfxMessageBox(strAcc); return FALSE; */ CString strCur,strSql,strCSls; CString m_strNT; CString m_strCR; //Код грузополучателя CString m_strCRAdr; //Код адреса доставки CString m_strCSA; //Код расч.сч. продовца CString m_strCREm; //Код e-mail _variant_t m_vNULL; _RecordsetPtr ptrRs1,ptrRs2,ptrRs3,ptrRs4; _CommandPtr ptrCmd1,ptrCmd2,ptrCmd3,ptrCmd4; _ConnectionPtr ptrCnn; COleVariant vC; CBlokRtf m_Blk; CWords m_W; // CCnvrt16 m_Ch16; //CCmdTargetPrn c; //c.BeginWaitCursor(); ptrCnn = ptrCon; //Соединение CRecSetProc* pR=new CRecSetProc; CString m_strNum,m_strDate,m_strDecDate,s,sEnd,strCopy; CString m_strNumDec,strSls,strO; CString m_strWe1,m_strWe2,m_strInd,m_strOKOHX,m_strOKOH; CString m_strVnd,m_strIndVnd,m_strOKOHXV,m_strOKOHV,strCst,m_strCnsgr; // char* m_bsConn; bool m_bBN; int iFind,iNum,i; // № нак iFind=strCod.Find('~'); m_strNum = strCod.Left(iFind); m_strNumDec = m_strNum; // дата iNum = strCod.Find('~',iFind+1); m_strDecDate = strCod.Mid(iFind+1,iNum-iFind-1); iFind = iNum; // код продовца iNum = strCod.Find('~',iFind+1); strSls = strCod.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iFind = strCod.ReverseFind('~'); m_strDate = strCod.Mid(iFind+1); m_strNT = strNT; // m_bsConn = bsConn; //AfxMessageBox(strAcc); iFind=strAcc.Find('~'); // код грузополучателя m_strCR = strAcc.Left(iFind); iNum = strAcc.Find('~',iFind+1); // Код адреса доставки m_strCRAdr = strAcc.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iNum = strAcc.Find('~',iFind+1); // Код расч.сч. продовца m_strCSA = strAcc.Mid(iFind+1,iNum-iFind-1); iFind = iNum; iFind = strAcc.ReverseFind('~'); // Код e-mail m_strCREm = strAcc.Mid(iFind+1); CString strFlNmBill; CString strPath; strPath = _T(""); //_T("D:\\MyProjects\\Strg\\Debug\\"); s = m_strDate;// s.Remove('-'); strFlNmBill = strPathOut; strFlNmBill+= _T("СЧ_"); strFlNmBill+= m_strNum + _T("_"); strFlNmBill+= s + _T(".rtf"); int lw; lw = MultiByteToWideChar(CP_ACP,0,strFlNmBill,-1,NULL,0); // s.Format(_T("lw = %i"),lw); // AfxMessageBox(s); WCHAR* strW = new WCHAR[lw]; MultiByteToWideChar(CP_ACP,0,strFlNmBill,-1,strW,lw); // strNZ = m_strNZ; wcscpy_s(strWDoc,lw,strW); // strNZ=strW; //AfxMessageBox("exit from RprCmdTs"); //AfxMessageBox(strNZ); delete strW; // strDoc = strFlNmBill; m_vNULL.vt = VT_ERROR; m_vNULL.scode = DISP_E_PARAMNOTFOUND; ptrCmd4 = NULL; ptrRs4 = NULL; ptrCmd4.CreateInstance(__uuidof(Command)); ptrCmd4->ActiveConnection = ptrCnn; ptrCmd4->CommandType = adCmdText; ptrRs4.CreateInstance(__uuidof(Recordset)); ptrRs4->CursorLocation = adUseClient; ptrRs4->PutRefSource(ptrCmd4); ptrCmd3 = NULL; ptrRs3 = NULL; ptrCmd3.CreateInstance(__uuidof(Command)); ptrCmd3->ActiveConnection = ptrCnn; ptrCmd3->CommandType = adCmdText; ptrRs3.CreateInstance(__uuidof(Recordset)); ptrRs3->CursorLocation = adUseClient; ptrRs3->PutRefSource(ptrCmd3); ptrCmd2 = NULL; ptrRs2 = NULL; ptrCmd2.CreateInstance(__uuidof(Command)); ptrCmd2->ActiveConnection = ptrCnn; ptrCmd2->CommandType = adCmdText; ptrRs2.CreateInstance(__uuidof(Recordset)); ptrRs2->CursorLocation = adUseClient; ptrRs2->PutRefSource(ptrCmd2); ptrCmd1 = NULL; ptrRs1 = NULL; ptrCmd1.CreateInstance(__uuidof(Command)); ptrCmd1->ActiveConnection = ptrCnn; ptrCmd1->CommandType = adCmdText; ptrRs1.CreateInstance(__uuidof(Recordset)); ptrRs1->CursorLocation = adUseClient; ptrRs1->PutRefSource(ptrCmd1); // Входящие шаблоны CStdioFile inBill; // Счёт // Исходящий файл CStdioFile otBill; strCur = m_strNum + _T(",'"); strCur+= m_strDate + _T("'"); strSql = _T("RT24NBill "); //RT24Bill strSql+= strCur; //AfxMessageBox(strSql ); //AfxMessageBox(strAcc); ptrCmd1->CommandText = (_bstr_t)strSql; try{ if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText); if(!pR->IsEmptyRec(ptrRs1)) { i = 9; //Код продовца vC=pR->GetValueRec(ptrRs1,i); vC.ChangeType(VT_BSTR); strSls = vC.bstrVal; strSls.TrimLeft(); strSls.TrimRight(); i = 8; //Код покупателя vC=pR->GetValueRec(ptrRs1,i); vC.ChangeType(VT_BSTR); strCst = vC.bstrVal; strCst.TrimLeft(); strCst.TrimRight(); } } catch(_com_error& e){ AfxMessageBox(e.ErrorMessage()); if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1=NULL; if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2=NULL; if(ptrRs3->State==adStateOpen) ptrRs3->Close(); ptrRs3=NULL; if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4=NULL; return FALSE; } CStringArray aHd; int iRpl = 25; // строки которые будут меняться (на 1 больше) aHd.SetSize(iRpl); for(i=0;i<iRpl;i++){ aHd.SetAt(i,_T("")); } CString m_strSls; /*----------------------------- ПРОДАВЕЦ-----------------------*/ /* bsCmd = _T("RT38Sls "); bsCmd+= (_bstr_t)strSls +_T(","); bsCmd+= _T("2,"); // Юридический адрес bsCmd+= (_bstr_t)strAcc; */ strSql = _T("RT38Sls_1 "); //Мы RT38Sls strSql+= strSls + _T(",2,"); //Юр адрес - 2 strSql+= m_strCSA; //Код расч.сч. продовца ptrCmd2->CommandText = (_bstr_t)strSql; //AfxMessageBox(strSql); try{ //---------------------------------------Про Продовца if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText); if(!pR->IsEmptyRec(ptrRs2)) { i=1; vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); m_strSls+= _T(" "); i=2; vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); m_strSls+= s; aHd.SetAt(1,m_strSls); // Наименование i=3; //Индекс vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); m_strSls+= _T(","); i=4; //Адрес юридический vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); m_strSls+=s + _T(", "); i=5; // тел vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); // m_strSls+=_T("тел.: ") + s; m_strSls+= s; aHd.SetAt(2,m_strSls); // Адрес,тел i=8; vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); // m_strSls=_T("ИНН/КПП "); m_strSls+= s; aHd.SetAt(3,m_strSls); // ИНН/КПП aHd.SetAt(4,aHd.GetAt(1)); i=6; // Расч. счёт vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); aHd.SetAt(5,m_strSls); i=7; //Банк vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); aHd.SetAt(8,m_strSls); // Банк i=11; //БИК vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); aHd.SetAt(9,m_strSls); // БИК i=12; // Кор.счёт vC=pR->GetValueRec(ptrRs2,i); vC.ChangeType(VT_BSTR); m_strSls = vC.bstrVal; m_strSls.TrimLeft(); m_strSls.TrimRight(); aHd.SetAt(11,m_strSls); // Кор.счёт } } catch(_com_error& e){ AfxMessageBox(e.ErrorMessage()); if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1=NULL; if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2=NULL; if(ptrRs3->State==adStateOpen) ptrRs3->Close(); ptrRs3=NULL; if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4=NULL; return FALSE; } ptrRs2->Close(); /*--------------------------- ПОКУПАТЕЛЬ-----------------------*/ CString m_strCst; /* bsCmd = _T("RT38Cst "); bsCmd+= (_bstr_t)strCst +_T(","); bsCmd+= _T("2,"); // Юридический адрес bsCmd+= _T("1"); // Только Наименование */ strSql = _T("RT38Cst_1 "); //Они strSql+= strCst + _T(",2,"); strSql+= _T("0"); //AfxMessageBox(strSql); ptrCmd3->CommandText = (_bstr_t)strSql; try{ if(ptrRs3->State==adStateOpen) ptrRs3->Close(); //AfxMessageBox(strSql); ptrRs3->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText); if(!pR->IsEmptyRec(ptrRs3)){ i=1; vC=pR->GetValueRec(ptrRs3,i); vC.ChangeType(VT_BSTR); m_strCst = vC.bstrVal; m_strCst+= _T(" "); i=2; vC=pR->GetValueRec(ptrRs3,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; m_strCst+= s; aHd.SetAt(15,m_strCst); // Плательщик } } catch(_com_error& e){ AfxMessageBox(e.ErrorMessage()); if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1=NULL; if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2=NULL; if(ptrRs3->State==adStateOpen) ptrRs3->Close(); ptrRs3=NULL; if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4=NULL; return FALSE; } //------------------------------------- про Грузополучателей strSql = _T("RT38Cnsgr "); strSql+= m_strCR + _T(","); //Код грузополучателя strSql+= m_strCRAdr+ _T(","); //Код адреса доставки strSql+= _T("1"); //не полная инф //AfxMessageBox(strSql); ptrCmd4->CommandText = (_bstr_t)strSql; try{ if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText); if(!pR->IsEmptyRec(ptrRs4)){ i=1; //Вид собственности vC=pR->GetValueRec(ptrRs4,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); m_strCnsgr+= s +_T(" "); i=2; //Наименование vC=pR->GetValueRec(ptrRs4,i); vC.ChangeType(VT_BSTR); s = vC.bstrVal; s.TrimLeft(); s.TrimRight(); m_strCnsgr+= s; aHd.SetAt(16,m_strCnsgr); // Грузополучатель //AfxMessageBox(m_strCnsgr); } } catch(_com_error& e){ AfxMessageBox(e.ErrorMessage()); if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1=NULL; if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2=NULL; if(ptrRs3->State==adStateOpen) ptrRs3->Close(); ptrRs3=NULL; if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4=NULL; return FALSE; } aHd.SetAt(12,m_strNum); // № CString sD,sMY,sDMY; sD = m_strDecDate.Left(m_strDecDate.Find(_T("."))); sD = _T("\" ")+sD; sD+= _T(" \""); aHd.SetAt(13,sD); sDMY= m_W.GetWrdMnth(m_strDecDate,1,true); sMY = sDMY.Mid(sDMY.Find(" ")); aHd.SetAt(14,sMY); aHd.SetAt(23,_T("Головина О.В.")); //Фильцов Д.Н. aHd.SetAt(24,_T("Радостева М.С.")); //Ермакова Е.В. //************************* Работа с файлами int curPos = 0; CString strBuf = _T(""); try{ s = strPath + _T("Bill.rtf"); otBill.Open(strFlNmBill,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText); inBill.Open(s,CFile::modeRead|CFile::shareDenyNone); CString strBuf=_T(""); CString strRpl=_T(""); int j=1; CString strFnd; bool theEnd=true; //---------------------------заполняю Шапку strFnd.Format("~%i~",j); while(theEnd){ inBill.ReadString(strBuf); // s=strBuf; strFnd.Format("~%i~",j); m_Blk.SetRplStrR(strBuf,strFnd,j,aHd); curPos = inBill.GetPosition(); //AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd); otBill.WriteString(strBuf); if(j==17){ theEnd = false; // AfxMessageBox("ok"); } } // m_Blk.Control(inBill,300); m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("\\row }\\trowd"),curPos); // m_Blk.Control(inBill,300); m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("{1\\cell "),curPos); // m_Blk.Control(inBill,300); m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("\\pard \\qc "),curPos); // m_Blk.Control(inBill,300); CString strSrc=_T(""); m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\pard \\ql"),curPos,strSrc); // s.Format("Поиск strSrc После GetStdPWS curPos = %i",curPos); //AfxMessageBox(s+'\n'+"strSrc = "+strSrc); // m_Blk.Control(inBill,300); CString strPst=_T(""); m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\trowd"),curPos,strPst); curPos++; inBill.Seek(curPos,CFile::begin); strPst+=_T("\\"); m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\trowd"),curPos,strPst); // s.Format("Поиск strPst После GetStdPWS curPos = %i",curPos); //AfxMessageBox(s+'\n'+"strPst = "+strPst); // m_Blk.Control(inBill,300); CString strNew; long Num = ptrRs1->GetRecordCount(); // s = m_W.GetWords(Num,false,false,true); s.Format("%i",Num); s.TrimRight(); aHd.SetAt(20,s); // Порядковых номеров //AfxMessageBox(s); double d17,d18,d19,dT; d17=d18=d19=dT=0; for(int x=1;x<=Num;x++){ // otInvOrd.WriteString(strPrv); //AfxMessageBox(strSrc); strNew = pR->OnFillRow(ptrRs1,strSrc,6,x, d17, d18, d19); //AfxMessageBox(strNew); vC = pR->GetValueRec(ptrRs1,5); vC.ChangeType(VT_R8); dT = vC.dblVal; d18 +=dT; vC = pR->GetValueRec(ptrRs1,6); vC.ChangeType(VT_R8); dT = vC.dblVal; d19 +=dT; otBill.WriteString(strNew); otBill.WriteString(strPst); ptrRs1->MoveNext(); } s.Format("%16.4f",d17); s.TrimRight(); s.TrimLeft(); aHd.SetAt(17,s); // Итого s.Format("%16.4f",d18); s.TrimRight(); s.TrimLeft(); aHd.SetAt(18,s); // Итого НДС s.Format("%16.2f",d19); s.TrimRight(); s.TrimLeft(); aHd.SetAt(19,s); // Всего к оплате aHd.SetAt(21,s); // на сумму s = m_W.GetWords(d19,true,true,true); aHd.SetAt(22,s); // на сумму прописью while(inBill.ReadString(strBuf)){ // s= strBuf; strFnd.Format("~%i~",j); m_Blk.SetRplStrR(strBuf,strFnd,j,aHd); //AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd); otBill.WriteString(strBuf); } inBill.Close(); otBill.Close(); } catch(CFileException* fx){ TCHAR buf[255]; fx->GetErrorMessage(buf,255); // AfxMessageBox(buf); fx->Delete(); } delete pR; //c.EndWaitCursor(); // AfxSetResourceHandle(hInstResClnt); if(ptrRs1->State==adStateOpen) ptrRs1->Close(); ptrRs1=NULL; if(ptrRs2->State==adStateOpen) ptrRs2->Close(); ptrRs2=NULL; if(ptrRs3->State==adStateOpen) ptrRs3->Close(); ptrRs3=NULL; if(ptrRs4->State==adStateOpen) ptrRs4->Close(); ptrRs4=NULL; return TRUE; }