Ajouter des lignes sur un doc existant.

Forum consacré aux développements d'applications interfacées avec les logiciels Sage

Modérateurs: Super Modérateur, Modérateurs

Règles du forum
Merci de prendre connaissance des règles d'utilisation du forum

Avant de poster un nouveau message, utilisez la fonction RECHERCHER. Indiquez la VERSION de votre logiciel et toutes informations utiles à la résolution de votre question. Ne rédigez pas vos messages en MAJUSCULES. Soyez courtois et pensez aux formules de POLITESSE d'usage. Les messages à vocation COMMERCIALE ou PUBLICITAIRE seront supprimés.

*** LORSQU'UN SUJET EST RESOLU, SON AUTEUR DOIT EDITER LE 1ER MESSAGE DU SUJET EN HAUT DE PAGE ET COCHER "SUJET RESOLU" ***

Ajouter des lignes sur un doc existant.

Messagede Nic0s » Ven 1 Avr 2011 14:53

bonjour , j'utilise les objets métiers.

je sais créer un nouveau document et ensuite y ajouter de nouvelle ligne.

Je sais trouver une document.
mais comment ajouter des ligne sur un document existant ?

(Ou comment d'un IBODocumentvente avoir un IPMDOCUMENT.... ?)
Nic0s
Posteur néophyte
Posteur néophyte
 
Messages: 8
Inscription: Mar 25 Mar 2008 16:15

Re: Ajouter des lignes sur un doc existant.

Messagede Nic0s » Mer 4 Mai 2011 12:26

Code: Tout sélectionner

Dim docsearch As IBODocumentVente3
Dim client As IBOClient3
Dim baseComptable As BSCPTAApplication3
dim bfind as boolean

docsearch = Nothing
baseComptable = baseCommerciale.CptaApplication
client = baseComptable.FactoryClient.ReadNumero(DO_TIERS)

For Each docsearch In baseCommerciale.FactoryDocumentVente.QueryTiersTypeOrderDate (client,DocumentType.DocumentTypeVenteCommande)
    If docsearch.DO_Ref = ENT_COM Then bfind = True
Next

If bfind Then
     ''le document existe deja , on ne fait qu'ajouter les lignes
     For Each l As Ligne In LIGNES
         AjouteLigneSortieArticleLotSerie(docsearch, l.AR_REF, l.DL_QTE, , l.AR_DESIGN, l.DL_PUNET, l.DL_REMISE, SpecialREf)
     Next
     'on ne fait pas la validation du doc  (inutile le document est deja créé)
Else
     documentGestionCo = CreeDocumentVentePicthema(baseCommerciale, typeDoc, DO_TIERS, DO_DATE, ENT_COM, ENT_ESCPTE, LI_Intitule)
      For Each l As Ligne In LIGNES
            AjouteLigneSortieArticleLotSerie(documentGestionCo, l.AR_REF, l.DL_QTE, , l.AR_DESIGN, l.DL_PUNET, l.DL_REMISE, SpecialREf)
       Next
End If

'nettoyage
client = Nothing
baseComptable = Nothing
docsearch = Nothing

et
Code: Tout sélectionner

Function CreeDocumentVentePicthema(ByRef baseCommerciale As BSCIALApplication3, _
                              ByVal typeDocument As DocumentType, _
                              ByVal codeClient As String, _
                              ByVal dateDocument As Date, _
                              ByVal Reference As String, _
                              ByVal TX_ESCOMPTE As Double, _
                              ByVal LI_Intitule As String) As IPMDocument

        Try

            Dim document As IPMDocument
            Dim client As IBOClient3
            Dim baseComptable As BSCPTAApplication3
            Dim bfind As Boolean
            bfind = False
            document = Nothing

            baseComptable = baseCommerciale.CptaApplication
            client = baseComptable.FactoryClient.ReadNumero(codeClient)

            document = baseCommerciale.CreateProcess_Document(typeDocument)
            Dim enteteDocumentVente As IBODocumentVente3
            enteteDocumentVente = document.Document
            enteteDocumentVente.SetDefaultClient(client)
            enteteDocumentVente.DO_Ref = Reference
            enteteDocumentVente.DO_TxEscompte = TX_ESCOMPTE
            enteteDocumentVente.Periodicite = baseCommerciale.FactoryPeriodicite.ReadIntitule("Picthema")

        Catch ex As Exception

            Dim erreur As String
            erreur = "Erreur en initialisation du document de vente : " + ex.Message

            Throw New Exception(erreur)

        End Try

    End Function
Function AjouteLigneSortieArticleLotSerie(ByRef document As IPMDocument, _
                                              ByVal referenceArticle As String, _
                                              ByVal quantite As Double, _
                                              Optional ByVal numeroLotSerie As String = "", _
                                              Optional ByVal Designation As String = "", _
                                              Optional ByVal PU As Double = Nothing, _
                                              Optional ByVal Remise As Double = Nothing, _
                                              Optional ByRef SpecialRef As List(Of String) = Nothing) As IBODocumentLigne3

        Try
            Dim baseCommerciale As BSCIALApplication3
            Dim enteteDocument As IBODocument3
            enteteDocument = document.Document

            'Dim nouvelleLigne As IBODocumentLigne3
            Dim nouvelleLigne As IBODocumentVenteLigne3

            nouvelleLigne = enteteDocument.FactoryDocumentLigne.Create
            baseCommerciale = enteteDocument.Stream

            If numeroLotSerie = String.Empty Then
                nouvelleLigne.SetDefaultArticleReference(referenceArticle, quantite)
                nouvelleLigne.SetDefaultRemise()
            Else
                Dim intituleDepot As String
                intituleDepot = enteteDocument.DepotStockage.DE_Intitule

                Dim lotParArticleDepot As IBOArticleDepotLot
                lotParArticleDepot = getLotArticleDepot(baseCommerciale, referenceArticle, intituleDepot, numeroLotSerie)
                nouvelleLigne.SetDefaultLot(lotParArticleDepot, quantite)
            End If

            If Designation <> "" Then
                nouvelleLigne.DL_Design = Designation
            End If



           
            If SpecialRef.Contains(referenceArticle) Then nouvelleLigne.DL_PrixUnitaire = PU
            If referenceArticle = "ZPICTHEMA" Then
                nouvelleLigne.DL_PoidsBrut = PU * 1000
                nouvelleLigne.DL_PoidsNet = PU * 1000
            End If
            Dim article As IBOArticle3
            article = baseCommerciale.FactoryArticle.ReadReference(referenceArticle)

            Try
                If article.InfoLibre.Item("AR_PRIXDESTOCK") <> 0 Then
                    nouvelleLigne.DL_PrixUnitaire = PU
                End If
            Catch ex As Exception

            End Try

            nouvelleLigne.WriteDefault()



            Return nouvelleLigne

        Catch ex As Exception

            Dim erreur As String
            erreur = "Erreur en crĂ©ation de ligne de sortie pour l'article " + referenceArticle + " : " + ex.Message

            Throw New Exception(erreur)

        End Try

    End Function
 


Merci a ceux qui m'ont aiguillé vers cette solution
Nic0s
Posteur néophyte
Posteur néophyte
 
Messages: 8
Inscription: Mar 25 Mar 2008 16:15


Retourner vers Développements ODBC, Objets métiers, SQL

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités