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

📄 stk_enter_passcheckinvbill.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  Tempstr:string;
  j:integer;
begin
  //真正开始存盘
  BeforeSaveError:=False;
  currencyCode:='00';
  Stkcheck:=1;
  //取单据号
  fBillno:=getno(AdoQry_Body.Connection,getCode(CmBx_Warehouse.text)+'R'+copy(MEdt_InAccountDate.text,3,2)+copy(MEdt_InAccountDate.text,6,2),'InvBill');
     //记录本仓库数据发生改变
  ChangeInvStatus(AdoQry_tmp,getCode(CmBx_Warehouse.text),copy(MEdt_InAccountDate.text,1,7));
   //增加InvInBill
  AdoQry_tmp.Close;
  AdoQry_tmp.sql.clear;
  AdoQry_tmp.sql.Add('insert InvInBill'+
                     '(InvBillno,'+
                     'whCode,'+
                     'InvBilldate,'+
                     'InvBillMonth,'+
                     'BillTypeCode,'+
                     'BillType2Code,'+
                     'EmployeeCode,'+
                     'Stk_EmployeeCode,'+
                     'DeptCode,'+
                     'WhPositionCode,'+
                     'InvBillwhchck,'+
                     'InvBillStkchck,'+
                     'currencyCode,'+
                    // 'InvBilltaxrate,'+
                     'InvBillremArk)'+
             'Values('''+FBillno+''','+
                    ''''+getCode(CmBx_Warehouse.text)+''','+
                    ''''+MEdt_InAccountDate.text+''','+
                    ''''+copy(MEdt_InAccountDate.text,1,7)+''','+
                    ''''+'0199'+''','+
                    ''''+'012'+''','+
                    ''''+userCode+''','+
                    ''''+userCode+''','+
                    ''''+ExtEdt_VendorCode.text+''','+
                    ''''+getCode(CmBx_WhPosition.text)+''','+
                    '1,'+
                    inttostr(Stkcheck)+','+
                    ''''+currencyCode+''','+
                    //Vendortaxrate_Percent+','+
                    quotedstr(Edt_RemArk.text)+')');

    AdoQry_tmp.execsql;
        //取InvBillID
  Billid:='';
  AdoQry_tmp.Close;
  AdoQry_tmp.sql.clear;
  AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
  AdoQry_tmp.open;
  Billid:=AdoQry_tmp.fieldbyname('Billid').asstring;
  Amount:=0;
  with AdoQry_Body do
  begin
    First;
    j:=1;
    for M:=0 to recordCount-1 do
    begin
      //由于显示在DBGRID中的价格不管外币还是人民币,都是用同一个字段,因
      //此在存盘时把字段分开,如下:
      if AdoQry_Body.fieldbyname('ProfitLossQty').asfloat<>0.00 then
      begin
     {if currencyCode='00' then
      begin
        tmp_InvBillPrice:=fieldbyname('InvBillPrice').asstring;
        tmp_InvBillnotaxPrice:=fieldbyname('InvBillnotaxPrice').asstring;
        tmp_InvBillAmount:=fieldbyname('InvBillAmount').asstring;
        tmp_InvBillnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
        tmp_InvBillPricec:=fieldbyname('InvBillPrice').asstring;
        tmp_InvBillnotaxPricec:=fieldbyname('InvBillnotaxPrice').asstring;
        tmp_InvBillAmountc:=fieldbyname('InvBillAmount').asstring;
        tmp_InvBillnotaxAmountc:=fieldbyname('InvBillnotaxAmount').asstring;
       end ; }
     { else
      begin
        tmp_InvBillPrice:=floattostr(fieldbyname('InvBillPrice').asfloat/strtofloat(ExchRate));
        tmp_InvBillnotaxPrice:=floattostr(fieldbyname('InvBillnotaxPrice').asfloat/strtofloat(ExchRate));
        tmp_InvBillAmount:=floattostr(fieldbyname('InvBillAmount').asfloat/strtofloat(ExchRate));
        tmp_InvBillnotaxAmount:=floattostr(fieldbyname('InvBillnotaxAmount').asfloat/strtofloat(ExchRate));
        tmp_InvBillPricec:=fieldbyname('InvBillPrice').asstring;
        tmp_InvBillnotaxPricec:=fieldbyname('InvBillnotaxPrice').asstring;
        tmp_InvBillAmountc:=fieldbyname('InvBillAmount').asstring;
        tmp_InvBillnotaxAmountc:=fieldbyname('InvBillnotaxAmount').asstring;
      end;}
      //只用人民币结算
      //Amount:=Amount+strtofloat(tmp_InvBillAmount);
      //更改加权平均价
      {if True then
      begin
        AdoQry_tmp.Close;
        AdoQry_tmp.sql.clear;
        AdoQry_tmp.sql.text:=
          ' if not exists (select Apqty from AveragePrice '+
                          ' where whCode='''+getCode(CmBx_Warehouse.text)+''' and '+
                               ' ItemCode='''+fieldbyname('ItemCode').asstring+''')'+
          ' insert AveragePrice(whCode,ItemCode) '+
               ' Values('''+getCode(CmBx_Warehouse.text)+''','+
               ''''+fieldbyname('ItemCode').asstring+''')'+
          ' update AveragePrice '+
          ' set Apqty=Apqty+'+fieldbyname('InvBillqty').asstring+','+
          '  ApAmount=ApAmount+'+tmp_InvBillnotaxAmount+
           ' where whCode='''+getCode(CmBx_Warehouse.text)+''' and '+
                          '       ItemCode='''+fieldbyname('ItemCode').asstring+''''+
          ' update AveragePrice '+
                          '  set AveragePrice=case when Apqty=0 then AveragePrice else ApAmount/Apqty end '+
                          ' where whCode='''+getCode(CmBx_Warehouse.text)+''' and '+
                          '       ItemCode='''+fieldbyname('ItemCode').asstring+'''';
        AdoQry_tmp.execsql;
      end;  }
      //增加InvBillLINE
      AdoQry_tmp.Close;
      AdoQry_tmp.sql.clear;
      AdoQry_tmp.sql.Add('insert InvInBillline'+
                                   '(InvBillid,'+
                                   'InvBilllineno,'+
                                   'ItemCode,'+
                                   'InvBillqty,'+
                                   'BilllineremArk,'+
                                   'Batchno '+
                                   {'bl.InvBillPrice,'+
                                   'bl.InvBillAmount,'+
                                   'bl.InvBillnotaxPrice,'+
                                   'bl.InvBillnotaxAmount,'+
                                   'bl.InvBillPricec,'+
                                   'bl.InvBillAmountc,'+
                                   'bl.InvBillnotaxPricec,'+
                                   'bl.InvBillnotaxAmountc '+ }
                                   ')'+
                         'Values('+Billid+','+
                                 inttostr(j)+','+
                                 ''''+fieldbyname('ItemCode').asstring+''','+
                                 fieldbyname('ProfitLossQty').asstring+','+
                                 ''''+fieldbyname('PLCause').asstring+''','+
                                 ''''+fieldbyname('Batchno').asstring+''''+
                                 {tmp_InvBillPrice+','+
                                 tmp_InvBillAmount+','+
                                 tmp_InvBillnotaxPrice+','+
                                 tmp_InvBillnotaxAmount+','+
                                 tmp_InvBillPricec+','+
                                 tmp_InvBillAmountc+','+
                                 tmp_InvBillnotaxPricec+','+
                                 tmp_InvBillnotaxAmountc+ }
                                 ')' );
      AdoQry_tmp.ExecSQL;

      //更改当前库存  更改Item表的库存数据
     { UpdateInv(AdoQry_tmp,
                tmp_WhCode,
                tmp_WhPositionCode,
                fieldbyname('ItemCode').asstring,
                '('+fieldbyname('InvBillqty').asstring+')',
                NeedChangePrice); }

    Tempstr:=UpdateInv(AdoQry_tmp,
                getCode(CmBx_Warehouse.text),
                getCode(CmBx_WhPosition.text),
                fieldbyname('ItemCode').asstring,
                '('+fieldbyname('ProfitLossQty').asstring+')',
                NeedChangePrice,True);
    if Tempstr<>'' then
    begin
      //DispStr:=Tempstr;
      Abort;
    end;
     { //更改批次库存数量
      if fieldbyname('Batchno').asstring<>'' then
      begin
        ChangeBatchInv(AdoQry_tmp,fieldbyname('Batchno').asstring,
                       'R',
                       medt_Date.text,
                       tmp_WhCode,
                       tmp_WhPositionCode,
                       fieldbyname('InvBillqty').asfloat);
      end;}
        j:=j+1;
      end;
      next;
    end;
  end;
  //更改入库单价格金额;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:=' update InvInBillline '+
                 ' set InvBillPrice=Sc_PriceMaster.Price,'+
                     ' InvBillAmount=Sc_PriceMaster.Price*InvBillQty,'+
                     '  InvBillNoTaxPrice=Sc_PriceMaster.Price,'+
                     '  InvBillNoTaxAmount=Sc_PriceMaster.Price*InvBillQty,'+
                     '  InvBillPriceC=Sc_PriceMaster.Price,'+
                     '  InvBillAmountC=Sc_PriceMaster.Price*InvBillQty,'+
                     '  InvBillNoTaxPriceC=Sc_PriceMaster.Price,'+
                     '  InvBillNoTaxAmountC=Sc_PriceMaster.Price*InvBillQty '+
              ' from Sc_PriceMaster '+
              ' where Sc_PriceMaster.ItemCode=InvInBillline.ItemCode'+
                    ' and InvInBillline.InvBillid='+Billid;
    AdoQry_tmp.ExecSQL;
  end;
end;

procedure TFrm_Stk_Enter_PassCheckInvBill.LEdt_PassEmployeeCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  if(Key=120)then
    CommonHint(Sender,AdoQry_Tmp,'EmployeeName','人员名称','EmployeeCode','人员代码','Employee');
end;

procedure TFrm_Stk_Enter_PassCheckInvBill.LEdt_PassEmployeeCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'EmployeeName','人员名称','EmployeeCode','人员代码','Employee');
end;

procedure TFrm_Stk_Enter_PassCheckInvBill.LEdt_PassEmployeeCodeExit(
  Sender: TObject);
begin
  inherited;
  if (ActiveControl.Name='ToolButton4') then
    Abort;
  if Trim(LEdt_PassEmployeeCode.text)='' then
  begin
    DispInfo('批准人不能为空请输入!',3);
    LEdt_PassEmployeeCode.SetFocus ;
    abort;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select EmployeeName from Employee where EmployeeCode='''+Trim(LEdt_PassEmployeeCode.text)+'''';
    open;
    if isempty then
    begin
      DispInfo('批准人不存在请重新输入!',3);
      LEdt_PassEmployeeCode.SetFocus ;
      abort;
    end
    else
      Edt_PassEmployeeName.text:=fieldbyname('EmployeeName').asstring;
  end;
end;


function TFrm_Stk_Enter_PassCheckInvBill.isProfitLoss: boolean;
begin
  Result:=True;
  with AdoQry_Body do
  begin
    First;
    while not eof do
    begin
      if fieldbyname('ProfitLossQty').asfloat<>0.00 then
      begin
        Result:=False;
        break;
      end;
      next;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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