public ActionResult Edit(int id, Modelss.Model.Mon_An monan)
        {
            try
            {
                // TODO: Add update logic here

                Modelss.Model.Mon_An tk = qltc.Mon_Ans.Single(d => d.MaMonAn == id);

                tk.TenMonAn = monan.TenMonAn;
                tk.LoaiMonAn1.TenLoaiMonAn = monan.LoaiMonAn1.TenLoaiMonAn;
                tk.GhiChu    = monan.GhiChu;
                tk.GiaTien   = monan.GiaTien;
                tk.MoTa      = monan.MoTa;
                tk.TrangThai = monan.TrangThai;

                qltc.SubmitChanges();


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, Modelss.Model.Mon_An monan)
        {
            try
            {
                // TODO: Add delete logic here
                var tk = qltc.Mon_Ans.Single(d => d.MaMonAn == id);
                qltc.Mon_Ans.DeleteOnSubmit(tk);
                qltc.SubmitChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Modelss.Model.Mon_An monan)
        {
            try
            {
                // TODO: Add insert logic here

                //string file = Path.GetFileNameWithoutExtension(monan.ImageUpload.FileName);
                //string extension = Path.GetExtension(monan.ImageUpload.FileName);
                //file = file + extension;
                //monan.HinhAnh = "~/Assert/img/" + file;
                //monan.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/Assert/img/"),file));
                qltc.Mon_Ans.InsertOnSubmit(monan);
                qltc.SubmitChanges();



                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult Create()
 {
     Modelss.Model.Mon_An monan = new Modelss.Model.Mon_An();
     return(View(monan));
 }
        public ActionResult xuLythemMonAn(FormCollection fc, HttpPostedFileBase hinh, Modelss.Model.Mon_An monan)
        {
            monan.TenMonAn  = fc["tenmonan"];
            monan.LoaiMonAn = int.Parse(fc["loaimonan"]);
            monan.GiaTien   = fc["giatien"];
            monan.TrangThai = fc["trangthai"];
            monan.GhiChu    = fc["ghichu"];
            monan.MoTa      = fc["mota"];
            monan.HinhAnh   = hinh.FileName;

            string dd = Server.MapPath("/Content/hinhanh/anhmonan/" + hinh.FileName);

            hinh.SaveAs(dd);
            qltc.Mon_Ans.InsertOnSubmit(monan);
            qltc.SubmitChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
 public ActionResult Index(int mamonan)
 {
     Modelss.Model.Mon_An monan = qltc.Mon_Ans.FirstOrDefault(t => t.MaMonAn == mamonan);
     return(View(monan));
 }