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

namespace Amozeshgah
{
    class Lesson
    {
        public int ID;
        public string Title;
        public string Vahed;
        public string Sharyeh;
        public string kind;
        public string Duration;
        DataAccess da = new DataAccess();
        public void Delete()
        {
            da.connect();
            string sql = "delete from Lessson where L_id={0}";
            sql = string.Format(sql, this.ID);
            da.docommand(sql);
            da.Disconnect();

        }

        public void Update()
        {
            da.connect();
            string sql = "update Lesson set L_ttile=N'{0}', L_vahed=N'{1}', L_sharyeh=N'{2}' , L_kind=N'{3}' , L_duration=N'{4}'  where L_id={5}";
            sql = string.Format(sql,
                this.Title,
                this.Vahed,
                this.Sharyeh,
                this.kind,
                this.Duration
                , this.ID);
            da.docommand(sql);
            da.Disconnect();
        }

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt = da.select("select * from  Lesson  where L_id=" + this.ID);
            this.Title = dt.Rows[0]["L_ttile"].ToString();
            this.Vahed = dt.Rows[0]["L_vahed"].ToString();
            this.Sharyeh = dt.Rows[0]["L_sharyeh"].ToString();
            this.kind = dt.Rows[0]["L_kind"].ToString();
            this.Duration = dt.Rows[0]["L_duration"].ToString();
            da.Disconnect();
        }
    }
}
