using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SystemX.Net.DB.DBType
{
    public interface IDBControl
    {
        string ConnectionText { get; set; }
        bool IsConnected { get; set; }
        
        bool InitConnection();
        bool OpenConnection();
        bool OpenConnection(bool bUseHostInfo, string strHostTableName, string strUserTableName);

        bool CloseConnection();

        SqlConnection getConnection();

        string MakeTableInfoQuery(string strTableName);
        bool CollectSchemaInfomation();

        byte[] GetCollectSerializationSchemaInfo();

        XTableInfo GetCollectSchemaInfo();
        DataTable GetHostList(bool bDBQueryCheck = false);
        DataTable GetUserList(bool bDBQueryCheck = false);

        bool ExecuteNonQuery(SqlCommand cmd);
        bool ExecuteNonCommandQuery(SqlCommand cmd);
        bool ExecuteNonStreamQuery(SqlCommand cmd);

        SqlDataReader QueryDatabase(string strSQL);
        SqlDataReader QueryDatabaseSub(string strSQL);
        SqlDataReader QueryCommandDatabase(string strSQL, bool bUseTransaction = false);
        SqlDataReader QueryStreamDatabase(string strSQL);

        DataTable QueryDataTable(string strSQL);
        DataTable QueryDataTable(string strSQL, out bool bHasRows);
        DataTable QueryDataTable(string strSQL, out int iRecordsAffected);
        DataTable QueryDataTable(string strSQL, out bool bHasRows, out int iRecordsAffected);
        DataSet QueryDataSet(string strSQL);
        DataSet QueryDataSet(string strSQL, out bool bHasRows);
        DataSet QueryDataSet(string strSQL, out int iRecordsAffected);
        DataSet QueryDataSet(string strSQL, out bool bHasRows, out int iRecordsAffected);
    }
}
