Ejemplo n.º 1
0
 public Ngay(string ngayTrongTiengAnh, Gio gioBatDau, Gio gioKetThuc, DateTime dt)
 {
     SetNgayTrongTuan(ngayTrongTiengAnh);
     GioBatDau  = gioBatDau;
     GioKetThuc = gioKetThuc;
     date       = dt;
 }
Ejemplo n.º 2
0
 //FrmLoaiXe7Cho LoaiXe = new FrmLoaiXe7Cho();
 public void HoaDonTinhTien_Load(object sender, EventArgs e)
 {
     txtTuyenDuong.Text = Tuyen.ToString();
     txtSoGhe.Text      = Ghe.ToString();
     txtGiaCuoc.Text    = Tien.ToString();
     txtSoXe.Text       = SoXe.ToString();
     txtGioKH.Text      = Ngay.ToString();
     txtGio.Text        = Gio.ToString();
     txtHanhKhach.Text  = THK.ToString();
     txtSDTHK.Text      = SDT.ToString();
 }
        public JsonResult Delete(string cartModel)
        {
            Gio tranggio = (Gio)Session["gio"];

            tranggio.Xoa(cartModel);
            Session["gio"] = tranggio;
            if (tranggio.DSSP.Count == 0)
            {
                TempData["giotrong"] = "<script>swal('chưa có sản phẩm trong giỏ!');</script>";
            }
            return(Json(new { status = true, tongtien = tranggio.TongTien }));
        }
        public ActionResult Index()
        {
            Gio tranggio = (Gio)Session["gio"];

            if (tranggio.DSSP.Count == 0)
            {
                TempData["giotrong"] = "<script>swal('chưa có sản phẩm trong giỏ!');</script>";

                return(RedirectToAction("", "Sanpham"));
            }



            return(View(tranggio.DSSP));
        }
        public JsonResult Update(string cartModel)
        {
            var jsonCart = new JavaScriptSerializer().Deserialize <List <Products> >(cartModel);
            Gio tranggio = (Gio)Session["gio"];

            foreach (var item in tranggio.DSSP)
            {
                var jsonItem = jsonCart.LastOrDefault(x => x.ProductID == item.ProductID);
                if (jsonItem != null)
                {
                    item.SoLuong = jsonItem.SoLuong;
                }
            }

            return(Json(new { status = true, tongtien = tranggio.TongTien }));
        }
Ejemplo n.º 6
0
        public ActionResult ThemGioHang(int ma, string url, FormCollection f, string command)
        {
            /*KHACHHANG kh = Session["TaiKhoan"] as KHACHHANG;
             * if(kh==null)
             * {
             *  TempData["LoginMessage"] = "Vui lòng đăng nhập";
             *  ViewBag.DangNhap = "Quý khách vui lòng đăng nhập!";
             *  return RedirectToAction("ChiTietSanPham","SanPham",new { @masp=ma});
             * }*/
            if (command == "Thêm vào giỏ hàng")
            {
                if (int.Parse(f["txtsl"].ToString()) == 0)
                {
                    return(Redirect(url));
                }
                SANPHAM sp = db.SANPHAMs.SingleOrDefault(n => n.MASP == ma);
                if (sp == null)
                {
                    Response.StatusCode = 404;
                    return(null);
                }
                int slt = (int)sp.SoLuongTon;

                List <Gio> lstGio  = layGioHang();
                Gio        sanpham = lstGio.Find(n => n.maSP == ma);
                if (sanpham == null)
                {
                    sanpham         = new Gio(ma);
                    sanpham.soLuong = int.Parse(f["txtsl"].ToString());
                    TempData["SLT"] = slt - sanpham.soLuong;
                    lstGio.Add(sanpham);
                    return(Redirect(url));
                }
                else
                {
                    sanpham.soLuong = sanpham.soLuong + int.Parse(f["txtsl"].ToString());
                    TempData["SLT"] = slt - sanpham.soLuong;
                    return(Redirect(url));
                }
            }
            else
            {
                return(RedirectToAction("MuaNgay", new { @ma = ma, @sl = f["txtsl"].ToString() }));
            }
        }
Ejemplo n.º 7
0
        public ActionResult CapNhatGio(int ma, FormCollection f)
        {
            SANPHAM sp = db.SANPHAMs.SingleOrDefault(n => n.MASP == ma);

            if (sp == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            List <Gio> lstGio  = layGioHang();
            Gio        sanpham = lstGio.Find(n => n.maSP == ma);

            if (sanpham != null)
            {
                sanpham.soLuong = sanpham.soLuong + int.Parse(f["txtsl"].ToString());
            }
            return(View("GioHang"));
        }
        public ActionResult Them(string id, int sl)
        {
            var p        = db.Sanpham(id);
            Gio tranggio = (Gio)Session["gio"];

            (tranggio).Them(p, sl);
            var sp = (tranggio.DSSP.FirstOrDefault(x => x.ProductID == id) as Products);

            if (sp != null && sp.SoLuong > p.SoLuongTrongKho)
            {
                sp.SoLuong = (int)p.SoLuongTrongKho;
            }
            TempData["url"] = Request.UrlReferrer;
            if (TempData["url"] != null)
            {
                TempData["them"] = true;
                return(Redirect(TempData["url"].ToString()));
            }
            return(RedirectToAction("Index", "Gio"));
        }
Ejemplo n.º 9
0
        public static ThongTinThanhToanTheoNgay TinhTienTheoNgay(Ngay ngay, int maLoaiPhong)
        {
            ThongTinThanhToanTheoNgay res = new ThongTinThanhToanTheoNgay();

            res.listDonGiaTheoKhoangThoiGian.AddRange(ThanhToanDAL.LayDonGiaMaGioBatDauVaGioKetThucNamTrong(ngay, maLoaiPhong));
            if (res.listDonGiaTheoKhoangThoiGian.Count == 0)
            {
                res.listDonGiaTheoKhoangThoiGian.AddRange(ThanhToanDAL.LayTatCaCacDonGiaNamTrongKhoang(ngay, maLoaiPhong));
                res.listDonGiaTheoKhoangThoiGian.AddRange(ThanhToanDAL.LayDonGiaMaGioBatDauNamTrong(ngay, maLoaiPhong));
                res.listDonGiaTheoKhoangThoiGian.AddRange(ThanhToanDAL.LayDonGiaMaGiaKetThucNamTrong(ngay, maLoaiPhong));
            }



            foreach (DonGiaTheoKhoangThoiGian donGia_KhoangTG in res.listDonGiaTheoKhoangThoiGian)
            {
                res.TongThanhTien += Math.Round(Gio.CalcTimeSpan(donGia_KhoangTG.GioBatDau, donGia_KhoangTG.GioKetThuc).TotalHours, 2) * donGia_KhoangTG.DonGia;
            }
            res.ngay = ngay;

            return(res);
        }
Ejemplo n.º 10
0
        public ActionResult ThanhToan()
        {
            Gio tranggio = Session["gio"] as Gio;

            if (tranggio.DSSP.Count == 0)
            {
                return(RedirectToAction("", "Trangchu"));
            }
            if (Session["customer"] == null)
            {
                TempData["chuadangnhap"] = "<script>swal('bạn chưa đăng nhập!');</script>";
                TempData["url"]          = "~/Gio/Thanhtoan";
                return(RedirectToAction("Dangnhap", "Trangchu"));
            }
            ViewBag.customer = Session["customer"];
            if (tranggio.DSSP.Count == 0)
            {
                return(RedirectToAction("", "Sanpham"));
            }

            return(View());
        }
Ejemplo n.º 11
0
        public ActionResult MuaNgay(int ma, string sl)
        {
            /*KHACHHANG kh = Session["TaiKhoan"] as KHACHHANG;
             * if(kh==null)
             * {
             *  TempData["LoginMessage"] = "Vui lòng đăng nhập";
             *  ViewBag.DangNhap = "Quý khách vui lòng đăng nhập!";
             *  return RedirectToAction("ChiTietSanPham","SanPham",new { @masp=ma});
             * }*/
            //int ma = mam;
            int     slm = int.Parse(sl.ToString());
            SANPHAM sp  = db.SANPHAMs.SingleOrDefault(n => n.MASP == ma);

            if (sp == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            int slt = (int)sp.SoLuongTon;

            List <Gio> lstGio  = layGioHang();
            Gio        sanpham = lstGio.Find(n => n.maSP == ma);

            if (sanpham == null)
            {
                sanpham         = new Gio(ma);
                sanpham.soLuong = slm;
                TempData["SLT"] = slt - sanpham.soLuong;
                lstGio.Add(sanpham);
                return(RedirectToAction("GioHang"));
            }
            else
            {
                sanpham.soLuong = sanpham.soLuong + slm;
                TempData["SLT"] = slt - sanpham.soLuong;
                return(RedirectToAction("GioHang"));
            }
        }
Ejemplo n.º 12
0
        public ActionResult XoaGioHang(int ma)
        {
            SANPHAM sp = db.SANPHAMs.SingleOrDefault(n => n.MASP == ma);

            if (sp == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            List <Gio> lstGio  = layGioHang();
            Gio        sanpham = lstGio.Find(n => n.maSP == ma);

            if (sanpham != null)
            {
                lstGio.RemoveAll(n => n.maSP == sanpham.maSP);
                TempData["SLT"] = sp.SoLuongTon;
            }
            if (lstGio.Count == 0)
            {
                return(RedirectToAction("Index", "TrangChu"));
            }
            return(RedirectToAction("GioHang"));
        }
Ejemplo n.º 13
0
        public ActionResult Chitiet()
        {
            Gio tranggio = (Gio)Session["gio"];

            return(PartialView("~/Views/Partial_view/Gio.cshtml", tranggio.DSSP));
        }
Ejemplo n.º 14
0
 public static TimeSpan CalcTimeSpan(Gio gioBatDau, Gio gioKetThuc)
 {
     return((new DateTime(1, 1, (gioKetThuc.hour == 24) ? 2 : 1, (gioKetThuc.hour == 24)?0:gioKetThuc.hour, gioKetThuc.minute, gioKetThuc.second)) - (new DateTime(1, 1, 1, gioBatDau.hour, gioBatDau.minute, gioBatDau.second)));
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            QlSachDbDataContext db = new QlSachDbDataContext();
            if ((string)Session["dn"] == "")
            {

                if (!(db.DangNhaps.Where(p => p.TenDangNhap == tbTenDangNhap.Text)).Any())
                {
                    DangNhap dn = new DangNhap();
                    dn.TenDangNhap = tbTenDangNhap.Text;
                    dn.MatKhau = Encoding.MaHoa(Encoding.key, tbMK.Text);
                    dn.Quyen = false;
                    dn.hoten = tbHoten.Text;
                    db.DangNhaps.InsertOnSubmit(dn);
                    db.SubmitChanges();
                }
                else
                {
                    //Type cstype = this.GetType();

                    //// Get a ClientScriptManager reference from the Page class.
                    //ClientScriptManager cs = Page.ClientScript;

                    //// Check to see if the startup script is already registered.
                    //if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
                    //{
                    //    String cstext = "alert('Tên đăng nhập này đã tồn tại!');";
                    //    cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
                    //}
                    Response.Write("<script>alert(\"Tên đăng nhập này đã tồn tại!\")</script>");
                    
                    return;
                }
                long makh;
                if (db.KhachHangs.Count() == 0)
                    makh = 0;
                else
                    makh = db.KhachHangs.Max(p => p.Makh);
                KhachHang kh = new KhachHang();
                kh.Makh = makh + 1;
                kh.hoten = tbHoten.Text;
                kh.SoDT = tbSdt.Text;
                kh.email = tbEmail.Text;
                kh.diachi = tbDiachi.Text;
                kh.TenDangNhap = tbTenDangNhap.Text;
                db.KhachHangs.InsertOnSubmit(kh);
                db.SubmitChanges();

                if (Session["gh"] == null)
                {
                    Response.Write("<script>alert(\"Giỏ hàng trống!\");window.location='default.aspx';</script>");
                    //Response.Redirect("default.aspx");
                    return;
                }

                long mahd = 0;
                if (db.hoadons.Count() == 0)
                    mahd = 0;
                else
                    mahd = db.hoadons.Max(p => p.MaHoaDon);
                hoadon hd = new hoadon();
                hd.MaHoaDon = mahd + 1;
                hd.makh = kh.Makh;
                hd.damua = false;
                hd.NgayMua = DateTime.Now;
                db.hoadons.InsertOnSubmit(hd);
                db.SubmitChanges();
                DataTable dt = new DataTable();
                Gio gh = new Gio();
                gh = (Gio)Session["gh"];
                dt = gh.dt;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ChiTietHoaDon cthd = new ChiTietHoaDon();
                    long macthd;
                    if (db.ChiTietHoaDons.Count() == 0)
                        macthd = 0;
                    else
                        macthd = db.ChiTietHoaDons.Max(p => p.MaChiTietHD);
                    cthd.MaChiTietHD = macthd + 1;
                    cthd.MaHoaDon = mahd + 1;
                    cthd.MaSach = dt.Rows[i]["masach"].ToString();
                    cthd.SoLuongMua = int.Parse(dt.Rows[i]["soluong"].ToString());
                    
                    //Trừ số lượng sách mua
                    sach s = db.saches.Single(p => p.masach == cthd.MaSach);
                    s.soluong -= cthd.SoLuongMua;
                    db.ChiTietHoaDons.InsertOnSubmit(cthd);
                    db.SubmitChanges();
                    //Type cstype = this.GetType();

                    //// Get a ClientScriptManager reference from the Page class.
                    //ClientScriptManager cs = Page.ClientScript;

                    //// Check to see if the startup script is already registered.
                    //if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
                    //{
                    //    String cstext = "alert('Đặt mua thành công!');";
                    //    cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
                    //}
                    

                }

                Response.Write("<script>alert(\"Đăng kí thành công!\")</script>");
                Response.Write("<script>window.location='xoagiohang.aspx';</script>");
            }
            else
            {
                string sdn = (string)Session["dn"];
                DangNhap dn = db.DangNhaps.Single(p => p.TenDangNhap == sdn);
                KhachHang kh = db.KhachHangs.Single(p => p.TenDangNhap == sdn);
                dn.MatKhau = Encoding.MaHoa(Encoding.key, tbMK.Text);
                db.SubmitChanges();
                kh.hoten = tbHoten.Text;
                kh.diachi = tbDiachi.Text;
                kh.SoDT = tbSdt.Text;
                kh.email = tbEmail.Text;
                db.SubmitChanges();
               
                Response.Write("<script>alert(\"Thay đổi thông tin thành công!\");window.location ='default.aspx';</script>");
                //Response.Redirect("~/default.aspx");
            }
        }
Ejemplo n.º 16
0
 public DonGiaTheoKhoangThoiGian(Gio gioBD, Gio gioKT, double donGia)
 {
     GioBatDau  = gioBD;
     GioKetThuc = gioKT;
     DonGia     = donGia;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            QlSachDbDataContext db = new QlSachDbDataContext();
            
            if (Request.QueryString["act"] == "tdtt" && (string)Session["dn"] != "")
            {
                var dnhap = db.DangNhaps.Single(p => p.TenDangNhap == (string)Session["dn"]);
                var a = db.KhachHangs.Where(p => p.TenDangNhap == dnhap.TenDangNhap);
                // Tài khoản chưa đang đăng nhập chưa có mã khách hàng, nghĩa là được tạo bởi admin, không phải tự đăng kí
                if (a.Count() == 0||dnhap.Quyen)
                {
                    Response.Write("<script>alert(\"Tài khoản này không được phép sử dụng chức năng này!\");window.location='default.aspx'</script>");
                    return;
                }

                GridView1.Visible = false;
                lbGioHang.Visible = false;
                lbTT.Visible = false;
                LTongtien.Visible = false;
                tbTenDangNhap.Enabled = false;
                RequireFieldValidator3.Enabled = false;
                Button1.Text = "Thay đổi";
             
                var q = from dn in db.DangNhaps
                        join kh in db.KhachHangs on dn.TenDangNhap equals kh.TenDangNhap
                        where dn.TenDangNhap == (string)Session["dn"]
                        select new
                                   {
                                       kh.hoten,
                                       kh.TenDangNhap,
                                       dn.MatKhau,
                                       kh.diachi,
                                       kh.SoDT,
                                       kh.email
                                   };

                tbTenDangNhap.Text = q.First().TenDangNhap;
                tbDiachi.Text = q.First().diachi;
                tbEmail.Text = q.First().email;
                tbSdt.Text = q.First().SoDT;
                tbHoten.Text = q.First().hoten;
            }
            else
            {
                //if (Session["gh"] == null)
                //    Response.Redirect("default.aspx");
                //else


                Gio gh = new Gio();
                gh = (Gio)Session["gh"];
                if (gh == null)
                {
                    if ((string)Session["dn"] != "") Response.Redirect("default.aspx");

                    lbTT.Visible = false;
                    lbGioHang.Visible = false;
                }
                else
                {
                    lbTT.Visible = true;
                    lbGioHang.Visible = true;
                    GridView1.DataSource = gh.dt;
                    GridView1.DataBind();
                    LTongtien.Text = string.Format("{0:0,0}", gh.TongTien()) + " VNĐ";
                }

            }
        }
        // GET: danh sách sản phẩm
        public ActionResult Index()
        {
            Gio tranggio = (Gio)Session["gio"];

            return(View());
        }
Ejemplo n.º 19
0
 void Session_Start(object sender, EventArgs e)
 {
     Session["gio"] = new Gio();
 }