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

namespace Amozeshgah
{
    class Time
    {
        public int ID;
        public string Start;
        public string End;
        public string Day;
        public string des;
        DataAccess da = new DataAccess();
        public void Delete()
        {
            da.connect();
            string sql = "delete from Time where ID={0}";
            sql = string.Format(sql, this.ID);
            da.docommand(sql);
            da.Disconnect();

        }

        public void Update()
        {
            da.connect();
            string sql = "update Time set Time_start=N'{0}', Time_end=N'{1}', Time_week_day=N'{2}' , Time_des=N'{3}'  where ID={4}";
            sql = string.Format(sql,
                this.Start,
                this.End,
                this.Day,
                this.des,
               this.ID);
            da.docommand(sql);
            da.Disconnect();
        }

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt = da.select("select * from  Time  where ID=" + this.ID);
            this.des = dt.Rows[0]["Time_des"].ToString();
            this.Start = dt.Rows[0]["Time_start"].ToString();
            this.End = dt.Rows[0]["Time_end"].ToString();
            this.Day = dt.Rows[0]["Time_week_day"].ToString();
            da.Disconnect();
        }
    }
}
