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项目
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Item_B5A()
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   FROM [MES_基本变量_原始数据] "
                + " where (TagID <> 0 )  and "
            + "  ((变量类型代码 = 9)  "
            + " or (变量类型代码 = 10)  "
            + " or (变量类型代码 = 11)  "
            + " or (变量类型代码 = 80)  "
            + " or (变量类型代码 = 101) "
            + " or (变量类型代码 = 102) "

            + " or (变量类型代码 = 78) "
            + " or (变量类型代码 = 79) "
            + " or (变量类型代码 = 41) "
            + " or (变量类型代码 = 51) "
            + " or (变量类型代码 = 8) "
            + " or (变量类型代码 = 21) "

            + " or (变量类型代码 = 105)) "
            + " and (是否启用 = 1)";

            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// 测量工位
        /// 变量特点=1001需要自动测量工位
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_OpName_B5A()
        {
            DataTable dt;
            string sql = "SELECT distinct 工位号 as 工位代码,[工位号]  FROM [MES_基本变量_原始数据]  "
                + " where ((变量类型代码 >= 19 and 变量类型代码 <= 24)  or (变量类型代码 = 101) or (变量类型代码 = 102))  and (是否启用 = 1) and (变量特点=1001)";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// 变量特点=1001需要自动测量工位
        /// sql = "SELECT  TagID,0 as TagValue,TagName,工位号,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo   "
        /// + " FROM MES_基本变量_原始数据 "
        /// + " where 变量类型代码 = 19  and 是否启用 = 1 and 变量特点=8 ";
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Read_CF_MIS_B5A()
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   "
                    + " FROM MES_基本变量_原始数据 "
                    + " where 变量类型代码 = 19  and 是否启用 = 1 and (变量特点=1001 )";
            // + " and OpcServer_OPNAME='" + opName + "'";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// 质量数据保存完数据 20
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Write_CF_B5A()
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   FROM [MES_基本变量_原始数据] where 变量类型代码 = 20 and  是否启用 = 1 and (变量特点=1001) ";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }

        /// <summary>
        /// 测量数据项目
        /// 用于B5A项目
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Item_B5A(string opName)
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   FROM [MES_基本变量_原始数据] "
                + " where (TagID <> 0 )  and "
            + "  ((变量类型代码 = 9)  "
            + " or (变量类型代码 = 10)  "
            + " or (变量类型代码 = 11)  "
            + " or (变量类型代码 = 101) "
            + " or (变量类型代码 = 102) "
            + " or (变量类型代码 = 105)) "
            + " and (是否启用 = 1)"
            + " and (工位号 = '"+opName+"')";

            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// 测量工位
        /// 变量特点=1001自动测量工位
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_OpName_B5A(string opName)
        {
            DataTable dt;
            string sql = "SELECT distinct 工位号 as 工位代码,[工位号]  FROM [MES_基本变量_原始数据]  "
                + " where ((变量类型代码 >= 19 and 变量类型代码 <= 24)  or (变量类型代码 = 101) or (变量类型代码 = 102))  and (是否启用 = 1) "
                + " and 工位号 = '" + opName+"'";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// sql = "SELECT  TagID,0 as TagValue,TagName,工位号,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo   "
        /// + " FROM MES_基本变量_原始数据 "
        /// + " where 变量类型代码 = 19  and 是否启用 = 1 and 变量特点=8 ";
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Read_CF_MIS_B5A(string opName)
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   "
                    + " FROM MES_基本变量_原始数据 "
                    + " where 变量类型代码 = 19  and 是否启用 = 1 "
                + " and 工位号 = '" + opName + "'";
            ;
            // + " and OpcServer_OPNAME='" + opName + "'";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
        /// <summary>
        /// 质量数据保存完数据
        /// 20
        /// </summary>
        /// <returns></returns>
        public static DataTable BaseData_tagTable_QualityData_Write_CF_B5A(string opName)
        {
            DataTable dt;
            string sql;
            sql = "SELECT  TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序   FROM [MES_基本变量_原始数据] where 变量类型代码 = 20 and  是否启用 = 1 "
                + " and 工位号 = '" + opName + "'";
            DataAccess.ExecuteDataTable(sql, out  dt);
            return dt;
        }
    }
}
