public void SendOrder(BaseLinkerOrderModel order)
        {
            Subiekt subiekt = this.gt.Uruchom((int)UruchomDopasujEnum.gtaUruchomDopasuj, (int)UruchomEnum.gtaUruchom) as Subiekt;

            // sprawdzalbym tutaj czy nie tworzymy duplikatu ale mozna uzywac metody Istnieje() tylko po Id lub odnoszac sie
            // do raw data w bazie
            SuDokument suDokument = subiekt.SuDokumentyManager.DodajZK();

            suDokument.KontrahentId = getKontrahentId(subiekt, order);

            Console.WriteLine("Adding order positions...");
            suDokument.NumerOryginalny = order.OrderId;

            foreach (BaseLinkerProductModel product in order.Products)
            {
                SuPozycja pozycja = suDokument.Pozycje.DodajUslugeJednorazowa() as SuPozycja;
                pozycja.UslJednNazwa           = product.Name;
                pozycja.CenaBruttoPrzedRabatem = product.PriceBrutto;
                pozycja.IloscJm = product.Quantity;
                pozycja.VatId   = getVatId(product.TaxRate);
            }

            suDokument.Zapisz();
            suDokument.Wyswietl();
            suDokument.Zamknij();
        }
Exemplo n.º 2
0
        public Sender()
        {
            var gt = new GT
            {
                Produkt = ProduktEnum.gtaProduktSubiekt,
                Serwer  = "(local)\\INSERTGT",
                Baza    = "test"
            };

            Subiekt = (Subiekt)gt.Uruchom((int)UruchomDopasujEnum.gtaUruchomDopasuj, (int)UruchomEnum.gtaUruchomWTle);
        }
Exemplo n.º 3
0
        private static Subiekt GetSubiekt()
        {
            var     gt  = new GT();
            Subiekt sgt = null;

            try
            {
                gt.Produkt = ProduktEnum.gtaProduktSubiekt;

                gt.Serwer = ConfigConnection.ServerGtProperty; //"(local)\\INSERTGT";
                if (ConfigConnection.ServerGtProperty.Contains("37.187.165"))
                {
                    throw new Exception("Trying to connect to PG server");
                }
                gt.Baza = ConfigConnection.BazaGtProperty;
                if (!string.IsNullOrEmpty(ConfigConnection.UzytkownikProperty))
                {
                    gt.Autentykacja    = AutentykacjaEnum.gtaAutentykacjaMieszana; //gtaAutentykacjaMieszana;
                    gt.Uzytkownik      = ConfigConnection.UzytkownikProperty;
                    gt.UzytkownikHaslo = ConfigConnection.UzytkownikHasloProperty;
                }
                else
                {
                    gt.Autentykacja = AutentykacjaEnum.gtaAutentykacjaWindows; //gtaAutentykacjaMieszana;
                }
                gt.Operator      = ConfigConnection.OperatorGtProperty;        //"Szef";
                gt.OperatorHaslo = ConfigConnection.OperatorGtHasloProperty;   //"";

                sgt =
                    (Subiekt)
                    gt.Uruchom((int)UruchomDopasujEnum.gtaUruchomDopasuj,
                               (int)UruchomEnum.gtaUruchomWTle);

                sgt.MagazynId = 1;

                return(sgt);
            }
            catch (Exception e)
            {
                sgt?.Zakoncz();
                //Utils.SendErrorEmailToDeveloper("Nie udało się uruchomić poprawnie subiekta!");
                return(null);
            }
        }
        private int getKontrahentId(Subiekt subiekt, BaseLinkerOrderModel order)
        {
            Kontrahent kontrahent;

            if (!subiekt.Kontrahenci.Istnieje(order.UserLogin))
            {
                Console.WriteLine("Creating nonexisting Kontrahent");
                kontrahent             = subiekt.KontrahenciManager.DodajKontrahenta();
                kontrahent.Symbol      = order.UserLogin;
                kontrahent.NazwaPelna  = order.DeliveryFullname;
                kontrahent.Nazwa       = order.DeliveryFullname;
                kontrahent.Ulica       = order.DeliveryAddress;
                kontrahent.KodPocztowy = order.DeliveryPostcode;
                kontrahent.Miejscowosc = order.DeliveryCity;

                kontrahent.Email = order.Email;
                kontrahent.Zapisz();
                kontrahent.Zamknij();
            }
            Console.WriteLine("Getting kontrahentId");
            kontrahent = subiekt.Kontrahenci.Wczytaj(order.UserLogin) as Kontrahent;
            return((int)kontrahent.Identyfikator);
        }
Exemplo n.º 5
0
 public SubiektClient()
 {
     //requires some work to add lazy initialization for better user expierience
     //not that straight forward due to STA limitations
     _subiekt = OpenSubiekt();
 }