inv_mnlistaudit_d.pas

来自「一个MRPII系统源代码版本」· PAS 代码 · 共 1,613 行 · 第 1/4 页

PAS
1,613
字号
      if not eof then
        lbl_onhandInv.Caption:=fieldbyname('onhandInv').asstring
      else
      lbl_onhandInv.Caption:='0';
    end;
end;

procedure TFrm_Inv_MnListAudit_D.edt_Batchno1Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  //批次有效性检查
  if (BatchCtrl(AdoQry_tmp,Extedt_ItemCode.text)) then
  begin
    if edt_Batchno1.Text='' then
    begin
        DispInfo('该物料需要批次控制,批次号不能为空!',1);
        twincontrol(sender).setfocus;
        abort;
    end
    else
      if not Batchnocheck(AdoQry_tmp,edt_Batchno1.text,Extedt_ItemCode.text,'',datetimetostr(now)) then
      begin
        twincontrol(sender).setfocus;
        abort;
      end;
  end
  else
    if edt_Batchno1.Text<>'' then
    begin
      DispInfo('该物料无需批次控制!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
{  if not BatchInvcheck(AdoQry_tmp,edt_Batchno1.text,'r',whCode,WhPositionCode,strtofloat(edt_MoRequestqty1.text)) then
  begin
    twincontrol(sender).setfocus;
    abort;
  end;
  }
end;

procedure TFrm_Inv_MnListAudit_D.edt_Batchno2Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  if (BatchCtrl(AdoQry_tmp,Extedt_ItemCode.text)) then
  begin
    if edt_Batchno2.Text='' then
    begin
        DispInfo('该物料需要批次控制,批次号不能为空!',1);
        twincontrol(sender).setfocus;
        abort;
    end
    else
      if not Batchnocheck(AdoQry_tmp,edt_Batchno2.text,Extedt_ItemCode.text,'',datetimetostr(now)) then
      begin
        twincontrol(sender).setfocus;
        abort;
      end;
  end
  else
    if edt_Batchno2.Text<>'' then
    begin
      DispInfo('该物料无需批次控制!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
{  if not BatchInvcheck(AdoQry_tmp,edt_Batchno2.text,'r',whCode,WhPositionCode,strtofloat(edt_MoRequestqty2.text)) then
  begin
    twincontrol(sender).setfocus;
    abort;
  end; }
end;

procedure TFrm_Inv_MnListAudit_D.edt_Batchno3Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  if (BatchCtrl(AdoQry_tmp,Extedt_ItemCode.text)) then
  begin
    if edt_Batchno3.Text='' then
    begin
        DispInfo('该物料需要批次控制,批次号不能为空!',1);
        twincontrol(sender).setfocus;
        abort;
    end
    else
      if not Batchnocheck(AdoQry_tmp,edt_Batchno3.text,Extedt_ItemCode.text,'',datetimetostr(now)) then
      begin
        twincontrol(sender).setfocus;
        abort;
      end;
  end
  else
    if edt_Batchno3.Text<>'' then
    begin
      DispInfo('该物料无需批次控制!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
{  if not BatchInvcheck(AdoQry_tmp,edt_Batchno3.text,'r',whCode,WhPositionCode,strtofloat(edt_MoRequestqty3.text)) then
  begin
    twincontrol(sender).setfocus;
    abort;
  end;  }
end;
{
procedure TFrm_Inv_MnListAudit_D.edt_MoRealqty1Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  FloatCheck(Sender);
  //实领数量的有效性检查
  if strtofloat(edt_MoRealqty1.text)<0 then
  begin
    if strtofloat(edt_MoRequestqty1.text)>0 then
    begin
      DispInfo('此时实领数量不能小于零!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
  end
  else
  if strtofloat(edt_MoRealqty1.text)>0 then
    begin
      if strtofloat(edt_MoRequestqty1.text)<0 then
      begin
        DispInfo('此时实领数量不能大于零!',1);
        twincontrol(sender).setfocus;
        abort;
      end;
  end;
  if strtofloat(edt_MoRealqty1.text)>strtofloat(lbl_onhandInv.Caption) then
  begin
    DispInfo('当前货位库存不足。',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if (strtofloat(edt_MoRealqty1.text)>0)and
     (strtofloat(edt_MoRealqty1.text)>strtofloat(lbl_MoCtrlqty.Caption)-strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('累计实领数量超过了限额数量!',3);
  end;
  if (strtofloat(edt_MoRealqty1.text)<0)and
     (-(strtofloat(edt_MoRealqty1.text))>strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('冲销数量不能大于累计实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if not check_Bill(edt_MoRealqty1.text) then
  begin
    DispInfo('同一张单据中,不能出现正负号相反的实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  selectnext(activecontrol,True,True);
  edt_Batchno1.ControlStyle:=[cSclickEvents];
  edt_Batchno1.ControlState:=[cSclicked];
  if edt_Batchno1.CanFocus then
     edt_Batchno1.Setfocus;
end;

procedure TFrm_Inv_MnListAudit_D.edt_MoRealqty2Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  FloatCheck(Sender);
  if strtofloat(edt_MoRealqty2.text)<0 then
  begin
    if strtofloat(edt_MoRequestqty2.text)>0 then
    begin
      DispInfo('此时实领数量不能小于零!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
  end
  else
  if strtofloat(edt_MoRealqty2.text)>0 then
    begin
      if strtofloat(edt_MoRequestqty2.text)<0 then
      begin
        DispInfo('此时实领数量不能大于零!',1);
        twincontrol(sender).setfocus;
        abort;
      end;
  end;
  if strtofloat(edt_MoRealqty2.text)>strtofloat(lbl_onhandInv.Caption) then
  begin
    DispInfo('当前货位库存不足。',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if (strtofloat(edt_MoRealqty2.text)>0)and
     (strtofloat(edt_MoRealqty2.text)>strtofloat(lbl_MoCtrlqty.Caption)-strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('累计实领数量超过了限额数量!',3);
  end;
  if (strtofloat(edt_MoRealqty2.text)<0)and
     (-(strtofloat(edt_MoRealqty2.text))>strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('冲销数量不能大于累计实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if not check_Bill(edt_MoRealqty2.text) then
  begin
    DispInfo('同一张单据中,不能出现正负号相反的实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  selectnext(activecontrol,True,True);
  edt_Batchno2.ControlStyle:=[cSclickEvents];
  edt_Batchno2.ControlState:=[cSclicked];
  if edt_Batchno2.CanFocus then
     edt_Batchno2.Setfocus;
end;

procedure TFrm_Inv_MnListAudit_D.edt_MoRealqty3Exit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;
  FloatCheck(Sender);
  if strtofloat(edt_MoRealqty3.text)<0 then
  begin
    if strtofloat(edt_MoRequestqty3.text)>0 then
    begin
      DispInfo('此时实领数量不能小于零!',1);
      twincontrol(sender).setfocus;
      abort;
    end;
  end
  else
  if strtofloat(edt_MoRealqty3.text)>0 then
    begin
      if strtofloat(edt_MoRequestqty3.text)<0 then
      begin
        DispInfo('此时实领数量不能大于零!',1);
        twincontrol(sender).setfocus;
        abort;
      end;
  end;
  if strtofloat(edt_MoRealqty3.text)>strtofloat(lbl_onhandInv.Caption) then
  begin
    DispInfo('当前货位库存不足。',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if (strtofloat(edt_MoRealqty3.text)>0)and
     (strtofloat(edt_MoRealqty3.text)>strtofloat(lbl_MoCtrlqty.Caption)-strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('累计实领数量超过了限额数量!',3);
  end;
  if (strtofloat(edt_MoRealqty3.text)<0)and
     (-(strtofloat(edt_MoRealqty3.text))>strtofloat(lbl_MoRealqty.Caption)) then
  begin
    DispInfo('冲销数量不能大于累计实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if not check_Bill(edt_MoRealqty3.text) then
  begin
    DispInfo('同一张单据中,不能出现正负号相反的实领数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  selectnext(activecontrol,True,True);
  edt_Batchno3.ControlStyle:=[cSclickEvents];
  edt_Batchno3.ControlState:=[cSclicked];
  if edt_Batchno3.CanFocus then
     edt_Batchno3.Setfocus;
end; }
function TFrm_Inv_MnListAudit_D.check_Bill(MoRealqty:string):boolean;
var  //判断该记录是否需要保存
  Bookm:tBookmArk;
begin
  Result:=True;
  AdoQry_Body.DisableControls ;
  Bookm:=AdoQry_Body.GetBookmArk ;
  with AdoQry_Body do
  begin
    First;
    locate('tmpflag',1,[]);
    if eof then
    begin
      First;
      locate('tmpflag',2,[]);
    end;
    if eof then
    begin
      First;
      locate('tmpflag',3,[]);
    end;
    if not eof then
    begin
      if fieldbyname('realoutqty3').asfloat<>0 then
      begin
        if (fieldbyname('realoutqty3').asfloat>0)and(strtofloat(MoRealqty)<0)then
           Result:=False
        else
        if (fieldbyname('realoutqty3').asfloat<0)and(strtofloat(MoRealqty)>0)then
           Result:=False
      end
      else if fieldbyname('realoutqty2').asfloat<>0 then
      begin
        if (fieldbyname('realoutqty2').asfloat>0)and(strtofloat(MoRealqty)<0)then
           Result:=False
        else
        if (fieldbyname('realoutqty2').asfloat<0)and(strtofloat(MoRealqty)>0)then
           Result:=False
      end
      else if fieldbyname('realoutqty1').asfloat<>0 then
      begin
        if (fieldbyname('realoutqty1').asfloat>0)and(strtofloat(MoRealqty)<0)then
           Result:=False
        else
        if (fieldbyname('realoutqty1').asfloat<0)and(strtofloat(MoRealqty)>0)then
           Result:=False
      end;
    end;
  end;
  AdoQry_Body.GotoBookmArk(Bookm);
  AdoQry_Body.EnableControls ;
end;

procedure TFrm_Inv_MnListAudit_D.cmbx_WhCode4KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,4,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.cmbx_WhCode5KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,5,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.cmbx_WhpCode4KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,4,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.cmbx_WhpCode5KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,5,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.edt_Batchno4KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,4,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.edt_Batchno5KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
     show_WhCode(Extedt_ItemCode.text,5,whCode);
end;

procedure TFrm_Inv_MnListAudit_D.edt_MoRealqty1Exit(Sender: TObject);
begin
  inherited;
  floatcheck(sender);
  if strtofloat((sender as tedit).Text)>strtofloat(lbl_MoCtrlqty.Caption) then
  begin
    DispInfo('实领数量不能超过限额数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;
  if strtofloat((sender as tedit).Text)>strtofloat(lbl_onhandInv.Caption) then
  begin
    DispInfo('实领数量不能超过当前货位可领数量数量!',3);
    twincontrol(sender).setfocus;
    abort;
  end;

end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?