using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using MES_SPC;

/// <summary>
///GetSQL_Output 的摘要说明
/// </summary>
public class GetSQL_Output
{//返回新的SQL语句
	public GetSQL_Output()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    //-----------------------专门由于导出excel数据量过多，而造成下载速度慢和打开excel慢而做的存储过程--------------------------------------------------------------------


    /// <summary>
    /// 质量数据查询
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="OPNameCheck"></param>
    /// <param name="OPName"></param>
    /// <param name="shaftNameCheck"></param>
    /// <param name="shaftName"></param>
    /// <param name="itemNameCheck"></param>
    /// <param name="itemName"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="isOK"></param>
    /// <param name="Isuse"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectGoodDataReport_ADODB_New
        (bool EnginIDCheck, string EnginID,
       bool OPNameCheck, string OPName,
        bool shaftNameCheck, string shaftName,
       bool itemNameCheck, string itemName,
        string startTime, string endTime, int isOK, bool Isuse, out string sql, out int Count,out int ColCount,out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "质量数据查询_综合查询_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号_ischeck", OPNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号", OPName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置_ischeck", shaftNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置", shaftName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量项目_ischeck", itemNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量项目", itemName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@合格标志", isOK.ToString()));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否禁用", Isuse));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar,4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句

            
            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = ColsArrayString[i];
            }
            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }

    /// <summary>
    /// 质量数据查询_数据备份_综合查询_ReturnSql
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="OPNameCheck"></param>
    /// <param name="OPName"></param>
    /// <param name="shaftNameCheck"></param>
    /// <param name="shaftName"></param>
    /// <param name="itemNameCheck"></param>
    /// <param name="itemName"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="isOK"></param>
    /// <param name="Isuse"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectGoodDataReport_ADODB_New_DataBak
            (bool EngineTypeCheck, string EngineType, bool EnginIDCheck, string EnginID,
           bool OPNameCheck, string OPName,
            bool shaftNameCheck, string shaftName,
           bool itemNameCheck, string itemName,
            string startTime, string endTime, int isOK, bool Isuse, out string sql, out int Count, out int ColCount, out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "质量数据查询_数据备份_综合查询_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandTimeout = 120;
            MyCommand.CommandType = CommandType.StoredProcedure;
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号_ischeck", EngineTypeCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号", EngineType));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号_ischeck", OPNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号", OPName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置_ischeck", shaftNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置", shaftName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量项目_ischeck", itemNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量项目", itemName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@合格标志", isOK.ToString()));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否禁用", Isuse));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = ColsArrayString[i];
            }
            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }

    /// <summary>
    /// 工件总成质量数据报表
    /// 引用页QualityData_Query_2.aspx(质量数据导出excel)
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="OPNameCheck"></param>
    /// <param name="OPName"></param>
    /// <param name="engineTypeIDCheck"></param>
    /// <param name="engineTypeID"></param>
    /// <param name="itemNameCheck"></param>
    /// <param name="itemName"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="isOK"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectGoodDataReport_2_ADODB_New
    (bool EnginIDCheck, string EnginID,
           bool OPNameCheck, string OPName,
            bool engineTypeIDCheck, int engineTypeID,
           bool itemNameCheck, string itemName,
            string startTime, string endTime, int isOK, out string sql, out int Count,out int ColCount,out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "测量数据合格_合并_视图_查询_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);


            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;


            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号_ischeck", OPNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号", OPName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号代码_ischeck", engineTypeIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号代码", engineTypeID));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置_ischeck", itemNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置", itemName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@总合格标志", isOK.ToString()));
            

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;
            MyCommand.CommandTimeout = 120;
            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            
            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = GetColumnName_Ver(ColsArrayString[i]);
            }

            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }

    /// <summary>
    /// 不合格质量数据
    /// 引用页QualityData_Query_2.aspx
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="OPNameCheck"></param>
    /// <param name="OPName"></param>
    /// <param name="engineTypeIDCheck"></param>
    /// <param name="engineTypeID"></param>
    /// <param name="itemNameCheck"></param>
    /// <param name="itemName"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectGoodDataReport_2_ADODB_New
    (bool EnginIDCheck, string EnginID,
   bool OPNameCheck, string OPName,
    bool engineTypeIDCheck, int engineTypeID,
   bool itemNameCheck, string itemName,
    string startTime, string endTime, out string sql, out int Count, out int ColCount, out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "测量数据合格_合并_视图_不合格数据_查询_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;


            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号_ischeck", OPNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号", OPName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号代码_ischeck", engineTypeIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机型号代码", engineTypeID));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置_ischeck", itemNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@测量位置", itemName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = GetColumnName_Ver(ColsArrayString[i]);
            }

            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }

    /// <summary>
    /// 测量数据合格_变速器总成称重_报表
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="isOK"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectGoodData_weight_Report_ADODB_New
(bool EnginIDCheck, string EnginID,
            string startTime, string endTime, int isOK, out string sql, out int Count, out int ColCount, out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "测量数据合格_变速器总成称重_报表_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@合格标志", isOK.ToString()));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = ColsArrayString[i];
            }

            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }
/// <summary>
/// 
/// </summary>
/// <param name="EnginIDCheck"></param>
/// <param name="EnginID"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="sql"></param>
/// <param name="Count"></param>
/// <param name="ColCount"></param>
/// <param name="ColsArray"></param>
    public static void SelectGoodData_OKGO_Report_ADODB
(bool EnginIDCheck, string EnginID,
            string startTime, string endTime, out string sql, out int Count, out int ColCount, out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "电子看板_发动机号_人工合格放行记录_查询_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@领班工号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@领班工号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = ColsArrayString[i];
            }

            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }
    /// <summary>
    /// 物料数据报表
    /// </summary>
    /// <param name="EnginIDCheck"></param>
    /// <param name="EnginID"></param>
    /// <param name="OPNameCheck"></param>
    /// <param name="OPName"></param>
    /// <param name="startTime"></param>
    /// <param name="endTime"></param>
    /// <param name="sql"></param>
    /// <param name="Count"></param>
    public static void SelectMaterialReport_ADODB_New
 (bool EnginIDCheck, string EnginID,
           bool OPNameCheck, string OPName,
            string startTime, string endTime, out string sql, out int Count, out int ColCount, out object[,] ColsArray)
    {
        try
        {
            string procedureName;
            procedureName = "物料数据查询_报表_ReturnSql";
            DateTime dt_startTime;
            DateTime dt_endTime;
            dt_startTime = DateTime.Parse(startTime);
            dt_endTime = DateTime.Parse(endTime);

            string constr = ApplicationConfiguration.ERP_ConnectionString;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand MyCommand = new SqlCommand(procedureName, conn);
            MyCommand.CommandType = CommandType.StoredProcedure;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号_ischeck", EnginIDCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发动机号", EnginID));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号_ischeck", OPNameCheck));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工位号", OPName));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始时间", dt_startTime));
            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束时间", dt_endTime));

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@selectStr_OutPut", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@selectStr_OutPut"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Count", SqlDbType.Int));
            MyCommand.Parameters["@Count"].Direction = ParameterDirection.Output;

            MyCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ColsArray", SqlDbType.NVarChar, 4000));
            MyCommand.Parameters["@ColsArray"].Direction = ParameterDirection.Output;

            MyCommand.ExecuteNonQuery();

            sql = Convert.ToString(MyCommand.Parameters["@selectStr_OutPut"].Value);
            Count = Convert.ToInt32(MyCommand.Parameters["@Count"].Value);//返回SQL语句


            string[] ColsArrayString = Convert.ToString(MyCommand.Parameters["@ColsArray"].Value).Split('|'); ;//所有列名的集合
            ColsArray = new object[1, ColsArrayString.Length];
            for (int i = 0; i < ColsArrayString.Length; i++)
            {
                ColsArray[0, i] = ColsArrayString[i];
            }

            ColCount = ColsArrayString.Length;
        }
        catch
        {
            sql = "";
            Count = 0;
            ColsArray = null;
            ColCount = 0;
        }
    }


    /// <summary>
    /// 字段名称各个字符中间增加回车，以保证文本竖着书写。
    /// </summary>
    /// <param name="columnName"></param>
    /// <returns></returns>
    private static string GetColumnName_Ver(string columnName)
    {
        string columnName_tr;
        columnName_tr = "";
        for (int i = 0; i < columnName.Length; i++)
        {
            columnName_tr = columnName_tr + columnName[i] + Environment.NewLine;
        }
        return columnName_tr;
    }
}