inv_mnlistaudit_d.pas

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

PAS
1,613
字号
      else if (strtofloat(edt_MoRealqty3.Text)<>0)
             and(strtofloat(edt_MoRealqty4.text)=0)
             and(AdoQry_Body.fieldbyname('tmpflag').asfloat<>0) then
          begin
            edt_MoRealqty3.Enabled :=True;
            edt_MoRealqty3.SetFocus ;
            edt_Batchno3.Enabled :=True;
          end
    end;
    //判断第4次领是否有焦点
    if edt_MoRealqty3.Enabled then
    else
    begin
      if (strtofloat(edt_MoRealqty4.Text)=0)and(strtofloat(edt_MoRealqty3.text)<>0)  then
      begin
        edt_MoRealqty4.Enabled :=True;
        edt_MoRealqty4.SetFocus ;
        edt_Batchno4.Enabled :=True;
      end
      else if (strtofloat(edt_MoRealqty4.Text)<>0)
             and(strtofloat(edt_MoRealqty5.text)=0)
             and(AdoQry_Body.fieldbyname('tmpflag').asfloat<>0) then
          begin
            edt_MoRealqty4.Enabled :=True;
            edt_MoRealqty4.SetFocus ;
            edt_Batchno4.Enabled :=True;
          end
    end;
    //判断第5次领是否有焦点
    if edt_MoRealqty4.Enabled then
    else
    begin
      if (strtofloat(edt_MoRealqty5.Text)=0)and(strtofloat(edt_MoRealqty4.text)<>0)  then
      begin
        edt_MoRealqty5.Enabled :=True;
        edt_MoRealqty5.SetFocus ;
        edt_Batchno5.Enabled :=True;
      end
      else if (strtofloat(edt_MoRealqty5.Text)<>0)
             and(AdoQry_Body.fieldbyname('tmpflag').asfloat<>0) then
          begin
            edt_MoRealqty5.Enabled :=True;
            edt_MoRealqty5.SetFocus ;
            edt_Batchno5.Enabled :=True;
          end
    end;
  if edt_MoRealqty1.Enabled  then
  begin
    InitCmBxText(cmbx_WhCode1,whCode);
    InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode1,'WhPosition','WhPositionCode',
      'WhPositionName','whCode='''+getCode(cmbx_WhCode1.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
    InitCmBxText(cmbx_WhpCode1,WhPositionCode);
    with AdoQry_Body do
    begin
      if fieldbyname('alterNative').AsInteger=1 then
      begin
        Bookm:=GetBookmArk ;
        tmp_Parentid:=fieldbyname('Parentid').AsInteger;
        Locate('ItemListid',tmp_Parentid,[]);
        td_Ctrlqty:=fieldbyname('moCtrlqty').asfloat-
           fieldbyname('MoRealqty').asfloat-
           fieldbyname('realoutqty1').asfloat;
        GotoBookmArk(Bookm);
        lbl_MoCtrlqty.Caption:=inttostr(round(td_Ctrlqty*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
      end
      else
        lbl_MoCtrlqty.Caption:=inttostr(round(fieldbyname('moCtrlqty').asfloat));
    end;

//    whCode:=cmbx_WhCode1.Text ;
//    WhPositionCode:=cmbx_WhpCode1.Text ;
  end;
  if edt_MoRealqty2.Enabled  then
  begin
    InitCmBxText(cmbx_WhCode2,whCode);
    InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode2,'WhPosition','WhPositionCode',
      'WhPositionName','whCode='''+getCode(cmbx_WhCode2.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
    InitCmBxText(cmbx_WhpCode2,WhPositionCode);
    with AdoQry_Body do
    begin
      if fieldbyname('alterNative').AsInteger=1 then
      begin
        Bookm:=GetBookmArk ;
        tmp_Parentid:=fieldbyname('Parentid').AsInteger;
        Locate('ItemListid',tmp_Parentid,[]);
        td_Ctrlqty:=fieldbyname('moCtrlqty').asfloat-
           fieldbyname('MoRealqty').asfloat-
           fieldbyname('realoutqty2').asfloat;
        GotoBookmArk(Bookm);
        lbl_MoCtrlqty.Caption:=inttostr(round(td_Ctrlqty*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
      end
      else
        lbl_MoCtrlqty.Caption:=inttostr(round(fieldbyname('moCtrlqty').asfloat));
    end;

//    whCode:=cmbx_WhCode2.Text ;
//    WhPositionCode:=cmbx_WhpCode2.Text ;
  end;
  if edt_MoRealqty3.Enabled  then
  begin
    InitCmBxText(cmbx_WhCode3,whCode);
    InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode3,'WhPosition','WhPositionCode',
      'WhPositionName','whCode='''+getCode(cmbx_WhCode3.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
    InitCmBxText(cmbx_WhpCode3,WhPositionCode);
    with AdoQry_Body do
    begin
      if fieldbyname('alterNative').AsInteger=1 then
      begin
        Bookm:=GetBookmArk ;
        tmp_Parentid:=fieldbyname('Parentid').AsInteger;
        Locate('ItemListid',tmp_Parentid,[]);
        td_Ctrlqty:=fieldbyname('moCtrlqty').asfloat-
           fieldbyname('MoRealqty').asfloat-
           fieldbyname('realoutqty3').asfloat;
        GotoBookmArk(Bookm);
        lbl_MoCtrlqty.Caption:=inttostr(round(td_Ctrlqty*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
      end
      else
        lbl_MoCtrlqty.Caption:=inttostr(round(fieldbyname('moCtrlqty').asfloat));
    end;
//    whCode:=cmbx_WhCode3.Text ;
//    WhPositionCode:=cmbx_WhpCode3.Text ;
  end;
  if edt_MoRealqty4.Enabled  then
  begin
    InitCmBxText(cmbx_WhCode4,whCode);
    InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode4,'WhPosition','WhPositionCode',
      'WhPositionName','whCode='''+getCode(cmbx_WhCode4.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
    InitCmBxText(cmbx_WhpCode4,WhPositionCode);
    with AdoQry_Body do
    begin
      if fieldbyname('alterNative').AsInteger=1 then
      begin
        Bookm:=GetBookmArk ;
        tmp_Parentid:=fieldbyname('Parentid').AsInteger;
        Locate('ItemListid',tmp_Parentid,[]);
        td_Ctrlqty:=fieldbyname('moCtrlqty').asfloat-
           fieldbyname('MoRealqty').asfloat-
           fieldbyname('realoutqty4').asfloat;
        GotoBookmArk(Bookm);
        lbl_MoCtrlqty.Caption:=inttostr(round(td_Ctrlqty*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
      end
      else
        lbl_MoCtrlqty.Caption:=inttostr(round(fieldbyname('moCtrlqty').asfloat));
    end;

//    whCode:=cmbx_WhCode4.Text ;
//    WhPositionCode:=cmbx_WhpCode4.Text ;
  end;
  if edt_MoRealqty5.Enabled  then
  begin
    InitCmBxText(cmbx_WhCode5,whCode);
    InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhpCode5,'WhPosition','WhPositionCode',
      'WhPositionName','whCode='''+getCode(cmbx_WhCode5.Text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
    InitCmBxText(cmbx_WhpCode5,WhPositionCode);
    with AdoQry_Body do
    begin
      if fieldbyname('alterNative').AsInteger=1 then
      begin
        Bookm:=GetBookmArk ;
        tmp_Parentid:=fieldbyname('Parentid').AsInteger;
        Locate('ItemListid',tmp_Parentid,[]);
        td_Ctrlqty:=fieldbyname('moCtrlqty').asfloat-
           fieldbyname('MoRealqty').asfloat-
           fieldbyname('realoutqty5').asfloat;
        GotoBookmArk(Bookm);
        lbl_MoCtrlqty.Caption:=inttostr(round(td_Ctrlqty*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
      end
      else
        lbl_MoCtrlqty.Caption:=inttostr(round(fieldbyname('moCtrlqty').asfloat));
    end;

//    whCode:=cmbx_WhCode5.Text ;
//    WhPositionCode:=cmbx_WhpCode5.Text ;
  end;
    CurrentInvfields:=getInvfield(AdoQry_tmp,getCode(whCode),getCode(WhPositionCode),'CurrentInv');
    with AdoQry_tmp do
    begin
      Close;
      sql.clear;
      sql.Add('select '+CurrentInvfields+ ' as onhandInv from CurrentInv where whCode='''+getCode(whCode)+''' and WhPositionCode='''+getCode(WhPositionCode)+''' and ItemCode='''+Extedt_ItemCode.text+'''');
      open;
      if not eof then
        lbl_onhandInv.Caption:=fieldbyname('onhandInv').asstring
      else
      lbl_onhandInv.Caption:='0';
    end;
  if edt_MoRealqty1.CanFocus then
     edt_MoRealqty1.SetFocus ;
     }
end;
{
procedure TFrm_Inv_MnListAudit_D.SaveBodyData;
var
  sqltext:string;
  Bookm:TBookmArk;
  tmp_Parentid:integer;
  this_qty:real;
begin//把Form的控件值写入缓存,要Post
 inherited;
  with AdoQry_Body do
  begin
    status:='ReadOnly';
    if status='Add' then
    begin
      fieldbyname('UomName').AsString:=lbl_UomName.Caption;
      fieldbyname('MoRealqty').Asstring:='0';
      fieldbyname('moCtrlqty').asstring:='0';
    end;
    if (judge1) then
       fieldbyname('tmpflag').asfloat:=1;
    if (judge2) then
       fieldbyname('tmpflag').asfloat:=2;
    if (judge3) then
       fieldbyname('tmpflag').asfloat:=3;
    if (judge4) then
       fieldbyname('tmpflag').asfloat:=4;
    if (judge5) then
       fieldbyname('tmpflag').asfloat:=5;

    fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
    fieldbyname('ItemDESC').AsString:=ExtEdt_ItemCode.Text+' '+lbl_ItemName.Caption;
    fieldbyname('whCode1').AsString:=cmbx_WhCode1.Text;
    fieldbyname('WhPositionCode1').AsString:=cmbx_WhpCode1.Text ;
    fieldbyname('Batchno1').Asstring:=edt_Batchno1.Text ;
//    fieldbyname('Requestqty1').Asstring:=edt_MoRequestqty1.Text;
    fieldbyname('realoutqty1').asstring:=edt_MoRealqty1.Text ;
    fieldbyname('Requesttime1').asstring:=lbl_Requesttime1.Caption ;
    fieldbyname('whCode2').AsString:=cmbx_WhCode2.Text;
    fieldbyname('WhPositionCode2').AsString:=cmbx_WhpCode2.Text ;
    fieldbyname('Batchno2').Asstring:=edt_Batchno2.Text ;
//    fieldbyname('Requestqty2').Asstring:=edt_MoRequestqty2.Text;
    fieldbyname('realoutqty2').asstring:=edt_MoRealqty2.Text ;
    fieldbyname('Requesttime2').asstring:=lbl_Requesttime2.Caption ;
    fieldbyname('whCode3').AsString:=cmbx_WhCode3.Text;
    fieldbyname('WhPositionCode3').AsString:=cmbx_WhpCode3.Text ;
    fieldbyname('Batchno3').Asstring:=edt_Batchno3.Text ;
//    fieldbyname('Requestqty3').Asstring:=edt_MoRequestqty3.Text;
    fieldbyname('realoutqty3').asstring:=edt_MoRealqty3.Text ;
    fieldbyname('Requesttime3').asstring:=lbl_Requesttime3.Caption ;
    //注销实领数量的缓存改变
    fieldbyname('whCode4').AsString:=cmbx_WhCode4.Text;
    fieldbyname('WhPositionCode4').AsString:=cmbx_WhpCode4.Text ;
    fieldbyname('Batchno4').Asstring:=edt_Batchno4.Text ;
    fieldbyname('realoutqty4').asstring:=edt_MoRealqty4.Text ;
    fieldbyname('Requesttime4').asstring:=lbl_Requesttime4.Caption ;
//
    fieldbyname('whCode5').AsString:=cmbx_WhCode5.Text;
    fieldbyname('WhPositionCode5').AsString:=cmbx_WhpCode5.Text ;
    fieldbyname('Batchno5').Asstring:=edt_Batchno5.Text ;
    fieldbyname('realoutqty5').asstring:=edt_MoRealqty5.Text ;
    fieldbyname('Requesttime5').asstring:=lbl_Requesttime5.Caption ;
    Post;
  end;

  with AdoQry_Body do
  begin
    if fieldbyname('alterNative').AsInteger=1 then
    begin
       if judge1 then
       begin
          this_qty:=round(fieldbyname('realoutqty1').asfloat/
               (fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
          Bookm:=GetBookmArk;
          tmp_Parentid:=fieldbyname('Parentid').AsInteger;
          Locate('ItemListid',tmp_Parentid,[]);
          edit;
          fieldbyname('realoutqty1').asfloat:=fieldbyname('realoutqty1').asfloat+this_qty;
          fieldbyname('tmpflag').asfloat:=1;
          post;
          GotoBookmArk(Bookm);
       end;
       if judge2 then
       begin
          this_qty:=round(fieldbyname('realoutqty2').asfloat/
               (fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
          Bookm:=GetBookmArk;
          tmp_Parentid:=fieldbyname('Parentid').AsInteger;
          Locate('ItemListid',tmp_Parentid,[]);
          edit;
          fieldbyname('realoutqty2').asfloat:=fieldbyname('realoutqty2').asfloat+this_qty;
          fieldbyname('tmpflag').asfloat:=2;
          post;
          GotoBookmArk(Bookm);
       end;
       if judge3 then
       begin
          this_qty:=round(fieldbyname('realoutqty3').asfloat/
               (fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
          Bookm:=GetBookmArk;
          tmp_Parentid:=fieldbyname('Parentid').AsInteger;
          Locate('ItemListid',tmp_Parentid,[]);
          edit;
          fieldbyname('realoutqty3').asfloat:=fieldbyname('realoutqty3').asfloat+this_qty;
          fieldbyname('tmpflag').asfloat:=3;
          post;
          GotoBookmArk(Bookm);
       end;
       if judge4 then
       begin
          this_qty:=round(fieldbyname('realoutqty4').asfloat/
               (fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
          Bookm:=GetBookmArk;
          tmp_Parentid:=fieldbyname('Parentid').AsInteger;
          Locate('ItemListid',tmp_Parentid,[]);
          edit;
          fieldbyname('realoutqty4').asfloat:=fieldbyname('realoutqty4').asfloat+this_qty;
          fieldbyname('tmpflag').asfloat:=4;
          post;
          GotoBookmArk(Bookm);
       end;
       if judge5 then
       begin
          this_qty:=round(fieldbyname('realoutqty5').asfloat/
               (fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100)));
          Bookm:=GetBookmArk;
          tmp_Parentid:=fieldbyname('Parentid').AsInteger;
          Locate('ItemListid',tmp_Parentid,[]);
          edit;
          fieldbyname('realoutqty5').asfloat:=fieldbyname('realoutqty').asfloat+this_qty;
          fieldbyname('tmpflag').asfloat:=5;
          post;
          GotoBookmArk(Bookm);
       end;

    end;

  end;
end;
}

procedure TFrm_Inv_MnListAudit_D.FormCreate(Sender: TObject);
begin
  inherited;
//
end;

procedure TFrm_Inv_MnListAudit_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
  inherited;
  enablecontrols:='btn_Cancel,';
end;

procedure TFrm_Inv_MnListAudit_D.SetFormParam(frmParam1, frmParam2,
  frmParam3, frmParam4, frmParam5, frmParam6: string);
begin
  inherited;
  tmp_Mono:=frmParam1;
  tmp_MoLineno:=frmParam2;
  whCode:=frmParam3;
  WhPositionCode:=frmParam4;
  tmp_Date:=frmParam5;
  tmp_ShiftType:=frmParam6;
end;

procedure TFrm_Inv_MnListAudit_D.InOutItemCodeCheck(Sender: TObject);
var
  CurrentInvfields:string;
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    exit;

  if status='Add' then
  begin
    //根据当前货位决定取CurrentInv中的那一个字段
    CurrentInvfields:=getInvfield(AdoQry_tmp,whCode,WhPositionCode,'CurrentInv');
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add(
         'Select Count(*) as rCount '+
           'From mnItemList '+
           'Where ItemCode='''+TEdit(Sender).Text+''' and '+
              'mono='''+tmp_Mono+''' and '+
              'MoLineno='+tmp_MoLineno);
      Open;
      if fieldbyname('rCount').asinteger>0 then
      begin
        DispInfo('该物料已经存在,不允许增加或修改!',1);
        TWinControl(Sender).SetFocus;
        Abort;
      end
      else
      begin
        AdoQry_Body.First;
        if AdoQry_Body.locate('ItemCode',Extedt_ItemCode.text,[]) then
        begin
            DispInfo('该物料已经存在,不允许增加或修改!',1);
            TWinControl(Sender).SetFocus;
            Abort;
        end
        else
        begin
          //显示计量单位
          Close;
          sql.clear;
          sql.Add('select UomName from Uom,Item where Item.ItemCode='''+Extedt_ItemCode.text+''' and Item.UomCode=Uom.UomCode ');
          open;
          lbl_UomName.Caption:=fieldbyname('UomName').asstring;
          //显示可用库存
          Close;
          sql.clear;

⌨️ 快捷键说明

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