validation addmatiere
update annee scolaire
when delete matiere, delete also matiere_mention and matiere_semestre

SELECT *
FROM table_name
WHERE NOW() BETWEEN debut AND fin;

// End date (example)
const endDate = new Date("2025-03-20"); // Replace with your actual end date

// Calculate the date 3 months before the end date
const threeMonthsBefore = new Date(endDate);
threeMonthsBefore.setMonth(threeMonthsBefore.getMonth() - 3);

// Get the current date
const currentDate = new Date();

// Check if the current date is between threeMonthsBefore and endDate
if (currentDate >= threeMonthsBefore && currentDate <= endDate) {
  console.log("The current date is within 3 months before the end date.");
} else {
  console.log("The current date is outside the range.");
}

Since you have an **Ethernet network** (but no Wi-Fi or router), you can share the SQLite database (`data.db`) over the network by sharing a folder. Here's how you can do it:

---

### **Step 1: Share the Database Folder Over the Network**
#### **On PC 1 (Hosting the Database)**
1. **Locate the folder**
   - Your database is at:
     ```
     C:\electron\database\data.db
     ```
   - Open **File Explorer** and go to `C:\electron\database\`.

2. **Right-click on the `database` folder → Click 'Properties'**
   - Go to the **'Sharing'** tab.
   - Click **'Advanced Sharing'**.
   - Check **'Share this folder'**.

3. **Set Permissions**
   - Click **'Permissions'**.
   - Select **'Everyone'** and give **Full Control** (or at least Read/Write if both PCs need to modify the database).
   - Click **OK** and **Apply**.

4. **Note the Network Path**
   - Open **Command Prompt** (`Win + R` → `cmd` → Enter).
   - Type:
     ```sh
     ipconfig
     ```
   - Look for your **Ethernet Adapter IPv4 Address** (e.g., `192.168.1.100`).

   The shared path will be:
   ```
   \\192.168.1.100\database
   ```

---

### **Step 2: Access the Database from PC 2**
#### **On PC 2 (Client PC)**
1. **Map the Network Drive**
   - Open **File Explorer**.
   - Click **'This PC' → 'Map Network Drive'**.
   - Choose a drive letter (e.g., `Z:`).
   - Enter the **Network Path** from Step 1 (e.g., `\\192.168.1.100\database`).
   - Click **Finish**.

2. **Modify SQLite Connection in Electron**
   In your Electron app on PC 2, change:
   ```javascript
   const sqlite = require('better-sqlite3');
   const database = new sqlite('//192.168.1.100/database/data.db');
   ```
   OR, if you mapped it to `Z:\`:
   ```javascript
   const database = new sqlite('Z:/data.db');
   ```

---

### **Step 3: Test the Connection**
1. **Run the Electron app on PC 2** and check if it can read/write to `data.db`.
2. If there's an error, check:
   - **Folder permissions** (PC 1 should allow read/write access).
   - **Windows Firewall** (Allow File Sharing for `Private Networks`).
   - **Network Discovery** (Enable it in **Control Panel → Network & Sharing Center**).

---

### **Important Notes**
- **Concurrency Issues:** SQLite locks the file when writing, so only one PC should write at a time. If you need multiple write operations, consider using a **server-based approach** (like Node.js with Express).
- **Performance:** Network latency may cause slow database operations.
- **Auto-Reconnection:** If PC 1 reboots, PC 2 might lose connection. You can remap the drive automatically on startup.

---

**✅ Done!** Now both PCs can access `data.db` over Ethernet. 🚀
Let me know if you need further help!
