package com.example.reminder_proj01;

import java.util.List;







import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Alarm 
{
	public static final String TABLE_NAME = "alarm";
	public static final String COL_ID = "_id";
	public static final String COL_CREATEDTIME = "created_time";
	public static final String COL_MODIFIEDTIME = "modified_time";
	public static final String COL_NAME = "name";
	public static final String COL_FROMDATE = "from_date";
	public static final String COL_TODATE = "to_date";
	public static final String COL_RULE = "rule";
	public static final String COL_INTERVAL = "interval";
	public static final String COL_SOUND = "sound";
	
	public static final String HIGH = "H";
	public static final String MED = "M";
	public static final String LOW = "L"; 
	
	private long createdTime;
	private long modifiedTime;
	private String name;
	private String fromDate;
	private String toDate;
	private String rule;
	private String interval;
	private Boolean sound = Boolean.FALSE;
	
	static String Sql_table() 
	{
		return Util.concat("CREATE TABLE ", TABLE_NAME, " (",
				COL_ID, " INTEGER PRIMARY KEY AUTOINCREMENT, ",
				COL_CREATEDTIME, " INTEGER, ",
				COL_MODIFIEDTIME, " INTEGER, ",
				COL_NAME, " TEXT, ",
				COL_FROMDATE, " DATE, ",
				COL_TODATE, " DATE, ",
				COL_RULE, " TEXT, ",				
				COL_INTERVAL, " TEXT, ",
				COL_SOUND, " INTEGER",
				");");
	}
	
	long save(SQLiteDatabase db, String name, String fromDate, String toDate, String rule, String interval, Boolean sound)
	{
		ContentValues cv = new ContentValues();
		long now = System.currentTimeMillis();
		cv.put(COL_CREATEDTIME, now);
		cv.put(COL_MODIFIEDTIME, now);
		cv.put(COL_NAME, name==null ? "" : name);
		cv.put(COL_FROMDATE, fromDate);
		cv.put(COL_TODATE, toDate);
		cv.put(COL_RULE, rule);
		cv.put(COL_INTERVAL, interval);
		cv.put(COL_SOUND, sound ? 1 : 0);
		//return(25);
		return db.insert(TABLE_NAME, null, cv);
	}
	
	
	public Alarm() {}
	/****/
	public long getCreatedTime()
	{
		return createdTime;
	}
	public void setCreatedTime(long createdTime) 
	{
		this.createdTime = createdTime;
	}
	/****/
	public long getModifiedTime() 
	{
		return modifiedTime;
	}
	public void setModifiedTime(long modifiedTime) 
	{
		this.modifiedTime = modifiedTime;
	}
	/****/
	public String getName() 
	{
		return name;
	}
	public void setName(String name) 
	{
		this.name = name;
	}
	/****/
	public String getFromDate() 
	{
		return fromDate;
	}
	public void setFromDate(String fromDate)
	{
		this.fromDate = fromDate;
	}
	/****/
	public String getToDate() 
	{
		return toDate;
	}
	public void setToDate(String toDate) 
	{
		this.toDate = toDate;
	}
	/****/
	public String getRule() 
	{
		return rule;
	}
	public void setRule(String rule) 
	{
		this.rule = rule;
	}
	/****/
	public String getInterval()
	{
		return interval;
	}
	public void setInterval(String interval) 
	{
		this.interval = interval;
	}
	/****/
	public Boolean getSound()
	{
		return sound;
	}
	public void setSound(Boolean sound)
	{
		this.sound = sound;
	}	
	/****/
	
	

}
