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

namespace Amozeshgah
{
    class Class1
    {
         public int ID;
        public string title;
        public string capacity;
        public string genus;
        public string des;

        public DataAccess da = new DataAccess();

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

        }

        public void Update()
        {
            da.connect();
            string sql = "update Class set C_title=N'{0}', C_Capacity=N'{1}', C_genus=N'{2}' , C_des=N'{3}'  where C_id={4}";
            sql = string.Format(sql,
                this.title,
                this.capacity,
                this.genus,
                this.des,
                this.ID);
            da.docommand(sql);
            da.Disconnect();
        }

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt = da.select("select * from  Class  where C_id=" + this.ID);
            this.title = dt.Rows[0]["C_title"].ToString();
            this.capacity = dt.Rows[0]["C_capacity"].ToString();
            this.genus = dt.Rows[0]["C_genus"].ToString();
            this.des = dt.Rows[0]["C_des"].ToString();
            da.Disconnect();
        }
    
    }
}
