public ActionResult EditMa([Bind(Include = "ID,MaGiamGia,GiaTri,NgayHetHan,SoLuong")] MaGiam magiam) { if (ModelState.IsValid) { db.Entry(magiam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(magiam)); }
public ActionResult Edit([Bind(Include = "SoHD,MaKH,NgayDatHang,NgayGiaoHang,TongTien,TrangThai,TenNguoiNhan,DiaChiNhan,DienThoaiKH,MaHinhThucTT,MaHinhThucGD,EmailNhanHang")] DonHang dh) { if (ModelState.IsValid) { db.Entry(dh).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("HoaDon", "ThongKe"); } return View(dh); }
public ActionResult Edit([Bind(Include = "MaSP,TenSP,DonGia,MoTa,MaLoai,TrangThai,HinhAnh,SoLuong,GioiTinh,NgayChinhSua,NgayTao")] SanPham sanpham) { if (ModelState.IsValid) { db.Entry(sanpham).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sanpham)); }
public ActionResult EditTinTuc([Bind(Include = "ID,TenBaiViet,NoiDung,MaLoaiTinTuc,Keyqword,Decription,title,MetaTitle,AnhDaiDien,CapNhat")] TinTuc tintuc ) { if (ModelState.IsValid) { db.Entry(tintuc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tintuc)); }
public ActionResult GioHang(FormCollection frm, DonHang donhang) { //Session["NgayGiaoHang"] = DateTime.Parse(DateTime.Now.ToString()); //Session["NgayNhanHang"] = DateTime.Parse(DateTime.Now.AddDays(+5).ToString("dd-MM-yyyy")); int x = 0; string danggiao = "Đang giao"; string ngaygiao = "2019/12/1"; if (Session["Email"] == null && Session["username"] == null) { return(RedirectToAction("DangNhap", "TaiKhoan")); } else { if (Session["username"] != null) { x = int.Parse(Session["makh"].ToString()); } else { x = int.Parse(Session["MaKH"].ToString()); } var user = db.KhachHangs.FirstOrDefault(n => n.MaKH == x); if (user.DiaChiKH == null || user.SoDienThoaiKH == null) { user = db.KhachHangs.Find(x); { user.SoDienThoaiKH = frm["dienthoainhanhang"]; user.DiaChiKH = frm["diachinhanhang"]; }; if (Session["username"] != null) { db.Entry(user); donhang.MaKH = int.Parse(Session["makh"].ToString()); donhang.NgayDatHang = DateTime.Parse(DateTime.Now.ToString()); //donhang.NgayGiaoHang = ngaygiao; donhang.TongTien = decimal.Parse(Session["TongTien"].ToString()); donhang.TrangThai = danggiao; donhang.TenNguoiNhan = frm["tennguoinhan"]; donhang.DienThoaiKH = frm["dienthoainhanhang"]; donhang.DiaChiNhan = frm["diachinhanhang"]; donhang.EmailNhanHang = frm["email"]; db.DonHangs.Add(donhang); db.SaveChanges(); List <SanPhamGH> listSP = LayGioHang(); foreach (var item in listSP) { ChiTietDH ctdh = new ChiTietDH(); ctdh.SoDH = donhang.SoHD; ctdh.MaSP = item.MaSP; ctdh.SoLuong = item.SoLuongMua; ctdh.DonGia = (decimal)item.DonGia; db.ChiTietDHs.Add(ctdh); db.SaveChanges(); } Session["GioHang"] = null; return(RedirectToAction("ThanhToanThanhCong", "GioHang")); } else { db.Entry(user); donhang.MaKH = int.Parse(Session["MaKH"].ToString()); donhang.NgayDatHang = DateTime.Parse(DateTime.Now.ToString()); //donhang.NgayGiaoHang = ngaygiao; donhang.TongTien = decimal.Parse(Session["TongTien"].ToString()); donhang.TrangThai = danggiao; donhang.TenNguoiNhan = frm["tennguoinhan"]; donhang.DienThoaiKH = frm["dienthoainhanhang"]; donhang.DiaChiNhan = frm["diachinhanhang"]; donhang.EmailNhanHang = frm["email"]; db.DonHangs.Add(donhang); db.SaveChanges(); List <SanPhamGH> listSP = LayGioHang(); foreach (var item in listSP) { ChiTietDH ctdh = new ChiTietDH(); ctdh.SoDH = donhang.SoHD; ctdh.MaSP = item.MaSP; ctdh.SoLuong = item.SoLuongMua; ctdh.DonGia = (decimal)item.DonGia; db.ChiTietDHs.Add(ctdh); db.SaveChanges(); } Session["GioHang"] = null; return(RedirectToAction("ThanhToanThanhCong", "GioHang")); } } else { if (Session["username"] != null) { donhang.MaKH = int.Parse(Session["makh"].ToString()); donhang.NgayDatHang = DateTime.Parse(DateTime.Now.ToString()); //donhang.NgayGiaoHang = DateTime.Parse(DateTime.Now.AddDays(+5).ToString("dd-MM-yyyy")); donhang.TongTien = decimal.Parse(Session["TongTien"].ToString()); donhang.TrangThai = danggiao; donhang.TenNguoiNhan = frm["tennguoinhan"]; donhang.DienThoaiKH = frm["dienthoainhanhang"]; donhang.DiaChiNhan = frm["diachinhanhang"]; donhang.EmailNhanHang = frm["email"]; db.DonHangs.Add(donhang); db.SaveChanges(); List <SanPhamGH> listSP = LayGioHang(); foreach (var item in listSP) { ChiTietDH ctdh = new ChiTietDH(); ctdh.SoDH = donhang.SoHD; ctdh.MaSP = item.MaSP; ctdh.SoLuong = item.SoLuongMua; ctdh.DonGia = (decimal)item.DonGia; db.ChiTietDHs.Add(ctdh); db.SaveChanges(); } Session["Madh"] = donhang.SoHD; return(RedirectToAction("ThanhToanThanhCong", "GioHang")); } else { donhang.MaKH = int.Parse(Session["MaKH"].ToString()); donhang.NgayDatHang = DateTime.Parse(DateTime.Now.ToString()); //donhang.NgayGiaoHang = DateTime.Parse(DateTime.Now.AddDays(+5).ToString("dd-MM-yyyy")); donhang.TongTien = decimal.Parse(Session["TongTien"].ToString()); donhang.TrangThai = danggiao; donhang.TenNguoiNhan = frm["tennguoinhan"]; donhang.DienThoaiKH = frm["dienthoainhanhang"]; donhang.DiaChiNhan = frm["diachinhanhang"]; donhang.EmailNhanHang = frm["email"]; db.DonHangs.Add(donhang); db.SaveChanges(); List <SanPhamGH> listSP = LayGioHang(); foreach (var item in listSP) { ChiTietDH ctdh = new ChiTietDH(); ctdh.SoDH = donhang.SoHD; ctdh.MaSP = item.MaSP; ctdh.SoLuong = item.SoLuongMua; ctdh.DonGia = (decimal)item.DonGia; db.ChiTietDHs.Add(ctdh); db.SaveChanges(); } Session["Madh"] = donhang.SoHD; return(RedirectToAction("ThanhToanThanhCong", "GioHang")); } } } }