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 car
    {
        public int id_ran;

        public string n_car;
        public string sh_plak;
        public string model;
        public string clascar;

        public void insert()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "insert into car(n_car,sh_plak,model,clascar) values (@n_car,@sh_plak,@model,@clascar)";
            com.Parameters.AddWithValue("@n_car", n_car);
            com.Parameters.AddWithValue("@sh_plak", sh_plak);
            com.Parameters.AddWithValue("@model", model);
            com.Parameters.AddWithValue("@clascar", clascar);
            database da = new database();
            da.connect();
            da.command(com);
            da.disconnect();
        }
        public void update()
        {
            //OleDbCommand com = new OleDbCommand();
            //com.CommandText = "update car set n_car=@n_car,sh_plak=@sh_plak,model=@model,clascar=@clascar where ranande.coderanande=car.coderanande";
            //com.Parameters.AddWithValue("@n_car", n_car);
            //com.Parameters.AddWithValue("@sh_plak", sh_plak);
            //com.Parameters.AddWithValue("@model", model);
            //com.Parameters.AddWithValue("@clascar", clascar);
            //com.Parameters.AddWithValue("@coderanande", coderanande);
            //database da = new database();
            //da.connect();
            //da.command(com);
            //da.disconnect();
        }
        public void delete()
        {

        }
        public DataTable show()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select coderanande,n_ranande,l_ranande,n_car,sh_plak,model,clascar from car inner join ranande on car.id_ran=ranande.id_ran";

            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();
            return dt;
        }
        public Boolean Exist()
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandText = "select * from car where sh_plak=@sh_plak";
            com.Parameters.AddWithValue("@sh_plak", sh_plak);
            database da = new database();
            da.connect();
            DataTable dt = da.docommand(com);
            da.disconnect();

            if (dt.Rows.Count > 0) return true;
            return false;

        }
    }
}
