using Microsoft.Data.SqlClient;
using System.Data;

namespace RB_MES_API.Controllers
{
    /// <summary>
    /// 直接SQL帮助类
    /// </summary>
    public interface IKDSqlHelper
    {
        /// <summary>
        /// 获取多个结果集
        /// </summary>
        /// <param name="cmdType"></param>
        /// <param name="cmdText"></param>
        /// <param name="sqlParams"></param>
        /// <returns></returns>
        public DataSet? GetDataSet(CommandType cmdType, string cmdText, SqlParameter[]? sqlParams, ref string? mess, bool KD = false);
        
        /// <summary>
        /// 并返回由查询返回的结果集中第一行的第一列
        /// </summary>
        /// <param name="cmdType"></param>
        /// <param name="cmdText"></param>
        /// <param name="sqlParams"></param>
        /// <returns></returns>
        public object? ExecuteScalar(CommandType cmdType, string cmdText, SqlParameter[] sqlParams, ref string? mess, bool KD = false);
        /// <summary>
        /// 执行存储过程，并获得返回值
        /// </summary>
        /// <param name="cmdText"></param>
        /// <param name="sqlParams"></param>
        /// <returns></returns>
        public Dictionary<object, object> GetProcedurePairs(string cmdText, SqlParameter[] sqlParams, ref string? mess, bool KD = false);

        /// <summary>
        /// 直接执行编译好的SQL语句
        /// </summary>
        /// <param name="cmdText">如果执行不带返回参数的存储过程，填写存储过程名</param>
        /// <param name="cmdType">必填</param>
        /// <param name="sqlParams">可以传空值</param>
        /// <returns></returns>
        public Task<string> ExecuteNonQueryAsync(string cmdText, CommandType cmdType, SqlParameter[]? sqlParams,  bool KD = false);
        /// <summary>
        /// 将整理好的表单批量导入数据库
        /// </summary>
        /// <param name="idata">整理好的数据集</param>
        /// <param name="TableName">数据库表名</param>
        /// <param name="reason">返回错误消息</param>
        /// <param name="KD">是否金蝶数据库</param>
        /// <returns></returns>
        public bool InsertBill(DataTable idata, string TableName, ref string? reason, bool KD = false);
       
    }
}
