// dialog1.cpp : implementation file
//
#include "stdafx.h"
#include "data_find2.h"
#include "dialog1.h"
#include "math.h"
#include "direct.h"
#include "iostream.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// dialog1 dialog
dialog1::dialog1(CWnd* pParent /*=NULL*/)
: CDialog(dialog1::IDD, pParent)
{
m_scfile = _T("");
FINDfile= _T("");
DELfile = _T("");
InvoiceStartNumber=GetPrivateProfileInt("InvoiveNumber","StartNumber",1,"d:\\ini\\data_find.ini");
InvoiceNum=GetPrivateProfileInt("InvoiveNumber","StartNumber",1,"d:\\ini\\data_find.ini");
InvoiceEndNumber=GetPrivateProfileInt("InvoiveNumber","EndNumber",1,"d:\\ini\\data_find.ini");
InvoiceNextStartNumber=GetPrivateProfileInt("InvoiveNumber","NextStartNumber",1,"d:\\ini\\data_find.ini");
InvoiceNextEndNumber=GetPrivateProfileInt("InvoiveNumber","NextEndNumber",1,"d:\\ini\\data_find.ini");
TotalLine=GetPrivateProfileInt("TotalLine","FileTotalLine",0,"d:\\ini\\data_find.ini");
//{{AFX_DATA_INIT(dialog1)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Totalsum=GetPrivateProfileInt("RecordTotle","RecordTotalsum",0,"d:\\ini\\data_find.ini");
}
void dialog1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(dialog1)
DDX_Control(pDX, IDC_BUTTON5, m_BUTTON5);
DDX_Control(pDX, IDC_BUTTON6, m_BUTTON6);
DDX_Control(pDX, IDOK, m_Dlg1_btnOk);
DDX_Control(pDX, IDCANCEL, m_Dlg1_btnCancel);
DDX_Text(pDX, IDC_EDIT1, m_scfile1);
DDX_Text(pDX, IDC_EDIT2, m_scfile2);
DDX_Text(pDX, IDC_EDIT4, InvoiceStartNumber);
DDX_Text(pDX, IDC_EDIT6, InvoiceNum);
DDX_Text(pDX, IDC_EDIT7, TotalLine);
DDX_Text(pDX, IDC_EDIT5, InvoiceEndNumber);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(dialog1, CDialog)
//{{AFX_MSG_MAP(dialog1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// dialog1 message handlers
void dialog1::OnButton1()
{ CFileDialog flg(TRUE);
flg.m_ofn.lpstrTitle = "请选择原始文件";
flg.m_ofn.lpstrFilter = "文本文件 (*.txt)|0*.txt|0所有文件 (*.*)|0*.*|0";
if(flg.DoModal() == IDOK)
{
m_filetitle = flg.GetFileTitle();
m_scfile = flg.GetPathName();
CString sbwater_okFileName(flg.GetFileName());
CString findfiletmp = flg.GetPathName();
int x = findfiletmp.ReverseFind('\\');
findfile = findfiletmp.Mid(0,x);
char tmpfindstr[100];
sprintf(tmpfindstr,"%s%s%s","\\" , "sbfind_temp\\find\\" ,sbfind_tempFileName);
findfile.Insert(findfile.GetLength(),LPCTSTR(tmpfindstr));
delTitle = flg.GetFileTitle();
m_scfile = flg.GetPathName();
CString delFileName(flg.GetFileName());
CString delfiletmp = flg.GetPathName();
int y = delfiletmp.ReverseFind('\\');
delfile = delfiletmp.Mid(0,y);
char tmpdelstr[100];
sprintf(tmpdelstr,"%s%s%s","\\" , "sbfind_temp\\del\\" ,delFileName);
invalidsfile.Insert(invalidsfile.GetLength(),LPCTSTR(tmpinvalidsstr));
}
else
return;
UpdateData(FALSE);
//set progress bar
FILE * fpsc;
if(fopen(LPCTSTR(m_scfile),"r") == NULL)
{
AfxMessageBox("源文件打开有误!");
return;
}
fpsc = fopen(LPCTSTR(m_scfile),"r");
Recordnumber = 0;
char everyline[1024];
while(1)
{
fgets(everyline,1024,fpsc);
if(feof(fpsc))
{
break;
}
CString streveryline(everyline);
if(streveryline.Mid(0,1) != 'A')
Recordnumber ++;
}
}
--------------------next---------------------
void dialog1::OnChangeEdit1()
{
m_scfile=m_scfile_temp;
UpdateData(FALSE);
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void dialog1::OnChangeEdit2()
{
m_scfile=m_scfile_temp;
UpdateData(FALSE);
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void dialog1::OnOK()
{
if(m_scfile!=""){
UpdateData(TRUE);
FILE * fpsc;
FILE * fpfind;
FILE * fpdel;
mkdir("find_temp");
mkdir("find_temp\\find\\");
mkdir("find_temp\\del\\");
if(fopen(LPCTSTR(m_scfile),"r") == NULL )
{
MessageBox("文件源文件打开有误","错误");
return;
}
if(fopen(LPCTSTR(findfile),"w") == NULL)
{
MessageBox("文件findfile打开有误!\n路径未建或文件正在被使用,无法写入!","错误");
return;
}
if(fopen(LPCTSTR(delfile),"w") == NULL)
{
MessageBox("文件delfile打开有误!\n路径未建或文件正在被使用,无法写入!","错误");
return;
}
fpsc = fopen(LPCTSTR(m_scfile),"r");
fpfind = fopen(LPCTSTR(findfile),"w");
fpdel = fopen(LPCTSTR(delfile),"w");
char source[10240];
char record1[10240];
char record2[10240];
CString findCount;
CString Flag_One;
long findlines=0;
long dellines=0;
CString strline,strTotalsum;
long ProcessNo=0;
long ProcessBase=1;
char AppID[10] = "0058";
char StackNum[10] = "158";
int GroupNum = 9;
int PageNum = 99;
int Stackflag = 0;
int Enclosure12 = 0;
int Enclosure34 = 4;
int ColourMarker = 0;
CString strbarcode;
MessageBox("\n\n请先打开需要处理的文件\n\n","警 告 !");
m_filetitle = flg.GetFileTitle();
m_scfile = flg.GetPathName();
CString find_tempFileName(flg.GetFileName());
CString findfiletmp = flg.GetPathName();
int x = findfiletmp.ReverseFind('\\');
findfile = findfiletmp.Mid(0,x);
char tmpfindtr[100];
sprintf(tmpfindstr,"%s%s%s","\\" , "find_temp\\find\\" ,find_tempFileName);
findfile.Insert(findfile.GetLength(),LPCTSTR(tmpfindtr));
}
void dialog1::OnButton2()
{ CFileDialog flg(TRUE);
flg.m_ofn.lpstrTitle = "请选择原始文件";
flg.m_ofn.lpstrFilter = "文本文件 (*.txt)\0*.txt\0所有文件 (*.*)\0*.*\0";
if(flg.DoModal()==IDOK)
{
strtext=flg.GetPathName();
CString strFile=" "+flg.GetFileName();
AfxMessageBox(strFile);
}
m_scfile_temp=m_scfile;////建立备份避免edit被修改
UpdateData(FALSE);
//set progress bar
FILE * fpsc;
if(fopen(LPCTSTR(m_scfile),"r") == NULL)
{
AfxMessageBox("源文件打开有误!");
return;
}
fpsc = fopen(LPCTSTR(m_scfile),"r");
Recordnumber = 0;
char everyline[1024];
while(1)
{
fgets(everyline,1024,fpsc);
if(feof(fpsc))
{
break;
}
CString streveryline(everyline);
if(streveryline.Mid(0,1) != 'A')
Recordnumber ++;
}
/////////////////////////////////选择合适的步进,避免进度条最大值超过65535(即每隔执行几条记录进度条执行一次
progress=(CProgressCtrl *)GetDlgItem(IDC_PROGRESS1);
progress->SetRange(1,Recordnumber + 1);
ProcessNum=1;
Processtemp=Recordnumber;
if(Recordnumber>60000)
{
ProcessNum=Processtemp/60000+1;
Processtemp=Recordnumber/ProcessNum;
progress<
}
}
void dialog1::OnButton3()
{MessageBox("\n\n请先打开需要处理的文件\n\n","警 告 !");
m_filetitle = flg.GetFileTitle();
m_scfile = flg.GetPathName();
CString find_tempFileName(flg.GetFileName());
CString delfiletmp = flg.GetPathName();
int x = delfiletmp.ReverseFind('\\');
delfile = delfiletmp.Mid(0,x);
char tmpdelstr[100];
sprintf(tmpdeltr,"%s%s%s","\\" , "find_temp\\del\\" ,find_tempFileName);
delfile.Insert(delfile.GetLength(),LPCTSTR(tmpdelstr));
}
--------------------next---------------------
void dialog1::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
d:\find\data_find2\dialog1.h(45) : error C2535: 'void __thiscall dialog1::OnButton3(void)' : member function already defined or declared
d:\find\data_find2\dialog1.h(42) : see declaration of 'OnButton3'
D:\find\data_find2\dialog1.cpp(24) : error C2065: 'm_scfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(24) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\find\data_find2\dialog1.cpp(25) : error C2065: 'FINDfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(25) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\find\data_find2\dialog1.cpp(26) : error C2065: 'DELfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(26) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\find\data_find2\dialog1.cpp(27) : error C2065: 'InvoiceStartNumber' : undeclared identifier
D:\find\data_find2\dialog1.cpp(29) : error C2065: 'InvoiceNum' : undeclared identifier
D:\find\data_find2\dialog1.cpp(30) : error C2065: 'InvoiceEndNumber' : undeclared identifier
D:\find\data_find2\dialog1.cpp(31) : error C2065: 'InvoiceNextStartNumber' : undeclared identifier
D:\find\data_find2\dialog1.cpp(32) : error C2065: 'InvoiceNextEndNumber' : undeclared identifier
D:\find\data_find2\dialog1.cpp(33) : error C2065: 'TotalLine' : undeclared identifier
D:\find\data_find2\dialog1.cpp(38) : error C2065: 'Totalsum' : undeclared identifier
D:\find\data_find2\dialog1.cpp(47) : error C2065: 'm_BUTTON5' : undeclared identifier
D:\find\data_find2\dialog1.cpp(48) : error C2065: 'm_BUTTON6' : undeclared identifier
D:\find\data_find2\dialog1.cpp(49) : error C2065: 'm_Dlg1_btnOk' : undeclared identifier
D:\find\data_find2\dialog1.cpp(50) : error C2065: 'm_Dlg1_btnCancel' : undeclared identifier
D:\find\data_find2\dialog1.cpp(51) : error C2065: 'm_scfile1' : undeclared identifier
D:\find\data_find2\dialog1.cpp(52) : error C2065: 'm_scfile2' : undeclared identifier
D:\find\data_find2\dialog1.cpp(85) : error C2065: 'findtitle' : undeclared identifier
D:\find\data_find2\dialog1.cpp(85) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(86) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(90) : error C2065: 'findfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(90) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(92) : error C2065: 'sbfind_tempFileName' : undeclared identifier
D:\find\data_find2\dialog1.cpp(93) : error C2228: left of '.Insert' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(93) : error C2228: left of '.GetLength' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(96) : error C2065: 'delTitle' : undeclared identifier
D:\find\data_find2\dialog1.cpp(96) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(97) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(101) : error C2065: 'delfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(101) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CS
--------------------next---------------------
D:\find\data_find2\dialog1.cpp(104) : error C2065: 'invalidsfile' : undeclared identifier
D:\find\data_find2\dialog1.cpp(104) : error C2228: left of '.Insert' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(104) : error C2228: left of '.GetLength' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(104) : error C2065: 'tmpinvalidsstr' : undeclared identifier
D:\find\data_find2\dialog1.cpp(129) : error C2065: 'Recordnumber' : undeclared identifier
D:\find\data_find2\dialog1.cpp(149) : error C2065: 'm_scfile_temp' : undeclared identifier
D:\find\data_find2\dialog1.cpp(175) : error C2446: '!=' : no conversion from 'char *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\find\data_find2\dialog1.cpp(175) : error C2040: '!=' : 'int' differs in levels of indirection from 'char [1]'
D:\find\data_find2\dialog1.cpp(232) : error C2065: 'm_filetitle' : undeclared identifier
D:\find\data_find2\dialog1.cpp(232) : error C2065: 'flg' : undeclared identifier
D:\find\data_find2\dialog1.cpp(232) : error C2228: left of '.GetFileTitle' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(233) : error C2228: left of '.GetPathName' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(234) : error C2228: left of '.GetFileName' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(235) : error C2228: left of '.GetPathName' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(237) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
D:\find\data_find2\dialog1.cpp(239) : error C2065: 'tmpfindstr' : undeclared identifier
D:\find\data_find2\dialog1.cpp(240) : error C2228: left of '.Insert' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(240) : error C2228: left of '.GetLength' must have class/struct/union type
D:\find\data_find2\dialog1.cpp(244) : error C2601: 'OnButton2' : local function definitions are illegal
D:\find\data_find2\dialog1.cpp(298) : error C2601: 'OnButton3' : local function definitions are illegal
D:\find\data_find2\dialog1.cpp(310) : error C2601: 'OnCancel' : local function definitions are illegal
D:\find\data_find2\dialog1.cpp(315) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
data_find2.exe - 55 error(s), 0 warning(s)
--------------------next---------------------
阅读(2340) | 评论(0) | 转发(0) |