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

namespace ryCommonDb
{
    /// <summary>
    /// 数据库操作接口
    /// </summary>
    public interface IDbInterface
    {
        /// <summary>
        /// 连接数据库
        /// </summary>
        /// <param name="sql"></param>
        int ConnDb(string sql);
        /// <summary>
        /// 断开数据库
        /// </summary>
        /// <returns></returns>
        int CloseDb();
        /// <summary>
        /// 获取数量
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="wheresql"></param>
        /// <returns></returns>
        int GetCount(string tableName, string wheresql);
        /// <summary>
        /// 获取分页语句
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="wheresql"></param>
        /// <param name="orderSQL"></param>
        /// <returns></returns>
        string GetPageSQL(string tableName, string wheresql, string orderSQL);
        /// <summary>
        /// 获取分页语句
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="wheresql"></param>
        /// <param name="orderSQL"></param>
        /// <returns></returns>
        string GetPageSQL2(string tableName, string wheresql, string orderSQL);
        /// <summary>
        /// 获取分页语句
        /// </summary>
        /// <param name="field"></param>
        /// <param name="tableName"></param>
        /// <param name="wheresql"></param>
        /// <param name="orderSQL"></param>
        /// <returns></returns>
        string GetPageSQL(string field, string tableName, string wheresql, string orderSQL);
        /// <summary>
        /// 获取分页语句
        /// </summary>
        /// <param name="field"></param>
        /// <param name="tableName"></param>
        /// <param name="wheresql"></param>
        /// <param name="orderSQL"></param>
        /// <returns></returns>
        string GetPageSQL2(string field, string tableName, string wheresql, string orderSQL);
        /// <summary>
        /// 添加Parameter参数
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        void AddParameter(string name, object value);
        /// <summary>
        /// 清空Parameter参数
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        void ClearParameter(object name, object value);
        /// <summary>
        /// 获取Parameter值
        /// </summary>
        /// <returns></returns>
        object[] GetParameter();
        /// <summary>
        /// 根据RyQuickSQL类来获取Parameter值
        /// </summary>
        /// <param name="mySQL"></param>
        /// <returns></returns>
        object[] GetParameter(RyQuickSQL mySQL);
        /// <summary>
        /// 开始执行事务
        /// </summary>
        void BeginTransaction();
        /// <summary>
        /// 提交事务
        /// </summary>
        void Commit();
        /// <summary>
        /// 判断是否包含数据
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="Parameter"></param>
        /// <returns></returns>
        bool ContainsData(string sql, object[] Parameter);
        /// <summary>
        /// 返回-1000表示该数据库不支持本接口
        /// </summary>
        /// <param name="newPwd"></param>
        /// <returns></returns>
        int ChangePwd(string newPwd);
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        System.Data.DataSet ReadData(string sql);
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="Parameter"></param>
        /// <returns></returns>
        System.Data.DataSet ReadData(string sql, object[] Parameter);
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="mySQL"></param>
        /// <returns></returns>
        System.Data.DataSet ReadData(string sql, RyQuickSQL mySQL);
        /// <summary>
        /// 根据id号获取数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        System.Data.DataSet ReadData(string tableName, string id);
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="Parameter"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string sql, object[] Parameter);
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="mySQL"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string sql, RyQuickSQL mySQL);
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string sql);
        /// <summary>
        /// 根据id号删除数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        int DelById(string tableName, string id);
        /// <summary>
        /// 创建数据库
        /// </summary>
        /// <param name="mySQL"></param>
        /// <returns></returns>
        int CreateDb(RyQuickSQL mySQL);
        /// <summary>
        /// 释放资源
        /// </summary>
        void Free();
    }
}
