private void dgv_HoaDon_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int r = dgv_HoaDon.CurrentCell.RowIndex;

            BienCucBo.Ma_HDBH = dgv_HoaDon.Rows[r].Cells[0].Value.ToString();
            string Ma_NV = dgv_HoaDon.Rows[r].Cells[1].Value.ToString();
            string Ma_KH = dgv_HoaDon.Rows[r].Cells[2].Value.ToString();

            //clear
            lbl_MaHD.DataBindings.Clear();
            lbl_MaNV.DataBindings.Clear();
            lbl_MaKH.DataBindings.Clear();
            lbl_Ngay.DataBindings.Clear();
            lbl_Tien.DataBindings.Clear();
            //binding
            lbl_MaHD.DataBindings.Add("Text", dt_hoadon, "Ma_HDBH");
            lbl_Ngay.DataBindings.Add("Text", dt_hoadon, "NgayXuatHD");
            lbl_Tien.DataBindings.Add("Text", dt_hoadon, "TongTien");
            //xử lí nhân viên
            ds_nhanvien = dbnhanvien.NhanVientheoMaNV(Ma_NV);
            dt_nhanvien = ds_nhanvien.Tables[0];
            lbl_MaNV.DataBindings.Add("Text", dt_nhanvien, "Ten_NV");
            //xử lí khách hàng
            ds_khachhang = dbkhachhang.KhachHangtheoMaKH(Ma_KH);
            dt_khachhang = ds_khachhang.Tables[0];
            lbl_MaKH.DataBindings.Add("Text", dt_khachhang, "Ten_KH");
            //xử lí dgv chi tiết
            ds_chitiet         = dbchitiet.ChitietTheoMaHD(BienCucBo.Ma_HDBH);
            dt_chitiet         = ds_chitiet.Tables[0];
            btn_Loc.DataSource = dt_chitiet;
        }
        private void LoadData()
        {
            try
            {
                //mở conn
                //if (cnn.State == ConnectionState.Open)
                //    cnn.Close();
                //cnn.Open();
                //adp = new SqlDataAdapter("Select * From MatHang Where Ma_MH =  '" + BienCucBo.Ma_MH + "' ", cnn);
                //adp.Fill(dt_khachhang);
                //datatable
                ds_khachhang = db.KhachHangtheoMaKH(BienCucBo.Ma_KH);
                dt_khachhang = ds_khachhang.Tables[0];
                //clear
                txt_MaKH.Clear();
                txt_TenKH.Clear();
                txtDiaChi.Clear();
                txtDT.Clear();
                txtEmail.Clear();

                //binding
                txt_MaKH.DataBindings.Add("Text", dt_khachhang, "Ma_KH");
                txt_TenKH.DataBindings.Add("Text", dt_khachhang, "Ten_KH");
                txtDiaChi.DataBindings.Add("Text", dt_khachhang, "DiaChi");
                txtDT.DataBindings.Add("Text", dt_khachhang, "DienThoai");
                txtEmail.DataBindings.Add("Text", dt_khachhang, "Email");
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Lỗi: " + ex);
            }
        }