Esempio n. 1
0
        protected void btnThanhToan_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["TenTK"];

            if (cookie != null)
            {
                string    tenTK = cookie.Value;
                HoaDonDTO hd    = new HoaDonDTO();
                //GioHangDTO gh = new GioHangDTO();
                hd.TenTaiKhoan    = tenTK;
                hd.NgayMua        = DateTime.Now;
                hd.DiaChiGiaoHang = "Tp.HCM";
                hd.SDTGiaoHang    = "0905939947";
                hd.TongTien       = GioHangBUS.TinhTongTienGH(tenTK);
                hd.MaHD           = HoaDonBUS.ThemHD(hd);
                DataTable dtbKetQua = GioHangBUS.LayDSGioHang(tenTK);

                foreach (DataRow dr in dtbKetQua.Rows)
                {
                    CTHoaDonDTO cthd = new CTHoaDonDTO();
                    cthd.MaHD    = hd.MaHD;
                    cthd.MaSP    = dr["MaSP"].ToString();
                    cthd.SoLuong = Convert.ToInt32(dr["SoLuong"]);
                    cthd.DonGia  = Convert.ToInt32(dr["GiaTien"]);
                    CTHoaDonBUS.ThemCTHD(cthd);



                    GioHangDTO gh = new GioHangDTO();
                    gh.TenTaiKhoan = tenTK;
                    gh.MaSP        = dr["MaSP"].ToString();
                    gh.SoLuong     = Convert.ToInt32(dr["SoLuong"]);
                    gh.SizeGiay    = dr["sizenumber"].ToString();
                    GioHangBUS.XoaGH(gh);

                    SanPhamBUS.CapNhatSoLuongTonKho(gh.MaSP, gh.SizeGiay, gh.SoLuong);
                }

                Response.Redirect("GioHang.aspx");
            }
        }