package controller.definition;

import org.sig.fw.database.model.DBModel;
import org.sig.fw.db.corrida.dao.Commande_Reference_DBAO;
import org.sig.fw.db.corrida.model.Commande_Reference;

import controller.history.Application_Controller;
import view.definition.Commande_Reference_View;

public class Commande_Reference_Controller extends Definition_Frame_Controller 
{
	public Commande_Reference_Controller(Application_Controller ctrl_application) 
	{
		super(ctrl_application);
		
		this.vw_definition = new Commande_Reference_View(this);
		this.vw_definition.setVisible(true);
	}

	@Override
	public void save(DBModel model)
	{
		Commande_Reference reference = (Commande_Reference) model;
		
		if(reference.getDbId() == -1)
		{
			new Commande_Reference_DBAO("cr").insert(reference);
		}
		else
		{
			new Commande_Reference_DBAO("cr").update(reference);
		}
		
		ctrl_application.activeUpdate("COMMANDE_REFERENCE", -1, -1);
	}
}
