为什么总提示:;expected but 'else' found      '.'expected bu ';'found以下是代码:
procedure TfrmDAout.pnlSaveClick(Sender: TObject);
var
  str1,str2,str3,str4:string;
  tempLT:string;
begin
  str2:='select * from goodsstoragerrecord where Barcode=:barcode';
  with qryselect do
  begin
    close;
    sql.Clear;
    sql.Add(str2);
    parameters.ParamByName('barcode').Value:=trim(Rzedtbarcode.Text);
    open;
  end;
  if qryselect.RecordCount<>0 then
  begin
    tempLT:=qryselect.FieldByName('Locator').AsString;
    str3:='select * from goodsstoragerrecord where Locator:=locator';
    with qryclearcolor do
    begin
      close;
      sql.Clear;
      sql.Add(str3);
      open;
    end;   if qryclearcolor.RecordCount=1 then
    begin
      str4:='delete stockcolor where position=:position';
      with qrydelcolor do
      begin
        close;
        sql.Clear;
        sql.Add(str4);
        parameters.ParamByName('position').Value:=tempLT;
        execsql;
      end;    end
    else
    begin
    str1:='delete Goodsstoragerrecord where Barcode=:barcode';
    with qrymyout do
      begin
      close;
      sql.Clear;
      sql.Add(str1);
      parameters.ParamByName('barcode').Value:=trim(Rzedtbarcode.Text);
      execsql;
      end;
          showmessage('出库成功!');
      end;
    end; end
  else
    begin
      showmessage('出库失败,请检查是否存在BarCode!')
    end;
end;
end;

解决方案 »

  1.   

    你的代码格式太不规范了,肯定是begin..end配对错误,你自己配一下看看吧,注意代码缩进,你这样得把看代码的累死
      

  2.   

    我重新整理了一下procedure TfrmDAout.pnlSaveClick(Sender: TObject);
    var
      str1,str2,str3,str4:string;
      tempLT:string;
    begin
      str2:='select * from goodsstoragerrecord where Barcode=:barcode';
      with qryselect do
        begin
           close;
           sql.Clear;
           sql.Add(str2);
           parameters.ParamByName('barcode').Value:=trim(Rzedtbarcode.Text);
           open;
        end;
      if qryselect.RecordCount<>0 then
         begin
            tempLT:=qryselect.FieldByName('Locator').AsString;
            str3:='select * from goodsstoragerrecord where Locator:=locator';
            with qryclearcolor do
               begin
                 close;
                 sql.Clear;
                 sql.Add(str3);
                 open;
               end;        if qryclearcolor.RecordCount=1 then
               begin
                 str4:='delete stockcolor where position=:position';
                 with qrydelcolor do
                   begin
                      close;
                      sql.Clear;
                      sql.Add(str4);
                      parameters.ParamByName('position').Value:=tempLT;
                      execsql;
                   end;           end
            else
               begin
                  str1:='delete Goodsstoragerrecord where Barcode=:barcode';
                  with qrymyout do
                     begin
                       close;
                       sql.Clear;
                       sql.Add(str1);
                       parameters.ParamByName('barcode').Value:=trim(Rzedtbarcode.Text);
                       execsql;
                     end;
                     showmessage('出库成功!');
                  end;
               end;        end
      else
         begin
           showmessage('出库失败,请检查是否存在BarCode!')
         end;
      end;
    end;
      

  3.   

    和没整理一样,每个begin..end之间缩进, 并且成对的begin与end对齐就很容易看出来哪里有错了~~
      

  4.   

      showmessage('出库成功!');
      end;//去掉
      end;//去掉
      begin
      showmessage('出库失败,请检查是否存在BarCode!')
      end;
      end;//去掉
      

  5.   

    showmessage('出库成功!');
      end;//去掉  begin
      showmessage('出库失败,请检查是否存在BarCode!')
      end;
      end;//去掉
      

  6.   

    分要全给我啊,一个end;10分,总共20分
      

  7.   

    主要问题就是你在else后面加了冗余的end
    语法没搞清啊,else后面接语句或者语句块就行了,不要特意加end表示结束的
    去掉else后面的冗余end就对了
      

  8.   

    去掉两个冗余的end,第二个else前面的end后面分号去掉就ok了
      

  9.   

    不是的  我delphi里面不是这么排版的  贴上来就全部顶到前面去了。没你们说得那么不规范啦
      

  10.   

    ecjtu5208  你太棒了 这都看的出来  给你分那是必须的!
    chengquan17   感谢你提的建议,所以分嘛,你俩平分喽~~