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

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

        public DataAccess da = new DataAccess();


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

        }
        public void SelectAll()
        {
            AmozeshgahDataSet1TableAdapters.StudentTableAdapter tb = new AmozeshgahDataSet1TableAdapters.StudentTableAdapter();

            da.connect();
           // string sql = "Select *  from Student";
           
            da.Disconnect();
           

        }
        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt=da.select("select * from  Student  where S_id=" + this.ID);
            this.name=dt.Rows[0]["S_name"].ToString();
            this.family = dt.Rows[0]["S_family"].ToString();
            this.father = dt.Rows[0]["S_father"].ToString();
            this.genus  = dt.Rows[0]["S_genus"].ToString();
            this.email  = dt.Rows[0]["S_email"].ToString();
            this.date   = dt.Rows[0]["s_date"].ToString();
            this.birth  = dt.Rows[0]["S_birth"].ToString();
            this.tel    = dt.Rows[0]["S_tel"].ToString();
            this.address = dt.Rows[0]["S_address"].ToString();
            this.shomareh = dt.Rows[0]["S_shomare_sh"].ToString();
            this.mobile  = dt.Rows[0]["S_mobile"].ToString();
            this.code    = dt.Rows[0]["S_code"].ToString();
            da.Disconnect();
        }
        public void Update()
    {
        da.connect();
        string sql = "update Student set S_name=N'{0}', S_family=N'{1}', S_father=N'{2}' , S_birth=N'{3}', S_code=N'{4}' , S_email= N'{5}' , S_mobile= N'{6}' , S_address= N'{7}', S_genus= N'{8}' , S_shomare_sh= N'{9}' , S_tel=N'{10}' , S_date=N'{11}' where S_id={12} ";
        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.ID);
        da.docommand(sql);
        da.Disconnect();
    }




    }
}
