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

📄 ar_enter_saleinvoice3.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  If  AdoQry_Body.RecordCount>0 Then
  begin
    BookmArk:=AdoQry_Body.BookmArk;
    AdoQry_Body.First;
    While Not AdoQry_Body.Eof Do
    begin
      AdoQry_Body.Edit;
      AdoQry_Body.fieldbyname('ShipLineNo').AsInteger:=AdoQry_Body.RecNo;
      AdoQry_Body.Post;
      AdoQry_Body.Next;
    end;
    AdoQry_Body.BookmArk:=BookMArk;
  end;}
end;

procedure TFrm_Ar_Enter_SaleInvoice3.Act_PreviewExecute(Sender: TObject);
begin
//  inherited;
{  if  Act_Save.Enabled = True then
  begin
    DispInfo('没有保存数据,不能预览!',1);
    Abort;
  end;
  If AdoQry_Body.RecordCount=0 Then
  begin
    DispInfo('没有行数据,不能预览!',1);
    Abort;
  end;
  Frm_Sal_Enter_ShipOrder_P:=TFrm_Sal_Enter_ShipOrder_P.Create(Application);
  Frm_Sal_Enter_ShipOrder_P.SetDBConnect(DbConnect);
  Frm_Sal_Enter_ShipOrder_P.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
  Frm_Sal_Enter_ShipOrder_P.GetHeadData(AdoQry_Body,Trim(Edt_ShipNo.Text),'Preview');
  Frm_Sal_Enter_ShipOrder_P:=Nil;}
end;

procedure TFrm_Ar_Enter_SaleInvoice3.Act_PrintExecute(Sender: TObject);
begin
 // inherited;
{ if  Act_Save.Enabled = True then
  begin
    DispInfo('没有保存数据,不能打印!',1);
    Abort;
  end;
  If AdoQry_Body.RecordCount=0 Then
  begin
    DispInfo('没有行数据,不能打印!',1);
    Abort;
  end;
  Frm_Sal_Enter_ShipOrder_P:=TFrm_Sal_Enter_ShipOrder_P.Create(Application);
  Frm_Sal_Enter_ShipOrder_P.SetDBConnect(DbConnect);
  Frm_Sal_Enter_ShipOrder_P.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
  Frm_Sal_Enter_ShipOrder_P.GetHeadData(AdoQry_Body,Trim(Edt_ShipNo.Text),'Print');
  Frm_Sal_Enter_ShipOrder_P:=Nil;}
end;

procedure TFrm_Ar_Enter_SaleInvoice3.Act_NewExecute(Sender: TObject);
begin
{  if Frm_Sal_Enter_ShipOrder_C1<>nil then
    Frm_Sal_Enter_ShipOrder_C1:=TFrm_Sal_Enter_ShipOrder_C1.Create(Application);
    Frm_Sal_Enter_ShipOrder_C1.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
    Frm_Sal_Enter_ShipOrder_C1.InitForm(DbConnect,False);}

  inherited;

end;

procedure TFrm_Ar_Enter_SaleInvoice3.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Frm_Ar_Enter_SaleInvoice3:=nil;
end;

procedure TFrm_Ar_Enter_SaleInvoice3.SaveData;
var
  SqlText:String;
  I:integer;
begin
  inherited;
  If AdoQry_Body.RecordCount=0 Then
  begin
    DispInfo('没有行数据,不能保存!',3);
    Abort;
  end;
  If CurrentFormStatus='Add' Then
  begin
    if Edt_InvoiceNo.Text='' then
    begin
      DispInfo('发票号不能为空!',3);
      edt_InvoiceNo.SetFocus;
      abort;
    end
    else 
    begin
      ExecuteSql(AdoQry_tmp,'Select * from sa_SaleInvoice where Invoiceno='+Quotedstr(edt_Invoiceno.text),0);
      if AdoQry_tmp.RecordCount>0 then
      begin
        DispInfo('发票号重复!',3);
        edt_InvoiceNo.SetFocus;
        abort;
      end;      
    end;
    if Edt_CurrencyCode.Text='' then
    begin
      DispInfo('货币不能为空!',3);
      edt_CurrencyCode.SetFocus;
      abort;
    end
    
  end;
  I:=1;
  AdoQry_Body.First;
  While Not AdoQry_Body.Eof Do
  begin
    If StrToFloat(FormatFloat('##0.##',AdoQry_Body.fieldbyname('ShipQty').AsFloat))>=0 Then
    begin
      DispInfo('第'+IntToStr(I)+'行数据的约定交货量大于等于了0,不能保存!',3);
      Abort;
    end;
    AdoQry_Body.Next;
     I:=I+1;
  end;
  Application.ProcessMessages;
  DbConnect.beginTrans;
  Try
    AdoQry_Body.First;
    If CurrentFormStatus='Add' Then
    begin
      if Edt_InvoiceNo.Text='' then
      abort;
      Application.ProcessMessages;
            SqlText:='Insert Sa_SaleInvoice '
              +' (InvoiceNo,InvoiceType,ExportTradeTypeCode,BillType,OrderType,SaleDeptCode,SaleEmployeeCode, '
              +'  SaleTypeCode,CreateDate,BillDate,InAccountDate,CreateEmployeeCode,CustomerCode,Bank,'
              +'  BankActNo,CurrencyCode,ExchangeRate,TaxRate,'
              +'  SaleTermCode,TotalTaxAmount,TotalTaxAmountC,TotalNoTaxAmount, '
              +'  TotalNoTaxAmountC,TotalTax,TotalTaxC,CancelAmount,CancelAmountC,editdate,edItEmployeeCode,RemArk)'
              +'  Values('
              +''''+Trim(Edt_InvoiceNo.Text)+''','
              +IIFString(Param1='0','0','2')+','
              +IIFString(Param1='0','null',IIFString(Trim(Edt_ExportTypeCode.Text)='','null',QuotedStr(Trim(Edt_ExportTypeCode.Text))))+','
              
              +'0,1, '
              +IIfString(Trim(edt_DeptCode.text)='','null',quotedstr(Trim(edt_DeptCode.text)))+','
              +IIfString(Trim(edt_SaleEmployeeCode.text)='','null',quotedstr(Trim(edt_SaleEmployeeCode.text)))+','
              +IIfString(Trim(edt_SaleTypeCode.text)='','null',quotedstr(Trim(edt_SaleTypeCode.text)))+','
              +'GetDate(),'
              +''''+Trim(MEdt_CreateDate.Text)+''','
              +QuotedStr(Medt_InAccountDate.Text)+','
              +''''+Trim(Edt_CreateEmployeeCode.Text)+''','
              +''''+Trim(Edt_CustomerCode.Text)+''','
              +''''+Trim(Edt_CustomerBank.Text)+''','
              +''''+Trim(Edt_CustomerBankActNo.Text)+''','
              +''''+Trim(Edt_CurrencyCode.Text)+''','
              +''''+Trim(Edt_ExchangeRate.Text)+''','
              +Edt_TaxRate.Text+','
              +IIfString(Trim(edt_SaletermCode.text)='','null',quotedstr(Trim(edt_SaletermCode.text)))+','
              +'-('+Trim(Edt_TotalTaxAmount.Text)+'),'
              +FormatFloat('####0.##',-(StrToFloat(Edt_ExchangeRate.Text)*StrToFloat(Edt_TotalTaxAmount.Text)))+','
              +'-('+Edt_TotalNoTaxAmount.Text+'),'
              +FormatFloat('####0.##',-(StrToFloat(Edt_ExchangeRate.Text)*StrToFloat(Edt_TotalNoTaxAmount.Text)))+','
              +FormatFloat('####0.##',-(StrToFloat(Edt_TotalTaxAmount.Text)-StrToFloat(Edt_TotalNoTaxAmount.Text)))+','
              +FormatFloat('####0.##',-StrToFloat(Edt_ExchangeRate.TExt)*(StrToFloat(Edt_TotalTaxAmount.Text)-StrToFloat(Edt_TotalNoTaxAmount.Text) )  )+','
              +'0,'
              +'0,'
              +quotedstr(GetServerDateTime(dbconnect))+','
              +quotedstr(userCode)+','
              +''''+Trim(Edt_RemArk.Text)+''')';
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:=SqlText;
      AdoQry_Tmp.ExecSQL;
      saveSalInvoiceHistory(dbconnect,Trim(Edt_InvoiceNo.Text),userCode,0);
      Sqltext:='Update customer with(Rowlock)'
              +'   set InvoiceSumTotal=IsNull(InvoiceSumTotal,0)+'+Edt_TotalTaxAmount.text
              +' Where CustomerCode='+QuotedStr(Edt_CustomerCode.text);
      ExecuteSql(AdoQry_Tmp,sqltext,1)              ;
      AdoQry_Body.First;
      While Not AdoQry_Body.Eof Do
      begin

        SqlText:='Insert Sa_SaleInvoiceLine '
                +' (InvoiceNo,InvBillId,InvBillLineNo,RemArk) '
                +' Values('
                +''''+Trim(Edt_InvoiceNo.Text)+''','
                +AdoQry_Body.fieldbyname('InvBillId').AsString+','
                +''''+AdoQry_Body.fieldbyname('ShipLineNo').AsString+''','
                +''' '''
                +')';
        AdoQry_Tmp.Close;
        AdoQry_Tmp.SQL.Text:=SqlText;
        AdoQry_Tmp.ExecSQL;
        SqlText:=' Update InvOutBill Set InvoiceNo='''+Trim(Edt_InvoiceNo.Text)+''' '
                +'     Where InvBillNo='''+AdoQry_Body.fieldbyname('ShipNo').AsString+''' ';
        AdoQry_Tmp.Close;
        AdoQry_Tmp.SQL.Text:=SqlText;
        AdoQry_Tmp.ExecSQL;
        saveSalInvoiceLineHistory(dbconnect,Trim(Edt_InvoiceNo.Text),AdoQry_Body.fieldbyname('InvBillId').asInteger,AdoQry_Body.fieldbyname('ShipLineNo').asString,userCode,0);
        AdoQry_Body.Next;
      end;
    end;
    If CurrentFormStatus='PArtEdit' Then
    begin
      saveSalInvoiceHistory(dbconnect,Trim(Edt_InvOiceNo.Text),userCode,1);
      SqlText:='Update Sa_SaleInvoice Set '
              +' SaleDeptCode='+quotedstr(Trim(edt_DeptCode.text))+','
              +' SaleEmployeeCode='+quotedstr(Trim(edt_SaleEmployeeCode.text))+','
              +' SaleTypeCode='+quotedstr(Trim(edt_SaleTypeCode.text))+','
              +' InAccountDate=' + QuotedStr(Medt_InAccountDate.Text)+','
              +' CreateEmployeeCode= '''+Edt_CreateEmployeeCode.Text+''','
              +' CustomerCode= '''+Trim(Edt_CustomerCode.Text)+''','
              +' Bank= '''+Trim(Edt_CustomerBank.Text)+''','
              +' BankActNo= '''+Trim(Edt_CustomerBankActNo.Text)+''','
              +' CurrencyCode= '''+Trim(Edt_CurrencyCode.Text)+''','
              +' ExchangeRate= '''+Trim(Edt_ExchangeRate.Text)+''','
              +' SaleTermCode= '''+Trim(Edt_SaleTermCode.Text)+''','
              +' RemArk='''+Edt_RemArk.Text+''' '
              +' Where InvoiceNo='''+Trim(Edt_InvOiceNo.Text)+'''';
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:=SqlText;
      AdoQry_Tmp.ExecSQL;
      AdoQry_Body.First;
      While Not AdoQry_Body.Eof Do
      begin
//        saveSalInvoiceLineHistory(dbconnect,AdoQry_Body.fieldbyname('Invoiceno').asstring,AdoQry_Body.fieldbyname('Shipno').asstring,AdoQry_Body.fieldbyname('Shiplineno').asinteger,userCode,1);
{        SqlText:=' UpDate Sa_SaleInvoiceLine '
                +' Set '
                +' ShipNo='''+AdoQry_Body.fieldbyname('ShipNo').AsString+''','
                +' ShipLineNo='''+IntToStr(AdoQry_Body.fieldbyname('ShipLineNo').AsInteger)+''','
                +' ItemCode='''+AdoQry_Body.fieldbyname('ItemCode').AsString+''','
                +' ShipQty='''+AdoQry_Body.fieldbyname('ShipQty').AsString+''','
                +' TaxPrice='''+FloatToStr(AdoQry_Body.fieldbyname('TaxPrice').AsFloat)+''','
                +' TaxAmount='''+FloatToStr(AdoQry_Body.fieldbyname('TaxAmount').AsFloat)+''','
                +' NoTaxPrice='''+FloatToStr(AdoQry_Body.fieldbyname('noTaxPrice').AsFloat)+''','
                +' NoTaxAmount='''+FloatToStr(AdoQry_Body.fieldbyname('noTaxAmount').AsFloat)+''','
                +' DiSCountRate='''+AdoQry_Body.fieldbyname('DiSCountRate').AsString+''','
                +' DiSCountAmount='''+AdoQry_Body.fieldbyname('DiSCountAmount').AsString+''''
                +' Where InvoiceNo='''+AdoQry_Body.fieldbyname('InvoiceNo').AsString+'''' ;

        AdoQry_Tmp.Close;
        AdoQry_Tmp.SQL.Text:=SqlText;
        AdoQry_Tmp.ExecSQL;
}
        AdoQry_Body.Next;
      end;
    end;
    DbConnect.CommitTrans;
    Act_Save.Enabled:=False;
    DispInfo('数据保存成功!',3);
  Except
   on e:exception do
    begin
    if dbconnect.InTransaction then
    DbConnect.RollBackTrans;
    recOrderror(self,AdoQry_tmp,e.message);
//    Edt_ShipNo.Text:='';
    DispInfo('保存数据失败,请重试!',1);
    Abort;
    end;
  end;

end;

procedure TFrm_Ar_Enter_SaleInvoice3.SaveHeadData;
begin
  If Edt_InvoiceNo.Text= '' then
  begin
    DispInfo('请输入发票号!',3);
    Edt_InvoiceNo.SetFocus;
    Abort;
  end;
  try
     Edt_ExchangeRate.Text := floattostr(strtofloat(Edt_ExchangeRate.text));
  except
     DispInfo('汇率输入错误!',3);
     Edt_ExchangeRate.SetFocus;
     Abort;
  end;
  inherited;
  with Frm_Ar_Enter_SaleInvoice3H.AdoQry_Head do
  begin
    If CurrentFormStatus='Add' Then
      Append
    else

⌨️ 快捷键说明

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