助力核心代码"/>
D7写的金税清成助力核心代码
毕业后从来没有进入过软件开发行业,喜欢,但没有为从业而努力,做着不相关的工作,偶尔来看看,无聊写写小程序,甚至已经好久没写过了,没有学习。因为工作需要,写了这么一个小工具,就是金税开票系统的清单小助力,开发票要开清单,清单数据量大时是无法想象开一张票要多久的,所以,只要有销售货物清单电子表,用这个工具就好办了,今天把核心的成生发票XML文件的代码贴出来,D7写的,有需要的照着改就可以写自己的清单助手了,我看有人写出来挣钱,我觉得还是免费香,呵呵。
代码很业余,将就看吧:
function openaexcelfile(thefilename:string):boolean;
var
i,tmpi,J,gfmsg_index,MaxRow, MaxCol,numberindex,lstcount:integer;
nownumber,newnumber: Integer; //a flag only!!!
je,tmpje,fixje:Currency;
ExcelApp, Sheet: Variant;
ListItemFp,ListItemDetail:TListItem;runok :boolean;
tmpstr:string;
begin
runok:=false;
if not FileExists(thefilename) then begin result:=runok; exit; end;
// ´´½¨Ò»¸öexcelµÄole¶ÔÏó
ExcelApp := CreateOleObject('Excel.Application');
try // ´ò¿ªÒ»¸öexcelÎļþ
ExcelApp.WorkBooks.Open(thefilename);
try // ÉèÖù¤×÷Çø
ExcelApp.WorkSheets[1].Activate;
Sheet := ExcelApp.WorkSheets[1]; //ĬÈÏ´ò¿ªµÚÒ»¸ö±í
MaxRow := Sheet.UsedRange.Rows.count; //ÓÐÊý¾ÝµÄÇøÓòµÄÐÐÊý
MaxCol := 9;//Sheet.UsedRange.Columns.count; //ÓÐÊý¾ÝµÄÇøÓòµÄÁÐÊý
Form1.Panel1.Visible:=true;
Form1.ProgressBar2.Max:=maxrow;
Form1.ProgressBar2.Position:=0;
sleep(10);
Form1.Panel1.Refresh;
sleep(10);
fixje:=0;
with Form1.ListView2 do
begin
Form1.ListView2.Clear; //×¼±¸Ìî³ä·¢Æ±±í
Form1.ListView1.Clear; //×¼±¸Ìî³äÏú»õÇåµ¥±í
//´¦Àí¶àÕÅƱµÄÇé¿ö:
numberindex:=1;lstcount:=0;
//ϸö°æ±¾:µ¥Î»±àÂë=strtoint(Sheet.Cells[2, 2].Value);//È¡±íµÚ2ÐеÚ1ÁÐ
//·ûºÅ×öΪ·¢Æ±¹º·½µ¥
//λ±àÂëÒÔ·½±ã¹ØÁª·¢Æ±µ¥Î»Ïà¹ØÐÅÏ¢
nownumber:=strtoint(Sheet.Cells[2, 2].Value); //È¡±íµÚ2ÐеÚ2ÁÐ
//·ûºÅ×öΪ·¢Æ±·Ö×é±êÖ¾
SetLength(UnitConsttype.afpmsg,numberindex); //¼Ç¼һÕÅÐÂƱ
ListItemFp:=Items.Add; //Ìî³ä·¢Æ±±í-ÐÂÔöÒ»ÐÐ
ListItemFp.Caption:=inttostr(numberindex); //·¢Æ±ÐòºÅ
tmpstr:=Sheet.Cells[2, 1].Value; //ÉóºËXLS±íÉèÖõĿͻ§±àºÅ
gfmsg_index:=getgfmsg_index(tmpstr); //
if gfmsg_index<>65534 then
begin
ListItemFp.SubItems.Add(allkhmsg[gfmsg_index].mc); //·¢Æ±Çåµ¥±íÐÂÌî³äÒ»ÁÐ
end
else begin
ListItemFp.SubItems.Add(ini_Gf.mc); //·¢Æ±Çåµ¥±íÐÂÌî³äÒ»ÁÐ
end;
UnitConsttype.afpmsg[numberindex-1].khbh:=Sheet.Cells[2, 1].Value;
UnitConsttype.afpmsg[numberindex-1].kpje:=0;
//±íÖÐÖ»ÓÐÒ»×鷢ƱÇ嵥ʱ£¬µÚÒ»´ÎÑ»·½áÊø±ãºÃ£º
for i := 2 to MaxRow do
begin
if Sheet.Cells[i, 1].Value=0 then
begin
result:=runok; exit;
end;
newnumber:=strtoint(Sheet.Cells[i, 2].Value);
if nownumber<>newnumber then
break; //ÖÐÖ¹µÚÒ»¸öÑ»·Ìå(µ±Ç°)£¬¿ªÊ¼µÚ¶þ¸ö£¨ÏÂÒ»¸ö£©¡£
if Form1.ProgressBar2.Position<Form1.ProgressBar2.Max then
Form1.ProgressBar2.Position:=Form1.ProgressBar2.Position+1;
//½«µÚÒ»×éƱÇåµ¥¼ÓÈë±íÖÐ,ͬʱ¼ÓÈ붯̬Êý×éÖÐ
//£¨Ä¬ÈÏÏÔʾµÚÒ»×éƱÇåµ¥£©:
with form1.ListView1 do
begin
lstcount:=lstcount+1;
ListItemDetail:=Items.Add;
listitemdetail.Caption:=inttostr(i-1);
ListItemDetail.SubItems.Add(Sheet.Cells[i, 3].Value);
//Óö¯Ì¬Êý×é¼Ç¼һÐÐÇåµ¥£º
SetLength(UnitConsttype.afpmsg[numberindex-1].lst,lstcount);
UnitConsttype.afpmsg[numberindex-1].qdhs :=lstcount;
UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].cpmc:=Sheet.Cells[i, 3].Value;
for J := 4 to MaxCol do
begin
//Sheet.Cells[i, j].Value; // »ñµÃexcelµÄÊý¾ÝµÚiÐУ¬µÚjÁе¥Ôª¸ñÄÚµÄÊý¾Ý
ListItemDetail.SubItems.Add(Sheet.Cells[i, j].Value);
case j of
4:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].cpxh:=Sheet.Cells[i, j].Value;
5:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dw:=Sheet.Cells[i, j].Value;
6:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].sl:=Sheet.Cells[i, j].Value;
7:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dj:=Sheet.Cells[i, j].Value;
8:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].je:=Sheet.Cells[i, j].Value;
9:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].ssbm:=Sheet.Cells[i, j].Value;
end;
if j=8 then begin
je:=Sheet.Cells[i, j].Value;
fixje:=fixje+strtofloat(UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].sl)
*strtofloat(UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dj);
UnitConsttype.afpmsg[numberindex-1].kpje:=
UnitConsttype.afpmsg[numberindex-1].kpje+ je ;
if numberindex=1 then form3.statusbar1.Panels.Items[6].Text:=
'µ±Ç°·¢Æ±×é½ð¶î£º' + Format('%.2f',[UnitConsttype.afpmsg[numberindex-1].kpje]);
end;
end; //end for (Ò»´Îsub)
end; //end with listview1
end; //end for (Ò»´Î)
//µÚ¶þ¸öÑ»·ÌåÔËÐÐÇ°Åжϣº
if I>MaxRow then //ÊÇ·ñÔÚµÚÒ»´ÎÑ»·ÖжÁÍêÁËÕûÕÅ±í£¨Ö»ÓÐÒ»ÕÅƱ£©
begin
//Èç¹ûÊ×´ÎÑ»·Íê³ÉÕû³É±í£¨Ö»ÓÐÒ»ÕÅ·¢Æ±£©Ê±ÖÐÖ¹:
ListItemFp.SubItems.Add(inttostr(lstcount)); //Ò»ÕÅƱ½áÊø:¼Ç¼ËûµÄÇåµ¥ÐÐÊý-ÔÚ³ÌÐòÁбí
UnitConsttype.afpmsg[numberindex-1].lstcount:=lstcount; //¼Ç¼ËûµÄÇåµ¥ÐÐÊý-ÔÚÊý×é³ÉÔ±
tmpje:=UnitConsttype.afpmsg[numberindex-1].kpje; //¼Ç¼¿ªÆ±½ð¶î-ÔÚ³ÌÐòÁбí
//Ç峡:
ExcelApp.WorkBooks.Close; //¹Ø±Õ¹¤×÷Çø
ExcelApp.Quit; // ÊÍ·Åole¶ÔÏó
form1.Panel2.Visible:=false; //Òþ²Ø½ø¶ÈÌõ
//ºË¶Ô·¢Æ±½ð¶î£º
if tmpje=fixje then
begin
ListItemFp.SubItems.Add(Format('%.2f',[tmpje])); //
end else begin
ListItemFp.SubItems.Add(Format('%.2f',[fixje-tmpje]));
ListItemFp.SubItems.Add('½ð¶îÒì³££º×ó²àÒѼÆËã³ö²î¶î£¬µ¼³öʱ½«±»×Ô¶¯ÐÞÕý£¡');
end;
form1.Panel1.Visible:=false;
result:=true;
exit; //½áÊøµ±Ç°Ê¼þ
end;
//»¹ÓÐÆäËû·¢Æ±·Ö×é:
tmpi:=I; //±ê¼ÇÆðʼÐÐ
for I := tmpi to MaxRow do //for ¶þ´Î ¿ªÊ¼
begin
newnumber:=strtoint(Sheet.Cells[i, 2].Value);
if form1.ProgressBar2.Position<form1.ProgressBar2.Max then
form1.ProgressBar2.Position:=form1.ProgressBar2.Position+1;
if (nownumber<>newnumber) then begin //Ê״νøÈ뱾ѻ·Ê±£¬±È½Ï¿Ï¶¨ÊÇ·ñµÄ£¡ËùÒÔÕâ¶Î´úÂë·ÅÔÚÕâÀï.
//³ÐÉÏ£º£¨ÓÐеķ¢Æ±·Ö×é±êÖ¾£©
ListItemFp.SubItems.Add(inttostr(lstcount)); //Ò»ÕÅƱ½áÊø,¼Ç¼ËûµÄÇåµ¥ÐÐÊý
UnitConsttype.afpmsg[numberindex-1].lstcount:=lstcount;
tmpje:=UnitConsttype.afpmsg[numberindex-1].kpje;
if tmpje=fixje then begin
ListItemFp.SubItems.Add(Format('%.2f',[tmpje])); //
end
else begin
ListItemFp.SubItems.Add(Format('%.2f',[fixje-tmpje]));
ListItemFp.SubItems.Add('½ð¶îÒì³££º×ó²àÒѼÆËã³ö²î¶î,µ¼³öʱ½«±»×Ô¶¯ÐÞÕý£¡');
end;
//ÆôÏ£º(×¼±¸¼Ç¼ÏÂÒ»ÕÅƱ)
numberindex:=numberindex+1;
nownumber:=newnumber;
lstcount:=0; //Çåµ¥ÐÐÊý¼ÆÊýÆ÷ÇåÁã
fixje:=0; //½ð¶îºË¶ÔÆ÷ÇåÁã
SetLength(UnitConsttype.afpmsg,numberindex); //¿ªÊ¼¼Ç¼ÐÂƱ
ListItemFp:=Items.Add; //Ìî³ä·¢Æ±±í-ÐÂÔöÒ»ÐÐ
tmpstr:=Sheet.Cells[I, 1].Value; //ÉóºËXLS±íÉèÖõĿͻ§±àºÅ
gfmsg_index:=getgfmsg_index(tmpstr); //
ListItemFp.Caption:=inttostr(numberindex); //·¢Æ±ÐòºÅ
//¸ù¾Ýµ±Ç°·¢Æ±Êý¾ÝÖ®¿Í»§±àºÅ»ñÈ¡¹º·½Ãû³Æ£º
if gfmsg_index<>65534 then
begin
ListItemFp.SubItems.Add(allkhmsg[gfmsg_index].mc); //·¢Æ±Çåµ¥±íÐÂÌî³äÒ»ÁÐ
end else begin
ListItemFp.SubItems.Add(ini_Gf.mc); //·¢Æ±Çåµ¥±íÐÂÌî³äÒ»ÁÐ
end;
UnitConsttype.afpmsg[numberindex-1].kpje:=0; //¿ªÆ±½ð¶î³õʼ»¯
end;
//¼Ç¼һÐÐÇåµ¥£º
lstcount:=lstcount+1; //Çåµ¥ÐÐÊý¼ÆÊýÆ÷
SetLength(UnitConsttype.afpmsg[numberindex-1].lst,lstcount); //¶¯Ì¬Êý×éÔöÈÝ
UnitConsttype.afpmsg[numberindex-1].khbh:=Sheet.Cells[i, 1].Value; //¿Í»§±àºÅ
UnitConsttype.afpmsg[numberindex-1].qdhs :=lstcount; //Çåµ¥ÐÐÊý
UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].cpmc:=Sheet.Cells[i, 3].Value;
for J := 4 to MaxCol do
begin
//Sheet.Cells[i, j].Value; // »ñµÃexcelµÄÊý¾ÝµÚiÐУ¬µÚjÁе¥Ôª¸ñÄÚµÄÊý¾Ý
case j of
4:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].cpxh:=Sheet.Cells[i, j].Value;
5:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dw:=Sheet.Cells[i, j].Value;
6:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].sl:=Sheet.Cells[i, j].Value;
7:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dj:=Sheet.Cells[i, j].Value;
8:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].je:=Sheet.Cells[i, j].Value;
9:UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].ssbm:=Sheet.Cells[i, j].Value;
end;
if j=8 then begin
je:=Sheet.Cells[i, j].Value;
UnitConsttype.afpmsg[numberindex-1].kpje:=UnitConsttype.afpmsg[numberindex-1].kpje+ je;
fixje:=fixje+strtofloat(UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].sl)
*strtofloat(UnitConsttype.afpmsg[numberindex-1].lst[lstcount-1].dj);
end;
end; //end for (¶þ´Îsub)
end; //end for(¶þ´Î)
ListItemFp.SubItems.Add(inttostr(lstcount)); //¶þ´ÎÑ»·Ìå½áÊø¼Ç¼×îºóÕâÕÅƱÇåµ¥ÐÐÊý¡¢½ð¶î£¡
UnitConsttype.afpmsg[numberindex-1].lstcount:=lstcount;
tmpje:=UnitConsttype.afpmsg[numberindex-1].kpje;
if tmpje=fixje then begin
ListItemFp.SubItems.Add(Format('%.2f',[tmpje]));
end
else begin
ListItemFp.SubItems.Add(Format('%.2f',[fixje-tmpje]));
ListItemFp.SubItems.Add('½ð¶îÒì³££º×ó²àÒѼÆËã³ö²î¶î,µ¼³öʱ½«±»×Ô¶¯ÐÞÕý£¡');
end;
end; //with listview2
runok:=true; //¹ý³ÌÔËÐе½ÕâÀ±êÖ¾Îļþ´ò¿ª³É¹¦¡£
finally // ¹Ø±Õ¹¤×÷Çø
ExcelApp.WorkBooks.Close;
end;
finally // ÊÍ·Åole¶ÔÏó
ExcelApp.Quit;
end;
form1.Panel1.Visible:=false;
result:=runok;
end;
//生成发票XML文件的代码:
procedure TForm1.SpeedButton3Click(Sender: TObject);
var
Xml: TXMLDocument;
Rootnode,node,nodeschild,nodeschildschild,childsdetails,fpsjnode : IXMLNode;
alllstcount,fpindexstart,i,iend,j,jend,gfmsg_index:integer;
fpdetailsName : array[0..14] of string;
tmpstr,XmlText,fpbhstr,qyspbmindexstr,qyspbmindextmpstr:string;
xlsdj,xlssl,je,Se,dj:TBcd;fpindex,fpcount,lstindex,lstcount,fpbh:byte;
khbhCheckOk:boolean;
begin
khbhCheckOk:=true;
if listview2.Items.Count=0 then exit;
if (not CheckBox1.Checked) and (listview2.Items.count > 1) then begin
if not (Assigned(listview2.Selected)) then begin
showmessage('SORRY£¬ÎÒÌ«±¿£¬²»Ö¹Ò»ÕÅƱµÄʱºòÄú»¹ÊÇÑ¡ÔñÆäÖÐÒ»ÕÅÈÃÎÒµ¼³ö°É.');
exit;
end;
end;
//if not(panel5.Caption = '') then panel5.Caption:='';
SaveDialog1.Filter := 'XMLÎļþ|*.xml';
saveDialog1.FileName:=xmlfilename;
if SaveDialog1.Execute then
begin
if (ExtractFileExt(SaveDialog1.FileName) <> '.xml') then begin //ΪûÓÐÀ©Õ¹ÃûµÄÎļþÃû¼ÓÀ©Õ¹Ãû
SaveDialog1.FileName := ChangeFileExt(SaveDialog1.FileName,'.xml');
end;
xmlfilepath:=SaveDialog1.FileName;
end
else begin //ÕâÀïÓÀÔ¶Ò²²»»áÖ´ÐУº
exit;
end;
//fpdetailsName[0]:='Xh';
fpdetailsName[0]:='Spmc'; fpdetailsName[1]:='Ggxh'; fpdetailsName[2]:='Jldw';
fpdetailsName[3]:='Spbm'; fpdetailsName[4]:='Qyspbm'; fpdetailsName[5]:='Syyhzcbz';
fpdetailsName[6]:='Lslbz'; fpdetailsName[7]:='Yhzcsm'; fpdetailsName[8]:='Dj';
fpdetailsName[9]:='Sl'; fpdetailsName[10]:='Je'; fpdetailsName[11]:='Slv';
fpdetailsName[12]:='Se'; fpdetailsName[13]:='Kce';
jend:=13;
Xml := TXMLDocument.Create(nil);
// Xml.LoadFromFile('aaa.xml');
try
//¼ÓÈë°æ±¾ÐÅÏ¢ ¡®<?xml version="1.0" encoding="GB2312" ?> ¡¯
Xml.Active := True;
Xml.Version := '1.0';
Xml.Encoding :='GBK';
Rootnode := Xml.CreateNode('Kp');
Xml.DocumentElement := Rootnode;
node := Xml.CreateNode('Version');
Rootnode.ChildNodes.Add(node);
node.Text := '2.0';
node := Xml.CreateNode('Fpxx'); //·¢Æ±¸ù½áµã
Rootnode.ChildNodes.Add(node);
nodeschild:=Xml.CreateNode('Zsl'); //·¢Æ±¸ù+:XMLÎļþº¬Óеĵ¥¾ÝÊýÁ¿£¨¼¸ÕÅƱ£©
node.ChildNodes.Add(nodeschild);
if CheckBox1.Checked then begin //"¶àÕÅƱµ¼Èë1¸öÎļþ"±»Ñ¡ÖÐʱ£º
nodeschild.Text :=inttostr(listview2.Items.Count);
fpcount:=listview2.Items.Count;
fpindexstart:=0;
end
else begin //·ñÔò,Ö»ÓÐÒ»ÕÅƱʱ£º
if listview2.Items.count=1 then begin
fpcount:=1;
fpindexstart:=fpcount-1;
end
else begin //»òÓжàÕÅƱ£¬µ«Ã»ÓÐÑ¡ÖÐ"¶àÕÅƱµ¼Èë1¸öÎļþ"ʱ£º
fpindexstart:=listview2.Selected.Index;
fpcount:=fpindexstart+1;
end;
nodeschild.Text := '1';
end;
fpsjnode := Xml.CreateNode('Fpsj'); //·¢Æ±¸ù+
node.ChildNodes.Add(fpsjnode);
//¶à/µ¥ÕÅƱ´ÓÕâÀ↑ʼ:
alllstcount:=0;
fpbh:=0;
for fpindex:=fpindexstart to fpcount-1 do
begin
tmpstr:=afpmsg[fpindex].khbh;
gfmsg_index:=getgfmsg_index(tmpstr);
//¸ù¾Ýµ±Ç°·¢Æ±Êý¾ÝÖ®¿Í»§±àºÅ»ñÈ¡¹º·½Ãû³Æ£º
if gfmsg_index<>65534 then
begin
ini_Gf.mc:=allkhmsg[gfmsg_index].mc;
ini_Gf.Sh:=allkhmsg[gfmsg_index].sh;
ini_Gf.Dzdh:=allkhmsg[gfmsg_index].dz + ' ' +allkhmsg[gfmsg_index].dh;
ini_Gf.Yhzh:=allkhmsg[gfmsg_index].khh + ' ' +allkhmsg[gfmsg_index].zh;
end else begin
khbhCheckOk:=false;
end;
node:=Xml.CreateNode('Fp'); //·¢Æ±¸ù++
fpsjnode.ChildNodes.Add(node);
nodeschild := Xml.CreateNode('Djh'); //·¢Æ±¸ù+++
node.ChildNodes.Add(nodeschild);
fpbh:=fpbh+1; //Ϊ֧³Ö¶àÕÅ·¢Æ±£¬ÒýÈ뷢Ʊ±àºÅ¼ÆÊýÆ÷
if fpbh<10 then begin
fpbhstr:='0'+trim(inttostr(fpbh));
end else begin
fpbhstr:=trim(inttostr(fpbh));
end;
nodeschild.Text:='5107'+FormatDateTime('yyyymmddhhnnss', Now)+ fpbhstr;
nodeschild := Xml.CreateNode('Gfmc'); //¹º·½Ãû³Æ
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=ini_Gf.mc; //ÔÚ¿Í»§±íÀïûÓÐÕÒµ½·¢Æ±±íÉèÖõĿͻ§±àºÅ£¨²»°²È«µÄ£©
nodeschild := Xml.CreateNode('Gfsh'); //¹º·½Ë°ºÅ
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=ini_Gf.Sh;
nodeschild := Xml.CreateNode('Gfyhzh'); //¹º·½ÒøÐÐÕʺÅ
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=ini_Gf.Yhzh;
nodeschild := Xml.CreateNode('Gfdzdh'); //¹º·½dzdh
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=ini_Gf.Dzdh;
nodeschild := Xml.CreateNode('Bz'); //±¸×¢
node.ChildNodes.Add(nodeschild);
nodeschild.Text:='';
nodeschild := Xml.CreateNode('Fhr'); //·¢Æ±¸´ºËÈË
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=mf.Fhr;
nodeschild := Xml.CreateNode('Skr'); //·¢Æ±SKÈË
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=mf.Skr;
nodeschild := Xml.CreateNode('Spbmbbh'); //»õÎï±àÂë°æ±¾
node.ChildNodes.Add(nodeschild);
nodeschild.Text:=mf.Spbmbbh;
nodeschild := Xml.CreateNode('Hsbz'); //º¬Ë°±êÖ¾
node.ChildNodes.Add(nodeschild);
nodeschild.Text:='0'; //º¬Ë°±ê־ʼÖÕΪ0 µ¼³öµÄxml
//µ¥¼ÛʼÖÕÒª¸ú¾ÝÓû§ÉèÖõĺ¬Ë°±êÖ¾
//½«±íÄÚµ¥¼Û¼ÆËãΪ²»º¬Ë°µ¥¼Û
nodeschild := Xml.CreateNode('Sgbz'); //??±êÖ¾(20191122δ֪¸üÐÂ)
node.ChildNodes.Add(nodeschild);
nodeschild.Text:='0'; //??±ê־ʼÖÕΪ0
nodeschild := Xml.CreateNode('Spxx'); //
node.ChildNodes.Add(nodeschild);
//Çåµ¥¿ªÊ¼£º±éÀ÷Çåµ¥£¨LSTVIEW£©
//Éú³É·¢Æ±×éÀïÏàÓ¦·¢Æ±XMLÎļþ
//ÿһ¸ö·¢Æ±×éºÅ£¬¶ÔÓ¦Ò»¸öLSTVIEWÀàÐ͵Ķ¯Ì¬Êý×飬
//´æ´¢Á˱»¹æ»®µ½¸Ã×éµÄËùÓÐÏú»õÇåµ¥£©.
//listview1.Items[i].SubItems.strings[0]; //¶ÁµÚiÐеÚ2ÁУ¨µÚÒ»ÁÐlistview1.Items[i].captionÊôÐԵõ½£©
lstcount:=UnitConsttype.afpmsg[fpindex].qdhs;
for lstindex :=0 to lstcount-1 do
begin
nodeschildschild := Xml.CreateNode('Sph'); //µÚÒ»ÐÐ
nodeschild.ChildNodes.Add(nodeschildschild);
qyspbmindextmpstr:='000';
qyspbmindexstr:=trim(inttostr(lstindex+1));
qyspbmindexstr:=copy(qyspbmindextmpstr,1,4-length(qyspbmindexstr))+qyspbmindexstr;
alllstcount:=alllstcount+1; //qyspbmindex
childsdetails := Xml.CreateNode('Xh'); //µÚÒ»ÐÐϸ½ÚÖ®ÐкÅ('Xh')
nodeschildschild.ChildNodes.Add(childsdetails);
childsdetails.Text:=inttostr(alllstcount);
//´¦Àíµ¥¼ÛÊÇ·ñº¬Ë°µÄÎÊÌâ
xlsdj:=StrToBcd(UnitConsttype.afpmsg[fpindex].lst[lstindex].dj);
dj:=getdj(xlsdj,StrToBcd(floattostr(mf.Zxsl))); //»ñÈ¡bcd¸ñʽº¬Ë°»ò²»º¬Ë°µ¥¼Û
if mf.Jesfhs then
begin
BcdSubtract(xlsdj,dj,Se); //BCD¼õ·¨:¼ÆËãEXCEL±íÄÚº¬Ë°µ¥¼Û¼õÈ¥º¯Êý·µ»ØµÄ²»º¬Ë°µ¥¼Û(dj)=µ¥¼ÛË°¶î£¬
end else begin
BcdSubtract(dj,xlsdj,Se); //µ¥¼Û²»º¬Ë°Ê±£¬Óú¯Êý·µ»ØµÄº¬Ë°µ¥¼Û(dj)¼õÈ¥µç×Ó±íÄÚ²»º¬Ë°µ¥¼Û=µ¥¼ÛË°¶î(Se)
BcdSubtract(dj,Se,dj); //º¬Ë°µ¥¼Û¼õȥ˰¶îµÈµ½²»º¬Ë°µ¥¼Û
end;
BcdMultiply(Se,strtobcd(UnitConsttype.afpmsg[fpindex].lst[lstindex].sl),Se); //BCD³Ë·¨ ¼ÆËã½ð¶î
BcdMultiply(dj,strtobcd(UnitConsttype.afpmsg[fpindex].lst[lstindex].sl),je); //BCD³Ë·¨ ¼ÆËã½ð¶î
{
dj:=BcdRound(dj,2);
se:=BcdRound(se,5);
je:=BcdRound(je,5);
}
for j:=0 to jend do
begin
childsdetails := Xml.CreateNode(fpdetailsName[j]); //µÚÒ»ÐÐϸ½ÚÖ®ÐкÅ('spmc')
nodeschildschild.ChildNodes.Add(childsdetails);
case j of
0:childsdetails.Text:=UnitConsttype.afpmsg[fpindex].lst[lstindex].cpmc;
1:childsdetails.Text:=UnitConsttype.afpmsg[fpindex].lst[lstindex].cpxh;
2:childsdetails.Text:=UnitConsttype.afpmsg[fpindex].lst[lstindex].dw;
3:childsdetails.Text:=UnitConsttype.afpmsg[fpindex].lst[lstindex].ssbm;
4:childsdetails.Text:='MY'+FormatDateTime('yyyymmddhhnn', Now)+fpbhstr+qyspbmindexstr;//trim(inttostr(1000+alllstcount));
5:childsdetails.Text:='0';
6:childsdetails.Text:='';
7:childsdetails.Text:='';
8:childsdetails.Text:=trim(BcdToStr(dj));
9:childsdetails.Text:=UnitConsttype.afpmsg[fpindex].lst[lstindex].sl;
10:childsdetails.Text:=BcdToStr(je);
11:childsdetails.Text:=trim(floattostr(mf.zxsl));
12:childsdetails.Text:=trim(BcdToStr(Se));
13:childsdetails.Text:='';
end;
end;
end;
end;
iend:=listview1.Items.Count;
for i := 0 to iend -1 do
begin
end;
XmlText:=FormatXMLData(xml.XML.Text); //¶ÔXML¸ñʽ»¯
Insert(' encoding="GBK"',XmlText,20); //ÐÞÕý°æ±¾ÐÅÏ¢´íÎó
xml.XML.Text:=XmlText; //¸³Öµµ¼Ö xml.Active:=False
xml.Active:=True; //ÖØи³Öµ"True",·ñÔòXml.SaveToFile½«µ÷ÓÃʧ°Ü
Xml.SaveToFile(xmlfilepath);
xml.Active := False;
if khbhCheckOk then
begin
showmessage('XMLÇåµ¥´´½¨³É¹¦£¡È·ÈÏ´°¿ÚÏ·½×´Ì¬À¸Ëùʾ²ÎÊýÎÞÎóºóÔÚ¿ªÆ±Èí¼þÖÐÊÖ¹¤µ¼Èë¼´¿É£¡');
end else begin
showmessage('µç×Ó±í¸ñÖÐÖÁÉÙÓÐÒ»¸ö<¿Í»§±àºÅ>ÔÚ<¿Í»§×ÊÁÏ>ÖÐûÓÐÕÒµ½£¡XMLÇåµ¥ËäÈ»´´½¨Íê³É£¬µ«Ëû¿ÉÄÜÓÐÎ󣡽¨ÒéÖØ×ö£¡');
end;
finally
Xml.Free;
end;
end;
更多推荐
D7写的金税清成助力核心代码
发布评论