在录入单据时,同一个品种两次或多次录入,如果保存时,就有可能出现库存溢出
如何避免?

解决方案 »

  1.   

    在ADOQuery的OnPostError事件中begin
      if (E is EDBEngineError) then
        if (E as EDBEngineError).Errors[0].ErrorCode=9729 then
        begin
          Application.MessageBox(PChar('元件编号有重复,请重新输入!'),sErr,MB_OK+MB_ICONERROR);
          Abort;
        end;
    end;
      

  2.   

    错误:
    Application.MessageBox(PChar('元件编号有重复,请重新输入!'),sErr,MB_OK+MB_ICONERROR);改为:
    Application.MessageBox(PChar('元件编号有重复,请重新输入!'),'错误',MB_OK+MB_ICONERROR);
      

  3.   

    在SQL中不允许重复的字段设为主键,然后用以下代吗:
    在ADOQuery的OnPostError事件中begin
      if (E is EDBEngineError) then
        if (E as EDBEngineError).Errors[0].ErrorCode=9729 then
        begin
          Application.MessageBox(PChar('重复,请重新输入!'),sErr,MB_OK+MB_ICONERROR);
          Abort;
        end;
    end;
      

  4.   

    楼上的我告你盗版^_^。连我自己定义的"sErr"你都不看。
      

  5.   

    begin
      try
        if IBTransaction.InTransaction then
           IBTransaction.Rollback;
        IBTransaction.StartTransaction;
      except
      end;
    end;