Exemple #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int id;

            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                // xem don
                id = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
                FGioHang f = new FGioHang(id);
                f.ShowDialog();
            }
            else if (e.ColumnIndex == 1 && e.RowIndex != -1)
            {
                // huy don
                id = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
                var confirmResult = MessageBox.Show("Bạn có muốn hủy đơn này ??",
                                                    "Cảnh báo!!",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (confirmResult == DialogResult.Yes)
                {
                    HuyDon(id);
                    MessageBox.Show("Hủy đơn thành công !");

                    getAll();
                }
            }
        }
Exemple #2
0
 public ActionResult Shipping()
 {
     if (Session["GioHang"] != null)
     {
         KhachHang khachHang = (KhachHang)Session["KhachHang"];
         if (khachHang != null)
         {
             GioHang  gioHang  = (GioHang)Session["GioHang"];
             FGioHang fGioHang = new FGioHang();
             GioHang  ngiohang = fGioHang.Update(gioHang.ID, khachHang.TenKH, khachHang.SDT, khachHang.Email, khachHang.DiaChi);
             Session["GioHang"] = ngiohang;
             return(View(ngiohang));
         }
         else
         {
             if (((GioHang)Session["GioHang"]).TenKH == null)
             {
                 return(View());
             }
             else
             {
                 GioHang gioHang = (GioHang)Session["GioHang"];
                 return(View(gioHang));
             }
         }
     }
     else
     {
         return(RedirectToAction("Home"));
     }
 }
Exemple #3
0
        public ActionResult Payment(string name, string phone, string mail, string address)
        {
            FGioHang fGioHang = new FGioHang();

            Session["GioHang"] = fGioHang.Update(((GioHang)Session["GioHang"]).ID, name, phone, mail, address);
            ViewBag.GioHang    = (GioHang)Session["GioHang"];
            return(View());
        }
Exemple #4
0
        public string UpdateGioHang(int idSanPham, int soLuong)
        {
            GioHang         gioHang         = (GioHang)Session["GioHang"];
            FSanPhamGioHang fSanPhamGioHang = new FSanPhamGioHang();
            string          json            = fSanPhamGioHang.ChangeItem(idSanPham, gioHang.ID, soLuong);
            FGioHang        fGioHang        = new FGioHang();

            Session["GioHang"] = fGioHang.GetGH_MaGH(gioHang.ID);
            return(json);
        }
Exemple #5
0
        public ActionResult Checkout()
        {
            if (Request.Cookies["IDCart"] != null)
            {
                Response.Cookies["IDCart"].Expires = DateTime.Now.AddDays(-1);
            }
            GioHang gioHang = (GioHang)Session["GioHang"];
            int     IDCart  = gioHang.ID;

            Session["GioHang"] = null;
            FGioHang fGioHang = new FGioHang();

            fGioHang.EndGioHang(IDCart);
            return(RedirectToAction("Home"));
        }
Exemple #6
0
        public ActionResult Product(int masp, int soLuong)
        {
            FSanPham        fSanPham        = new FSanPham();
            FSanPhamGioHang fSanPhamGioHang = new FSanPhamGioHang();
            FGioHang        fGioHang        = new FGioHang();
            var             sp = fSanPham.FindSanPham(masp);

            if (sp.TenSP.Length > 40)
            {
                sp.TenSP = sp.TenSP.Substring(0, 35) + "...";
            }
            var            gioHang        = (GioHang)Session["GioHang"];
            SanPhamGioHang sanPhamGioHang = new SanPhamGioHang();

            if (Session["KhachHang"] != null)
            {
                KhachHang x = (KhachHang)Session["KhachHang"];
                if (gioHang == null)
                {
                    gioHang = fGioHang.NewGH(x);
                }
                gioHang            = fSanPhamGioHang.AddItem(masp, gioHang.ID, soLuong);
                Session["GioHang"] = gioHang;
                return(RedirectToAction("Shopcart"));
            }
            else
            {
                if (Request.Cookies["IDCart"] != null)
                {
                    string x          = Request.Cookies["IDCart"].Value;
                    var    giohangtam = fGioHang.GetGH_MaGH(Convert.ToInt32(x));
                    giohangtam         = fSanPhamGioHang.AddItem(masp, Convert.ToInt32(x), soLuong);
                    Session["GioHang"] = giohangtam;
                    return(RedirectToAction("Shopcart"));
                }
                else
                {
                    gioHang = fGioHang.NewGH();
                    Response.Cookies["IDCart"].Value   = gioHang.ID.ToString();
                    Response.Cookies["IDCart"].Expires = DateTime.Now.AddDays(1);
                    gioHang            = fSanPhamGioHang.AddItem(masp, gioHang.ID, soLuong);
                    Session["GioHang"] = gioHang;
                    return(RedirectToAction("Shopcart"));
                }
            }
        }
Exemple #7
0
 public string GetKhachHang()
 {
     if (Request.Cookies["ID"] != null)
     {
         string     x          = Request.Cookies["ID"].Value;
         FKhachHang fKhachHang = new FKhachHang();
         KhachHang  kh         = fKhachHang.GetKH(Convert.ToInt32(x));
         Session["KhachHang"] = kh;
         FGioHang fGioHang = new FGioHang();
         GioHang  gioHang  = fGioHang.GetGH_MaND(kh.ID);
         Session["GioHang"] = gioHang;
         StringBuilder htmlStr = new StringBuilder("");
         htmlStr.Append(@"<li class=""header-item dropdown"">");
         htmlStr.Append(@"<a href = ""/Home/CustomerInfo"">Hello, ");
         htmlStr.Append(kh.TenKH);
         htmlStr.Append("</a>");
         htmlStr.Append(@"<div class=""dropdown-content"">");
         htmlStr.Append(@"<a href = ""/Home/Logout"">Log out</a>");
         htmlStr.Append(@"</div>");
         htmlStr.Append(@"</li>");
         return(htmlStr.ToString());
     }
     else if (Session["KhachHang"] != null)
     {
         KhachHang kh       = (KhachHang)Session["KhachHang"];
         FGioHang  fGioHang = new FGioHang();
         GioHang   gioHang  = fGioHang.GetGH_MaND(kh.ID);
         Session["GioHang"] = gioHang;
         StringBuilder htmlStr = new StringBuilder("");
         htmlStr.Append(@"<li class=""header-item dropdown"">");
         htmlStr.Append(@"<a href = ""/Home/CustomerInfo"">Hello, ");
         htmlStr.Append(kh.TenKH);
         htmlStr.Append("</a>");
         htmlStr.Append(@"<div class=""dropdown-content"">");
         htmlStr.Append(@"<a href = ""/Home/Logout"">Log out</a>");
         htmlStr.Append(@"</div>");
         htmlStr.Append(@"</li>");
         return(htmlStr.ToString());
     }
     else
     {
         return(@"<li class=""header-item""><a href =""/Home/Login"">Login</a></li>");
     }
 }
Exemple #8
0
        // GET: Shopcart
        public ActionResult Shopcart()
        {
            var temp    = Session["KhachHang"];
            var gioHang = (GioHang)Session["GioHang"];

            if (temp != null)
            {
                if (gioHang == null)
                {
                    gioHang            = new GioHang();
                    Session["GioHang"] = gioHang;
                    return(View(gioHang));
                }
                else
                {
                    return(View(gioHang));
                }
            }
            else
            {
                if (gioHang != null)
                {
                    return(View(gioHang));
                }
                else if (Request.Cookies["IDCart"] != null)
                {
                    string   x        = Request.Cookies["IDCart"].Value;
                    FGioHang fGioHang = new FGioHang();
                    gioHang            = fGioHang.GetGH_MaGH(Convert.ToInt32(x));
                    Session["GioHang"] = gioHang;
                    return(View(gioHang));
                }
                else
                {
                    gioHang            = new GioHang();
                    Session["GioHang"] = gioHang;
                    return(View(gioHang));
                }
            }
        }