Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            phieutratien phieutratien = db.phieutratien.Find(id);

            db.phieutratien.Remove(phieutratien);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "idptt,idnxb,sotientra,tinhtrang")] phieutratien phieutratien)
        {
            if (ModelState.IsValid)
            {
                nxb n = db.nxb.Find(phieutratien.idnxb);
                n.sotienphaitra -= phieutratien.sotientra;
                db.phieutratien.Add(phieutratien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idnxb = new SelectList(db.nxb, "idnxb", "tennxb", phieutratien.idnxb);
            return(View(phieutratien));
        }
Beispiel #3
0
        // GET: phieutratiens/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieutratien phieutratien = db.phieutratien.Find(id);

            if (phieutratien == null)
            {
                return(HttpNotFound());
            }
            return(View(phieutratien));
        }
Beispiel #4
0
        // GET: phieutratiens/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieutratien phieutratien = db.phieutratien.Find(id);

            if (phieutratien == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idnxb = new SelectList(db.nxb, "idnxb", "tennxb", phieutratien.idnxb);
            return(View(phieutratien));
        }
Beispiel #5
0
        public ActionResult Edit([Bind(Include = "idptt,idnxb,sotientra,tinhtrang")] phieutratien phieutratien)
        {
            if (ModelState.IsValid)
            {
                phieutratien pttcu = db.phieutratien.Find(phieutratien.idptt);
                db.Entry(pttcu).State = EntityState.Detached;

                nxb n = db.nxb.Find(phieutratien.idnxb);
                n.sotienphaitra = n.sotienphaitra - phieutratien.sotientra + pttcu.sotientra;

                db.Entry(phieutratien).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.idnxb = new SelectList(db.nxb, "idnxb", "tennxb", phieutratien.idnxb);
            return(View(phieutratien));
        }