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

📄 ap_enter_noinvoiceinvinorder.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        Extedt_OutCode.Text:=outCode;
        lbl_OutName.text:=outName;
      end;}
      Edt_InvBillNo.text:='';
    end;
  end;
  //如果入库对象为供应商,则入库对象代码一定要为供应商代码,通过调用Extedt_OutCodeExit事件
  // if (Cmbbx_OutType.text='供应商') and (Extedt_OutCode.Text<>'') then
  //   Extedt_OutCodeExit(Extedt_OutCode)
  // else
  begin
    {currencyCode:='00';
    lbl_CurrencyName.text:='00 人民币';
    Vendortaxrate_Percent:='0';
    ExchRate:='1';}
  end;
  //IoType:=0;
  //单据类型
  //BillTypeCode:=Param1;
  Edt_VendorName.Enabled :=False;
  Edt_WhName.Enabled :=False;
  Edt_CurrencyName.Enabled :=False;
  Edt_WhPositionName.Enabled :=False;
  Edt_InvBillTaxRate.Enabled :=False;
  Edt_InvBillNo.Enabled :=False;
  Edt_CurrencyCode.Enabled :=False;
  Edt_BillTypeName.Enabled :=False;  
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder.SaveData;
var
  Billno:string;
  tmp_InvBillPrice,tmp_InvBillnotaxPrice,
  tmp_InvBillAmount,tmp_InvBillnotaxAmount,tmp_InvBillPricec,
  tmp_InvBillnotaxPricec,tmp_InvBillAmountc,tmp_InvBillnotaxAmountc:string;

  M:integer;
  Amount:real;
  Billid:string;
begin
  //取单据号
  inherited;
  if AdoQry_Body.state<>dsBrowse then
    AdoQry_Body.post;      
 { //取服务器的日期;
  Executesql(AdoQry_tmp,'select convert (varchAr(10),getdate(),102) as a ',0);
  curdate:=AdoQry_tmp.fieldbyname('a').asstring;}
  if not Edt_InvBillDate.Enabled  then
    Edt_InvBillDate.Enabled:=True;
  if Trim(Edt_InvBillDate.text)>curdate  then
  begin
    DispInfo('单据日期和单据月份必须小于等于当前日期或月份',3);
    Edt_InvBillDate.setfocus;
    abort;
  end;
  dbconnect.beginTrans;
  try
   if Status='Add' then
   begin
     //增加InvInBill
      AdoQry_tmp.Close;
      AdoQry_tmp.sql.clear;
      AdoQry_tmp.sql.Add('insert InvInBill'+
                         '(InvBillno,'+
                         'VendorCode ,'+
                         'whCode,'+
                         'InvBilldate,'+
                         'InvBillMonth,'+
                         'BillTypeCode,'+
                         'EmployeeCode,'+
                         'WH_EmployeeCode,'+
                         'WhPositionCode,'+
                         'InvBillwhchck,'+
                         'InvBillFinChck,'+
                         'ISHistoryBill,'+
                         'currencyCode,'+
                         'ExchRate,'+
                         'InvBilltaxrate,'+
                         'InvBillCreateTime,'+
                         'VendorBillNo,'+
                         'InvBillValuation,'+
                         'InvBillremArk)'+
                 'Values('''+Trim(Edt_InvBillNo.text)+''','+
                         ''''+LkEdt_VendorCode.text+''','+
                        ''''+getCode(CmBx_WhCode.text)+''','+
                        ''''+Edt_InvBillDate.text+''','+
                        ''''+copy(Edt_InvBillDate.text,1,7)+''','+
                        ''''+getCode(CmBx_BillTypeCode.text)+''','+
                        ''''+userCode+''','+
                        ''''+userCode+''','+
                        ''''+getCode(Edt_WhPositionCode.text)+''','+
                        '1,'+
                        '0,'+
                        '1,'+
                        ''''+Trim(Edt_CurrencyCode.text)+''','+
                        Trim(Edt_ExchRate.text)+','+
                        Vendortaxrate_Percent+','+
                        ''''+curdate+''','+
                       ''''+Edt_VendorBillNo.text+''','+
                       '1,'+
                       '''应付模块初示化数据'+Edt_InvBillRemArk.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;
      AdoQry_Body.DisableControls ;
      with AdoQry_Body do
      begin
        First;
        //for M:=0 to recordCount-1 do
        while not eof do
        begin
          //由于显示在DBGRID中的价格不管外币还是人民币,都是用同一个字段,因
          //此在存盘时把字段分开,如下:
          if IsMasterCurrency(Trim(Edt_CurrencyCode.text)) then
          begin
            tmp_InvBillAmount:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
            tmp_InvBillAmountc:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmountc:=fieldbyname('InvBillnotaxAmount').asstring;
          end
          else
          begin
            tmp_InvBillAmount:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
            tmp_InvBillAmountc:=floattostr(fieldbyname('InvBillAmount').asfloat*strtofloat(ExchRate));
            tmp_InvBillnotaxAmountc:=floattostr(fieldbyname('InvBillnotaxAmount').asfloat*strtofloat(ExchRate));
          end;
          //只用人民币结算
          Amount:=Amount+strtofloat(tmp_InvBillAmount);
            //增加InvBillLINE
          AdoQry_tmp.Close;
          AdoQry_tmp.sql.clear;
          AdoQry_tmp.sql.Add('insert InvInBillline'+
                                       '(InvBillid,'+
                                       'InvBilllineno,'+
                                       'ItemCode,'+
                                       'BilllineremArk,'+
                                       'bl.InvBillAmount,'+
                                       'bl.InvBillnotaxAmount,'+
                                       'bl.InvBillAmountc,'+
                                       'bl.InvBillnotaxAmountc )'+
                             'Values('+Billid+','+
                                     fieldbyname('InvBilllineno').asstring+','+
                                     ''''+fieldbyname('ItemCode').asstring+''','+
                                     ''''+fieldbyname('BilllineremArk').asstring+''','+
                                     tmp_InvBillAmount+','+
                                     tmp_InvBillnotaxAmount+','+
                                     tmp_InvBillAmountc+','+
                                     tmp_InvBillnotaxAmountc+')' );
            AdoQry_tmp.ExecSQL;
          next;
        end;
      end;
    end;
      AdoQry_Body.EnableControls ;
      if(Status='PArtEdit')or(Status='AllEdit') then
      begin
        AdoQry_tmp.Close;
        AdoQry_tmp.sql.clear;
        AdoQry_tmp.sql.Add('update InvInBill set '+
                           'InvBillno='''+Trim(Edt_InvBillNo.text)+''','+
                           'VendorCode='''+LkEdt_VendorCode.text+''','+
                           'whCode='''+getCode(CmBx_WhCode.text)+''','+
                           'InvBilldate='''+Edt_InvBillDate.text+''','+
                           'InvBillMonth='''+copy(Edt_InvBillDate.text,1,7)+''','+
                           'BillTypeCode='''+getCode(CmBx_BillTypeCode.text)+''','+
                           'EmployeeCode='''+userCode+''','+
                           'WH_EmployeeCode='''+userCode+''','+
                           'WhPositionCode='''+getCode(Edt_WhPositionCode.text)+''','+
                           'InvBillwhchck=1,'+
                           'InvBillFinChck=0,'+
                           'currencyCode='''+Trim(Edt_CurrencyCode.text)+''','+
                           'ExchRate='+ Trim(Edt_ExchRate.text)+','+
                           'InvBilltaxrate='+Vendortaxrate_Percent+','+
                           'InvBillCreateTime='''+curdate+''','+
                           'VendorBillNo='''+Edt_VendorBillNo.text+''','+
                           'InvBillremArk=''应付模块初示化数据''+'''+Edt_InvBillRemArk.text+''''+
                           'where InvBillid='+AdoQry_Body.fieldbyname('InvBillid').asstring);

         AdoQry_tmp.execsql;
      Amount:=0;
      AdoQry_Body.DisableControls ;
      with AdoQry_Body do
      begin
        First;
        //for M:=0 to recordCount-1 do
        while not eof do
        begin
          //由于显示在DBGRID中的价格不管外币还是人民币,都是用同一个字段,因
          //此在存盘时把字段分开,如下:
          if IsMasterCurrency(Trim(Edt_CurrencyCode.text)) then
          begin
            tmp_InvBillAmount:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
            tmp_InvBillAmountc:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmountc:=fieldbyname('InvBillnotaxAmount').asstring;
          end
          else
          begin
            tmp_InvBillAmount:=fieldbyname('InvBillAmount').asstring;
            tmp_InvBillnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
            tmp_InvBillAmountc:=floattostr(fieldbyname('InvBillAmount').asfloat*strtofloat(ExchRate));
            tmp_InvBillnotaxAmountc:=floattostr(fieldbyname('InvBillnotaxAmount').asfloat*strtofloat(ExchRate));
          end;
          //只用人民币结算
          Amount:=Amount+strtofloat(tmp_InvBillAmount);
        //增加InvBillLINE
        AdoQry_tmp.Close;
        AdoQry_tmp.sql.clear;
        AdoQry_tmp.sql.Add('update  InvInBillline set '+
                                  ' BilllineremArk='''+fieldbyname('BilllineremArk').asstring+''','+
                                  ' InvBillAmount='+ tmp_InvBillAmount+','+
                                  ' InvBillnotaxAmount='+tmp_InvBillnotaxAmount+','+
                                  ' InvBillAmountc='+tmp_InvBillnotaxAmountc+','+
                                  ' InvBillnotaxAmountc='+tmp_InvBillnotaxAmountc+
                                  ' where InvBillid='+AdoQry_Body.fieldbyname('InvBillid').asstring+
                                  ' and ItemCode='''+fieldbyname('ItemCode').asstring+''''+
                                  ' and InvBillLineNo='+fieldbyname('InvBillLineNo').asstring);
          AdoQry_tmp.ExecSQL;
          next;
        end;
       end;
      end;
      AdoQry_Body.EnableControls ;
      dbconnect.CommitTrans ;
      Edt_InvBillDate.Enabled:=False;      
    except
       dbconnect.RollBackTrans;
       DispInfo('保存失败',1);
       abort;
    end;
    Billmemo:=Edt_InvBillRemArk.text;
    BillwhCode:=getCode(cmbx_WhCode.text);
    BillWhPositionCode:=getCode(Edt_WhPositionCode.text);
    //llBillType2Code:=getCode(cmbbx_BillType2Code.text);
    //lloutType:=getCode(Cmbbx_OutType.text);
    Edt_InvBillNo.text:=Billno;
    BilloutCode:=LkEdt_VendorCode.text;
    BilloutName:=Edt_VendorName.text;
    BillLoginDate:=Edt_InvBillDate.text;
    Frm_Ap_Enter_NoInvoiceInvInOrderH.InvBillid:=Billid;
    act_insertline.Enabled :=False;
    act_Deleteline.Enabled :=False;
    act_Save.Enabled :=False;
    act_Modify.Enabled :=False;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder.SaveHeadData;
begin
  inherited;
  with AdoQry_Head do
  begin
    fieldbyname('VendorCode').asstring:=LkEdt_VendorCode.text;
    fieldbyname('VendorName').asstring:=Edt_VendorName.text;
    fieldbyname('InvBillNo').asstring:=Billno;
    fieldbyname('InvBillDate').asstring:=Edt_InvBillDate.text;
    //fieldbyname('InvBillMonth').asstring:=Edt_InvBillMonth.text;
    fieldbyname('BillTypeCode').asstring:=CmBx_BillTypeCode.text;
    fieldbyname('BillTypeName').asstring:=Edt_BillTypeName.text;
    if  pos('%',Edt_InvBillTaxRate.text)>0  then
      fieldbyname('InvBillTaxRate').asstring:=copy(Trim(Edt_InvBillTaxRate.text),1, pos('%',Edt_InvBillTaxRate.text)-1)
    else
      fieldbyname('InvBillTaxRate').asstring:=Edt_InvBillTaxRate.text;
    fieldbyname('WhCode').asstring:= CmBx_WhCode.text;
    fieldbyname('WhName').asstring:=Edt_WhName.text;
    fieldbyname('WhPositionCode').asstring:=Edt_WhPositionCode.text;
    fieldbyname('WhPositionName').asstring:=Edt_WhPositionName.text;
    fieldbyname('CurrencyCode').asstring:=Edt_CurrencyCode.text;
    fieldbyname('CurrencyName').asstring:=Edt_CurrencyName.text;
    fieldbyname('VendorBillNo').asstring:=Edt_VendorBillNo.text;
    //fieldbyname('InvBillCreateTime').asstring:=Edt_InvBillCreateTime.text;
    //fieldbyname('WH_EmployeeCode').asstring:=Edt_Wh_EmployeeCode.text;
    //fieldbyname('EmployeeName').asstring:=Edt_EmployeeName.text;
    fieldbyname('InvBillRemArk').asstring:=Edt_InvBillRemArk.text;
  end;
  //此程序不能做这一事件,因为用了CASE语句,所以不能增加

⌨️ 快捷键说明

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