using System;
using System.Data;
using System.Data.SqlClient;
using DataLinkMesWork;
using System.Collections;
using System.Collections.Specialized;
//using SystemFramework;

namespace bizFacade
{
    /// <summary>
    /// 电子看板信息系统
    /// </summary>
    public partial class BaseDataSystemMES
    {
        /// <summary>
        /// 拧紧结束后，查询拧紧不合格轴的数量，[测量数据合格_合格标志_查询]
        /// </summary>
        /// <param name="EngineID">发动机号</param>
        /// <param name="OPName">工位号</param>
        /// <param name="Count_NG">不合格数量</param>
        /// <returns></returns>
        public static bool BaseData_QualityData_B5A_IsGoodBad_select(string EngineID,string OPName,out int Count_NG)
        {
            Count_NG = 0;
            string procedureName;
            procedureName = "测量数据合格_合格标志_查询";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", OPName);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@不合格数", Count_NG);
            thisParms[2].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                Count_NG = Convert.ToInt32(thisParms[2].Value.ToString());
                return true;
            }
            return false;
 
        }

        /// <summary>
        /// 测量数据合格索引_禁用
        /// </summary>
        /// <param name="engineID"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_UnUsing
                                                    (string engineID, string opName)
        {
            string procedureName;
            procedureName = "测量数据合格索引_禁用";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }

        /// <summary>
        /// 测量数据合格索引_分线数据_删除
        /// </summary>
        /// <param name="engineID"></param>
        /// <param name="opName"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_SubTable_Delete
                                                    (string engineID,string opName)
        {
            string procedureName;
            procedureName = "测量数据合格索引_分线数据_删除";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }

        /// <summary>
        /// alter     PROCEDURE [dbo].[测量数据合格_手动拧紧_列位置_增加]
        ///@EngineTypeID int =null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineID nvarchar(100)=null,
        ///@TagValue nvarchar(100)=null,
        ///@合格标志 int=null,
        ///@工位号 nvarchar(50)=null,
        ///@托盘编号 nvarchar(50)=null,
        ///@列位置 int=null,
        ///@变量排序 int=null,
        ///@TagID_CF int=null
        /// </summary>
        /// <param name="engineTypeID"></param>
        /// <param name="engineType"></param>
        /// <param name="engineID"></param>
        /// <param name="tagValue"></param>
        /// <param name="isGoodBad"></param>
        /// <param name="opName"></param>
        /// <param name="partPallet"></param>
        /// <param name="shiftID"></param>
        /// <param name="orderBy"></param>
        /// <param name="tagID_CF"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_Insert
(int engineTypeID,string engineType,string engineID, 
            string tagValue, int isGoodBad,
            string opName,string partPallet, 
            int shiftID,int orderBy,int tagID_CF
            )
        {
            string procedureName;
            procedureName = "测量数据合格_手动拧紧_列位置_增加";
            SqlParameter[] thisParms = new SqlParameter[10];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineType", engineType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@托盘编号", partPallet);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@列位置", shiftID);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@变量排序", orderBy);
            thisParms[9] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID_CF);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }
        /// <summary>
        /// alter     PROCEDURE [dbo].[测量数据合格_手动拧紧_增加]
        ///@EngineTypeID int =null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineID nvarchar(100)=null,
        ///@TagValue nvarchar(100)=null,
        ///@合格标志 int=null,
        ///@工位号 nvarchar(50)=null,
        ///@托盘编号 nvarchar(50)=null,
        ///@TagID int=null,
        ///@TagID_CF int=null
        /// </summary>
        /// <param name="engineTypeID"></param>
        /// <param name="engineType"></param>
        /// <param name="engineID"></param>
        /// <param name="tagValue"></param>
        /// <param name="isGoodBad"></param>
        /// <param name="opName"></param>
        /// <param name="partPallet"></param>
        /// <param name="tagID"></param>
        /// <param name="tagID_CF"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_Insert
(int engineTypeID, string engineType, string engineID,
            string tagValue, int isGoodBad,
            string opName, string partPallet, int tagID, int tagID_CF)
        {
            string procedureName;
            procedureName = "测量数据合格_手动拧紧_增加";
            SqlParameter[] thisParms = new SqlParameter[9];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineType", engineType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@托盘编号", partPallet);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@TagID", tagID);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID_CF);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }
        /// <summary>
        /// alter     PROCEDURE [dbo].[测量数据合格_增加_物料检测]
        ///@EngineTypeID int =null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineID nvarchar(100)=null,
        ///@TagValue nvarchar(100)=null,
        ///@合格标志 int=null,
        ///@工位号 nvarchar(50)=null,
        ///@托盘编号 nvarchar(50)=null,
        ///@TagID int=null,
        ///@TagID_CF int=null
        /// </summary>
        /// <param name="engineTypeID"></param>
        /// <param name="engineType"></param>
        /// <param name="engineID"></param>
        /// <param name="tagValue"></param>
        /// <param name="isGoodBad"></param>
        /// <param name="opName"></param>
        /// <param name="partPallet"></param>
        /// <param name="tagID"></param>
        /// <param name="tagID_CF"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_Insert_MaterialTest
(int engineTypeID, string engineType, string engineID,
            string tagValue, int isGoodBad,
            string opName, string partPallet, int tagID, int tagID_CF)
        {
            string procedureName;
            procedureName = "测量数据合格_增加_物料检测";
            SqlParameter[] thisParms = new SqlParameter[9];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineType", engineType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@托盘编号", partPallet);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@TagID", tagID);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID_CF);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }
//        /// <summary>
//        /// 测量数据合格_增加_物料检测
//        /// </summary>
//        /// <param name="Id_tagCF"></param>
//        /// <param name="engineTypeID"></param>
//        /// <param name="engineID"></param>
//        /// <param name="tagID"></param>
//        /// <param name="tagValue"></param>
//        /// <param name="isGoodBad"></param>
//        /// <returns></returns>
//        public static bool BaseData_tagTable_QualityData_B5A_Insert_MaterialTest
//(int Id_tagCF, int engineTypeID, string engineID, int tagID, string tagValue, int isGoodBad)
//        {
//            string procedureName;
//            procedureName = "测量数据合格_增加_物料检测";
//            SqlParameter[] thisParms = new SqlParameter[6];
//            thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
//            thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID);
//            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
//            thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", tagID);
//            thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue);
//            thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", isGoodBad);
//            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
//        }
        /// <summary>
        /// ALTER           PROCEDURE [dbo].[电子看板_发动机号_总合格标志_增加] 
        ///@工位号 nvarchar(50) = null,
        ///@发动机号 nvarchar(50) = null,
        ///@合格标志 int = 0测量数据合格索引_增加
        ///0合格；1不合格
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="isOK"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsOK_Insert
            (string opName, string EngineID, int isOK)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_总合格标志_增加";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 测量数据合格索引 合格标志修改-2012-08-23 chenghai
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="isOK">0合格；1不合格</param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_IsOK_update
            (string opName, string EngineID, int isOK)
        {
            string procedureName;
            procedureName = "电子看板_测量数据合格索引_合格标志_修改";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                return true;
            }
            return false;
        }


        /// <summary>
        /// ALTER           PROCEDURE [dbo].[电子看板_发动机号_总合格标志_查询] 
        ///@工位号 nvarchar(50) = null,
        ///@发动机号 nvarchar(50) = null,
        ///@合格标志 int = 0 output
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="isOK">0合格；1不合格</param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsOK_Select
            (string opName, string EngineID, out int isOK)
        {
            isOK = 1;
            string procedureName;
            procedureName = "电子看板_发动机号_总合格标志_查询";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK);
            thisParms[2].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                isOK = Convert.ToInt32(thisParms[2].Value.ToString());
                return true;
            }
            return false;
        }
        /// <summary>
        /// 测量数据合格_发动机返修前数据_合格标志_查询,用于3010工位
        /// </summary>
        /// <param name="EngineID">工件号</param>
        /// <param name="isOK"></param>
        /// <returns></returns>
        public static bool TestData_EngineRework_IsOK_Select
    (string EngineID, out int isOK_M, out int isOK_S)
        {
            isOK_M = 1;
            isOK_S = 1;
            string procedureName;
            procedureName = "测量数据合格_发动机返修前数据_合格标志_查询";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@合格标志_M", isOK_M);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志_S", isOK_S);
            thisParms[1].Direction = ParameterDirection.Output;
            thisParms[2].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                isOK_M = Convert.ToInt32(thisParms[1].Value.ToString());
                isOK_S = Convert.ToInt32(thisParms[2].Value.ToString());
                return true;
            }
            return false;
        }

        /// <summary>
        /// 电子看板_发动机号_不合格放行_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsNG_Select
    (string opName, string EngineID, out DataTable  dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_不合格放行_查询";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms,out dt))
            {
                if (dt != null)
                {
                    if(dt.Rows.Count==1)
                        return true;
                }
                return false;
            }
            return false;
        }
        /// <summary>
        /// 电子看板_发动机号_不合格放行_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="worker"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsNG_Insert
    (string opName, string EngineID, string worker,string text)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_不合格放行_增加";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@操作者编号", worker);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@不合格原因", text);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 电子看板_发动机号_不合格放行_删除
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsNG_Delete
(string opName, string EngineID)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_不合格放行_删除";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }


        /// <summary>
        /// 电子看板_发动机号_不合格放行_删除_分线线首
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsNG_Delete_fenxian_xianshou
(string opName, string EngineID)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_不合格放行_删除_分线线首";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }


        /// <summary>
        /// 电子看板_零件图号_生产厂家_查询
        /// </summary>
        /// <param name="partDrawCode"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool MaterialFactory_Select(string partDrawCode,out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_零件图号_生产厂家_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@零件图号", partDrawCode);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms,out dt);
        }

        /// <summary>
        /// 派工订单_订单信息_查询
        /// </summary>
        /// <param name="partDrawCode"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool Get_DataByOrderForm(string OrderForm, out DataTable dt)
        {
            string procedureName;
            procedureName = "派工订单_订单信息_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 电子看板_零件图号_生产厂家_增加
        /// </summary>
        /// <param name="partDrawCode"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static bool MaterialFactory_Insert(string partDrawCode,string factory)
        {
            string procedureName;
            procedureName = "电子看板_零件图号_生产厂家_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@零件图号", partDrawCode);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@生产厂家", factory);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 电子看板_零件图号_生产厂家_修改
        /// </summary>
        /// <param name="factoryCode"></param>
        /// <param name="partDrawCode"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static bool MaterialFactory_Update(int factoryCode,  string partDrawCode, string factory)
        {
            string procedureName;
            procedureName = "电子看板_零件图号_生产厂家_修改";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@厂家代码", factoryCode);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@零件图号", partDrawCode);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@生产厂家", factory);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 电子看板_零件图号_生产厂家_删除
        /// </summary>
        /// <param name="factoryCode"></param>
        /// <returns></returns>
        public static bool MaterialFactory_Delete(int factoryCode)
        {
            string procedureName;
            procedureName = "电子看板_零件图号_生产厂家_删除";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@厂家代码", factoryCode);

            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// [电子看板_发动机号_不合格放行_返修下线_查询]
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsNG_PartUnLoad_Select
    (string EngineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_不合格放行_返修下线_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }


        /// <summary>
        /// [电子看板_发动机号_返修下线_查询]-2012-09-14-chenghai 以前只有不合格 才打印工位号
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_fanxiu_PartUnLoad_Select
    (string EngineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_返修下线_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }

     
        /// <summary>
        /// 测量数据合格索引_不合格标志_查询-2012-12-05-kexin OP3024用 打印不合格工位
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_buhege_PartUnLoad_Select
    (string EngineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "测量数据合格索引_不合格标志_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }


        /// <summary>
        /// [测量数据合格索引_返修上线信息_查询] OP3024 b6返修上线使用
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_Repair_PartUnLoad_Select
    (string EngineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "测量数据合格索引_返修上线信息_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }

        /// <summary>
        ///电子看板_发动机号_人工合格放行记录_增加数据
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool OKGo_Insert
    (string Opname, string EngineID, string  Enginetype,string headernum, string usernum)
        { 
            string procedureName;
            procedureName = "电子看板_发动机号_人工合格放行记录_增加数据";
            SqlParameter[] thisParms = new SqlParameter[5];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", Opname);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@机型", Enginetype);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@输入领班号", headernum);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@操作者编号", usernum);
            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
              return true;
            }
            return false;
        }




        /// <summary>
        /// [显示测量数据_工位号] 王可心 2012-12-06
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_ShowOpname
    (string EngineID, int LineType,out DataTable dt)
        {
            string procedureName;
            procedureName = "显示测量数据_工位号";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@固定条形码扫描枪", LineType);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }
        /// <summary>
        /// [显示测量数据_工位数据] 王可心 2012-12-06
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_ShowOpname_Data
    (string EngineID,string OpName,out DataTable dt)
        {
            string procedureName;
            procedureName = "显示测量数据_工位数据";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }
        /// <summary>
        /// 显示测量数据_工位数据_分线数据 王可心 2012-12-11
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_ShowOpname_Data_SubLine
    (string EngineID, string OpName, out DataTable dt)
        {
            string procedureName;
            procedureName = "显示测量数据_工位数据_分线数据";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }
        /// <summary>
        /// [显示测量数据_工位号_分线] 王可心 2012-12-11
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_ShowOpname_SubLine
    (string EngineID, int LineType, out DataTable dt)
        {
            string procedureName;
            procedureName = "显示测量数据_工位号_分线";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@固定条形码扫描枪", LineType);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }

        /// <summary>
        ///[电子看板_发动机号_线首工位_分线删除数据_根据发动机号]
        /// </summary>
        /// <param name="factoryCode"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_SubLine_DataDelete(string EngineID, string OpName)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_线首工位_分线删除数据_根据发动机号";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号_分线", OpName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        //2012-12-15 王可心
        /// <summary>
        /// [测量数据合格_变速器总成称重_根据发动机号_删除]
        /// </summary>
        /// <param name="engineID"></param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_Weight_Delete
                                                    (string engineID)
        {
            string procedureName;
            procedureName = "测量数据合格_变速器总成称重_根据发动机号_删除";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms);
        }

        /// <summary>
        /// [测量数据合格索引_不合格标志_OP3100_查询]  用于3100工位  2012-12-21
        /// </summary>
        /// <param name="EngineID">工件号</param>
        /// <param name="isOK_S"></param>
        /// <returns>合格返回true 不合格返回false</returns>
        public static bool TestData_EngineRework_IsOK_Select_OP3100
    (string EngineID)
        {

            int isOK_S = 1;
            string procedureName;
            procedureName = "测量数据合格索引_不合格标志_OP3100_查询";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@数量", isOK_S);

            thisParms[1].Direction = ParameterDirection.Output;


            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                isOK_S = Convert.ToInt32(thisParms[1].Value.ToString());
                if (isOK_S == 0)
                { return true; }
                else
                { 
                    return false; }
               
            }
            return false;
        }

        /// <summary>
        /// 测量数据合格索引 合格标志修改-2012-12-22 王可心 应用于OP3020R
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="isOK">0合格；1不合格</param>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_IsOK_OP3020_update
            (string opName, string EngineID, int isOK)
        {
            string procedureName;
            procedureName = "电子看板_测量数据合格索引_合格标志_返修工位_修改";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK);

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                return true;
            }
            return false;
        }


        /// <summary>
        /// [测量数据合格索引_不合格标志_轴齿上线_查询]  王可心 2012-12-23  轴齿上线匹配时 分线工件合格标志查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineID"></param>
        /// <param name="isOK">0合格；1不合格</param>
        /// <returns></returns>
        public static bool BaseData_tagTable_Engine_IsOK_SubLine_Select
            (string EngineID, int mathType,out int CountNum)
        {
            CountNum = 0;
            string procedureName;
            procedureName = "测量数据合格索引_不合格标志_轴齿上线_查询";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@匹配方式", mathType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@数量", CountNum);
            thisParms[2].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                CountNum = Convert.ToInt32(thisParms[2].Value.ToString());
                return true;
            }
            return false;
        }


        /// <summary>
        /// [测量数据发动机在线状态_下线工位_OP3100_查询]2012-12-30-王可心 OP3100用 下线时查看该工件以前是否进行过下线
        /// </summary>
        /// <param name="EngineID">发动机号</param>
        /// <param name="dt"></param>
        /// <returns>以前下线过返回true ，否则返回false</returns>
        static public void BaseData_tagTable_Engine_PartUnLoad_Select_OP3100(string EngineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "测量数据发动机在线状态_下线工位_OP3100_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        ///电子看板_发动机号_线首工位_查询发动机号 王可心 2013-11-07
        /// </summary>
        /// <param name="EngineID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool EngineNum_Select(DateTime BeginTime, DateTime EndTime, out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_线首工位_查询发动机号";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@开始时间", BeginTime);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@结束时间", EndTime);
            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt))
            {
                if (dt != null)
                {
                    if (dt.Rows.Count == 1)
                        return true;
                }
                return false;
            }
            return false;
        }

    }
}
