コード例 #1
0
        public ActionResult Create(InvoiceMaster invoicemaster)
        {
            invoicemaster.DateCreated = DateTime.Now;
            invoicemaster.DateModified = DateTime.Now;
            invoicemaster.InvoiceDetail.DateCreated = DateTime.Now;
            invoicemaster.InvoiceDetail.DateModified = DateTime.Now;
            invoicemaster.InvoiceDetail.IdInvoiceMaster = invoicemaster.IdInvoiceMaster;
            invoicemaster.State = true;

            var member = db.Members.Find(invoicemaster.IdMember);
            member.TotalAmountDue += invoicemaster.InvoiceDetail.Price;
            member.Invoices.Add(invoicemaster);

            if (ModelState.IsValid)
            {
                db.InvoiceMasters.Add(invoicemaster);
                db.Entry(member).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType", invoicemaster.IdInvoiceType);
            ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", invoicemaster.IdMember);
            return View(invoicemaster);
        }
コード例 #2
0
        //
        // GET: /InvoiceMaster/Create
        public ActionResult Create()
        {
            InvoiceMaster invoiceMaster = new InvoiceMaster();
            invoiceMaster.DateInvoiceMaster = DateTime.Now;

            ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType");
            ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber");
            ViewBag.IdChargeCode = new SelectList(db.ChargeCodes, "IdChargeCode", "NameChargeCode");

            return View(invoiceMaster);
        }
コード例 #3
0
 public ActionResult Edit(InvoiceMaster invoicemaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invoicemaster).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType", invoicemaster.IdInvoiceType);
     ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", invoicemaster.IdMember);
     return View(invoicemaster);
 }
コード例 #4
0
ファイル: MLSMASRepository.cs プロジェクト: jascenci/MS
 public void Update(InvoiceMaster invoiceMaster)
 {
     _db.Entry(invoiceMaster).State = EntityState.Modified;
     _db.SaveChanges();
 }