Exemplo n.º 1
0
        public Purchase GetById(Guid id)
        {
            Purchase purchase = null;

            using (var em = EntityManagerFactory.CreateInstance(ds))
            {
                string sql = "SELECT p.ID,p.PurchaseCode,p.PurchaseDate,p.SupplierId,s.SupplierName,"
                             + "p.PaymentMethod,p.Status,p.Notes,p.GrandTotal, "
                             + "p.CreatedDate, p.ModifiedDate, p.CreatedBy, p.ModifiedBy, "
                             + "p.AmountInWords,p.DueDate,p.PrintCounter, p.TermOfPayment "
                             + "FROM Purchase p "
                             + "INNER JOIN Supplier s ON p.SupplierId=s.ID "
                             + "WHERE "
                             + "p.ID='{" + id + "}'";

                purchase = em.ExecuteObject <Purchase>(sql, new PurchaseMapper());

                if (purchase != null)
                {
                    purchase.PurchaseItems = purchaseItemRepository.GetByPurchaseId(purchase.ID);
                }
            }

            return(purchase);
        }
Exemplo n.º 2
0
        private void LoadPurchaseItems(Guid id)
        {
            var purchaseItems = purchaseItemRepository.GetByPurchaseId(id);

            lvwPurchase.Items.Clear();

            decimal total = 0;

            foreach (var purchaseItem in purchaseItems)
            {
                total = total + (purchaseItem.Qty * purchaseItem.Price);
                PopulatePurchaseItem(purchaseItem);
            }

            lblTotal.Text = total.ToString("N0").Replace(",", ".");
        }