using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace Transport.DAL
{
    class dal_company
    {

        public static DataTable selectedCompanyDetails(string sqlQuery)
        {
            try
            {

                SqlConnection con = new SqlConnection(dal_config.connection_string);
                SqlCommand com = new SqlCommand();
                com.CommandType = CommandType.Text;
                com.CommandText = sqlQuery;
                com.Connection = con;

                SqlDataAdapter DA = new SqlDataAdapter(com);
                DataSet dataset = new DataSet();

                DA.Fill(dataset, "CompanyTable");

                return dataset.Tables[0];

            }
            catch (Exception e)
            {
                return null;
            }
        }


        public static DataTable CompanyList()
        {
            
            string SQLQuery = "SELECT company_id,company_name FROM tbl_company ";

            try
            {

                SqlConnection con = new SqlConnection(dal_config.connection_string);
                SqlCommand com = new SqlCommand();
                com.CommandType = CommandType.Text;
                com.CommandText = SQLQuery;
                com.Connection = con;

                SqlDataAdapter DA = new SqlDataAdapter(com);
                DataSet dataset = new DataSet();

                DA.Fill(dataset, "CompanyTable");

                return dataset.Tables[0];

            }
            catch (Exception e)
            {
                return null;
            }
        }
    }
}
