public ActionResult DatHang(FormCollection collection) { //Them Don hang DonHang ddh = new DonHang(); KhachHang kh = (KhachHang)Session["MaKH"]; //List<GioHang> gh = LayGioHang(); ShoppingCart gh = (ShoppingCart)Session["GioHang"]; ddh.MaKH = kh.MaKH; ddh.NgayDat = DateTime.Now; var ngaygiao = String.Format("{0:MM/dd/yyyy}", collection["Ngaygiao"]); ddh.NgayGiao = DateTime.Parse(ngaygiao); ddh.TinhTrangGH = false; ddh.DaThanhToan = false; db.DonHangs.Add(ddh); db.SaveChanges(); //Them chi tiet don hang foreach (var item in gh.Items) { ChiTietSanPham ctdh = new ChiTietSanPham(); ctdh.MaDonHang = ddh.MaDonHang; ctdh.MaSP = item.MaSP; ctdh.SoLuong = item.SoLuongTon; ctdh.DonGia = (decimal)item.GiaBan; db.ChiTietSanPhams.Add(ctdh); } db.SaveChanges(); Session["GioHang"] = null; return(RedirectToAction("Xacnhandonhang", "Cart")); }
public ActionResult Create(SanPham sanpham, HttpPostedFileBase fileUpload) { //luu ten file ViewBag.MaLoai = new SelectList(db.LoaiSanPhams.ToList(), "MaLoai", "TenLoai"); ViewBag.MaNCC = new SelectList(db.NhaCungCaps.ToList(), "MaNCC", "TenNCC"); if (fileUpload == null) { ViewBag.ThongBao = "Chọn Hình Ảnh"; return(View()); } if (ModelState.IsValid) { var fileName = Path.GetFileName(fileUpload.FileName); //luu duong dan cua file var path = Path.Combine(Server.MapPath("~/HinhAnhSanPham"), fileName); //kiem tra hinh anh da ton tại chưa if (System.IO.File.Exists(path)) { ViewBag.ThongBao = "Hình Ảnh Đã Tồn Tại"; } else { fileUpload.SaveAs(path); } sanpham.HinhAnh = fileName; db.SanPhams.Add(sanpham); db.SaveChanges(); } return(View()); }
public ActionResult UpdateNghiepVu() { ReflectionController rc = new ReflectionController(); List <Type> listControllerType = rc.GetControllers("QuanLyXe.Areas.Admin.Controllers"); List <string> listControllerOld = db.NghiepVus.Select(c => c.MaNghiepVu).ToList(); List <string> listPermistionOld = db.BlogPermissions.Select(p => p.PermisstionName).ToList(); foreach (var c in listControllerType) { if (!listControllerOld.Contains(c.Name)) { NghiepVu nv = new NghiepVu() { MaNghiepVu = c.Name, TenNghiepVu = "Chưa có mô tả" }; db.NghiepVus.Add(nv); } List <string> listPermisstion = rc.GetActions(c); foreach (var p in listPermisstion) { if (!listPermistionOld.Contains(c.Name + "-" + p)) { BlogPermission permission = new BlogPermission() { PermisstionName = c.Name + "-" + p, Description = "Chưa có mô tả", MaNghiepVu = c.Name }; db.BlogPermissions.Add(permission); } } } db.SaveChanges(); TempData["err"] = "<div class='alert alert-info' role='alert'><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><span class='sr-only'></span>Cập Nhật</div>"; return(RedirectToAction("Index")); }
public ActionResult DangKy(KhachHang kh, FormCollection f) { var hoten = f["txtTen"].ToString(); var ngaysinh = String.Format("{0:MM/dd/yyyy}", f["NgaySinh"]); var dienthoai = f["txtPhone"].ToString(); var diachi = f["txtDiaChi"].ToString(); var gioitinh = f["txtGioiTinh"].ToString(); var email = f["txtEmail"].ToString(); var taikhoan = f["txtTK"].ToString(); var matkhau = f["txtMK"].ToString(); var admin = int.Parse("0".ToString()); var chophep = int.Parse("0".ToString()); //var admin = int.Parse(f["txtadmin"].ToString()); //var chophep = int.Parse(f["txtchophep"].ToString()); kh.TenKH = hoten; kh.NgaySinh = DateTime.Parse(ngaysinh); kh.DienThoai = dienthoai; kh.DiaChi = diachi; kh.GioiTinh = gioitinh; kh.Email = email; kh.TaiKhoan = taikhoan; kh.MatKhau = matkhau; kh.isAdmin = admin; kh.Allowed = chophep; db.KhachHangs.Add(kh); //Luu vaoo csdl db.SaveChanges(); return(RedirectToAction("DangNhap", "NguoiDung")); }
public ActionResult Create([Bind(Include = "MaLoai,TenLoai")] LoaiSanPham loaiSanPham) { if (ModelState.IsValid) { db.LoaiSanPhams.Add(loaiSanPham); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiSanPham)); }
public ActionResult Create([Bind(Include = "MaNCC,TenNCC,DienThoai,DiaChi")] NhaCungCap nhaCungCap) { if (ModelState.IsValid) { db.NhaCungCaps.Add(nhaCungCap); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaCungCap)); }
public ActionResult Create([Bind(Include = "MaKH,TenKH,NgaySinh,DienThoai,DiaChi,GioiTinh,Email,TaiKhoan,MatKhau,isAdmin,Allowed")] KhachHang khachHang) { if (ModelState.IsValid) { db.KhachHangs.Add(khachHang); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(khachHang)); }
public ActionResult Create([Bind(Include = "PermissionId,PermisstionName,Description,MaNghiepVu")] BlogPermission blogPermission) { if (ModelState.IsValid) { db.BlogPermissions.Add(blogPermission); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaNghiepVu = new SelectList(db.NghiepVus, "MaNghiepVu", "TenNghiepVu", blogPermission.MaNghiepVu); return(View(blogPermission)); }
public ActionResult Create([Bind(Include = "MaDonHang,NgayGiao,NgayDat,DaThanhToan,TinhTrangGH,MaKH")] DonHang donHang) { if (ModelState.IsValid) { db.DonHangs.Add(donHang); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaKH = new SelectList(db.KhachHangs, "MaKH", "TenKH", donHang.MaKH); return(View(donHang)); }
public ActionResult Create([Bind(Include = "MaSP,MaDonHang,SoLuong,DonGia")] ChiTietSanPham chiTietSanPham) { if (ModelState.IsValid) { db.ChiTietSanPhams.Add(chiTietSanPham); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaDonHang = new SelectList(db.DonHangs, "MaDonHang", "MaDonHang", chiTietSanPham.MaDonHang); ViewBag.MaSP = new SelectList(db.SanPhams, "MaSP", "TenSP", chiTietSanPham.MaSP); return(View(chiTietSanPham)); }
public ActionResult Sendnote(Note n, FormCollection f) { //if(ModelState.IsValid) //{ // db.Notes.Add(n); // db.SaveChanges(); //} //return View(); var hoten = f["txtten"].ToString(); var email = f["txtemail"].ToString(); var dienthoai = f["txtsdt"].ToString(); var note = f["txtnote"].ToString(); n.TenKH = hoten; n.Email = email; n.DienThoat = dienthoai; n.Comment = note; db.Notes.Add(n); db.SaveChanges(); return(RedirectToAction("Index", "QuanLyLinhKien")); }
public string updatePermission(int id, int usertemp) { string msg = ""; var grant = db.CapPheps.Find(id, usertemp); if (grant == null) { CapPhep cp = new CapPhep() { PermissionId = id, MaKH = usertemp, Description = "" }; db.CapPheps.Add(cp); msg = /*"<div class='alert alert-success'>Quyền cấp thành công</div>"*/ "<div class='alert alert-success'><h3 class='h4 mb-0 text-success' style='text-align:center'>Cấp Quyền Thành Công<i class='ar fa-check - circle'></i></h3></div>"; } else { db.CapPheps.Remove(grant); msg = /*"<div class='alert alert-danger'>Quyền hủy thành công</div>";*/ "<div class='alert alert-danger'><h3 class='h4 mb-0 text-danger' style='text-align:center'>Quyền Hủy Thành Công<i class='fas fa-exclamation - triangle'></i></h3></div>"; } db.SaveChanges(); return(msg); }