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

namespace Amozeshgah
{
    class C_User
    {
        public int ID;
        public string name;
        public string family;
        public string User_name;
        public string pass;

        public DataAccess da = new DataAccess();

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

        }

        public void Update()
        {
            da.connect();
            string sql = "update Users set name=N'{0}', family=N'{1}', UserName=N'{2}' , pass=N'{3}'  where ID={4}";
            sql = string.Format(sql,
                this.name ,
                this.family ,
                this.User_name,
                this.pass,
                this.ID);
            da.docommand(sql);
            da.Disconnect();
        }

        public void GetOne()
        {
            DataTable dt = new DataTable();
            da.connect();
            dt = da.select("select * from  Users  where ID=" + this.ID);
            this.name = dt.Rows[0]["name"].ToString();
            this.family = dt.Rows[0]["family"].ToString();
            this.User_name = dt.Rows[0]["UserName"].ToString();
            this.pass = dt.Rows[0]["pass"].ToString();
            da.Disconnect();
        }
    }
}
