⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inv_mninaudit.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      AdoQry_tmp.sql.clear;
      AdoQry_tmp.SQL.text:=
      'Delete from InvInBillline '+
         'Where InvBillId='+FInvBillId+
             '  and InvBillqty=0 '+
             '  and InvBillId='+FInvBillId;
      AdoQry_tmp.execsql;
      AdoQry_tmp.Connection.CommitTrans;
      AdoQry_Head.edit;
      AdoQry_Head.fieldbyname('InvBilltmpflag').asinteger:=1;
      AdoQry_Head.post;
      dbgrideh.ReadOnly:=True;
      dbgrideh.Columns [8].ReadOnly :=True;
      dbgrideh.Columns [9].ReadOnly :=True;
      Edt_Date.Enabled:=False;
      act_Check.Enabled:=False;
      Act_Auto.Enabled:=False;
      Edt_MeMo.Enabled:=False;
      AdoQry_Body.enableControls;
    finally
      DBGridEh.Enabled :=True;
    end;
  except
    AdoQry_tmp.Connection.RollBackTrans;
    DispInfo('单据保存失败,请稍后再试!',1);
   AdoQry_Body.EnableControls ;
  end;
end;



procedure TFrm_Inv_MnInAudit.Act_PreviewExecute(Sender: TObject);
begin
 //inherited;
  BillPrint(AdoQry_Tmp.Connection,GetCode(Lbl_WhCodeName.Caption),Edt_BillNo.Text,Param6,ModuleCode,True,False,True,'');
end;

procedure TFrm_Inv_MnInAudit.Act_PrintExecute(Sender: TObject);
begin
 //inherited;
  BillPrint(AdoQry_Tmp.Connection,GetCode(Lbl_WhCodeName.Caption),Edt_BillNo.Text,Param6,ModuleCode,False,False,True,'');
end;

procedure TFrm_Inv_MnInAudit.setstrol;
begin
  Act_Excel.Enabled:=False;
  Act_Excel.Visible:=False;  
  if AdoQry_Head.fieldbyname('InvBilltmpflag').asinteger=1 then
  begin
    edt_Date.enabled:=False;
    edt_memo.enabled:=False;
    act_Check.Enabled :=False;
    act_auto.Enabled :=False;
    dbgrideh.Columns [8].ReadOnly :=True;
    dbgrideh.Columns [9].ReadOnly :=True;
  end
  else
  begin
    edt_Date.enabled:=True;
    edt_memo.enabled:=True;
    act_Check.Enabled :=True;
    act_auto.Enabled :=True;
    dbgrideh.ReadOnly:=False;
    dbgrideh.Columns [8].ReadOnly :=False;
    dbgrideh.Columns [9].ReadOnly :=False;
  end;
end;

procedure TFrm_Inv_MnInAudit.FormActivate(Sender: TObject);
begin
  inherited;
  ToolButton13.left:=TlBtn_Print.Left+ToolButton13.Width;
  ToolButton4.left:=ToolButton13.Left+ToolButton4.Width;
end;
procedure TFrm_Inv_MnInAudit.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
{  with AdoQry_Tmp2 do //保存当前备注 by johnson
  begin
    Close;
    sql.text:='update InvInBill '+
              '   set InvBillremArk='''+Edt_Memo.text+''' '+
              ' where InvBillId='+FInvBillid;
    execsql;
  end;}
end;

{function TFrm_Inv_MnInAudit.CurrentInvCheck(ItemCode, whCode,
  WhPosition: string; qty: real): Boolean;
var
  Sql_Txt:string;
  InvQty:real;
begin
  Sql_Txt:='select case when OnHandInv<>0 then OnHandInv'+
           '            when OnCheckInv<>0 then OnCheckInv'+
           '            when FreezeInv<>0 then FreezeInv'+
           '            when WasterInv<>0 then WasterInv'+
           '            when OnShipInv<>0 then OnShipInv'+
           '       else 0 end InvQty '+
           '  from CurrentInv'+
           ' where ItemCode='''+ItemCode+''' and '+
           '       whCode='''+whCode+''' and '+
           '       WhPositionCode='''+WhPosition+'''';
  with AdoQry_Tmp do
  begin
    Close;
    sql.clear;
    sql.Add(Sql_txt);
    open;
    If IsEmpty then
    begin
      Result:=False;
      exit;
    end;
    InvQty:=fieldbyname('InvQty').asFloat;
    If (qty<0) and (abs(qty)>InvQty) then
    Result:=False
    else
    Result:=True;
  end;
end;}

procedure TFrm_Inv_MnInAudit.DBGridEhGetCellParams(Sender: TObject;
  Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  If AdoQry_Body.fieldbyname('BackFlush').asinteger=1 then
    AFont.color:=clBlue;
end;


function TFrm_Inv_MnInAudit.ISCancelMps: boolean;  //是否核销主计划;
begin
  Result:=False;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:=' Select  MrpParamValueN From MrpParam Where MrpParamCode=''VisualManuObject''';
    open;
    if fieldbyname('MrpParamValueN').asinteger=1 then
      Result:=True;
  end;
end;

procedure TFrm_Inv_MnInAudit.CancelMps(InvBillID, InvBillLineNo:string;
  ItemCode: string; Qty: double);                   //核销主计划;
var
  Mpsid:string;
  tmpQty:double;
  CancelQty:double;
begin
  //核销量大于零
  if qty>0 then
  begin
    with AdoQry_Tmp2 do
    begin
      Close;
      sql.text:=' select MpsId ,ItemCode ,'+
                       ' MpsQty,MpsFinishQty, '+
                       '  MpsQty-MpsFinishQty as CancelQty '+
                ' from  Mps where MpsStatus=3 and ItemCode='''+ItemCode+'''' +
                ' Order by  MpsDate   ';
      open;
      if isempty then exit;
      AdoQry_Tmp2.First;
      tmpQty:=Qty;
      while not eof do
      begin
        CancelQty:=AdoQry_Tmp2.fieldbyname('CancelQty').asfloat;
        if (CancelQty >0 ) and (tmpQty>0)then
        begin
          Mpsid:=AdoQry_Tmp2.fieldbyname('MpsId').asstring;
          if CancelQty>=tmpQty then
          begin
            CancelQty:=tmpQty;
            tmpQty:=0;
          end
          else
          begin
            //CancelQty:=tmpQty;
            tmpQty:=tmpQty-CancelQty;
          end;
          with AdoQry_tmp   do
          begin
            //增加其主生产计划的的已完成量;
            Close;
            Sql.text:=' update Mps set MpsFinishQty=MpsFinishQty+'+floattostr(CancelQty)+
                      ' where Mpsid='+Mpsid;
            execsql;
            //核销过程的记录记在Inv_InvCancelMps表中;
            Close;
            Sql.text:=' insert Inv_InvCancelMps (InvBillID,InvBillLineNo, MpsID, CancelQty)'+
                      ' Values('+InvBillID+','+ InvBillLineNo+','+Mpsid+','+floattostr(CancelQty)+')';
            execsql;
          end;
        end;
        AdoQry_Tmp2.next;
      end;
    end;
  end;
  //核销量小于零
  if qty<0 then
  begin
    with AdoQry_Tmp2 do
    begin
      Close;
      sql.text:=' select MpsId ,ItemCode ,'+
                       ' MpsQty,MpsFinishQty, '+
                       '  MpsQty-MpsFinishQty as CancelQty '+
                ' from  Mps where MpsStatus=3 and ItemCode='''+ItemCode+'''' +
                ' Order by  MpsDate  DESC  ';
      open;
      if isempty then exit;
      AdoQry_Tmp2.First;
      tmpQty:=Qty;
      while not eof do
      begin
        CancelQty:=AdoQry_Tmp2.fieldbyname('CancelQty').asfloat;
        if (CancelQty >0 ) and (tmpQty<0)then
        begin
          Mpsid:=AdoQry_Tmp2.fieldbyname('MpsId').asstring;
          if CancelQty>=abs(tmpQty) then
          begin
            CancelQty:=tmpQty;
            tmpQty:=0;
          end
          else
          begin
            //CancelQty:=tmpQty;
            tmpQty:=tmpQty+CancelQty;
          end;
          with AdoQry_tmp do
          begin
            //减少其主生产计划的的已完成量;
            Close;
            Sql.text:=' update Mps set MpsFinishQty=MpsFinishQty-('+floattostr(abs(CancelQty))+')'+
                      ' where Mpsid='+Mpsid;
            execsql;
            //核销过程的记录记在Inv_InvCancelMps表中;
            Close;
            Sql.text:=' insert Inv_InvCancelMps (InvBillID,InvBillLineNo, MpsID, CancelQty)'+
                      ' Values('+InvBillID+','+ InvBillLineNo+','+Mpsid+','+floattostr(CancelQty)+')';
            execsql;
          end;
        end;
        AdoQry_Tmp2.next;
      end;
    end;
  end;

end;

function TFrm_Inv_MnInAudit.ISStockItem(ItemCode: string): boolean;
begin
  Result:=True;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select ISStockItem from Item where ItemCode='''+ItemCode+'''';
    open;
    if fieldbyname('ISStockItem').asinteger=0 then
      Result:=False;
  end;
end;

function TFrm_Inv_MnInAudit.ISMudiFather(ItemCode: string): boolean;  // 是否多父项
begin
  Result:=False;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select distinct ite_ItemCode from Bom where ItemCode='''+ItemCode+''''+
               ' and BomStatus in (0,2) ';
    open;
    if recordCount>1 then
      Result:=True;
  end;
end;

function TFrm_Inv_MnInAudit.FindFatherCode(ItemCode: string): string;  //找父项物料代码;
begin
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select  ite_ItemCode from Bom where ItemCode='''+ItemCode+''''+
               ' and BomStatus in (0,2) ';
    open;
    if not eof then
      Result:=fieldbyname('ite_ItemCode').asstring;
  end;

end;

function TFrm_Inv_MnInAudit.ISPirsSale(ItemCode: string): boolean;  //是否特销件;
begin
  Result:=False;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select PmCode from Item  where ItemCode='''+ItemCode+'''';
    open;
    if fieldbyname('PmCode').asinteger=4 then
      Result:=True;
  end;

end;

function TFrm_Inv_MnInAudit.GetRealInQty(ItemCode: string;
  Billqty: string): double;                               //得到真实的入库数量;
begin
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select '+BillQty+
              '/(BomQty*(1+BomScrAp_Percent/100.00)) as Qty '+
              ' from Bom where ItemCode='''+ItemCode+'''';
    open;
    Result:=fieldbyname('Qty').asfloat;
    Close;
  end;
end;

end.

⌨️ 快捷键说明

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