Exemple #1
0
        public ActionResult ThemmoiTH(THUONGHIEU thuonghieu, FormCollection fom)
        {
            if (Session["TaikhoanAdmin"] == null)
            {
                return(RedirectToAction("Login_Admin", "Admin"));
            }

            var ntensp      = fom["ntensp"];
            var nthuonghieu = fom["nthuonghieu"];

            THUONGHIEU test = data.THUONGHIEUs.SingleOrDefault(n => n.TenTH.Contains(ntensp));

            if (test != null)
            {
                ViewBag.Thongbao = "Thương Hiệu Đã Tồn Tại";
            }

            else
            {
                thuonghieu.TenTH = ntensp;

                data.THUONGHIEUs.InsertOnSubmit(thuonghieu);
                data.SubmitChanges();

                return(RedirectToAction("Table_TH"));
            }


            return(View());
        }
Exemple #2
0
        public ActionResult ThemmoiTH(THUONGHIEU th)
        {
            data.THUONGHIEUs.InsertOnSubmit(th);
            data.SubmitChanges();

            return(RedirectToAction("QuanlyThuonghieu"));
        }
Exemple #3
0
 public ActionResult ThemMoiTH(THUONGHIEU thuonghieu, HttpPostedFileBase fileUpLoad)
 {
     ViewBag.MATH = new SelectList(db.THUONGHIEUs.ToList().OrderBy(n => n.TENTH), "MATH", "TENTH");
     if (ModelState.IsValid)
     {
         db.THUONGHIEUs.InsertOnSubmit(thuonghieu);
         db.SubmitChanges();
     }
     return(RedirectToAction("ThuongHieu", "Home"));
 }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "MaTH,TenTH")] THUONGHIEU thuonghieu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(thuonghieu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(thuonghieu));
 }
Exemple #5
0
        public ActionResult Themmoithuonghieu(THUONGHIEU thuonghieu, FormCollection f)
        {
            if (ModelState.IsValid)
            {
                db.Entry(thuonghieu).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();
            }

            return(RedirectToAction("QLThuonghieu"));
        }
Exemple #6
0
 public ActionResult Suathuonghieu(THUONGHIEU thuonghieu, FormCollection f)
 {
     if (ModelState.IsValid)
     {
         db.Entry(thuonghieu).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     ViewBag.MaTH = thuonghieu.MaTH;
     return(RedirectToAction("QLThuonghieu"));
 }
        public ActionResult Update(int math)
        {
            THUONGHIEU            thuonghieu = productBrandService.getProductBrandById(math);
            ProductBrandViewModel th         = new ProductBrandViewModel();

            th.MATH      = math;
            th.TENTH     = thuonghieu.TENTH;
            th.HINHTH    = thuonghieu.HINHTH;
            ViewBag.MATH = thuonghieu.HINHTH;
            return(View(th));
        }
Exemple #8
0
        public ActionResult Create([Bind(Include = "MaTH,TenTH")] THUONGHIEU thuonghieu)
        {
            if (ModelState.IsValid)
            {
                db.THUONGHIEUx.Add(thuonghieu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(thuonghieu));
        }
Exemple #9
0
        public ActionResult Suathuonghieu(int id)
        {
            THUONGHIEU thuonghieu = db.THUONGHIEUx.SingleOrDefault(n => n.MaTH == id);

            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(thuonghieu));
        }
Exemple #10
0
        public ActionResult XoaTH(int id)
        {
            THUONGHIEU th = data.THUONGHIEUs.SingleOrDefault(n => n.MaTH == id);

            ViewBag.Magiay = th.MaTH;
            if (th == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(th));
        }
Exemple #11
0
 public ActionResult SuaTH(THUONGHIEU thuonghieu)
 {
     if (ModelState.IsValid)
     {
         var obj = db.THUONGHIEUs.SingleOrDefault(p => p.MATH == thuonghieu.MATH);
         obj.TENTH = thuonghieu.TENTH;
         db.SubmitChanges();
         return(RedirectToAction("ThuongHieu"));
     }
     ViewBag.MATH = new SelectList(db.THUONGHIEUs.ToList().OrderBy(n => n.TENTH), "MATH", "TENTH");
     return(View(thuonghieu));
 }
Exemple #12
0
        public ActionResult XoaTH(int?id)
        {
            THUONGHIEU thuonghieu = db.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(thuonghieu));
        }
Exemple #13
0
        public ActionResult ThemTH(THUONGHIEU thuonghieu, HttpPostedFileBase fileupload, FormCollection f)
        {
            if (Session["TaiKhoan"].ToString() == "admin")
            {
                if (kiemtraKyTu(f["TenTH"], 50) != null)
                {
                    ViewBag.ThongBaoLoi = kiemtraKyTu(f["TenTH"], 50);
                    return(View(thuonghieu));
                }

                if (fileupload == null)
                {
                    ViewBag.Thongbao = "Vui lòng chọn ảnh sản phẩm";
                    return(View(thuonghieu));
                }
                else if (ModelState.IsValid)
                {
                    //Lưu tên file ;
                    // dong bat loi file la anh
                    var    filename      = Path.GetFileName(fileupload.FileName);
                    string fileExtexsion = Path.GetExtension(fileupload.FileName);
                    if (fileExtexsion.ToLower() == ".gif" || fileExtexsion.ToLower() == ".png" || fileExtexsion.ToLower() == ".jpg" || fileExtexsion.ToLower() == ".jpeg")
                    {
                        //Lưu đường dẫn của File
                        var path = Path.Combine(Server.MapPath("~/img"), filename);
                        if (System.IO.File.Exists(path))
                        {
                            ViewBag.Thongbao = "Hình ảnh đã tồn tại";
                        }
                        else
                        {
                            //Lưu hình ảnh vào đường dẫn
                            fileupload.SaveAs(path);
                        }
                        thuonghieu.imgHeader  = filename;
                        thuonghieu.imgContent = f["imgContend"].ToString();
                        thuonghieu.TenTH      = f["TenTH"].ToString();
                        thuonghieu.TrangThai  = true;
                        db.THUONGHIEUs.InsertOnSubmit(thuonghieu);
                        db.SubmitChanges();
                    }
                    else
                    {
                        ViewBag.Thongbao = "Vui lòng chọn file là ảnh";
                        return(View(thuonghieu));
                    }
                }

                return(RedirectToAction("ThuongHieu"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #14
0
        public ActionResult SuaTH(int?id)
        {
            THUONGHIEU thuonghieu = db.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            ViewBag.MATH = new SelectList(db.THUONGHIEUs.ToList().OrderBy(n => n.TENTH), "MATH", "TENTH", thuonghieu.MATH);
            return(View(thuonghieu));
        }
 public bool addProductBrand(THUONGHIEU th)
 {
     try
     {
         db.THUONGHIEUx.Add(th);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #16
0
        public ActionResult XoaTH(int id)
        {
            if (Session["TaiKhoan"].ToString() == "admin")
            {
                THUONGHIEU kh = db.THUONGHIEUs.SingleOrDefault(m => m.MaTH == id);
                kh.TrangThai = false;
                UpdateModel(kh);
                db.SubmitChanges();
                return(RedirectToAction("ThuongHieu", "Admin"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #17
0
        public ActionResult XacnhanXoathuonghieu(int id)
        {
            THUONGHIEU thuonghieu = db.THUONGHIEUx.SingleOrDefault(n => n.MaTH == id);

            ViewBag.MaTH = thuonghieu.MaTH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.Entry(thuonghieu).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
            return(RedirectToAction("QLThuonghieu"));
        }
Exemple #18
0
        // GET: /Admin/QLThuongHieu/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            THUONGHIEU thuonghieu = db.THUONGHIEUx.Find(id);

            if (thuonghieu == null)
            {
                return(HttpNotFound());
            }
            return(View(thuonghieu));
        }
Exemple #19
0
        public ActionResult XacNhanXoaTH(int?id)
        {
            THUONGHIEU thuonghieu = db.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.THUONGHIEUs.DeleteOnSubmit(thuonghieu);
            db.SubmitChanges();
            return(RedirectToAction("ThuongHieu"));
        }
Exemple #20
0
        public ActionResult XacnhanxoaTH(int id)
        {
            THUONGHIEU th = data.THUONGHIEUs.SingleOrDefault(n => n.MaTH == id);

            ViewBag.Magiay = th.MaTH;
            if (th == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.THUONGHIEUs.DeleteOnSubmit(th);
            data.SubmitChanges();
            return(RedirectToAction("QuanlyThuonghieu"));
        }
Exemple #21
0
        public ActionResult Sua(int id, FormCollection coll)
        {
            THUONGHIEU thuonghieu = data.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            UpdateModel(thuonghieu);
            data.SubmitChanges();

            return(RedirectToAction("Index"));
        }
Exemple #22
0
        public THUONGHIEU toTHUONG_HIEU()
        {
            THUONGHIEU th = Context.getInstance().db.THUONGHIEUx.Where(key => key.MaThuongHieu == MaThuongHieu).FirstOrDefault();

            if (th == null)
            {
                th = new THUONGHIEU();
                th.MaThuongHieu = MaThuongHieu;
            }
            th.MaThuongHieu  = MaThuongHieu;
            th.TenThuongHieu = TenThuongHieu;
            th.MoTa          = MoTa;
            th.TrangThai     = TrangThai;
            return(th);
        }
Exemple #23
0
        public ActionResult Sua(int id)
        {
            if (CheckAdmin() == false)
            {
                return(RedirectToAction("Login", "QuanLySanPham"));
            }
            THUONGHIEU thuonghieu = data.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(thuonghieu));
        }
Exemple #24
0
        public ActionResult SuaTP(int id, FormCollection collect)
        {
            var msth          = id;
            var tenth         = collect["ntenth"];
            var tenthuonghieu = collect["nthuonghieu"];


            THUONGHIEU th = data.THUONGHIEUs.SingleOrDefault(n => n.MaTH == msth);

            th.TenTH = tenth;

            th.MaTH = msth;
            UpdateModel(th);
            data.SubmitChanges();
            return(RedirectToAction("Table_TH"));
        }
        public ActionResult Create(ProductBrandViewModel th)
        {
            ViewBag.message = "";
            if (ModelState.IsValid)
            {
                THUONGHIEU thuonghieu = new THUONGHIEU();
                thuonghieu.TENTH  = th.TENTH;
                thuonghieu.HINHTH = th.HINHTH;

                if (productBrandService.addProductBrand(thuonghieu))
                {
                    ViewBag.message = "Thêm mới thương hiệu thành công";
                }
            }
            return(View(th));
        }
Exemple #26
0
        public ActionResult XoaTHDaChon(int id)
        {
            if (Session["TaikhoanAdmin"] == null)
            {
                return(RedirectToAction("Login_Admin", "Admin"));
            }
            THUONGHIEU thuonghieu = data.THUONGHIEUs.SingleOrDefault(n => n.MaTH == id);

            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.THUONGHIEUs.DeleteOnSubmit(thuonghieu);
            data.SubmitChanges();
            return(RedirectToAction("Table_TH", "Admin"));
        }
 public bool updateProductBrand(THUONGHIEU th)
 {
     try
     {
         var result = db.THUONGHIEUx.Find(th.MATH);
         if (result != null)
         {
             result.TENTH  = th.TENTH;
             result.HINHTH = th.HINHTH;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
Exemple #28
0
        public ActionResult ProductDetail(string masp)
        {
            if (masp == null)
            {
                return(RedirectToAction("Index", "KhachHang"));
            }
            SANPHAM              s   = db.SANPHAMs.Where(sp => sp.MASANPHAM == masp).Single();
            THUONGHIEU           t   = db.THUONGHIEUs.Where(th => th.MATHUONGHIEU == s.MATHUONGHIEU).Single();
            List <NEM_KICHTHUOC> kth = db.NEM_KICHTHUOCs.Where(kt => kt.MASANPHAM == masp).ToList();

            ViewBag.kichthuoc  = kth;
            ViewBag.thuonghieu = t;
            if (Session["kh"] != null)
            {
                KHACHHANG      k     = Session["kh"] as KHACHHANG;
                List <SANPHAM> thich = new List <SANPHAM>();
                var            data  = from sp in db.SANPHAMs
                                       join th in db.SPTHICHes
                                       on sp.MASANPHAM equals th.MASANPHAM
                                       where th.USERNAME == k.USERNAME
                                       select sp;
                foreach (var item in data)
                {
                    SANPHAM ss = item as SANPHAM;
                    thich.Add(ss);
                }
                ViewBag.thich = thich;
            }
            List <SANPHAM> related = db.SANPHAMs.Where(sp => sp.MALOAI == s.MALOAI && sp.MASANPHAM != s.MASANPHAM).Take(4).ToList();

            ViewBag.related = related;
            //lay desc
            NEM_DACDIEM ldd = db.NEM_DACDIEMs.Where(dd => dd.MASANPHAM == masp).SingleOrDefault();

            if (ldd != null)
            {
                ViewBag.dd = ldd;
            }
            return(View(s));
        }
Exemple #29
0
        public ActionResult Xoa(int id, FormCollection coll)
        {
            //Lay ra doi tuong sach can xoa theo ma
            THUONGHIEU thuonghieu = data.THUONGHIEUs.SingleOrDefault(n => n.MATH == id);

            ViewBag.MATH = thuonghieu.MATH;
            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            try
            {
                data.THUONGHIEUs.DeleteOnSubmit(thuonghieu);
                data.SubmitChanges();
            }
            catch (Exception e)
            {
                ViewBag.Loi = "Không thể xóa sản phẩm này";
                return(Xoa(id));
            }

            return(RedirectToAction("Index"));
        }
Exemple #30
0
 public ActionResult ThemMoiTH(THUONGHIEU thuonghieu)
 {
     data.THUONGHIEUs.InsertOnSubmit(thuonghieu);
     data.SubmitChanges();
     return(RedirectToAction("Index"));
 }