Exemple #1
0
        public ActionResult SuaDichVu(String MAHD, String edit_id, String edit_so_luong)
        {
            if (MAHD == null || edit_id == null || edit_so_luong == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DICHVUDADAT dsdv = db.DICHVUDADATs.Find(Int32.Parse(MAHD), Int32.Parse(edit_id));
            int         sol  = Int32.Parse(edit_so_luong);
            DICHVU      dv   = db.DICHVUs.Find(dsdv.MADV);
            int         del  = (int)(sol - dsdv.SOLUONG);

            if (del > dv.TONKHO)
            {
                return(RedirectToAction("GoiDichVu", "HoaDon", new { id = MAHD }));
            }
            else
            {
                dsdv.SOLUONG         = sol;
                dv.TONKHO           -= del;
                db.Entry(dsdv).State = EntityState.Modified;
                db.Entry(dv).State   = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = MAHD }));
        }
Exemple #2
0
        public ActionResult XacNhanGoiDichVu(String MAHD, String MADV, String SOLUONG)
        {
            if (MAHD == null || MADV == null || SOLUONG == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int mahd = Int32.Parse(MAHD);
            int madv = Int32.Parse(MADV);
            int sol  = Int32.Parse(SOLUONG);
            var ds   = db.DICHVUDADATs.Where(t => t.MAHD == mahd).ToList();

            try
            {
                bool check = false;
                foreach (var item in ds)
                {
                    if (item.MADV == madv)
                    {
                        item.SOLUONG += sol;
                        check         = true;
                        break;
                    }
                }
                if (!check)
                {
                    DICHVUDADAT dv = new DICHVUDADAT();
                    dv.MAHD    = Int32.Parse(MAHD);
                    dv.MADV    = Int32.Parse(MADV);
                    dv.SOLUONG = Int32.Parse(SOLUONG);
                    db.DICHVUDADATs.Add(dv);
                }
                DICHVU dichvu = db.DICHVUs.Find(madv);
                if (dichvu.TONKHO == null)
                {
                    dichvu.TONKHO = null;
                }
                else
                {
                    dichvu.TONKHO -= sol;
                }

                db.SaveChanges();
            }
            catch
            {
            }
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = MAHD }));
        }
Exemple #3
0
 public ActionResult XoaDichVu(String MAHD, String MADV)
 {
     if (MAHD == null || MADV == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     else
     {
         //DICHVUDADAT d = db.DICHVUDADATs.Find(Int32.Parse(MAHD),Int32.Parse(MADV));
         var         d  = db.DICHVUDADATs.Where(u => u.MAHD == Int32.Parse(MAHD) && u.MADV == Int32.Parse(MADV));
         DICHVUDADAT dv = (DICHVUDADAT)d;
         db.DICHVUDADATs.Remove(dv);
         db.SaveChanges();
         return(RedirectToAction("GoiDichVu", "HoaDon", new { id = MAHD }));
     }
 }