Public Module ImportDM Public GIDTyp, GIDFirma, GIDNumer, GIDLp As Integer 'aktualny dekret Public DecimalGroupSep As String Public DecimalSep As String Function szukaj_sep(ByVal line As String, ByVal start As Integer, ByVal separator As String) As Integer Dim i As Integer szukaj_sep = -1 i = InStr(start, line, separator, CompareMethod.Text) If i > start Then szukaj_sep = i End Function Function ToDate(Data As String) As Date Dim dd As Date Dim pos As Integer Data = Replace(Data, "/", ".") Data = Replace(Data, "-", ".") pos = szukaj_sep(Data, 1, ".") Dim TestAr() As String = Split(Data, ".", , CompareMethod.Text) If pos = 5 Then 'rrrr.mm.dd dd = DateSerial(TestAr(0), TestAr(1), TestAr(2)) Else 'dd.mm.rrrr dd = DateSerial(TestAr(2), TestAr(1), TestAr(0)) End If ToDate = dd End Function Function XL_Date(Data As Date) As Integer XL_Date = 36161 + CInt(Data.ToOADate()) End Function Function Liczba(bf As String) As String Dim w As String w = Replace(bf, ",", DecimalSep) w = Replace(bf, ".", DecimalSep) Liczba = w End Function Public Function ZamknijDekret(ByVal CzyZapisac As Boolean) As Boolean If wynikXL = 0 Then Return (True) Else Return (False) End Function Public Function UtworzDekretZbiorczy(ByVal IdentKsieg As String, ByVal Data As Date, ByVal DokData As Date, ByVal DokZrodlowy As String, ByVal Opis As String, ByVal SumaCT As Decimal, ByVal SumaDT As Decimal) As Boolean Dim DekretZbiorczyInfo As New cdn_api.XLDekretZbiorczyInfo_20182 With DekretZbiorczyInfo .Wersja = Wersja .Tryb = 2 'Tryb wystawienia wsadowy '.GIDTyp = Range("e7").Value 'GID dekretu (zwracanego po dodaniu) '.GIDFirma = Range("e8").Value ' '.GIDNumer = Range("e9").Value ' '.GIDLp = Range("e10").Value ' .Data = XL_Date(Data) 'Data dekretu .DataDokumentu = XL_Date(DokData) 'Data dokumentu .KwotaDebet = Str(SumaDT * 100) + Chr(0) 'Kwota sumaryczna winien pomnożona przez 100 .KwotaCredit = Str(SumaCT * 100) + Chr(0) 'Kwota sumaryczna ma pomnożona przez 100 .NumerDokumentu = DokZrodlowy + Chr(0) 'Numer dokumentu źródłowego .Dziennik = My.Settings.Dziennik_Docelowy + Chr(0) 'Dziennik księgowań .Bufor = "BUFOR" + Chr(0) 'Bufor księgowań (pusty = KG) .Identyfikator = IdentKsieg 'identyfikator księgowy - numer dokument z Jastrzębia .Opis = Opis + Chr(0) 'Opis dekretu End With If wynikXL = 0 Then GIDFirma = DekretZbiorczyInfo.GIDFirma GIDTyp = DekretZbiorczyInfo.GIDTyp GIDNumer = DekretZbiorczyInfo.GIDNumer GIDLp = DekretZbiorczyInfo.GIDLp Return (True) Else GIDFirma = 0 GIDTyp = 0 GIDNumer = 0 GIDLp = 0 Return (False) End If End Function Public Function DodajSkladowy(ByVal DZKNumer As Integer) As Boolean Dim DekretSkladowyInfo As New cdn_api.XLDekretInfo_20182 Dim ret As Boolean = False Dim w, i As Integer i = 0 Try MainFrm.Tamy_ImpDM_Dekr.Fill(MainFrm.DsMain.Tbmy_ImpDM_Dekr, DZKNumer) MainFrm.BsTbmy_ImpDM_Dekr.MoveFirst() While i < MainFrm.BsTbmy_ImpDM_Dekr.Count With DekretSkladowyInfo .Data = MainFrm.BsTbmy_ImpDM_Dekr.Current("Data") 'Data dekretu .DataDokumentu = MainFrm.BsTbmy_ImpDM_Dekr.Current("DataDokumentu") 'Data dokumentu .Kwota = Str(MainFrm.BsTbmy_ImpDM_Dekr.Current("Kwota") * 100) + Chr(0) 'Kwota pomnożona przez 100 '.KwotaWalDT = Str(MainFrm.BsTbmy_ImpDM_Dekr.Current("")) + Chr(0) 'Kwota winien w walucie pomnożona przez 100 '.KwotaWalCT = Str(MainFrm.BsTbmy_ImpDM_Dekr.Current("")) + Chr(0) 'Kwota ma w walucie pomnożona przez 100 .NumerDokumentu = MainFrm.BsTbmy_ImpDM_Dekr.Current("DokZr") + Chr(0) 'Numer dokumentu .Dziennik = My.Settings.Dziennik_Docelowy + Chr(0) 'Dziennik księgowań .Bufor = "BUFOR" + Chr(0) 'Bufor księgowań (pusty = KG) .KontoDebet = MainFrm.BsTbmy_ImpDM_Dekr.Current("KontoDebet") + Chr(0) 'Numer konta winien (WN) .KontoCredit = MainFrm.BsTbmy_ImpDM_Dekr.Current("KontoCredit") + Chr(0) 'Numer konta ma (MA) '.KontoWalDT = MainFrm.BsTbmy_ImpDM_Dekr.Current("") + Chr(0) '.KontoWalCT = MainFrm.BsTbmy_ImpDM_Dekr.Current("") + Chr(0) .Identyfikator = MainFrm.BsTbmy_ImpDM_Dekr.Current("Identyfikator") .Opis = MainFrm.BsTbmy_ImpDM_Dekr.Current("Opis") + Chr(0) 'Opis dekretu End With MainFrm.BsTbmy_ImpDM_Dekr.MoveNext() i += 1 End While If wynikXL = 0 Then ret = True Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try Return (ret) End Function End Module