示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id);

            db.phieuthanhtoans.Remove(phieuthanhtoan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "id,tenphieu,idloaiphieu,iddoandulich,ngaytao")] phieuthanhtoan phieuthanhtoan)
 {
     if (ModelState.IsValid)
     {
         p.sua(phieuthanhtoan);
         return(RedirectToAction("Index"));
     }
     ViewBag.iddoandulich = new SelectList(db.doanduliches, "id", "tendoan", phieuthanhtoan.iddoandulich);
     ViewBag.idloaiphieu  = new SelectList(db.loaiphieux, "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu);
     return(View(phieuthanhtoan));
 }
示例#3
0
        public bool add(phieuthanhtoan ptt)
        {
            int i = 1;

            foreach (chitietthanhtoan ct in ptt.chitietthanhtoan)
            {
                ct.idchitiet = i;
                i++;
            }
            return(db.Add(ptt));
        }
示例#4
0
        // GET: phieuthanhtoans/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieuthanhtoan phieuthanhtoan = pttbus.db.First(c => c.id == id);

            if (phieuthanhtoan == null)
            {
                return(HttpNotFound());
            }
            return(View(phieuthanhtoan));
        }
示例#5
0
        // GET: phieuthanhtoans/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id);

            if (phieuthanhtoan == null)
            {
                return(HttpNotFound());
            }
            return(View(phieuthanhtoan));
        }
示例#6
0
        public ActionResult Edit([Bind(Include = "id,tenphieu,idloaiphieu,iddoandulich,ngaytao")] phieuthanhtoan phieuthanhtoan,
                                 [Bind(Prefix = "ct")] chitietthanhtoan[] chitietthanhtoan)
        {
            if (ModelState.IsValid)
            {
                pttbus.update(phieuthanhtoan, chitietthanhtoan);
                return(RedirectToAction("Index"));
            }
            ViewBag.iddoandulich = new SelectList(pttbus.db1.GetAll(), "id", "tendoan", phieuthanhtoan.iddoandulich);
            ViewBag.idloaiphieu  = new SelectList(pttbus.db2.GetAll(), "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu);
            phieuthanhtoanviewmodel pttvm = new phieuthanhtoanviewmodel();

            pttvm.phieuthanhtoan = phieuthanhtoan;
            return(View(pttvm));
        }
示例#7
0
        // GET: phieuthanhtoans/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieuthanhtoan phieuthanhtoan = db.phieuthanhtoans.Find(id);

            if (phieuthanhtoan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.iddoandulich = new SelectList(db.doanduliches, "id", "tendoan", phieuthanhtoan.iddoandulich);
            ViewBag.idloaiphieu  = new SelectList(db.loaiphieux, "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu);
            return(View(phieuthanhtoan));
        }
示例#8
0
        // GET: phieuthanhtoans/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phieuthanhtoan phieuthanhtoan = pttbus.db.First(c => c.id == id);

            if (phieuthanhtoan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.iddoandulich = new SelectList(pttbus.db1.GetAll(), "id", "tendoan", phieuthanhtoan.iddoandulich);
            ViewBag.idloaiphieu  = new SelectList(pttbus.db2.GetAll(), "id", "tenloaiphieu", phieuthanhtoan.idloaiphieu);
            phieuthanhtoanviewmodel pttvm = new phieuthanhtoanviewmodel();

            pttvm.phieuthanhtoan = phieuthanhtoan;
            return(View(pttvm));
        }
示例#9
0
        public bool update(phieuthanhtoan ptt, chitietthanhtoan[] cttt)
        {
            List <chitietthanhtoan> ctttcu = db3.Find(c => c.idphieuthanhtoan == ptt.id).ToList();

            foreach (chitietthanhtoan ct in ctttcu)
            {
                db3.Delete(ct);
            }
            int i = 1;

            foreach (chitietthanhtoan ct in cttt)
            {
                ct.idphieuthanhtoan = ptt.id;
                ct.idchitiet        = i;
                i++;
                db3.Add(ct);
            }
            return(db.Update(ptt));
        }
示例#10
0
 public bool sua(phieuthanhtoan p)
 {
     db.Entry(p).State = EntityState.Modified;
     db.SaveChanges();
     return(true);
 }
示例#11
0
 public bool them(phieuthanhtoan p)
 {
     db.phieuthanhtoans.Add(p);
     db.SaveChanges();
     return(true);
 }