예제 #1
0
        public ActionResult SuaDichVu(String ma_hd, String edit_id, String edit_so_luong)
        {
            if (ma_hd == null || edit_id == null || edit_so_luong == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblDichVuDaDat dsdv = db.tblDichVuDaDats.Find(Int32.Parse(edit_id));
            int            sol  = Int32.Parse(edit_so_luong);
            tblDichVu      dv   = db.tblDichVus.Find(dsdv.ma_dv);
            int            del  = (int)(sol - dsdv.so_luong);

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

            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }
예제 #2
0
        public ActionResult XoaDichVu(String ma_hd, String del_id)
        {
            tblDichVuDaDat d = db.tblDichVuDaDats.Find(Int32.Parse(del_id));

            db.tblDichVuDaDats.Remove(d);
            db.SaveChanges();
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }
예제 #3
0
        public ActionResult SuaDichVu(String ma_hd, String edit_id, String edit_so_luong)
        {
            if (ma_hd == null || edit_id == null || edit_so_luong == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblDichVuDaDat dsdv = db.tblDichVuDaDats.Find(Int32.Parse(edit_id));

            dsdv.so_luong        = Int32.Parse(edit_so_luong);
            db.Entry(dsdv).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }
예제 #4
0
        public ActionResult XoaDichVu(string ma_hd, string del_id)
        {
            int            soluong     = 0;
            tblDichVuDaDat dichVuDaDat = db.tblDichVuDaDats.Find(Int32.Parse(del_id));

            soluong = (int)dichVuDaDat.so_luong;

            tblDichVu dichVu = db.tblDichVus.Where(x => x.ma_dv == dichVuDaDat.ma_dv).SingleOrDefault();

            dichVu.ton_kho = dichVu.ton_kho + soluong;

            db.tblDichVuDaDats.Remove(dichVuDaDat);
            db.SaveChanges();
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }
예제 #5
0
        public ActionResult XacNhanGoiDichVu(string ma_hd, string ma_dv, string so_luong)
        {
            if (ma_hd == null || ma_dv == null || so_luong == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            int mahd     = Int32.Parse(ma_hd);
            int madv     = Int32.Parse(ma_dv);
            int soluong  = Int32.Parse(so_luong);
            var danhSach = db.tblDichVuDaDats.Where(t => t.ma_hd == mahd).ToList();

            try
            {
                bool check = false;

                foreach (var item in danhSach)
                {
                    if (item.ma_dv == madv)
                    {
                        item.so_luong += soluong;
                        check          = true;
                        break;
                    }
                }
                if (!check)
                {
                    tblDichVuDaDat dv = new tblDichVuDaDat();
                    dv.ma_hd    = Int32.Parse(ma_hd);
                    dv.ma_dv    = Int32.Parse(ma_dv);
                    dv.so_luong = Int32.Parse(so_luong);
                    db.tblDichVuDaDats.Add(dv);
                }
                tblDichVu dichvu = db.tblDichVus.Find(madv);
                dichvu.ton_kho -= soluong;
                db.SaveChanges();
            }
            catch
            {
            }
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }
예제 #6
0
        public ActionResult XacNhanGoiDichVu(String ma_hd, String ma_dv, String so_luong)
        {
            if (ma_hd == null || ma_dv == null || so_luong == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblDichVuDaDat dsdv = new tblDichVuDaDat();

            try
            {
                dsdv.ma_hd    = Int32.Parse(ma_hd);
                dsdv.ma_dv    = Int32.Parse(ma_dv);
                dsdv.so_luong = Int32.Parse(so_luong);
                db.tblDichVuDaDats.Add(dsdv);
                db.SaveChanges();
            }
            catch
            {
            }
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = ma_hd }));
        }