using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Amozeshgah
{
    class Term
    {
        public int ID;
        public string Title;
        public string Start;
        public string End;
        public string Year;
        public string Month;

        DataAccess da = new DataAccess();
        public void Delete()
        {
            da.connect();
            string sql = "delete from Term where Trm_id={0}";
            sql = string.Format(sql, this.ID);
            da.docommand(sql);
            da.Disconnect();

        }

        public void Update()
        {
            da.connect();
            string sql = "update Term set Trm_title=N'{0}', Trm_start=N'{1}', Trm_end=N'{2}' , Trm_year=N'{3}' , Trm_month=N'{4}'  where Trm_id={5}";
            sql = string.Format(sql,
                this.Title ,
                this.Start,
                this.End,
                this.Year,
                this.Month
                , this.ID);
            da.docommand(sql);
            da.Disconnect();
        }

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt = da.select("select * from  Term  where Trm_id=" + this.ID);
            this.Title = dt.Rows[0]["Trm_title"].ToString();
            this.Start = dt.Rows[0]["Trm_start"].ToString();
            this.End = dt.Rows[0]["Trm_end"].ToString();
            this.Year = dt.Rows[0]["Trm_year"].ToString();
            this.Month = dt.Rows[0]["Trm_month"].ToString();
            da.Disconnect();
        }
    }
}
