public void SavePurchaseOrder(List <PurchaseOrderUtil> newPOUlist, LUUser user)
        {
            PurchaseOrderItemDao poitem = new PurchaseOrderItemDao();

            try
            {
                POBatch batch = new POBatch();
                batch.POBatchDate = DateTime.Now;
                batch.Printed     = false;
                batch.GeneratedBy = user.UserID;
                POBatchDao.db.POBatches.Add(batch);
                POBatchDao.db.SaveChanges();

                PersistPO(newPOUlist, batch, user);
            }
            catch (DbEntityValidationException ea)
            {
                foreach (var eve in ea.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
 public PurchaseOrderController()
 {
     ItemDao         = new ItemDao();
     StockCardDao    = new StockCardDao();
     SupplierItemDao = new SupplierItemDao();
     POBatchDao      = new PoBatchDao();
     StockReorder    = new Dictionary <Item, List <SupplierItem> >();
     PODao           = new PurchaseOrderDao();
     POItemDao       = new PurchaseOrderItemDao();
 }
 public StockCardController()
 {
     supplierItemDao = new SupplierItemDao();
     poItemDao       = new PurchaseOrderItemDao();
     stockCardDao    = new StockCardDao();
 }