예제 #1
0
        public ActionResult Create([Bind(Include = "Magiay,Manhacc,Manhasx,Maloaigiay,Tengiay,Soluongton,Giaban,Hinhanh,Mota")] Giay giay, HttpPostedFileBase UploadImage)
        {
            if (ModelState.IsValid)
            {
                if (UploadImage != null)
                {
                    if (UploadImage.ContentType == "image/jpg" || UploadImage.ContentType == "image/png" || UploadImage.ContentType == "image/jpeg")

                    {
                        UploadImage.SaveAs(Server.MapPath("/") + "/Content/img_product/" + UploadImage.FileName);
                        giay.Hinhanh = UploadImage.FileName;
                    }

                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
                db.Giays.Add(giay);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Maloaigiay = new SelectList(db.LoaiGiays, "Maloaigiay", "Tenloaigiay", giay.Maloaigiay);
            ViewBag.Manhacc    = new SelectList(db.NhaCungCaps, "Manhacc", "Tennhacc", giay.Manhacc);
            ViewBag.Manhasx    = new SelectList(db.NhaSanXuats, "Manhasx", "Tennhasx", giay.Manhasx);
            return(View(giay));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Maloaigiay,Tenloaigiay")] LoaiGiay loaiGiay)
        {
            if (ModelState.IsValid)
            {
                db.LoaiGiays.Add(loaiGiay);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(loaiGiay));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Madh,Makh,Tendh,Ngaydat,Ngaygiao,Tinhtranggh,Dathanhtoan")] DonHang donHang)
        {
            if (ModelState.IsValid)
            {
                db.DonHangs.Add(donHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(donHang));
        }
        public ActionResult Create([Bind(Include = "Manhasx,Tennhasx,Diachi,Sdt,Website")] NhaSanXuat nhaSanXuat)
        {
            if (ModelState.IsValid)
            {
                db.NhaSanXuats.Add(nhaSanXuat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhaSanXuat));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "Mamau,Tenmau")] Mau mau)
        {
            if (ModelState.IsValid)
            {
                db.Maus.Add(mau);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mau));
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "Matk,Tentk,Matkhau")] TaiKhoan taiKhoan)
        {
            if (ModelState.IsValid)
            {
                db.TaiKhoans.Add(taiKhoan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(taiKhoan));
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "Masize,Sosize")] Size size)
        {
            if (ModelState.IsValid)
            {
                db.Sizes.Add(size);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(size));
        }
예제 #8
0
        //Thêm mới
        public int AddBill(Bill model)
        {
            Bill db = shopModel.Bills.Find(model.id);

            if (db != null)
            {
                return(-1);
            }
            shopModel.Bills.Add(model);
            shopModel.SaveChanges();

            return(model.id);
        }
예제 #9
0
        //Thêm mới
        public bool AddBill_Details(Bill_Details model)
        {
            Bill_Details db = shopModel.Bill_Details.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.Bill_Details.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #10
0
        //Thêm mới
        public bool AddProduct(Product model)
        {
            Product db = shopModel.Products.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.Products.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #11
0
        //Thêm mới
        public bool AddBrand(Brand model)
        {
            Brand db = shopModel.Brands.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.Brands.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #12
0
        //Thêm mới
        public bool AddUser(UserLogin model)
        {
            UserLogin db = shopModel.UserLogins.Find(model.account);

            if (db != null)
            {
                return(false);
            }
            shopModel.UserLogins.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #13
0
        //Thêm mới
        public bool AddSale(Sale model)
        {
            Sale db = shopModel.Sales.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.Sales.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #14
0
        //Thêm mới
        public bool AddColor(Color model)
        {
            Color db = shopModel.Colors.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.Colors.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #15
0
        //Thêm mới
        public bool Addstype(stype model)
        {
            stype db = shopModel.stypes.Find(model.id);

            if (db != null)
            {
                return(false);
            }
            shopModel.stypes.Add(model);
            shopModel.SaveChanges();

            return(true);
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "Mamau,Magiay,Ghichu")] ChiTietMau chiTietMau)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietMaus.Add(chiTietMau);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Magiay = new SelectList(db.Giays, "Magiay", "Tengiay", chiTietMau.Magiay);
            ViewBag.Mamau  = new SelectList(db.Maus, "Mamau", "Tenmau", chiTietMau.Mamau);
            return(View(chiTietMau));
        }
예제 #17
0
        public ActionResult Create([Bind(Include = "Magiay,Manhacc,Manhasx,Maloaigiay,Tengiay,Soluongton,Giaban,Mau,Size,Hinhanh")] Giay giay)
        {
            if (ModelState.IsValid)
            {
                db.Giays.Add(giay);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Maloaigiay = new SelectList(db.LoaiGiays, "Maloaigiay", "Tenloaigiay", giay.Maloaigiay);
            ViewBag.Manhacc    = new SelectList(db.NhaCungCaps, "Manhacc", "Tennhacc", giay.Manhacc);
            ViewBag.Manhasx    = new SelectList(db.NhaSanXuats, "Manhasx", "Tennhasx", giay.Manhasx);
            return(View(giay));
        }
예제 #18
0
 public ActionResult AddOrEdit(Order ord)
 {
     using (ShopModel db = new ShopModel())
     {
         if (ord.Id == 0)
         {
             db.Orders.Add(ord);
             db.SaveChanges();
             return(Json(new { success = true, message = "Order Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(ord).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Order Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #19
0
 public ActionResult AddOrEdit(Product pro)
 {
     using (ShopModel db = new ShopModel())
     {
         if (pro.Id == 0)
         {
             db.Products.Add(pro);
             db.SaveChanges();
             return(Json(new { success = true, message = "Product Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(pro).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Product Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #20
0
 public ActionResult Delete(int id)
 {
     using (ShopModel db = new ShopModel())
     {
         Order ord = db.Orders.Where(x => x.Id == id).FirstOrDefault <Order>();
         db.Orders.Remove(ord);
         db.SaveChanges();
         return(Json(new { success = true, message = "Order Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #21
0
 public ActionResult Delete(int id)
 {
     using (ShopModel db = new ShopModel())
     {
         Product pro = db.Products.Where(x => x.Id == id).FirstOrDefault <Product>();
         db.Products.Remove(pro);
         db.SaveChanges();
         return(Json(new { success = true, message = "Product Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #22
0
 public void Save()
 {
     context.SaveChanges();
 }