using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataLinkMesWork;
using System.Security.Cryptography;
//using SystemFramework;
using System.Web;

namespace bizFacade
{
    public partial class MES
    {
        /// <summary>
        /// 测量数据工位_监控系统_MOBY_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="IsAllowWork"></param>
        /// <returns></returns>
        public static void Moby_Select(string opName, out string orderNum,
            out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code,
            out int IsrepairBarcode, out string repairBarcode)
        {
            orderNum = "";
            EngineTypeID = 0;
            EngineType = "";
            EngineID = "";
            PartPallet_Code = "";
            IsrepairBarcode = 0;
            repairBarcode = "";
            try
            {
                string procedureName;
                procedureName = "测量数据工位_监控系统_MOBY_查询";
                SqlParameter[] thisParms = new SqlParameter[8];
                thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
                thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", SqlDbType.NVarChar, 50, "订单号");
                thisParms[1].Direction = ParameterDirection.Output;
                thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", SqlDbType.Int, 4, "产品型号代码");
                thisParms[2].Direction = ParameterDirection.Output;
                thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", SqlDbType.NVarChar, 50, "发动机型号");
                thisParms[3].Direction = ParameterDirection.Output;
                thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机号", SqlDbType.NVarChar, 50, "发动机号");
                thisParms[4].Direction = ParameterDirection.Output;
                thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘号", SqlDbType.NVarChar, 50, "托盘号");
                thisParms[5].Direction = ParameterDirection.Output;
                thisParms[6] = new System.Data.SqlClient.SqlParameter("@拆解标志", SqlDbType.Int, 4, "拆解标志");
                thisParms[6].Direction = ParameterDirection.Output;
                thisParms[7] = new System.Data.SqlClient.SqlParameter("@拆解返修条码", SqlDbType.NVarChar, 50, "拆解返修条码");
                thisParms[7].Direction = ParameterDirection.Output;
                DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
                if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null && thisParms[6].Value != null && thisParms[7].Value != null)
                {
                    orderNum = thisParms[1].Value.ToString();
                    EngineTypeID = Convert.ToInt32(thisParms[2].Value); ;
                    EngineType = thisParms[3].Value.ToString();
                    EngineID = thisParms[4].Value.ToString();
                    PartPallet_Code = thisParms[5].Value.ToString();
                    IsrepairBarcode = Convert.ToInt32(thisParms[6].Value); ;
                    repairBarcode = thisParms[7].Value.ToString();
                }
            }
            catch
            {
                orderNum = "";
                EngineTypeID = 0;
                EngineType = "";
                EngineID = "";
                PartPallet_Code = "";
                IsrepairBarcode = 0;
                repairBarcode = "";
            }
        }

        /// <summary>
        /// 基本数据_工作日历_班次产量查询_Web页面显示_初始化查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="IsAllowWork"></param>
        /// <returns></returns>
        public static void InitOpNameOuputCount(string opName, out int outputValue, out int nowOutputValue,
            out int opNameBeatValue, out int NowOpNameBeatValue, out int classNumber)
        {
            outputValue = 0;//工位产量
            nowOutputValue = 0;//在线产量
            opNameBeatValue = 0;//工位节拍
            NowOpNameBeatValue = 0;//在线节拍
            classNumber = 0;//班次
            try
            {
                string procedureName;
                procedureName = "Web页面显示_计划产量初始化查询";
                SqlParameter[] thisParms = new SqlParameter[6];
                thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
                thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位产量", SqlDbType.Int, 4, "工位产量");
                thisParms[1].Direction = ParameterDirection.Output;
                thisParms[2] = new System.Data.SqlClient.SqlParameter("@工位节拍", SqlDbType.Int, 4, "工位节拍");
                thisParms[2].Direction = ParameterDirection.Output;
                thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线产量", SqlDbType.Int, 4, "在线产量");
                thisParms[3].Direction = ParameterDirection.Output;
                thisParms[4] = new System.Data.SqlClient.SqlParameter("@在线节拍", SqlDbType.Int, 4, "在线节拍");
                thisParms[4].Direction = ParameterDirection.Output;
                thisParms[5] = new System.Data.SqlClient.SqlParameter("@班次代码", SqlDbType.Int, 4, "班次代码");
                thisParms[5].Direction = ParameterDirection.Output;
                DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
                if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null)
                {
                    outputValue = Convert.ToInt32(thisParms[1].Value);
                    opNameBeatValue = Convert.ToInt32(thisParms[2].Value);
                    nowOutputValue = Convert.ToInt32(thisParms[3].Value);
                    NowOpNameBeatValue = Convert.ToInt32(thisParms[4].Value);
                    classNumber = Convert.ToInt32(thisParms[5].Value);
                }
            }
            catch
            {
                outputValue = 0;
                opNameBeatValue = 0;
                nowOutputValue = 0;
                NowOpNameBeatValue = 0;
                classNumber = 0;
            }
        }

        static public bool MaterialsDelete(string engineID, string engineType)
        {
            string procedureName = "轴系返修零件_删除";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工件编号", engineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号", engineType);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 测量数据工位_监控系统_手动转线_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="outLineRepair1"></param>
        /// <returns></returns>
        static public bool AskManualTransfer(string opName, int manualTransfer1, int applyOffLine, int updateOptions1)
        {
            string procedureName = "测量数据工位_监控系统_手动转线_增加";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否启动转线", manualTransfer1);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@是否强制下线", applyOffLine);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@更新项目", updateOptions1);

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

        /// <summary>
        /// 电子看板_工序内容_查询
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineTypeID">产品型号代码</param>
        /// <param name="dt"></param>
        static public void Process_Select(string opName, int engineTypeID, string EngineType, out DataTable dt)
        {
            dt = null;
            string sql = "exec 电子看板_工序内容_查询 '" + opName + "'," + engineTypeID.ToString() + ",'" + EngineType + "'";
            DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 生产计划_派工订单_查询_工位执行
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="dt"></param>
        static public void OrderFormList_Select(string opName, out DataTable dt)
        {
            dt = null;
            string sql = "exec 生产计划_派工订单_查询_工位执行 '" + opName + "'";
            DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 电子看板_装配零件_物料验证_查询 20131231
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineID">发动机号</param>
        /// <param name="dt"></param>
        static public bool PartMaterialVerify_Select(string opName, int engineTypeID, string engineType, out DataTable dt)
        {
            dt = null;
            string procedureName;
            procedureName = "电子看板_装配零件_临时表_查询";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType);
            //thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_查询_工作顺序
        /// </summary>
        /// <param name="opNum">工位号</param>
        /// <param name="EngineTypeID">产品型号代码</param>
        /// <param name="dt"></param>
        static public bool ShaftPositionSelect(string opNum, int EngineTypeID, out DataTable dt)
        {
            string procedureName = "电子看板_工位机型_质量数据测量位置_临时表_查询";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opNum);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", EngineTypeID);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        /// 电子看板_工位机型_物料检测测量位置_查询_物料检测
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        static public bool MaterialCheckSelect(string opName, out DataTable dt)
        {
            string procedureName = "电子看板_工位机型_物料检测测量位置_查询_物料检测";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        /// 测量数据合格_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineID"></param>
        /// <param name="tb"></param>
        /// <returns></returns>
        static public bool QualitySelect(string opName, string engineID, out DataTable dt)
        {
            string 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, out dt);
        }

        /// <summary>
        /// 启用拧紧
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="orderNum"></param>
        /// <returns></returns>
        static public bool IsBackWork_Add(string opName, int IsBackWork)
        {
            string procedureName = "测量数据工位_监控系统_拧紧与返修拧紧_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否启用备用模式", IsBackWork);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 将手动转线/申请下线/返修上线更新到数据库中
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="manualValue"></param>
        /// <param name="outlineValue"></param>
        /// <param name="repairVaule"></param>
        /// <returns></returns>
        static public bool updataCbxFunction_add(string opName, int manualValue, int outlineValue, int repairVaule)
        {
            string procedureName = "测量数据工位_监控系统_上线下线转线_增加";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@申请下线", outlineValue);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@返修上线", repairVaule);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@手动转线", manualValue);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 测量数据工位_监控系统_订单号_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="orderNum"></param>
        /// <returns></returns>
        static public bool OrderNum_Add(string opName, string orderNum)
        {
            string procedureName = "测量数据工位_监控系统_订单号_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", orderNum);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 测量数据工位_监控系统_订单号_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="orderNum"></param>
        /// <returns></returns>
        static public bool Insert_OnlineOutline(string opName, int orderNum)
        {
            string procedureName = "测量数据工位_监控系统_在线离线屏蔽_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位状态", orderNum);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 功能按钮-从数据库中更新在线/离线/屏蔽
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="tb"></param>
        public static void Init_OnlineOutline(string opname, out DataTable tb)
        {
            string sql = "SELECT [工位状态] FROM [dbo].[测量数据工位_监控系统_在线离线屏蔽] WHERE [工位号]='" + opname + "'";
            //string connectionString = ApplicationConfig.ConnectionString;
            string errorMessage;
            tb = null;
            DataAccess.ExecuteDataTable(sql, out tb);
        }

        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_查询_返修
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeId"></param>
        /// <param name="engineType"></param>
        /// <param name="tb"></param>
        public static void Init_TreeData1(string opName, int engineTypeId, string engineType, out DataTable tb)
        {
            string sql = "SELECT [序号],[说明] FROM [dbo].[电子看板_工位机型_质量数据测量位置] WHERE [工位号]='" + opName + "' and [产品型号代码]=" + engineTypeId + " and [发动机型号]='" + engineType + "'";
            //string connectionString = ApplicationConfig.ConnectionString;
            string errorMessage;
            tb = null;
            DataAccess.ExecuteDataTable(sql, out tb);
        }

        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_查询_返修
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        static public bool Init_TreeData(string opName, out DataTable dt)
        {
            string procedureName = "电子看板_工位机型_质量数据测量位置_查询_返修";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        /// 测量数据工位_监控系统_发动机型号_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="enginetype"></param>
        /// <param name="enginetypeID"></param>
        /// <returns></returns>
        static public bool EngineNum_Add(string opName, string enginetype, int enginetypeID)
        {
            string procedureName = "测量数据工位_监控系统_发动机型号_增加";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机型号", enginetype);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", enginetypeID);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 测量数据工位_监控系统_手动打印_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <param name="day"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public static bool OpName_MIS_Manual_Insert(string opName, int year, int month, int day, int num)
        {
            string produceName = "测量数据工位_监控系统_手动打印_增加";
            SqlParameter[] thisParms = new SqlParameter[5];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@年", year);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@月", month);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@日", day);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@流水号", num);
            return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms);
        }

        /// <summary>
        /// 测量数据工位_监控系统_订单号_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool OpName_MIS_OrderForm_Select(string opName, out DataTable dt)
        {
            string sql = "select top 1 订单号 from 测量数据工位_监控系统_订单号 where 工位号='" + opName + "'";
            return DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 测量数据工位_监控系统_发动机型号_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool OpName_MIS_EngineType_Select(string opName, out DataTable dt)
        {
            string sql = "select top 1 产品型号代码,发动机型号 from 测量数据工位_监控系统_发动机型号 where 工位号='" + opName + "'";
            return DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 测量数据工位_监控系统_系统初始化
        /// </summary>
        /// <param name="opName"></param>
        /// <returns></returns>
        public static bool WebLoginIn(string opName)
        {
            string produceName = "测量数据工位_监控系统_系统初始化";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms);
        }

        /// <summary>
        /// 获得工位对应的返修工位号
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="tb"></param>
        public static void GetopRepairName(string opname, out DataTable tb)
        {
            string sql = "SELECT TOP 1 [返修工位号] FROM [dbo].[MES_计划BOM_工位与名称_视图] WHERE [工位号]='" + opname + "'";
            //string connectionString =ApplicationConfig.ConnectionString;
            string errorMessage;
            tb = null;
            DataAccess.ExecuteDataTable(sql, out tb);
        }

        /// <summary>
        /// 测量数据工位_监控系统_离线返修_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="outLineRepair1"></param>
        /// <returns></returns>
        static public bool AskOutLineRepair(string opName, int outLineRepair1)
        {
            string procedureName = "测量数据工位_监控系统_离线返修_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@离线返修", outLineRepair1);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 电子看板_装配零件_修改_零件批号
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineType"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool Material_Betch_Update(string opName, string engineType, DataTable dt)
        {
            string produceName = "电子看板_装配零件_修改_零件批号";
            SqlParameter[] thisParms = new SqlParameter[5];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@零件图号", SqlDbType.NVarChar, 50, "零件图号");
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@零件批号", SqlDbType.NVarChar, 50, "零件批号");
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@生产厂家", SqlDbType.NVarChar, 50, "生产厂家");
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType);
            return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, dt);
        }

        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_临时表_修改_返修
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool Insert_selectTreeData(DataTable dt)
        {
            string produceName = "电子看板_工位机型_质量数据测量位置_临时表_修改_返修";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", SqlDbType.NVarChar, 50, "工位号");
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", SqlDbType.Int, 4, "产品型号代码");
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@序号", SqlDbType.Int, 4, "序号");
            return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, dt);
        }

        /// <summary>
        /// 返修上线插入界面选择的工位合格标志
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="tb"></param>
        public static bool Insert_RepairPartLoad_OpInfo(string opname, string zbz_parameter, string csq_parameter, string zzx_parameter, string jcx_parameter)
        {
            string sql = "UPDATE [电子看板_发动机号_线首工位_工位合格标志] SET [轴部装线]=" + zbz_parameter
                + " ,[差速器线]=" + csq_parameter
                + " ,[总装线]=" + zzx_parameter
                + " ,[检测线]=" + jcx_parameter
                + " WHERE [工位号]='" + opname + "'";
            //string connectionString = ApplicationConfig.ConnectionString;
            string errorMessage;
            return DataAccess.ExecuteSQL(sql);
        }

        /// <summary>
        /// 返修上线插入界面选择的工位合格标志
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="dt"></param>
        public static bool Select_RepairLoadBtn(string opname, out DataTable dt)
        {
            string sql = "SELECT [轴部装线],[差速器线],[总装线],[检测线] FROM [电子看板_发动机号_线首工位_工位合格标志] WHERE 工位号='" + opname + "'";
            //string connectionString = ApplicationConfig.ConnectionString;
            string errorMessage;
            return DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 获得返修数量信息
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool OpName_MIS_RepiareNum_Select(string opName, out DataTable dt)
        {
            string sql = "select top 1 设置数量,当前数量 from 测量数据工位_监控系统_批量返修 where 工位号='" + opName + "'";
            return DataAccess.ExecuteDataTable(sql, out dt);
        }

        /// <summary>
        /// 插入返修数量信息
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="RepiareNum"></param>
        /// <returns></returns>
        static public bool Insert_RepiareNum(string opName, int RepiareNum)
        {
            string procedureName = "测量数据工位_监控系统_批量返修_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@返修数量", RepiareNum);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// 生产计划_派工订单_查询_工位执行_完工判断
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="isCompleted"></param>
        /// <param name="num_plan"></param>
        /// <param name="num_complete"></param>
        public static void Select_OrderFormList_OrderComplete(string opName, out int isCompleted, out int num_plan, out int num_complete)
        {
            isCompleted = 0;//订单数量是否完全上线
            num_plan = 0;//计划数量
            num_complete = 0;//上线数量
            try
            {
                string procedureName;
                procedureName = "生产计划_派工订单_查询_工位执行_完工判断";
                SqlParameter[] thisParms = new SqlParameter[4];
                thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
                thisParms[1] = new System.Data.SqlClient.SqlParameter("@ISCOMPLETE", SqlDbType.Int, 4, "ISCOMPLETE");
                thisParms[1].Direction = ParameterDirection.Output;
                thisParms[2] = new System.Data.SqlClient.SqlParameter("@NUM_PLAN", SqlDbType.Int, 4, "NUM_PLAN");
                thisParms[2].Direction = ParameterDirection.Output;
                thisParms[3] = new System.Data.SqlClient.SqlParameter("@NUM_COMPLETE", SqlDbType.Int, 4, "NUM_COMPLETE");
                thisParms[3].Direction = ParameterDirection.Output;

                DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
                if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null)
                {
                    isCompleted = Convert.ToInt32(thisParms[1].Value);
                    num_plan = Convert.ToInt32(thisParms[2].Value);
                    num_complete = Convert.ToInt32(thisParms[3].Value);
                }
            }
            catch
            {
                isCompleted = 0;
                num_plan = 0;
                num_complete = 0;
            }
        }

        /// <summary>
        /// WEB根据工位号和线外扫描主物料查询质量数据合格索引(包括了分线的信息、存储过程中根据工位类型区分) 20170318 corbin
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="lineout_barcode"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool QualityDataButton_bgColor_alert_Select(string opname, out DataTable dt)
        {
            string procedureName = "显示测量数据_工位号_根据线外工位验证_查询";
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname);
            //sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@发动机号", lineout_barcode);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt);
        }

        /// <summary>
        /// 显示物料数据_根据_工位号_发动机型号_查询_分线数据
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="opname"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        static public bool MaterialDataSelect_F_EnergineID(string opname, string energineID, out DataTable dt)
        {
            string procedureName;
            procedureName = "显示物料数据_根据_工位号_发动机型号_查询_分线数据";
            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname);
            sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@发动机号", energineID);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt);
        }
    }
}