Exemplo n.º 1
15
 private void UpdateSaleViewModel(Jq cq)
 {
     PaymentForms.Clear();
     PaymentForms.AddRange(cq.All("gadakhdisFormebi",
         cqq => new AmountItemViewModel()
     {
         Link = cqq.GetLink("gadakhdisForma"),
         Name = cqq.GetText("dasakheleba"),
         Value = cqq.GetText("tankha"),
         ViewState = "Plus"
     }));
     PaymentForms.Last().ViewState = "Equals";
     PaymentForms.Add(new AmountItemViewModel()
         {
             Name = "სულ გადახდილი",
             Value = cq.GetText("sulMigebuliTankha"),
             ViewState = "Minus"
         });
     PaymentForms.Add(new AmountItemViewModel()
         {
             Name = "სულ გადასახდელი",
             Value = cq.GetText("misagebiTankha"),
             Value2 = cq.GetText("fasdaklebuliMisagebiTankha"),
             ViewState = "Equals"
         });
     PaymentForms.Add(new AmountItemViewModel()
     {
         Name = "ხურდა",
         Value = cq.GetText("gasacemiTankha"),
         ViewState = "Normal"
     });
     AddItem = cq.GetForm("produktisDamateba");
     Submit = cq.GetLink("cheki");
     Submit.OnExecuted += () => IsToolVisible = false;
     Func<Jq, ItemViewModel> createItem = (q) =>
         new ItemViewModel()
         {
             Id = q.GetText("id"),
             Version = q.GetText("versia"),
             Name = q.GetText("dasakheleba"),
             Ean = q.GetText("ean"),
             Reference = q.GetText("ref"),
             Quantity = q.GetText("raodenoba"),
             UnitPrice = q.GetText("fasdaklebuliFasi"),
             TotalPrice = q.GetText("jami"),
             DiscountedTotalPrice = q.GetText("fasdaklebuliJami"),
             Photo = q.GetText("img"),
             Increase = q.GetForm("momateba"),
             Decrease = q.GetForm("mokleba")
         };
     var itemViewModels = cq.All("produktebi", createItem).ToList();
     var newItems = (from first in itemViewModels
                     from second in Items.Where(x => x.Id == first.Id).DefaultIfEmpty()
                     where second == null
                     select first).ToList();
     var changedItems = (from first in itemViewModels
                         from second in Items.Where(x => x.Id == first.Id)
                         where second.Version != first.Version
                         select new { First = first, Second = second }).ToList();
     var deletedItems = (from first in Items
                         from second in itemViewModels.Where(x => x.Id == first.Id).DefaultIfEmpty()
                         where second == null
                         select first).ToList();
     deletedItems.ForEach(x => Items.Remove(Items.First(e => e.Id == x.Id)));
     changedItems.ForEach(x => x.Second.Update(x.First));
     newItems.ForEach(x => Items.Insert(0, x));
     ViewState = "Normal";
 }
Exemplo n.º 2
1
        public async Task PrintReceipt(Jq cq)
        {

            var biSource = new BitmapImage();

            var ms = await (await new HttpClient().GetAsync(cq.GetText("logo"))).Content.ReadAsStreamAsync();
            ms.Seek(0, SeekOrigin.Begin);
            biSource.BeginInit();
            biSource.StreamSource = ms;
            biSource.EndInit();

            var receipt = new Receipt
                {
                    Phone = { Text = cq.GetText("tel") },
                    Address = { Text = cq.GetText("misamarti") },
                    Barcode = { Text = cq.GetText("chekisNomeri") },
                    Logo = { Source = biSource }
                };

            var items = cq.All("chekisKhazebi", cqq => new PartReceiptItem()
                {
                    Name = { Text = cqq.GetText("dasakheleba") },
                    Ean = { Text = cqq.GetText("kodi") },
                    UnitPrice = { Text = cqq.GetText("ertFasi") },
                    Quantity = { Text = cqq.GetText("raodenoba") },
                    Total = { Text = cqq.GetText("jami") },
                });
            foreach (var item in items)
            {
                receipt.Items.Items.Add(item);
            }
            var amountItems = cq.All("jamisKhazebi", cqq => new PartReceiptAmountItem()
                {
                    Name = { Text = cqq.GetText("dasakheleba") },
                    Amount = { Text = cqq.GetText("tankha") }
                });
            foreach (var aItem in amountItems)
            {
                receipt.Amounts.Items.Add(aItem);
            }
            var printer = new Printer(ConfigurationManager.AppSettings["ReceiptPrinter"]);
            printer.PrintReceipt(receipt);
        }
Exemplo n.º 3
0
        public async void Navigate(HttpRequestMessage request)
        {
            var response = await this.SendAsync(request);

            var sc = response.StatusCode;
            var redirected = sc == HttpStatusCode.TemporaryRedirect ||
                sc == HttpStatusCode.Moved || sc == HttpStatusCode.MovedPermanently ||
                sc == HttpStatusCode.Found;
            if (redirected)
            {
                var req = new HttpRequestMessage(HttpMethod.Get,
                                                 new Uri(response.RequestMessage.RequestUri,
                                                         response.Headers.Location));
                Navigate(req);
                return;
            }

            var content = await response.Content.ReadAsStringAsync();
            var jq = new Jq((JsonObject)JsonReader<JsonObject>.Parse(content), Navigate);
            if (jq.GetText("title") == "Home")
            {
                TForm form = jq.GetForm("airchiePosi");
                form["posisNomeri"] = ConfigurationManager.AppSettings["pos"];
                form.Execute(null);
                return;
            }

            var url = request.Method != HttpMethod.Get ? response.Headers.Location : request.RequestUri;

            if (_lastUri != null && (_stack.Count == 0 || _stack.Peek() != request.RequestUri))
                _stack.Push(_lastUri);
            _lastUri = _lastUri == url ? null : url;
            _shell.Show(new ScreenActivationContext(jq, Navigate));
        }
Exemplo n.º 4
0
        public async Task PrintReceipt(Jq cq)
        {
            var biSource = new BitmapImage();

            var ms = await(await new HttpClient().GetAsync(cq.GetText("logo"))).Content.ReadAsStreamAsync();

            ms.Seek(0, SeekOrigin.Begin);
            biSource.BeginInit();
            biSource.StreamSource = ms;
            biSource.EndInit();

            var receipt = new Receipt
            {
                Phone   = { Text = cq.GetText("tel") },
                Address = { Text = cq.GetText("misamarti") },
                Barcode = { Text = cq.GetText("chekisNomeri") },
                Logo    = { Source = biSource }
            };

            var items = cq.All("chekisKhazebi", cqq => new PartReceiptItem()
            {
                Name      = { Text = cqq.GetText("dasakheleba") },
                Ean       = { Text = cqq.GetText("kodi") },
                UnitPrice = { Text = cqq.GetText("ertFasi") },
                Quantity  = { Text = cqq.GetText("raodenoba") },
                Total     = { Text = cqq.GetText("jami") },
            });

            foreach (var item in items)
            {
                receipt.Items.Items.Add(item);
            }
            var amountItems = cq.All("jamisKhazebi", cqq => new PartReceiptAmountItem()
            {
                Name   = { Text = cqq.GetText("dasakheleba") },
                Amount = { Text = cqq.GetText("tankha") }
            });

            foreach (var aItem in amountItems)
            {
                receipt.Amounts.Items.Add(aItem);
            }
            var printer = new Printer(ConfigurationManager.AppSettings["ReceiptPrinter"]);

            printer.PrintReceipt(receipt);
        }
Exemplo n.º 5
0
        private void UpdateSaleViewModel(Jq cq)
        {
            PaymentForms.Clear();
            PaymentForms.AddRange(cq.All("gadakhdisFormebi",
                                         cqq => new AmountItemViewModel()
            {
                Link      = cqq.GetLink("gadakhdisForma"),
                Name      = cqq.GetText("dasakheleba"),
                Value     = cqq.GetText("tankha"),
                ViewState = "Plus"
            }));
            PaymentForms.Last().ViewState = "Equals";
            PaymentForms.Add(new AmountItemViewModel()
            {
                Name      = "სულ გადახდილი",
                Value     = cq.GetText("sulMigebuliTankha"),
                ViewState = "Minus"
            });
            PaymentForms.Add(new AmountItemViewModel()
            {
                Name      = "სულ გადასახდელი",
                Value     = cq.GetText("misagebiTankha"),
                Value2    = cq.GetText("fasdaklebuliMisagebiTankha"),
                ViewState = "Equals"
            });
            PaymentForms.Add(new AmountItemViewModel()
            {
                Name      = "ხურდა",
                Value     = cq.GetText("gasacemiTankha"),
                ViewState = "Normal"
            });
            AddItem            = cq.GetForm("produktisDamateba");
            Submit             = cq.GetLink("cheki");
            Submit.OnExecuted += () => IsToolVisible = false;
            Func <Jq, ItemViewModel> createItem = (q) =>
                                                  new ItemViewModel()
            {
                Id                   = q.GetText("id"),
                Version              = q.GetText("versia"),
                Name                 = q.GetText("dasakheleba"),
                Ean                  = q.GetText("ean"),
                Reference            = q.GetText("ref"),
                Quantity             = q.GetText("raodenoba"),
                UnitPrice            = q.GetText("fasdaklebuliFasi"),
                TotalPrice           = q.GetText("jami"),
                DiscountedTotalPrice = q.GetText("fasdaklebuliJami"),
                Photo                = q.GetText("img"),
                Increase             = q.GetForm("momateba"),
                Decrease             = q.GetForm("mokleba")
            };
            var itemViewModels = cq.All("produktebi", createItem).ToList();
            var newItems       = (from first in itemViewModels
                                  from second in Items.Where(x => x.Id == first.Id).DefaultIfEmpty()
                                  where second == null
                                  select first).ToList();
            var changedItems = (from first in itemViewModels
                                from second in Items.Where(x => x.Id == first.Id)
                                where second.Version != first.Version
                                select new { First = first, Second = second }).ToList();
            var deletedItems = (from first in Items
                                from second in itemViewModels.Where(x => x.Id == first.Id).DefaultIfEmpty()
                                where second == null
                                select first).ToList();

            deletedItems.ForEach(x => Items.Remove(Items.First(e => e.Id == x.Id)));
            changedItems.ForEach(x => x.Second.Update(x.First));
            newItems.ForEach(x => Items.Insert(0, x));
            ViewState = "Normal";
        }