//Phương thức thanh toán void ThanhToan(object sender, EventArgs e) { //Lấy thông tin BanHangThanhToanPresentation wpf = (BanHangThanhToanPresentation)sender; _hoaDon.TienKhachTra_HD = wpf._hoaDon.TienKhachTra_HD; _hoaDon.VouCher_HD = wpf._hoaDon.VouCher_HD; _hoaDon.MaGiamGia = wpf._hoaDon.MaGiamGia; _hoaDon.TienMaGiamGia = wpf._hoaDon.TienMaGiamGia; _hoaDon.TienThuaTraLaiKhach = wpf._hoaDon.TienThuaTraLaiKhach; _hoaDon.DangDung_HD = true; //Tính lại tiền TongTien(); //Lưu lại phiên bán hàng BanHangBusiness.BanHang(_hoaDon, _dsSPMua, true); //In hóa đơn bool _InHoaDon = wpf._InHoaDon; if (_InHoaDon) { //Chuẩn bị dữ liệu Pos_ds _Pos_ds = new Pos_ds(); DataTable _dtHoaDonBanLe = _Pos_ds.tbl_HOADON; DataRow _drHoaDonBanLe; foreach (SanPhamPublic _spHoaDon in _dsSPMua) { _drHoaDonBanLe = _dtHoaDonBanLe.NewRow(); _drHoaDonBanLe["MaSP_SP"] = _spHoaDon.MaSP_SP; _drHoaDonBanLe["TenSP_SP"] = _spHoaDon.TenSP_SP; _drHoaDonBanLe["GiaBan_SP"] = _spHoaDon.GiaBan; _drHoaDonBanLe["DVT_SP"] = _spHoaDon.DVT_SP.TenDVT_DVT; _drHoaDonBanLe["SoLuong_SP"] = _spHoaDon.SoLuong_SP; _drHoaDonBanLe["ChietKhau_SP"] = _spHoaDon.CKTienMat; _drHoaDonBanLe["ThanhTien_SP"] = _spHoaDon.ThanhTien_SP; _dtHoaDonBanLe.Rows.Add(_drHoaDonBanLe); } _hoaDon.TongSoLuongSP = _dsSPMua.Sum(item => item.SoLuong_SP); HoaDonBanLe_UPresentation wpf_HoaDon = new HoaDonBanLe_UPresentation(); wpf_HoaDon._status_para = "Bản gốc"; wpf_HoaDon._dtHoaDon = _dtHoaDonBanLe; wpf_HoaDon._hoaDon = _hoaDon; wpf_HoaDon.ShowDialog(); } //Khởi tạo lại dữ liệu _dsSPMua.Clear(); KhoiTaoDuLieu(); TongTien(); txtMaHang.Focus(); //Xóa thông tin khách hàng vừa mua gdKhachHang.Children.Clear(); }
//NÚT THANH TOÁN private void btnThanhToan_Click(object sender, RoutedEventArgs e) { //Lấy dữ liệu (hóa đơn) BanHangThanhToanPresentation wpf = new BanHangThanhToanPresentation(); wpf._hoaDon = _hoaDon;//(Hóa đơn gốc) wpf._ThanhToan += new EventHandler(ThanhToan); wpf.ShowDialog(); }