Esempio n. 1
0
        public ActionResult SaveInvoice(iPadInvoice invoice, int[] iPadID)
        {
            if (iPadID == null)
            {
                throw new ArgumentException("未选择平板");
            }
            var file             = HttpContext.Request.Files[0];
            var saveFullFilePath = FileManager.Upload(file);

            invoice.File = saveFullFilePath;

            var id = Core.iPad_InvoiceManager.Save(invoice);

            if (id > 0)
            {
                var list = iPadID.Select(e => new Register_iPad {
                    IID = e, RID = id, Relation = Relation.Invoice_iPad
                }).ToList();
                Core.Register_iPadManager.Add(list, id, Relation.Invoice_iPad);
            }
            else
            {
                throw new ArgumentException("保存平板发票信息错误!");
            }


            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public int Save(iPadInvoice invoice)
 {
     using (var db = GetDbContext())
     {
         var entry = db.iPad_Invoices.Find(invoice.ID);
         if (entry == null)
         {
             db.iPad_Invoices.Add(invoice);
         }
         else
         {
             db.Entry(entry).CurrentValues.SetValues(invoice);
         }
         db.SaveChanges();
         return(invoice.ID);
     }
 }