如题,下面的代码不能实现~!
{with DM.OraTable1 do
    begin
      Close;
      TableName:='001';
      Filter:='num='''+xnum+''' and RQ='''+StrtoDate(xrq)+'''';//这里的过滤条件设置的类型不对,num是string,rq是日期型(TDate)
       Filtered:=True;
      Open;
      if Eof then
      begin
        while i<=stringgrid1.RowCount do
        begin
          if (Length(stringgrid1.Cells[2,i])<>0) or ((stringgrid1.Cells[1,i]='DK) and (Length(stringgrid1.Cells[2,i])=0)) then
            begin
              DM.OraTable1.Append;
              with stringgrid1 do
              begin
                DM.OraTable1['num']:=xnum;
              try
                DM.OraTable1['rq']:=StrtoDate(xrq);
                except
                  messagedlg('错误的日期范围', mtinformation, [mbok], 0);
                  tjbz:=1;
                  Break;
                end;
              try
                DM.OraTable1['xjjrq']:=StrtoDate(edtXJJRQ.Text);
                except
                  messagedlg('错误的日期范围', mtinformation, [mbok], 0);
                  tjbz:=1;
                  Break;
                end;
                DM.OraTable1['yyxh']:=Trim(Cells[0,i]);
                if i>1 then
                  if (Cells[1,i-1]='FGQ) then
                    begin
                      DM.OraTable1['xxmc']:='';
                      Cells[1,i]:='';
                    end;
                DM.OraTable1['xxmc']:=Trim(Cells[1,i]);
            with DM.OraTable3 do
             begin
               Close;
             TableName := 'DM_XXMC';
             Filter := 'xxMC='''+Trim(Cells[1, i])+'''';
             Filtered := true;
             Open;
             if not Eof then
               DM.OraTable1['xxdm'] := FIELDBYNAME('xxdm').ASSTRING
               else
                DM.OraTable1['xxdm'] := ''
           end;
           DM.OraTable3.Close;           try
             cd := StrToFloat(string(Cells[2, i], 5, 2));      
              if (cd < 5) or (cd > 10) then
             begin
               if stringgrid1.Cells[1, i] = 'YG' then
                  messagedlg('长度范围错(1~10)!', mtinformation, [mbok], 0)
             else if cd > 8888.00 then
                  messagedlg('长度范围错(0~8888.00)!', mtinformation,[mbok], 0);
                  tjbz := 1;
                  Break;
             end
             else
                  DM.OraTable1['xxcd']:=cd;
              except
                messagedlg('长度数据格式错!', mtinformation, [mbok], 0);
                tjbz := 1;
                Break;
              end;              try
                if CELLS[1, I] = 'DK' then
                  DM.OraTable1['xxsd'] := StrtoFloat(string(Cells[4, i + 1], 7, 2)) -0.5
                else
                  DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i]));
              except
                if cd <> 0 then
                  DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i - 1])) + cd
              end;              if i = 0 then
              begin
                if Length(Cells[0, i]) = 0 then
                begin
                  gs1 := 0;
                  cd1 := cd;
                  qsxh := 1;
                  gg := Cells[3, i];
                end
                else
                begin
                  gs1 := 1;
                  cd1 := cd;
                  qsxh := 1;
                  gg := Cells[3, i];
                end;
              end;              DM.OraTable1['xxxh'] := Trim(Cells[3, i]);  //型号
              if (Cells[1, I] = 'YG') or (Cells[1, I] = 'DJ') then
              begin
                if i>0 then
                begin
                  if Trim(Cells[3, i]) = gg then
                  begin
                    gs1 := gs1 + 1;
                    cd1 := cd1 + cd
                  end
                  else
                  begin
                  with DM.OraTable2 do
                  begin
                    Close;
                    TableName:='002'; 
                    Filter:='';
                    Filtered:=False;
                    Open;
                  end;
                    DM.OraTable2.Append;
                    DM.OraTable2['num']:=Trim(xnum);
                    DM.OraTable2['rq']:=StrtoDate(xrq);
                    DM.OraTable2['yyyggg'] := gg;
                    DM.OraTable2['yyygcd'] := cd1;
                    DM.OraTable2['yyyggs'] := gs1;
                    DM.OraTable2['yyqsgxh'] := qsxh;
                    qsxh := qsxh + gs1;
                    gs1 := 1;
                    cd1 := cd;
                    gg := Cells[3, i];
                  end;
                end;
              end;
            end;
          end;
          i := i + 1;
        end;
        if tjbz = 0 then
        begin
          DM.OraTable1.Post;
          DM.OraTable2.Append;
          DM.OraTable2['num']:=xnum;
          DM.OraTable2['rq']:=StrtoDate(xrq);
          DM.OraTable2['yyyggg']:=gg;
          j := i;
          while (Length(stringgrid1.Cells[2, i]) <> 0) and
            (StrtoFloat(stringgrid1.Cells[2, i]) > 0) do
          begin
            if stringgrid1.Cells[1, j] = 'YG' then
            begin
              cd1 := cd1 + cd;
              j := j + 1;
            end;
          end;
          DM.OraTable2['yyygcd']:=cd1;
          DM.OraTable2['yyyggs']:=gs1;
          DM.OraTable2['yyqsgxh']:=qsxh;
          DM.OraTable2.Post;
        end;
      end;
    end;
        messagedlg('数据保存完毕.....', mtinformation, [mbok], 0);