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

namespace ajans.class_ajans
{
   public class eshterak
    {
        public int id_esh;
        public string code_eshterak;
        public string n_eshterak;
        public string l_eshterak;
        public string codem_eshterak;
        public string ts_eshterak;
        public string mob_eshterak;
        public string tel_eshterak;
        public string shp_eshterak;
        public string posti_eshterak;
        public string address_eshterak;

        public DataTable show()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak";
            //"select code_eshterak,n_eshterak,l_eshterak,codem_eshterak,ts_eshterak,mob_eshterak,tel_eshterak,shp_eshterak,posti_eshterak,address_eshterak from eshterak";
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;

        }
        public void insert()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "insert into eshterak (code_eshterak,n_eshterak,l_eshterak,codem_eshterak,ts_eshterak,mob_eshterak,tel_eshterak,shp_eshterak,posti_eshterak,address_eshterak) values (@code_eshterak,@n_eshterak,@l_eshterak,@codem_eshterak,@ts_eshterak,@mob_eshterak,@tel_eshterak,@shp_eshterak,@posti_eshterak,@address_eshterak) ";
            com.Parameters.AddWithValue("@code_eshterak", code_eshterak);
            com.Parameters.AddWithValue("@n_eshterak", n_eshterak);
            com.Parameters.AddWithValue("@l_eshterak", l_eshterak);
            com.Parameters.AddWithValue("@codem_eshterak", codem_eshterak);
            com.Parameters.AddWithValue("@ts_eshterak", ts_eshterak);
            com.Parameters.AddWithValue("@mob_eshterak", mob_eshterak);
            com.Parameters.AddWithValue("@tel_eshterak", tel_eshterak);
            com.Parameters.AddWithValue("@shp_eshterak", shp_eshterak);
            com.Parameters.AddWithValue("@posti_eshterak", posti_eshterak);
            com.Parameters.AddWithValue("@address_eshterak", address_eshterak);
            database da = new database();
            da.connect();
            da.command(com);
            da.disconnect();
        }
        public void update()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "update eshterak set n_eshterak=@n_eshterak,l_eshterak=@l_eshterak,codem_eshterak=@codem_eshterak,ts_eshterak=@ts_eshterak,mob_eshterak=@mob_eshterak,tel_eshterak=@tel_eshterak,shp_eshterak=@shp_eshterak,posti_eshterak=@posti_eshterak,address_eshterak=@address_eshterak,code_eshterak=@code_eshterak where id_esh=@id_esh";
            com.Parameters.AddWithValue("@n_eshterak", n_eshterak);
            com.Parameters.AddWithValue("@l_eshterak", l_eshterak);
            com.Parameters.AddWithValue("@codem_eshterak", codem_eshterak);
            com.Parameters.AddWithValue("@ts_eshterak", ts_eshterak);
            com.Parameters.AddWithValue("@mob_eshterak", mob_eshterak);
            com.Parameters.AddWithValue("@tel_eshterak", tel_eshterak);
            com.Parameters.AddWithValue("@shp_eshterak", shp_eshterak);
            com.Parameters.AddWithValue("@posti_eshterak", posti_eshterak);
            com.Parameters.AddWithValue("@address_eshterak", address_eshterak);
            com.Parameters.AddWithValue("@code_eshterak", code_eshterak);
            com.Parameters.AddWithValue("@id_esh", id_esh);
            database da = new database();
            da.connect();
            da.command(com);
            da.disconnect();
        }
        public void delete()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "delete from eshterak where (code_eshterak=@code_eshterak) ";
            com.Parameters.AddWithValue("@code_eshterak", code_eshterak);
            //com.Parameters.AddWithValue("@l_eshterak", l_eshterak);
            //com.Parameters.AddWithValue("@codem_eshterak", codem_eshterak);
            //com.Parameters.AddWithValue("@ts_eshterak", ts_eshterak);
            //com.Parameters.AddWithValue("@mob_eshterak", mob_eshterak);
            //com.Parameters.AddWithValue("@tel_eshterak", tel_eshterak);
            //com.Parameters.AddWithValue("@shp_eshterak", shp_eshterak);
            //com.Parameters.AddWithValue("@posti_eshterak", posti_eshterak);
            //com.Parameters.AddWithValue("@address_eshterak", address_eshterak);
            database da = new database();
            da.connect();
            da.command(com);
            da.disconnect();
        }
        public DataTable searchbynamevafamili()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak where n_eshterak like @n_eshterak and l_eshterak like @l_eshterak ";
            com.Parameters.AddWithValue("@n_eshterak", "%" + n_eshterak + "%");
            com.Parameters.AddWithValue("@l_eshterak", "%" + l_eshterak + "%");
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;


        }

        public DataTable searchbycode_esh()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak where code_eshterak like @code_eshterak";
            com.Parameters.AddWithValue("@code_eshterak", "%" + code_eshterak + "%");
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;


        }

        public DataTable searchbymob()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak where mob_eshterak like @mob_eshterak";
            com.Parameters.AddWithValue("@mob_eshterak", "%" + mob_eshterak + "%");
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;
        }
        public DataTable searchby_shomarepelak()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak where shp_eshterak like @shp_eshterak";
            com.Parameters.AddWithValue("@shp_eshterak", "%" + shp_eshterak + "%");
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;
        }
        public DataTable searchby_codeposti()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from eshterak where posti_eshterak like @posti_eshterak";
            com.Parameters.AddWithValue("@posti_eshterak", "%" + posti_eshterak + "%");
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;
        }
    }
}
