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

namespace Amozeshgah
{
    class Teacher
    {
        public int ID;
        public string name;
        public string family;
        public string father;
        public string code;
        public string shomareh;
        public string birth;
        public string genus;
        public string email;
        public string tel;
        public string mobile;
        public string address;
        public string date;
        public string madrak;

        public DataAccess da = new DataAccess();

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt=da.select("select * from  Teacher  where T_id=" + this.ID);
            this.name=dt.Rows[0]["T_name"].ToString();
            this.family = dt.Rows[0]["T_family"].ToString();
            this.father = dt.Rows[0]["T_father"].ToString();
            this.genus  = dt.Rows[0]["T_genus"].ToString();
            this.email  = dt.Rows[0]["T_email"].ToString();
            this.date   = dt.Rows[0]["T_date"].ToString();
            this.birth  = dt.Rows[0]["T_birth"].ToString();
            this.tel    = dt.Rows[0]["T_tel"].ToString();
            this.address = dt.Rows[0]["T_address"].ToString();
            this.shomareh = dt.Rows[0]["T_shomare_sh"].ToString();
            this.mobile  = dt.Rows[0]["T_mobile"].ToString();
            this.code    = dt.Rows[0]["T_code"].ToString();
            this.madrak = dt.Rows[0]["T_madrk"].ToString();
            da.Disconnect();
        }
        

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

        }
        public void Update()
        {
            da.connect();
            string sql = "update Teacher set T_name=N'{0}', T_family=N'{1}', T_father=N'{2}' , T_birth=N'{3}', T_code=N'{4}' , T_email= N'{5}' , T_mobile= N'{6}' , T_address= N'{7}', T_genus= N'{8}' , T_shomare_sh= N'{9}' , T_tel=N'{10}' , T_date=N'{11}',T_madrk=N'{12}' where T_id={13} ";
            sql = string.Format(sql,
                this.name,
                this.family,
                this.father,
                this.birth,
                this.code,
                this.email,
                this.mobile,
                this.address,
                this.genus,
                this.shomareh,
                this.tel,
                this.date,
                this.madrak,
                this.ID);
            da.docommand(sql);
            da.Disconnect();
        }
    }
}
