Ejemplo n.º 1
0
        //txt mã sản phẩm preview keydown
        private void txtMaHang_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                //Kiểm tra xem mã có hợp lệ không(Mã chỉ chứa chữ cái, dấu chấm và dấu gạch dưới)
                string _checkMaSp = @"^([a-zA-Z0-9._?]+)$";
                if (!Regex.IsMatch(txtMaHang.Text.Trim(), _checkMaSp))
                {
                    lbWarning.Visibility = System.Windows.Visibility.Visible;
                    lbWarning.Text       = "Mã sản phẩm không hợp lệ!";
                    txtMaHang.Focus();
                    txtMaHang.SelectAll();
                    return;
                }

                if (txtMaHang.Text.Trim().EndsWith("?"))
                {
                    NhapMua_TimKiemSPPresentation wpf_tim = new NhapMua_TimKiemSPPresentation();
                    wpf_tim._strTim     = txtMaHang.Text.Trim().Replace("?", "");
                    wpf_tim._TimKiemSP += new EventHandler(TimKiemSP);
                    wpf_tim.ShowDialog();
                }
                else
                {
                    btnThemHang_Click(sender, e);
                }
            }
        }
Ejemplo n.º 2
0
        //Tìm kiếm sp dowork
        private void TimKiemSP_dowork(object sender, EventArgs e)
        {
            #region 1.Lấy danh sách sản phẩm dc chọn từ wpf tìm kiếm
            NhapMua_TimKiemSPPresentation wpf         = (NhapMua_TimKiemSPPresentation)sender;
            List <SanPhamPublic>          _ListSPChon = wpf._ListSPChon;
            #endregion

            #region 2. Thêm vào datable sp
            foreach (SanPhamPublic _sp in _ListSPChon)
            {
                //Kiểm tra sản phẩm này đã có trong bảng chưa?
                if (KiemTraTonTai(_sp.MaSP_SP))
                {
                    continue;
                }
                //Nếu chưa thì add vào list sản phẩm nhập
                _sp.GiaNhap_SP = UntilitiesBusiness.ThemDauPhay(_sp.GiaNhap_SP);
                int _SoLuongNhap = _sp.SoLuong_SP;
                int _GiaNhap     = Convert.ToInt32(UntilitiesBusiness.BoDauPhay(_sp.GiaNhap_SP));
                int _ThanhTien   = _SoLuongNhap * _GiaNhap;
                _sp.ThanhTien_SP = UntilitiesBusiness.ThemDauPhay(_ThanhTien.ToString());

                _ListSpNhap.Add(_sp);
            }
            #endregion
        }
Ejemplo n.º 3
0
        //Nút tìm kiếm
        private void btnTimKiem_Click(object sender, RoutedEventArgs e)
        {
            NhapMua_TimKiemSPPresentation wpf = new NhapMua_TimKiemSPPresentation();

            wpf._TimKiemSP += new EventHandler(TimKiemSP);
            wpf.ShowDialog();
        }
Ejemplo n.º 4
0
        //Timfm kiếm sản phẩm
        private void TimKiemSP(object sender, EventArgs e)
        {
            NhapMua_TimKiemSPPresentation wpf_tim   = (NhapMua_TimKiemSPPresentation)sender;
            List <SanPhamPublic>          _lstSPTim = wpf_tim._ListSPChon;

            if (_lstSPTim.Count > 0)
            {
                foreach (SanPhamPublic _sp in _lstSPTim)
                {
                    //Kiểm tra xem trong hệ thống có sản phẩm này không?
                    DataTable _dtSp = BanHangBusiness.LaySpTheoMa(_sp.MaSP_SP).Tables[0];//Chứa toàn bộ sản phẩm của hệ thống
                    if (_dtSp.Rows.Count == 0)
                    {
                        lbWarning.Visibility = System.Windows.Visibility.Visible;
                        lbWarning.Text       = "Mã sản phẩm không tồn tại. Vui lòng kiểm tra lại!";
                        txtMaHang.Focus();
                        txtMaHang.SelectAll();
                        return;
                    }
                    //Kiểm tra số lượng hàng có đủ ko?
                    int _SoLuongCon = Convert.ToInt32(_dtSp.Rows[0]["SoLuong_SP"].ToString());
                    if (_SoLuongCon < 1)
                    {
                        lbWarning.Visibility = System.Windows.Visibility.Visible;
                        lbWarning.Text       = "Hết sản phẩm.";
                        txtMaHang.Focus();
                        txtMaHang.SelectAll();
                        return;
                    }
                    _dtSp.Dispose();

                    ThemHangVaoDsHangMua(_sp.MaSP_SP);
                }

                //Hiển thị giỏ hàng
                dgDanhSachSanPham.ItemsSource = _dsSPMua;
                dgDanhSachSanPham.Items.Refresh();

                //Tính tổng tiền hóa đơn
                TongTien();

                //Đặt con trỏ vào ô nhập mã hàng khác
                txtMaHang.Focus();
                txtMaHang.Text = "";

                btnThanhToan.IsEnabled = true;
                btnChietKhau.IsEnabled = true;
                btnHuy.IsEnabled       = true;
            }
        }
Ejemplo n.º 5
0
 //Key down
 private void txtMaSP_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (txtMaSP.Text.Trim().EndsWith("?"))
         {
             NhapMua_TimKiemSPPresentation wpf_tim = new NhapMua_TimKiemSPPresentation();
             wpf_tim._strTim     = txtMaSP.Text.Trim().Replace("?", "");
             wpf_tim._TimKiemSP += new EventHandler(TimKiemSP);
             wpf_tim.ShowDialog();
         }
         else
         {
             btnThemSP_Click(sender, e);
         }
     }
 }
Ejemplo n.º 6
0
        private void TimKiemSP(object sender, EventArgs e)
        {
            NhapMua_TimKiemSPPresentation wpf_tim = (NhapMua_TimKiemSPPresentation)sender;
            List <SanPhamPublic>          _lstSP  = wpf_tim._ListSPChon;


            foreach (SanPhamPublic _sp in _lstSP)
            {
                //Kiểm tra nếu trong ds chưa có thì thêm
                SanPhamPublic _result = _dsSanPham.Find(item => item.MaSP_SP == txtMaSP.Text.Trim().ToUpper());

                if (_result == null)
                {
                    _dsSanPham.Add(_sp);
                }
            }
            dgDsSanPham.ItemsSource = _dsSanPham;
            dgDsSanPham.Items.Refresh();
            txtMaSP.Focus();
            txtMaSP.SelectAll();
        }