public ActionResult phanhoi(FormCollection collection, phanhoi PH)
        {
            var Hoten   = collection["Hoten"];
            var Email   = collection["Email"];
            var tinnhan = collection["tinnhan"];

            if (String.IsNullOrEmpty(Hoten))
            {
                ViewData["Loi1"] = "Họ tên khách hàng không được bỏ trống !";
            }
            else if (String.IsNullOrEmpty(Email))
            {
                ViewData["Loi2"] = "Email không được bỏ trống !";
            }
            else if (String.IsNullOrEmpty(tinnhan))
            {
                ViewData["Loi3"] = "Nội dung không được bỏ trống !";
            }
            else
            {
                PH.hoten       = Hoten;
                PH.mail        = Email;
                PH.noidungmail = tinnhan;
                data.phanhois.InsertOnSubmit(PH);
                data.SubmitChanges();
                return(RedirectToAction("phanhoi", "TrangChu"));
            }
            return(this.phanhoi());
        }
Example #2
0
        public void XoaPH(int maph)
        {
            phanhoi ph = new phanhoi();

            ph = LayPHTheoId(maph);
            context.phanhois.Remove(ph);
            context.SaveChanges();
        }
Example #3
0
        public phanhoi LayPHTheoId(int maph)
        {
            phanhoi ph = new phanhoi();

            ph = (from p in context.phanhois
                  where p.MAPH == maph
                  select p).ToList().FirstOrDefault();
            return(ph);
        }
Example #4
0
        public void ThemPH(int makh, int masp, string noidung)
        {
            phanhoi ph = new phanhoi();

            ph.MAKH       = makh;
            ph.MASP       = masp;
            ph.NOIDUNG    = noidung;
            ph.THOIGIANPH = DateTime.Now.Date;
            context.phanhois.Add(ph);
            context.SaveChanges();
        }
        public int XoaPH(int maph)
        {
            //Response.Write(maph);
            phanhoi ph = new phanhoi();

            ph = context.phanhois.Where(p => p.MAPH == maph).ToList().LastOrDefault();
            context.phanhois.Remove(ph);
            int check = context.SaveChanges();

            Response.Redirect("/Product/Product_Detail/" + ph.MASP);
            return(check);
        }
        public ActionResult Index(string name, string email, string subject, string message)
        {
            phanhoi    ph         = new phanhoi();
            ContactDao contactDao = new ContactDao();

            ph.email   = email;
            ph.hoten   = name;
            ph.ngayph  = DateTime.Now.Date;
            ph.vande   = subject;
            ph.noidung = message;
            int result = contactDao.postPhanHoi(ph);

            if (result > 0)
            {
                ViewData["thongbao"] = "ok";
            }
            return(View());
        }
        public int ThemPH(int masp, string nd)
        {
            //Response.Write(masp);
            //Response.Write(nd);
            phanhoi ph = new phanhoi();

            ph.MASP       = masp;
            ph.MAKH       = (int)Session["dangnhap"];
            ph.NOIDUNG    = nd;
            ph.THOIGIANPH = DateTime.Now.Date;
            context.phanhois.Add(ph);
            int check = context.SaveChanges();

            if (check != 0)
            {
                Response.Redirect("/Product/Product_Detail/" + ph.MASP);
            }
            else
            {
                Response.Write("Không thêm được");
            }
            return(check);
        }
 public int postPhanHoi(phanhoi ph)
 {
     context.phanhois.Add(ph);
     return(context.SaveChanges());
 }