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

📄 inv_checkin_b.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        +','''+AdoQry_Head.fieldbyname('OnCheckDate').AsString+''''
        +','''+FormatDateTime('yyyy.mm',AdoQry_Head.fieldbyname('OnCheckDate').
          AsDateTime)+''''
        +','''+FBillTypeCode+''''
        +','''+UserCode+''''
        +','''+UserCode+''''
        +','''+AdoQry_Head.fieldbyname('VendorCode').AsString+''''
        +','''+FWhPositionCode+''''
        +','''+AdoQry_Head.fieldbyname('PoNo').AsString+''''
        +','''+AdoQry_Head.fieldbyname('VendorBillNo').AsString+''''
        +',getdate()'
        +','+QuotedStr(UserCode)
        +','+QuotedStr(opType)
        +')';
    AdoQry_Tmp.ExecSQL;
    end
    else
    begin
      CmBx_WarehouseChange(CmBx_Warehouse);
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select OnCheckBillId From OnCheckBill'
        +' Where OnCheckBillNo='''+AdoQry_Head.fieldbyname('OnCheckBillNo').AsString+''''
        +' And WHCode='''+AdoQry_Head.fieldbyname('WHCode').AsString+'''';
      AdoQry_Tmp.Open;
      Bill_ID:=AdoQry_Tmp.fieldbyname('OnCheckBillId').AsString;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select ItemCode'
        +',OnCheckQty'
        +',PoLineNo'
        +' From OnCheckBillLine'
        +' Where OnCheckBillId='+Bill_ID+'';
      AdoQry_Tmp.Open;
      AdoQry_Tmp.First;
      AdoQry_Tmp1.Connection:=DBConnect;
      while not AdoQry_Tmp.Eof do
      begin
        Tempstr:=UpdateInv(AdoQry_Tmp1,AdoQry_Head.fieldbyname('WHCode').AsString
          ,FWhPositionCode,AdoQry_Tmp.fieldbyname('ItemCode').AsString
          ,'(-('+AdoQry_Tmp.fieldbyname('OnCheckQty').AsString+'))'
          ,NeedChangePrice,True);
        if Tempstr<>'' then
        begin
          DispStr:=Tempstr;
          Abort;
        end;
        AdoQry_Tmp1.Close;
        AdoQry_Tmp1.SQL.Text:='Update PoLine Set'
          +' PoInQty=PoInQty-('+AdoQry_Tmp.fieldbyname('OnCheckQty').AsString+')'
          +' Where PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+''''
          +' And PoLineNo='''+AdoQry_Tmp.fieldbyname('PoLineNo').AsString+'''';
        AdoQry_Tmp1.ExecSQL;

        MOPOOperation(AdoQry_Tmp1,'POCheck',AdoQry_Head.fieldbyname('PoNo').AsString
          ,AdoQry_Body.fieldbyname('PoLineNo').AsInteger);

        AdoQry_Tmp.Next;
      end;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='insert OnCheckBillLineHistory(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
        +',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,chgtime,chgEmployeeCode,chgType)'
        +' select OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
        +',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,'
        +' getdate(),'
        +QuotedStr(userCode)
        +',''删除'' from oncheckBillline Where OnCheckBillId='+Bill_ID+'';
      AdoQry_Tmp.ExecSQL;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Delete OnCheckBillLine'
        +' Where OnCheckBillId='+Bill_ID+'';
      AdoQry_Tmp.ExecSQL;
    end;
    AdoQry_Body.DisableControls ;
    AdoQry_Body.First;
    Bill_LineNo:=1;
    opType:='增加';
    while(not AdoQry_Body.Eof)do
    begin
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Insert OnCheckBillLine'
        +'(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
        +',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo)'
        +'Values('
        +''''+Bill_Id+''''
        +','+IntToStr(Bill_LineNo)+''
        +','''+AdoQry_Body.fieldbyname('ItemCode').AsString+''''
        +','+AdoQry_Body.fieldbyname('OnCheckQty').AsString+''
        +','+'0'+''
        +','+'0'+''
        +','+'0'+''
        +','''+AdoQry_Body.fieldbyname('POLineNo').AsString+''''
        +','''+AdoQry_Body.fieldbyname('BillLineRemArk').AsString+''''
        +','''+AdoQry_Body.fieldbyname('BatchNo').AsString+''''
        +')';
      AdoQry_Tmp.ExecSQL;

      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:=' Insert OnCheckBillLineHistory'
        +'(OnCheckBillId,OnCheckBillLineNo,ItemCode,OnCheckQty,ReceivedQty'
        +',QcStatus,OnCheckStatus,POLineNo,BillLineRemArk,BatchNo,chgtime,chgEmployeeCode,chgType)'
        +'Values('
        +''''+Bill_Id+''''
        +','+IntToStr(Bill_LineNo)+''
        +','''+AdoQry_Body.fieldbyname('ItemCode').AsString+''''
        +','+AdoQry_Body.fieldbyname('OnCheckQty').AsString+''
        +','+'0'+''
        +','+'0'+''
        +','+'0'+''
        +','''+AdoQry_Body.fieldbyname('POLineNo').AsString+''''
        +','''+AdoQry_Body.fieldbyname('BillLineRemArk').AsString+''''
        +','''+AdoQry_Body.fieldbyname('BatchNo').AsString+''''
        +',getdate()'
        +','+QuotedStr(UserCode)
        +','+QuotedStr(opType)
        +')';
      AdoQry_Tmp.ExecSQL;
      Tempstr:=UpdateInv(AdoQry_Tmp,AdoQry_Head.fieldbyname('WHCode').AsString
        ,FWhPositionCode,AdoQry_Body.fieldbyname('ItemCode').AsString
        ,'('+AdoQry_Body.fieldbyname('OnCheckQty').AsString+')'
        ,NeedChangePrice,True);
      if Tempstr<>'' then
      begin
        DispStr:=Tempstr;
        Abort;
      end;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Update PoLine Set'
        +' PoInQty=PoInQty+'+AdoQry_Body.fieldbyname('OnCheckQty').AsString+''
        +' Where PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+''''
        +' And PoLineNo='''+AdoQry_Body.fieldbyname('PoLineNo').AsString+'''';
      AdoQry_Tmp.ExecSQL;
      MOPOOperation(AdoQry_Tmp,'POCheck',AdoQry_Head.fieldbyname('PoNo').AsString
        ,AdoQry_Body.fieldbyname('PoLineNo').AsInteger);
      AdoQry_Body.Next;
      Bill_LineNo:=Bill_LineNo+1;
    end;
    DBConnect.CommitTrans;
    AdoQry_Body.EnableControls ;
  except
    DBConnect.RollBackTrans;
    AdoQry_Body.EnableControls ;    
    DispInfo(DispStr,3);
    Abort;
  end;
end;

procedure TFrm_Inv_CheckIn_B.SaveHeadData;
begin
  inherited;
  with AdoQry_Head do
  begin
    edit;
    fieldbyname('WHCode').AsString:=GetCode(CmBx_Warehouse.Text);
    fieldbyname('WHName').AsString:=GetName(CmBx_Warehouse.Text);
    fieldbyname('PONO').AsString:=Edt_PoNO.Text;
    fieldbyname('VendorCode').AsString:=ExtEdt_VendorCode.Text;
    fieldbyname('VendorName').AsString:=Lbl_VendorName.Caption;
    fieldbyname('VendorBillNo').AsString:=Edt_VendorBillNo.Text;
    fieldbyname('OnCheckBillNo').AsString:=Edt_BillNo.Text;
    fieldbyname('OnCheckDate').AsString:=MEdt_BillDate.Text;
    fieldbyname('BillTypeName').AsString:=Lbl_BillType.Caption;
  end;
end;

procedure TFrm_Inv_CheckIn_B.SetStatus(CurrentStatus: String;
  var AnswerStatus, EnableControls: String);
begin
  inherited;
  if (CurrentStatus='Edit') then
  begin
    AnswerStatus:='PArtEdit';
    EnableControls:='';
  end
  else if (CurrentStatus='Add') then
  begin
    AnswerStatus:='Add';
    EnableControls:='';
  end;
end;

procedure TFrm_Inv_CheckIn_B.FormCreate(Sender: TObject);
begin
  inherited;
  Frm_Entry_Detail:=TFrm_Inv_CheckIn_D.Create(Self);
end;

procedure TFrm_Inv_CheckIn_B.CmBx_WarehouseChange(Sender: TObject);
begin
  inherited;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select WhPositionCode'
    +' From WhPosition Where WhPositionType=1'
    +' And WHCode='''+GetCode(CmBx_Warehouse.Text)+'''';
  AdoQry_Tmp.Open;
  FWhPositionCode:=AdoQry_Tmp.fieldbyname('WhPositionCode').AsString;
end;

procedure TFrm_Inv_CheckIn_B.PoCodeCheck(Sender: TObject);
begin
  if ActiveControl=ExtEdt_VendorCode then
    Exit;  
  inherited;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select Po.PoType,Po.VendorCode'
    +' From Po Where Po.PoNo='''+TEdit(Sender).Text+'''';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.fieldbyname('VendorCode').AsString<>ExtEdt_VendorCode.Text then
  begin
    DispInfo('订单号不存在或不属于该供应商!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
  Case AdoQry_Tmp.fieldbyname('PoType').AsInteger of
    0:
    begin
      FBillTypeCode:='0101';
      Lbl_BillType.Caption:='采购入库单';
    end;
    1:
    begin
      FBillTypeCode:='0103';
      Lbl_BillType.Caption:='委外采购入库单';
    end;
    2:
    begin
      FBillTypeCode:='0102';
      Lbl_BillType.Caption:='进口采购入库单';
    end;
  end;
  Frm_Entry_Detail.SetFormParam(FBillTypeCode,FWhPositionCode,FFDays,FBDays,FOQty,'');
end;

procedure TFrm_Inv_CheckIn_B.Edt_PoNOKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
  begin
    TEdit(Sender).Text:=GetPoNo(ExtEdt_VendorCode.Text,'',DBConnect);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

procedure TFrm_Inv_CheckIn_B.Act_PreviewExecute(Sender: TObject);
begin
 // inherited;
 BillPrint(AdoQry_Tmp.Connection,GetCode(CmBx_Warehouse.text),Edt_BillNo.text,'1102',ModuleCode,True,False,True,'');
end;

procedure TFrm_Inv_CheckIn_B.Act_PrintExecute(Sender: TObject);
begin
 // inherited;
  BillPrint(AdoQry_Tmp.Connection,GetCode(CmBx_Warehouse.text),Edt_BillNo.text,'1102',ModuleCode,False,False,True,'');
end;

procedure TFrm_Inv_CheckIn_B.Act_DeleteLineExecute(Sender: TObject);
begin
  if(AdoQry_Body.fieldbyname('QcStatus').AsString='0')
    or(AdoQry_Body.fieldbyname('QcStatus').AsString='')then
    inherited
  else
    DispInfo('该记录已经通过质量判定,不允许删除!',3);
end;

procedure TFrm_Inv_CheckIn_B.CmBx_WarehouseExit(Sender: TObject);
begin
  inherited;
  if FWhPositionCode='' then
  begin
    DispInfo('该仓库没有定义待检货位!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

end.

⌨️ 快捷键说明

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