//对分录表进行插入和修改时所执行的操作 procedure TDocuInputOpType(opname: string); var i:integer; inputvaloutputvaloldnum:string; begin //如果是新增凭证则直接将分录表中的数据逐条插入 if opname=insert then begin for i:= to do begin //如果表格中为空则跳出循环 if stringgridCells[i]= then continue; inputval:=stringgridcells[i]; outputval:=stringgridcells[i]; //插入数据由于借方和贷方数据在sql server中为money故需要进行转换 adocommandCommandText:=insert into 分录表([凭证编号][科目代码] [借方][贷方][摘要]) values(+dbeditText+ +stringgridCells[i]+cast(+inputval+ as money) cast(+outputval+ as money)+stringgridCells[i]+); adocommandExecute; end; end; if opname=edit then begin for i:= to do begin if stringgridCells[i]= then continue; inputval:=stringgridcells[i]; outputval:=stringgridcells[i]; //对凭证所属的分录表原有数据进行更新 if i<=recordnum then adocommandCommandText:=update 分录表 set [科目代码] =+stringgridcells[i]+[借方]=cast(+inputval+ as money) [贷方]=cast(+outputval+ as money)[摘要]=+stringgridCells[i] + where 编号=+mytable[i]+ else //插入凭证所属的分录表中的新数据 adocommandCommandText:=insert into 分录表([凭证编号][科目代码] [借方][贷方][摘要]) values(+dbeditText+ +stringgridCells[i]+cast(+inputval+ as money) cast(+outputval+ as money)+stringgridCells[i]+); adocommandExecute; end; end; end; [] [] [] |