Esempio n. 1
0
        public ActionResult Save(int idPhieuTN, DateTime date, ChiTietPhieuSua[] chitietphieusua)
        {
            string result = "Error! Thêm chi tiết không thể hoàn tất!";

            if (idPhieuTN != 0 && date != null && chitietphieusua != null)
            {
                PhieuSuaChua phieuSua = new PhieuSuaChua();
                phieuSua.IDPhieuTN   = idPhieuTN;
                phieuSua.NgaySuaChua = date;
                db.PhieuSuaChuas.Add(phieuSua);
                db.SaveChanges();
                int idPhieuSua = phieuSua.IDPhieu;
                foreach (var ct in chitietphieusua)
                {
                    ChiTietPhieuSua C = new ChiTietPhieuSua();
                    C.IDPhieu    = idPhieuSua;
                    C.IDPhuTung  = ct.IDPhuTung;
                    C.DonGia     = ct.DonGia;
                    C.SoLuongBan = ct.SoLuongBan;
                    C.IDTienCong = ct.IDTienCong;
                    C.ThanhTien  = ct.ThanhTien;
                    db.ChiTietPhieuSuas.Add(C);
                }
                db.SaveChanges();
                result = "Thành công! Thêm chi tiết hoàn tất!";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ChiTietPhieuSua chiTietPhieuSua = db.ChiTietPhieuSuas.Find(id);

            db.ChiTietPhieuSuas.Remove(chiTietPhieuSua);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "IDPhieu,IDPhuTung,SoLuongBan,DonGia,IDTienCong,ThanhTien,NoiDung")] ChiTietPhieuSua chiTietPhieuSua)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chiTietPhieuSua).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDPhieu    = new SelectList(db.PhieuSuaChuas, "IDPhieu", "IDPhieu", chiTietPhieuSua.IDPhieu);
     ViewBag.IDPhuTung  = new SelectList(db.PhuTungs, "IDPhuTung", "TenPhuTung", chiTietPhieuSua.IDPhuTung);
     ViewBag.IDTienCong = new SelectList(db.TienCongs, "IDTienCong", "LoaiTC", chiTietPhieuSua.IDTienCong);
     return(View(chiTietPhieuSua));
 }
Esempio n. 4
0
        // GET: ChiTietPhieuSuas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChiTietPhieuSua chiTietPhieuSua = db.ChiTietPhieuSuas.Find(id);

            if (chiTietPhieuSua == null)
            {
                return(HttpNotFound());
            }
            return(View(chiTietPhieuSua));
        }
Esempio n. 5
0
        // GET: ChiTietPhieuSuas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChiTietPhieuSua chiTietPhieuSua = db.ChiTietPhieuSuas.Find(id);

            if (chiTietPhieuSua == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IDPhieu    = new SelectList(db.PhieuSuaChuas, "IDPhieu", "IDPhieu", chiTietPhieuSua.IDPhieu);
            ViewBag.IDPhuTung  = new SelectList(db.PhuTungs, "IDPhuTung", "TenPhuTung", chiTietPhieuSua.IDPhuTung);
            ViewBag.IDTienCong = new SelectList(db.TienCongs, "IDTienCong", "LoaiTC", chiTietPhieuSua.IDTienCong);
            return(View(chiTietPhieuSua));
        }