コード例 #1
0
        //Phương thức tìm hóa đơn
        private void TimHoaDon(object sender, EventArgs e)
        {
            KiemKeTimHoaDonPresentation wpf = (KiemKeTimHoaDonPresentation)sender;
            string _soHD = wpf._soHD;

            txtSoHD.Text = _soHD;
        }
コード例 #2
0
        //Nút nhập hóa đơn
        private void btnHoDon_Click(object sender, RoutedEventArgs e)
        {
            if (txtSoHD.Text.EndsWith("?"))
            {
                KiemKeTimHoaDonPresentation wpf = new KiemKeTimHoaDonPresentation();
                wpf._strTim     = txtSoHD.Text.Replace("?", "");
                wpf._TimHoaDon += new EventHandler(TimHoaDon);
                wpf.ShowDialog();
                goto go;
            }

            //Kiểm tra số hóa đơn nhập vào
            if (!KiemTraSoHD())
            {
                return;
            }
go:
            //Lấy hóa đơn và hàng mua
            string _soHD = txtSoHD.Text.Trim();
            List <HangMuaPubLic> _lst = TraHangBusiness.LayDsHangMua(_soHD);

            if (_lst != null)
            {
                _lstHangMua = _lst;
                _hoaDon     = _lstHangMua[0].HoaDon;

                //Kiểm tra xem giá bán có thay đổi ko. nếu có thì ko cho mua tiếp trên hóa đơn này
                KiemTraGia();

                //Hiển thị thông tin
                dgHangMua.ItemsSource = _lstHangMua;

                lbSoHD.Content     = _hoaDon.SoHD_HD;
                lbNgayLap.Content  = _hoaDon.NgayLap_HD.ToString("dd/MM/yyyy HH:mm tt");
                lbNhanVien.Content = _hoaDon.NguoiLap_HD.MaNV_NV;

                //Khách hàng
                if (String.IsNullOrEmpty(_hoaDon.KhachHang_HD.MaKH_KH))
                {
                    lbKhachHang.Content = "Khách vãng lai";
                }
                else
                {
                    _hoaDon.KhachHang_HD = TraHangBusiness.LayKhachHang(_hoaDon.KhachHang_HD.MaKH_KH);
                    lbKhachHang.Content  = _hoaDon.KhachHang_HD.HoTen_KH;
                }

                //Tính tổng tiền hóa đơn cũ
                _TienDaTra          = TinhTien();
                _hoaDon.TongTien_HD = _hoaDonMoi.TongTien_HD;//Lấy tổng tiền (tính số điểm khách hàng để trừ khi hủy hóa đơn)

                //Tắt nút nhập
                txtSoHD.Text       = "";
                btnHoDon.IsEnabled = false;
            }
            else
            {
                lbWarning.Visibility = System.Windows.Visibility.Visible;
                lbWarning.Content    = "Lỗi hóa đơn, hóa đơn không chứa sản phẩm nào!";
                txtSoHD.Focus();
                txtSoHD.SelectAll();
            }
        }