Witam. Pracuje nad projektem szkolnym automatycznej "listy obecnosci" uzywajac skanera RFID i bazy danych zrobionej w accessie. Wyglada to mniej wiecej tak:

15314051951866eb90ad55.png

Moim celem jest cos w stylu takiego zapytania:

Jeśli tag RFID znajduje się w tabeli Student sprawdź na jakim jest kursie, jakie moduły znajdują się w tym kursie, jakie sesje sa przypisane do tych modułów i zarejestruj obecność w tabeli Attendance.

Do tej pory udało mi się zbindować bazę danych z dataGridView, zeskanować tag, i umieścić go jako nowy wiersz w tabeli attendance wraz z datą i godziną zeskanowania, ale mam spore trudności w "wyciąganiu" wartości z określonych pól bazy danych. Oto mój obecny kod.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;

namespace AutoReg
{
    public partial class Form1 : Form
    {
        // Create the serial port with basic settings
        public SerialPort port = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);
        public int tagNo = 0;

        public Form1()
        {
            InitializeComponent();

            //Attach a method to be called when there is data waiting in the port's buffer
            port.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);

            //Begin communications
            port.Open();
        }
      
        public void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            while (port.ReadChar() != 2) ;

            int v = 0;
            port.ReadChar(); // drop 1st 2 bytes - we actually only read the lower 32-bits of the code
            port.ReadChar();

            for (int i = 7; i >= 0; i--)
            {
                int c = port.ReadChar(); // a ascii hex char
                int part = c - '0';

                // test if 'Alpha'

                if (part > 9) part -= 7;     // Quick & dirty !


                v |= part << (i * 4);
            }

            for (int i = 0; i < 5; i++)
            {
                port.ReadChar();
            }

            tagNo = v; ;

            this.Invoke(new MethodInvoker(delegate()
            {
                
                    //TUTAJ  UMIESCIC ZAPYTANIE
                    DataRow row = autoRegDataSet.Attendance.Rows.Add();
                    row[0] = v.ToString();
                    row[2] = DateTime.Now;
               
            }));
                        
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'autoRegDataSet.Attendance' table. You can move, or remove it, as needed.
            this.attendanceTableAdapter.Fill(this.autoRegDataSet.Attendance);
           
        }
     }
}