Beispiel #1
0
        public ActionResult Dangnhap(FormCollection collection)
        {
            var tendn   = collection["TenDN"];
            var matkhau = collection["Matkhau"];

            if (String.IsNullOrEmpty(tendn))
            {
                ViewData["Loi1"] = "Bạn phải nhập tên đăng nhập";
            }
            else if (String.IsNullOrEmpty(matkhau))
            {
                ViewData["Loi2"] = "Bạn phải nhập mật khẩu";
            }
            else
            {
                TheDocGia kh = data.TheDocGias.SingleOrDefault(n => n.TaiKhoan == tendn && n.MatKhau == matkhau);
                if (kh != null)
                {
                    Session["Taikhoan"]     = kh;
                    Session["TenNguoiDung"] = tendn;
                    return(RedirectToAction("Index", "ThuVien"));
                }
                else
                {
                    ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng";
                }
            }
            return(View());
        }
        public ActionResult Suadocgia(int id)
        {
            TheDocGia tdg = data.TheDocGias.SingleOrDefault(n => n.MaTheDocGia == id);

            //ViewBag.Masach = sach.MaSach;
            if (tdg == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(tdg));
        }
        public ActionResult Chitietdocgia(int id)
        {
            TheDocGia tdg = data.TheDocGias.SingleOrDefault(n => n.MaTheDocGia == id);

            ViewBag.MaTheDocGia = tdg.MaTheDocGia;
            if (tdg == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(tdg));
        }
        public ActionResult Xacnhanxoadocgia(int id)
        {
            TheDocGia tdg = data.TheDocGias.SingleOrDefault(n => n.MaTheDocGia == id);

            ViewBag.MaTheDocGia = tdg.MaTheDocGia;
            if (tdg == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.TheDocGias.Remove(tdg);
            data.SaveChanges();
            return(RedirectToAction("Docgia"));
        }
        public ActionResult Suadocgia(TheDocGia tdg, HttpPostedFileBase fileUpload)
        {
            TheDocGia thisthe = data.TheDocGias.SingleOrDefault(n => n.MaTheDocGia == tdg.MaTheDocGia);

            thisthe.MaTheDocGia = tdg.MaTheDocGia;
            thisthe.HoTen       = tdg.HoTen;
            thisthe.TaiKhoan    = tdg.TaiKhoan;
            thisthe.MatKhau     = tdg.MatKhau;
            thisthe.DiachiKH    = tdg.DiachiKH;
            thisthe.Email       = tdg.Email;
            thisthe.DienthoaiKH = tdg.DienthoaiKH;
            thisthe.Ngaysinh    = tdg.Ngaysinh;
            thisthe.Ngaylapthe  = tdg.Ngaylapthe;
            data.SaveChanges();
            return(RedirectToAction("Docgia"));
        }
Beispiel #6
0
        public ActionResult DatPhieu(FormCollection collection)
        {
            PhieuMuonSach    pms          = new PhieuMuonSach();
            TheDocGia        kh           = (TheDocGia)Session["Taikhoan"];
            List <Phieumuon> lstPhieumuon = LayPhieumuon();

            pms.MaTheDocGia = kh.MaTheDocGia;
            pms.NgayMuon    = DateTime.Now;
            pms.NgayTra     = DateTime.Now.AddDays(7);
            data.PhieuMuonSaches.Add(pms);
            data.SaveChanges();
            foreach (var item in lstPhieumuon)
            {
                CTPhieuMuon ctpm = new CTPhieuMuon();
                ctpm.MaPhieuMuon = pms.MaPhieuMuon;
                ctpm.MaSach      = item.iMasach;
                ctpm.SoLuong     = item.iSoluong;
                data.CTPhieuMuons.Add(ctpm);
            }
            data.SaveChanges();
            Session["Phieumuon"] = null;
            return(RedirectToAction("XacnhanPhieumuon", "Phieumuon"));
        }
Beispiel #7
0
        public ActionResult Dangky(FormCollection collection, TheDocGia kh)
        {
            var hoten          = collection["HotenKH"];
            var tendn          = collection["TenDN"];
            var matkhau        = collection["Matkhau"];
            var matkhaunhaplai = collection["Matkhaunhaplai"];
            var diachi         = collection["Diachi"];
            var email          = collection["Email"];
            var dienthoai      = collection["Dienthoai"];
            var ngaysinh       = String.Format("{0:MM/dd/yyyy}", collection["Ngaysinh"]);

            if (String.IsNullOrEmpty(hoten))
            {
                ViewData["Loi1"] = "Họ tên khách hàng không được để trống";
            }
            else if (String.IsNullOrEmpty(tendn))
            {
                ViewData["Loi2"] = "Phải nhập tên đăng nhập";
            }
            else if (String.IsNullOrEmpty(matkhau))
            {
                ViewData["Loi3"] = "Phải nhập mật khẩu";
            }
            else if (String.IsNullOrEmpty(matkhaunhaplai))
            {
                ViewData["Loi4"] = "Phải nhập lại mật khẩu";
            }
            else if (String.IsNullOrEmpty(email))
            {
                ViewData["Loi5"] = "Email không được bỏ trống";
            }
            else if (String.IsNullOrEmpty(dienthoai))
            {
                ViewData["Loi6"] = "Phải nhập điệnt thoại";
            }
            else if (String.IsNullOrEmpty(diachi))
            {
                ViewData["Loi7"] = "Phải nhập địa chỉ";
            }
            else
            {
                kh.HoTen       = hoten;
                kh.TaiKhoan    = tendn;
                kh.MatKhau     = matkhau;
                kh.Email       = email;
                kh.DiachiKH    = diachi;
                kh.DienthoaiKH = dienthoai;
                kh.Ngaysinh    = DateTime.Parse(ngaysinh);
                kh.Ngaylapthe  = DateTime.Now;
                var query = from tdn in data.TheDocGias where tdn.TaiKhoan == kh.TaiKhoan select tdn;
                if (query.Count() > 0)
                {
                    ViewBag.ThongBaoLoi = "Tài khoản đã có người đăng kí";
                    return(this.Dangky());
                }
                else
                {
                    data.TheDocGias.Add(kh);
                    data.SaveChanges();
                    return(RedirectToAction("Dangnhap"));
                }
            }
            return(this.Dangky());
        }
 public ActionResult Themmoidocgia(TheDocGia tdg)
 {
     data.TheDocGias.Add(tdg);
     data.SaveChanges();
     return(RedirectToAction("Docgia"));
 }