public TermControl(Term term)
        {
            InitializeComponent();
            SetupStyle();
            SetImages();

            this.term = term;

            new TermPresenter(this);
        }
        public bool Delete(Term term)
        {
            EXterm.DbConnection.Lock();

            EXterm.DbConnection.ExecuteNonQuery(
                "DELETE FROM Term WHERE " +
                "WHERE 'Id' = " + term.Id
                );

            EXterm.DbConnection.Unlock();

            return true;
        }
        public bool Insert(Term term)
        {
            EXterm.DbConnection.Lock();
            EXterm.DbConnection.ExecuteNonQuery (
                "INSERT INTO Term (" +
                "'Id', 'Date', 'Text'" +
                ") VALUES (" +
                "NULL, '" +
                Utils.DateTimeUtils.GetSeconds(term.Date) + "', '" +
                term.Text + "'" +
                ")"
                );

            term.Id = EXterm.DbConnection.LastInsertId;
            term.Dirty = false;
            EXterm.DbConnection.Unlock();

            return true;
        }
 public ITermView CreateTermView(Term term)
 {
     return new TermControl(term);
 }
 private static void FillTestData()
 {
     //Data.Model.Term term = new Data.Model.Term(Utils.DateTimeUtils.GetBeginningOfWeek(DateTime.Now).AddHours(12), "Term testowy");
     Data.Model.Term term = new Data.Model.Term(new DateTime (2006,6,27).AddHours(12), "Term testowy");
     EXterm.DbConnection.CreateDAOFactory().CreateTermDAO().Insert(term);
 }
        private static Term CreateValidTerm(object id, object date, object text)
        {
            long validId = 0;
            DateTime validDate = DateTime.MinValue;
            string validText = String.Empty;

            if ((id != null) && (id != DBNull.Value))
                validId = long.Parse(id.ToString());
            else
                return null;

            if ((date != null) && (date != DBNull.Value))
                validDate = Utils.DateTimeUtils.GetDate (long.Parse(date.ToString()));
            else
                return null;

            if ((text != null) && (text != DBNull.Value))
                validText = text.ToString();

            Term t = new Term(validDate, validText);
            t.Id = validId;

            return t;
        }
        public bool Update(Term term)
        {
            if (!term.Dirty)
                return true;

            EXterm.DbConnection.Lock();

            EXterm.DbConnection.ExecuteNonQuery(
                "UPDATE Term SET " +
                "'Date' = " + Utils.DateTimeUtils.GetSeconds(term.Date) + ", " +
                "'Text' = '" + term.Text + "' " +
                "WHERE 'Id' = " + term.Id
                );

            EXterm.DbConnection.Unlock();

            term.Dirty = false;
            return true;
        }