protected void btnThanhToan_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { string tenTK = cookie.Value; HoaDonDTO hd = new HoaDonDTO(); 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.LayGH(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); } } }
protected void btnThanhToan_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { string tentk = cookie.Value; TaiKhoanDTO tk = TaiKhoanBUS.LayThongTinTK(tentk); HoaDonDTO hd = new HoaDonDTO(); hd.TenTaiKhoan = tentk; hd.NgayMua = DateTime.Now; hd.DiaChiGiaoHang = tk.DiaChi; hd.SdtGiaoHang = tk.SoDienThoai; hd.TongTien = GioHangBUS.TinhTongTienGH(tentk); hd.MaHD = HoaDonBUS.ThemHD(hd); DataTable dtbKQ = GioHangBUS.LayGH(tentk); foreach (DataRow dr in dtbKQ.Rows) { CTHoaDonDTO cthd = new CTHoaDonDTO(); cthd.MaHD = hd.MaHD; cthd.MaHoa = dr["MaHoa"].ToString(); cthd.SoLuong = Convert.ToInt32(dr["SoLuong"]); cthd.DonGia = Convert.ToInt32(dr["GiaTien"]); CTHoaDonBUS.ThemCTHD(cthd); } } }
public frmBill() { InitializeComponent(); hdBUS = new HoaDonBUS(); htttBUS = new HinhThucThanhToanBUS(); dvmhBUS = new DonViMuaHangBUS(); nvbBUS = new NhanVienBanBUS(); hhBUS = new HangHoaBUS(); nmBUS = new NguoiMuaBUS(); cthdBUS = new CTHoaDonBUS(); }
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"); } }
private void btnXuatHoaDon_Click(object sender, EventArgs e) { HoaDonDTO hoaDon = new HoaDonDTO(); hoaDon.NhanVienLap = TaiKhoanBUS.LayTaiKhoanDangNhap(); hoaDon.NgayLap = DateTime.Now; hoaDon.TongTien = ((FrmBanHang)this.FindForm()).TinhThanhTien(); hoaDon.TienMat = Convert.ToDouble(txtTienMat.Text.Remove(txtTienMat.Text.Length - 1)); hoaDon.TienThua = Convert.ToDouble(txtTienThua.Text.Remove(txtTienThua.Text.Length - 1)); hoaDon.TrangThai = true; List <CTHoaDonDTO> lsCTHD = new List <CTHoaDonDTO>(); List <CTHoaDon_ToppingDTO> lsCTHD_Topping = new List <CTHoaDon_ToppingDTO>(); int idCTHDMark = 0; // Đánh dấu topping thuộc CTHĐ nào foreach (DataGridViewRow row in dgvHoaDon.Rows) { if (row.Tag.GetType() == typeof(MonDTO)) { CTHoaDonDTO cthd = new CTHoaDonDTO(); cthd.MaHoaDon = HoaDonBUS.LayMaHoaDonMoiNhat() + 1; cthd.MaMon = ((MonDTO)row.Tag).MaMon; cthd.SoLuong = Convert.ToInt32(row.Cells["colSoLuong"].Value); cthd.DonGia = Convert.ToDouble(((MonDTO)row.Tag).GiaTien); if (row.Cells["colGhiChu"].Value != null) { cthd.GhiChu = row.Cells["colGhiChu"].Value.ToString(); } else { cthd.GhiChu = string.Empty; } lsCTHD.Add(cthd); idCTHDMark++; } else { CTHoaDon_ToppingDTO cthd_topping = new CTHoaDon_ToppingDTO(); cthd_topping.MaCTHD = CTHoaDonBUS.LayMaCTHoaDonMoiNhat() + idCTHDMark; cthd_topping.MaTopping = ((ToppingDTO)row.Tag).MaTopping; cthd_topping.SoLuong = Convert.ToInt32(row.Cells["colSoLuong"].Value); cthd_topping.DonGia = Convert.ToDouble(((ToppingDTO)row.Tag).GiaTien); if (row.Cells["colGhiChu"].Value != null) { cthd_topping.GhiChu = row.Cells["colGhiChu"].Value.ToString(); } else { cthd_topping.GhiChu = string.Empty; } lsCTHD_Topping.Add(cthd_topping); } } if (HoaDonBUS.LuuHoaDon(hoaDon, lsCTHD, lsCTHD_Topping)) { if (DialogResult.Yes == MessageBox.Show("Bạn có muốn in hoá đơn?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { FrmHienThiBaoCao frm = new FrmHienThiBaoCao(); frm.HienThiHoaDonMoiNhat(); FrmMain.Instance.TopMost = false; frm.Show(); } ((FrmBanHang)this.FindForm()).QuayLaiManHinhChonMon(true); } else { MessageBox.Show("Có lỗi xảy ra khi tạo hoá đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }