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

namespace bizFacade
{
    public class MES_Loading
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        static public void MES_LoadingOPName(string opName, out DataTable dt)
        {
            string sql;
            sql = " select 线外工位号 as opname from [dbo].[线外工位验证] where 工位号='"+opName+"'";
            DataAccess.ExecuteDataTable(sql, out dt);
        }


        /// <summary>
        /// MES_界面显示_标签语言_视图_查询
        /// </summary>
        /// <param name="mainModule">主模块代码</param>
        /// <param name="MesWebCode">MesWebCode</param>
        /// <param name="工位号">opName</param>
        /// <param name="tb"></param>
        public static void MES_Loading_select(string mainModule, string MesWebCode,string opName, out DataTable tb)
        {
            string procedureName = "MES_界面显示_标签语言_视图_查询";
            //string connectionString = ApplicationConfig.ConnectionString;
            DataSet ds;
            string errorMessage;
            bool isOK;
            SqlParameter[] sqlParameters = new SqlParameter[3];
            sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@主模块代码", mainModule);
            sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@MesWebCode", MesWebCode);
            sqlParameters[2] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            isOK = DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out  ds);
            if (isOK)
            {
                tb = ds.Tables[0];
            }
            else
            {
                tb = null;
            }

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

        /// <summary>
        /// 测量数据合格_查询
        /// </summary>
        /// <param name="opname"></param>
        /// <param name="engineid"></param>
        /// <param name="tb"></param>
        public static void initImage(string opname, string engineid, out DataTable tb)
        {
            string procedureName = "测量数据合格_查询";
            //string connectionString = ApplicationConfig.ConnectionString;
            DataSet ds;
            string errorMessage;
            bool isOK;
            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname);
            sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineid);
            isOK = DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out ds);
            if (isOK)
            {
                tb = ds.Tables[0];
            }
            else
            {
                tb = null;
            }

        }
    }
}
