Beispiel #1
0
 private void SprawdzDokument()
 {
     if (_Dokument is DokumentHandlowy)
     {
         DokumentHandlowy = _Dokument as DokumentHandlowy;
     }
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            Login login = CreateLogin();

            if (login != null)
            {
                using (Session session = login.CreateSession(false, false))
                {
                    using (var t = session.Logout(true))
                    {
                        var            context = Context.Empty.Clone(session);
                        var            storage = context.Login != null ? context.Login.StorageProvider : null;
                        IReportService rs;

                        HandelModule     hm  = HandelModule.GetInstance(session);
                        DokumentHandlowy dok = hm.DokHandlowe.NumerWgNumeruDokumentu["FV/000004/19"];
                        context.Set(dok);
                        context.Session.GetService(out rs);

                        var reportResult = new ReportResult              //rezultat służący do uruchamiania raportów
                        {
                            Caption = "Generowanie faktury",             //nazwa zadania
                            Context = context,                           //kontekst raportu
                            Preview = false,                             //nie pokazuj okna z podglądem raportu
                            //DataType = dok.GetType(), //typ dla którego będzie generowany wydruk
                            Format             = ReportResultFormat.PDF, //format zapisu
                            TemplateFileName   = "XtraReports/Wzorce użytkownika/dokument_sprzedazy.repx",
                            TemplateFileSource = AspxSource.Local,       //wskazanie na aspx wydruku
                        };
                        var stream = rs.GenerateReport(reportResult);
                        t.Commit();
                    }
                }
            }
        }
Beispiel #3
0
 internal static void Kontroluj(DokumentHandlowy d, Mode m)
 {
     if (d == null)
     {
         throw new ArgumentNullException("d");
     }
     if (!d.Definicja.KontrolerRelacjiInfo.Disabled)
     {
         KontrolerRelacji relacji = new KontrolerRelacji(d, m);
         if (relacji.Check())
         {
             if (relacji.ShouldRemove)
             {
                 relacji.Remove();
             }
             if (relacji.ShouldRestore)
             {
                 relacji.Restore();
             }
             if (relacji.ShouldSplit)
             {
                 relacji.Split();
             }
         }
     }
 }
Beispiel #4
0
        internal string GetWalutaPlatnosci(DokumentHandlowy dokument, out double kursWaluty)
        {
            InicjalizatorWalutyInfo info;
            DokumentHandlowy        handlowy;

            kursWaluty = 0.0;
            if (!this.TryGetInicjalizatorWalutyInfo(dokument, out handlowy, out info))
            {
                //return dokument.BruttoCy.Symbol;
                return(dokument.BruttoCySymbol);
            }
            var type = new
            {
                //nadrzedny = (handlowy == null) ? null : handlowy.BruttoCy.Symbol,
                nadrzedny = (handlowy == null) ? null : handlowy.BruttoCySymbol,
                dokument  = this.GetWalutaPlatnosci(dokument, handlowy, info.WalutaPlatnosci)
            };

            //if (info.KursZNadrzednego && Currency.EqualSymbols(type.nadrzedny, type.dokument))
            if (info.KursZNadrzednego && type.nadrzedny == type.dokument)
            {
                kursWaluty = handlowy.KursWaluty;
            }
            return(type.dokument);
        }
Beispiel #5
0
        private void DrukujJeden(Context cx, DokumentHandlowy dokument)
        {
            var kodKontrahenta = dokument.Kontrahent.Kod;
            var numerFaktury   = String.Join("", dokument.NumerPelnyZapisany.Split(Path.GetInvalidFileNameChars()));
            var timeStamp      = DateTime.Now.ToString("ddMMyyyyHHmmss");
            var rozszerzenie   = ".pdf";

            var nazwaPliku = $"{kodKontrahenta}_{numerFaktury}_{timeStamp}{rozszerzenie}";

            var folder = "C:\\Wydruki";

            Directory.CreateDirectory(folder);

            var path = Path.Combine(folder, nazwaPliku);

            var reportResult = new Soneta.Business.UI.ReportResult()
            {
                Context          = cx,
                DataType         = dokument.GetType(),
                TemplateFileName = @"handel/sprzedaz.aspx",
                Format           = Soneta.Business.UI.ReportResultFormat.PDF,
            };

            BusApplication.Instance.GetService(out IReportService service);

            using (var stream = service.GenerateReport(reportResult))
            {
                using (var file = System.IO.File.Create(path))
                {
                    Soneta.Tools.CoreTools.StreamCopy(stream, file);
                    file.Flush();
                }
            }
        }
Beispiel #6
0
 public PozycjaDokHandlowego this[DokumentHandlowy dh, int ident]
 {
     get
     {
         return(this.Table.BaseQuery.Where(p => p.Dokument.ID == dh.ID && p.Ident == ident).FirstOrDefault());
     }
 }
Beispiel #7
0
        public object ReadDataWorker()
        {
            Session.GetService(out IFileSystemService fss);
            if (fss == null)
            {
                return(null);
            }

            byte[] fileContent = fss.ReadFile(BaseParams.Plik);

            string result = Encoding.UTF8.GetString(fileContent);

            string[] words = Regex.Split(result, "[^a-zA-Z]+");

            DokumentHandlowy dokhan;

            using (var tran = Session.Logout(true))
            {
                dokhan = new DokumentHandlowy
                {
                    Definicja  = HandelModule.GetInstance(Session).DefDokHandlowych.WgSymbolu[words[1]],
                    Magazyn    = HandelModule.GetInstance(Session).Magazyny.Magazyny.WgNazwa[words[3]],
                    Kontrahent = CRMModule.GetInstance(Session).Kontrahenci.WgKodu[words[5]],
                };
                HandelModule.GetInstance(Session).DokHandlowe.AddRow(dokhan);
                dokhan.Data = Now;
                tran.CommitUI();
            }
            return(dokhan);
        }
Beispiel #8
0
 public RelacjeHandlowe this[DokumentHandlowy podrzedny, TypRelacjiHandlowej typ]
 {
     get { return(new RelacjeHandlowe()
         {
             BaseQuery = GetQuery(Table.BaseQuery.Where(rh => rh.Podrzedny.ID == podrzedny.ID && rh.TypInt == (int)typ))
         }); }
 }
Beispiel #9
0
 public static DocumentState GetDocumentSate(this DokumentHandlowy document)
 {
     return(document.Zatwierdzony
         ? DocumentState.Approved
         : (document.Anulowany
             ? DocumentState.Canceled
             : (document.Bufor ? DocumentState.Buffer : throw  new NotImplementedException())));
 }
 private void DodajPozycje(DokumentHandlowy doc)
 {
     InUITransaction(() =>
     {
         var pos = new PozycjaDokHandlowego(doc);
         Session.GetHandel().PozycjeDokHan.AddRow(pos);
         pos.Towar = Session.GetTowary().Towary.WgKodu["Bikini"];
     });
 }
Beispiel #11
0
        public void DodajTransport(DokumentHandlowy dokument, decimal rabat)
        {
            var pos = new PozycjaDokHandlowego(dokument);

            dokument.Session.GetHandel().PozycjeDokHan.AddRow(pos);

            pos.Towar = dokument.Session.GetTowary().Towary.WgKodu["TRANSPORT"];
            pos.Rabat = new Percent(rabat);
        }
Beispiel #12
0
 protected PunktRow([Required] DokumentHandlowy dokument) : base(true)
 {
     if (dokument == null)
     {
         throw new RequiredException(this, "Dokument");
     }
     GetRecord();
     record.Dokument = dokument;
 }
 public DokumentAnalizyZwrotu(AnalizaZwrotu analiza, DokumentHandlowy dokumentHandlowy)
 {
     this.analiza           = analiza;
     this.dokumentHandlowy  = dokumentHandlowy;
     this.pozycje           = new PozycjeAnalizyZwrotu();
     this.pozycjeKorygowane = new PozycjeAnalizyZwrotu();
     this.ilosciPoKorektach = new Dictionary <Guid, double>();
     this.ilosciKorygowane  = new Dictionary <Guid, double>();
 }
Beispiel #14
0
 public RelacjeHandlowe this[DokumentHandlowy nadrzedny, DefRelacjiHandlowej definicja]
 {
     get
     {
         return(new RelacjeHandlowe()
         {
             BaseQuery = GetQuery(Table.BaseQuery.Where(rh => rh.Nadrzedny.ID == nadrzedny.ID && rh.Definicja.ID == definicja.ID))
         });
     }
 }
Beispiel #15
0
 private ReportResult UtworzReportResult(Context cx, DokumentHandlowy dokument)
 {
     return(new ReportResult()
     {
         Context = cx,
         DataType = dokument.GetType(),
         TemplateFileName = @"handel/sprzedaz.aspx",
         Format = Soneta.Business.UI.ReportResultFormat.PDF,
     });
 }
Beispiel #16
0
 public PozycjeDokHan this[DokumentHandlowy dokument]
 {
     get
     {
         return(new PozycjeDokHan()
         {
             BaseQuery = GetQuery(Table.BaseQuery.Where(p => p.Dokument.ID == dokument.ID))
         });
     }
 }
Beispiel #17
0
 public RelacjeHandlowe this[DokumentHandlowy podrzedny]
 {
     get
     {
         return(new RelacjeHandlowe()
         {
             BaseQuery = GetQuery(Table.BaseQuery.Where(rh => rh.Podrzedny.ID == podrzedny.ID))
         });
     }
 }
Beispiel #18
0
 public PozRelHandlowej this[DokumentHandlowy nadrzednydok]
 {
     get
     {
         return(new PozRelHandlowej()
         {
             BaseQuery = GetQuery(Table.BaseQuery.Where(p => p.NadrzednyDok.ID == nadrzednydok.ID))
         });
     }
 }
Beispiel #19
0
        private string GenrujNazwePliku(DokumentHandlowy dokument)
        {
            var kodKontrahenta = dokument.Kontrahent.Kod;
            var numerFaktury   = String.Join("", dokument.NumerPelnyZapisany.Split(Path.GetInvalidFileNameChars()));
            var timeStamp      = DateTime.Now.ToString("ddMMyyyyHHmmss");
            var rozszerzenie   = ".pdf";

            var nazwaPliku = $"{kodKontrahenta}_{numerFaktury}_{timeStamp}{rozszerzenie}";

            return(nazwaPliku);
        }
 public int IndexOf(DokumentHandlowy dh)
 {
     for (var i = 0; i < this.List.Count; i++)
     {
         if (((ZwrotAnalizaDokHandlowyOld)this.List[i]).DokumentHandlowy.Equals(dh))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #21
0
 public PozRelHandlowej this[DokumentHandlowy podrzednydok, int podrzednaident]
 {
     get
     {
         return(new PozRelHandlowej()
         {
             BaseQuery = GetQuery(Table.BaseQuery
                                  .Where(p => p.PodrzednyDok.ID == podrzednydok.ID && p.PodrzednaIdent == podrzednaident))
         });
     }
 }
Beispiel #22
0
 internal static void KontrolujDynamicznie(DokumentHandlowy d)
 {
     if (d == null)
     {
         throw new ArgumentNullException("d");
     }
     if (!d.Definicja.KontrolerRelacjiInfo.Disabled && !d.Module.RelacjeHandlowe.WgPodrzednyTyp[d, TypRelacjiHandlowej.Kopiowania].IsEmpty)
     {
         d.SposobRozliczaniaNadrzednego = SposobRozliczaniaNadrzednego.Dynamicznie;
     }
 }
        public void Add(DokumentHandlowy dh, PozycjaAnalizyZwrotu pozycja)
        {
            var item = this[dh];

            if (item == null)
            {
                item = new DokumentAnalizyZwrotu(analiza, dh);
                this.Add(item);
            }

            item.Pozycje.Add(pozycja);
            pozycja.Dokumenty.Add(item);
        }
 public DokumentAnalizyZwrotu this[DokumentHandlowy dh]
 {
     get
     {
         foreach (var d in this)
         {
             if (d.DokumentHandlowy.Guid == dh.Guid)
             {
                 return(d);
             }
         }
         return(null);
     }
 }
 public ZwrotAnalizaDokHandlowyOld this[DokumentHandlowy dh]
 {
     get
     {
         foreach (var i in this.List)
         {
             if (((ZwrotAnalizaDokHandlowyOld)i).DokumentHandlowy.Equals(dh))
             {
                 return((ZwrotAnalizaDokHandlowyOld)i);
             }
         }
         return(null);
     }
 }
        public ZwrotAnalizaDokHandlowyOld Add(DokumentHandlowy dh, PozycjaZwrotuAnalizaOld pozycja)
        {
            var item = this[dh];

            if (item == null)
            {
                item = new ZwrotAnalizaDokHandlowyOld(dh);
                this.List.Add(item);
            }
            if (pozycja != null)
            {
                item.Pozycje.Add(pozycja);
            }
            return(item);
        }
        private DokumentHandlowy DodajDokument()
        {
            DokumentHandlowy doc = null;

            InUITransaction(() =>
            {
                doc = new DokumentHandlowy
                {
                    Definicja = Session.GetHandel().DefDokHandlowych.WgSymbolu["ZO"]
                };
                Session.GetHandel().DokHandlowe.AddRow(doc);
                doc.Magazyn    = Session.GetMagazyny().Magazyny.Firma;
                doc.Kontrahent = Session.GetCRM().Kontrahenci.WgKodu["ABC"];
            });
            return(doc);
        }
Beispiel #28
0
        private string GetWalutaPlatnosci(DokumentHandlowy dokument, DokumentHandlowy nadrzedny, ZrodloWaluty zrodloWaluty)
        {
            ZrodloWaluty waluty = zrodloWaluty;

            switch (waluty)
            {
            case ZrodloWaluty.ZNadrzednego:
                //return nadrzedny.BruttoCy.Symbol;
                return(nadrzedny.BruttoCySymbol);

            case ZrodloWaluty.ZKartyKontrahenta:
            {
                DokumentHandlowy[] handlowyArray = new DokumentHandlowy[] { dokument, nadrzedny };
                foreach (DokumentHandlowy handlowy in handlowyArray)
                {
                    if ((handlowy != null) && (handlowy.Kontrahent != null))
                    {
                        if (handlowy.WalutaKontrahenta != null)
                        {
                            return(handlowy.WalutaKontrahenta.Symbol);
                        }
                        return(this.GetWalutaPlatnosci(dokument, nadrzedny, ZrodloWaluty.ZDefinicji));
                    }
                }
                break;
            }

            case (ZrodloWaluty.ZKartyKontrahenta | ZrodloWaluty.ZNadrzednego):
                break;

            case ZrodloWaluty.ZDefinicjiPodrzednego:
                return(this.GetWalutaPlatnosci(dokument, nadrzedny, dokument.Definicja.InicjalizatorWalutyInfo.WalutaPlatnosci));

            case ZrodloWaluty.ZDefinicji:
                //return dokument.Definicja.WalutaPlatnosci.Symbol;
                return(dokument.Definicja.WalutaPlatnosci.Symbol);

            default:
                if (waluty == ZrodloWaluty.ZCennika)
                {
                    throw new NotSupportedException(string.Format("Ustawienie {0} dla źr\x00f3dła waluty płatności nie jest obsługiwane.", zrodloWaluty));
                }
                break;
            }
            //return dokument.BruttoCy.Symbol;
            return(dokument.BruttoCySymbol);
        }
Beispiel #29
0
        public void GenerujKorekte()
        {
            // Metoda tworzy dokument korygujący do dokumentu wyciągniętego z kontekstu
            using (ITransaction tran = Session.Logout(true))
            {
                // Pobranie serwisu relacji
                Session.GetService(out IRelacjeService relacjeService);

                // Utworzenie dokumentu korekty
                DokumentHandlowy korekta = relacjeService.NowaKorekta(new[] { Dokument }).First();

                // Zatwierdzanie dokumentu
                korekta.Stan = StanDokumentuHandlowego.Zatwierdzony;

                tran.Commit();
            }
        }
Beispiel #30
0
        private void WyslijEmail(Stream stream, DokumentHandlowy dokument)
        {
            stream.Seek(0L, SeekOrigin.Begin);

            var adres = dokument.Kontrahent.EMAIL;

            if (!EnovaMail.TestMail(adres))
            {
                return;
            }
            var enovaMail = new EnovaMail(dokument.Session);

            enovaMail.AddAttachment("Zalacznik.pdf", stream);
            enovaMail.AddTo(adres);
            enovaMail.AddSubject("Faktura");
            enovaMail.AddBody("Faktura jest w załączniku");

            enovaMail.SendMail();
        }