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>
        /// 测量数据合格索引_增加
        /// 用于B5A项目
        /// ALTER                           PROCEDURE [dbo].[测量数据合格索引_增加]
        ///@EngineID nvarchar(50)=null,
        ///@TagID_CF int = null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineTypeID int = null,
        ///@工位号 nvarchar(50)=null,
        ///@订单号 nvarchar(50)=null,
        ///@合格标志 int=null,
        ///@TagValue1 nvarchar(50)=null,
        ///@TagValue2 nvarchar(50)=null,
        ///@TagValue3 nvarchar(50)=null,
        ///@TagValue4 nvarchar(50)=null,
        ///@TagValue5 nvarchar(50)=null,
        ///@TagValue6 nvarchar(50)=null,
        ///@TagValue7 nvarchar(50)=null,
        ///@TagValue8 nvarchar(50)=null,
        ///@TagValue9 nvarchar(50)=null,
        ///@TagValue10 nvarchar(50)=null,
        ///@TagValue nvarchar(50)=null,
        ///@Id_tagCF   int=null output
        /// </summary>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_IndexInsert
            (string EngineID, int tagID, string EngineType, int EngineTypeID, string opName, 
            int isGoodBad,string PartPalletCode, out int Id_tagCF)
        {
            string procedureName;
            procedureName = "测量数据合格索引_增加";
            Id_tagCF = 0;
            SqlParameter[] thisParms = new SqlParameter[8];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
            thisParms[7].Direction = ParameterDirection.Output;

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

        /// <summary>
        /// alter                           PROCEDURE dbo.[测量数据合格_增加]
        ///@Id_tagCF int = null,
        ///@EngineTypeID int =null,
        ///@EngineID nvarchar(100)=null,
        ///@TagID int=null,
        ///@TagValue nvarchar(100)=null,
        ///@IsGoodBad int=null,
        /// </summary>
        /// <param name="Id_tagCF"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="engineID"></param>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        public static bool BaseData_tagTable_QualityData_B5A_Insert
    (int Id_tagCF,int engineTypeID,string engineID,string opName,DataTable dt)
        {
            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", SqlDbType.Int, 4, "TagID");
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue");
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad");
            //thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置");
            //thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目");
            //thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            //thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值");
            //thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值");
            //thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值");
            //thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位");
            //thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置");
            //thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序");
            //table.Columns.Add("TagID", typeof(System.Int32));
            //table.Columns.Add("TagValue", typeof(System.String));
            //table.Columns.Add("IsGoodBad", typeof(System.Int32));
            //table.Columns.Add("测量位置", typeof(System.String));
            //table.Columns.Add("测量项目", typeof(System.String));
            //table.Columns.Add("工位号", typeof(System.String));
            //table.Columns.Add("理论值", typeof(System.String));
            //table.Columns.Add("上限值", typeof(System.String));
            //table.Columns.Add("下限值", typeof(System.String));
            //table.Columns.Add("测量单位", typeof(System.String));
            //table.Columns.Add("列位置", typeof(System.Int32));
            //table.Columns.Add("变量排序", typeof(System.Int32));
            return DataAccess.ExecuteStoredProcedure(procedureName, ref  thisParms, dt);
        }
        /// <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
(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);
        }

        //2012-12-12   离线状态时 只保存合格索引
        /// <summary>
        /// 测量数据合格索引_增加_工位离线状态 2012-12-26 
        /// 用于B5A项目
        /// ALTER                           PROCEDURE [dbo].[测量数据合格索引_增加_工位离线状态]
        ///@EngineID nvarchar(50)=null,
        ///@TagID_CF int = null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineTypeID int = null,
        ///@工位号 nvarchar(50)=null,
        ///@订单号 nvarchar(50)=null,
        ///@合格标志 int=null,
        ///@TagValue1 nvarchar(50)=null,
        ///@TagValue2 nvarchar(50)=null,
        ///@TagValue3 nvarchar(50)=null,
        ///@TagValue4 nvarchar(50)=null,
        ///@TagValue5 nvarchar(50)=null,
        ///@TagValue6 nvarchar(50)=null,
        ///@TagValue7 nvarchar(50)=null,
        ///@TagValue8 nvarchar(50)=null,
        ///@TagValue9 nvarchar(50)=null,
        ///@TagValue10 nvarchar(50)=null,
        ///@TagValue nvarchar(50)=null,
        ///@Id_tagCF   int=null output 
        /// </summary>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_IndexInsert_OffLine
            (string EngineID, int tagID, string EngineType, int EngineTypeID, string opName,
           int isGoodBad, string PartPalletCode, out int Id_tagCF)
        {
            string procedureName;
            procedureName = "测量数据合格索引_增加_工位离线状态";
            Id_tagCF = 0;
            SqlParameter[] thisParms = new SqlParameter[8];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
            thisParms[7].Direction = ParameterDirection.Output;

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

        //2012-12-16
        /// <summary>
        /// [测量数据合格索引_增加_只装配物料工位]
        /// 用于B5A项目
        /// ALTER                           PROCEDURE [dbo].[[测量数据合格索引_增加_只装配物料工位]]
        ///@EngineID nvarchar(50)=null,
        ///@TagID_CF int = null,
        ///@EngineType nvarchar(50)=null,
        ///@EngineTypeID int = null,
        ///@工位号 nvarchar(50)=null,
        ///@托盘编号 nvarchar(50)=null,
        ///@合格标志 int=null,
        ///@TagValue1 nvarchar(50)=null,
        ///@TagValue2 nvarchar(50)=null,
        ///@TagValue3 nvarchar(50)=null,
        ///@TagValue4 nvarchar(50)=null,
        ///@TagValue5 nvarchar(50)=null,
        ///@TagValue6 nvarchar(50)=null,
        ///@TagValue7 nvarchar(50)=null,
        ///@TagValue8 nvarchar(50)=null,
        ///@TagValue9 nvarchar(50)=null,
        ///@TagValue10 nvarchar(50)=null,
        ///@TagValue nvarchar(50)=null,
        ///@Id_tagCF   int=null output
        /// </summary>
        /// <returns></returns>
        public static bool BaseData_tagTable_QualityData_B5A_IndexInsert_OnlyMaterial
            (string EngineID, int tagID, string EngineType, int EngineTypeID, string opName,
              int isGoodBad, string PartPalletCode, out int Id_tagCF)
        {
            string procedureName;
            procedureName = "测量数据合格索引_增加_只装配物料工位";
            Id_tagCF = 0;
            SqlParameter[] thisParms = new SqlParameter[8];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
            thisParms[7].Direction = ParameterDirection.Output;

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


    }
}
