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 partial class MES1
    {
        /// <summary>
        /// 北汽福田工位状态监控MOBY_查询_订单下达用
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="IsAllowWork"></param>
        /// <returns></returns>
        public static void Moby_Select_FirstOpName(string opName, out string OrderForm,
            out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code,
            out int IsrepairBarcode, out string repairBarcode, out string EngineTypeString)
        {
            DataTable dt = new DataTable();
            OrderForm = "";
            EngineTypeID = 0;
            EngineType = "";
            EngineID = "";
            PartPallet_Code = "";
            IsrepairBarcode = 0;
            repairBarcode = "";
            EngineTypeString = "";
            try
            {
                string procedureName;
                procedureName = "北汽福田工位状态监控MOBY_查询_订单下达用";
                SqlParameter[] thisParms = new SqlParameter[1];
                thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);

                DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
                if (dt.Rows.Count > 0)
                {
                    OrderForm = dt.Rows[0][MobyTagType.OrderForm_MES].ToString();
                    EngineTypeID = Convert.ToInt32(dt.Rows[0][MobyTagType.EngineTypeID_MES]); ;
                    EngineType = dt.Rows[0][MobyTagType.EngineType_MES].ToString();
                    EngineID = dt.Rows[0][MobyTagType.EngineID_MES].ToString();
                    PartPallet_Code = dt.Rows[0][MobyTagType.PartPallet_Code].ToString();
                    EngineTypeString = dt.Rows[0][MobyTagType.EngineTypeBasic].ToString();
                }
            }
            catch
            {
                OrderForm = "";
                EngineTypeID = 0;
                EngineType = "";
                EngineID = "";
                PartPallet_Code = "";
                IsrepairBarcode = 0;
                repairBarcode = "";
                EngineTypeString = "";
            }
        }
        /// <summary>
        /// 普通工位，非上线工位
        /// 北汽福田工位状态监控MOBY_查询_订单下达用
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="OrderForm"></param>
        /// <param name="EngineTypeID"></param>
        /// <param name="EngineType"></param>
        /// <param name="EngineID"></param>
        /// <param name="PartPallet_Code"></param>
        /// <param name="IsrepairBarcode"></param>
        /// <param name="repairBarcode"></param>
        public static void Moby_Select(string opName, out string OrderForm,
            out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code,
            out int IsrepairBarcode, out string repairBarcode, out string EngineTypeString,out string BeforEngineType , int type = 1)
        {
            DataTable dt = new DataTable();
            OrderForm = "";
            EngineTypeID = 0;
            EngineType = "";
            EngineID = "";
            PartPallet_Code = "";
            IsrepairBarcode = 0;
            repairBarcode = "";
            EngineTypeString = "";
            BeforEngineType = "";
            try
            {
                string procedureName;
                procedureName = "北汽福田工位状态监控MOBY_查询_订单下达用";
                SqlParameter[] thisParms = new SqlParameter[2];
                thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
                thisParms[1] = new System.Data.SqlClient.SqlParameter("@计数类型", type);

                DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
                if (dt.Rows.Count > 0)
                {
                    OrderForm = dt.Rows[0][MobyTagType.OrderForm].ToString();
                    EngineTypeID = Convert.ToInt32(dt.Rows[0][MobyTagType.EngineTypeID]); ;
                    EngineType = dt.Rows[0][MobyTagType.EngineType].ToString();
                    EngineID = dt.Rows[0][MobyTagType.EngineID].ToString();
                    PartPallet_Code = dt.Rows[0][MobyTagType.PartPallet_Code].ToString();
                    EngineTypeString = dt.Rows[0][MobyTagType.EngineTypeBasic].ToString();
                    BeforEngineType = dt.Rows[0]["上台机型"].ToString();
                }
            }
            catch
            {
                OrderForm = "";
                EngineTypeID = 0;
                EngineType = "";
                EngineID = "";
                PartPallet_Code = "";
                IsrepairBarcode = 0;
                repairBarcode = "";
                EngineTypeString = "";
                BeforEngineType = "";
            }
        }
    }
}
