/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ge.mziuri.dao;

import ge.mziuri.model.Event;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;


 

public class EventDAOImpl implements EventDAO{

    
    private Connection con;
    
    private PreparedStatement pstmt;
    
    public EventDAOImpl() {
       con = DatabaseUtil.getConnection();
    }
    
    @Override
    public void CreateEvent(Event event) {
       try { 
           pstmt = con.prepareStatement("INSERT INTO EVENT (name, desc, date, price, category, type, places)"
                    + " VALUES (?,?,?,?,?,?,?)");
            pstmt.setString(1, event.getName());
            pstmt.setString(2, event.getDesc());
            pstmt.setDate(3, (Date) event.getDate());
            pstmt.setDouble(4, event.getPrice());
            pstmt.setString(5, event.getCategory().toString());
            pstmt.setString(6, event.getType().toString());
            pstmt.setInt(7, event.getPlaces());
            pstmt.executeUpdate();
            
       }catch(SQLException ex){
            System.out.println(ex.getMessage());
       }
    }

    @Override
    public void DeleteEvent(Event event) {
       
    }

    @Override
    public void UpdateEvent(Event event) {
        
    }

   
    
}

@@ -1380,81 +1380,967 @@
     
-%0A    %7D%0A%0A    @Override%0A    public void UpdateEvent(Event event) %7B%0A        
+try %7B%0A           pstmt = con.prepareStatement(%22DELETE FROM EVENT WHERE id = ? %22);%0A           pstmt.setInt(1, event.getId());%0A           pstmt.executeUpdate();%0A       %7D%0A       catch(SQLException ex) %7B%0A           System.out.println(ex.getMessage());%0A       %7D%0A    %7D%0A%0A    @Override%0A    public void UpdateEvent(Event event) %7B%0A        try %7B%0A            pstmt = con.prepareStatement(%22UPDATE EVENT SET name = ?, desc = ?, date = ?,%22%0A                    + %22price = ?, category = ? WHERE id = ? %22);%0A            pstmt.setString(1, event.getName());%0A            pstmt.setString(2, event.getDesc());%0A            pstmt.setDate(3, (Date) event.getDate()); //cast may be incorrect%0A            pstmt.setDouble(4, event.getPrice());%0A            pstmt.setString(5, event.getCategory().toString());%0A            pstmt.setInt(6, event.getId());%0A            pstmt.executeUpdate();%0A        %7D%0A        catch(SQLException ex) %7B%0A            System.out.println(ex.getMessage());%0A        %7D
 %0A   

add delete & update methods in eventDAOImpl