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>
        /// 获得总线发动机号
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineType"></param>
        /// <param name="dt"></param>
        static public void GetEngineID_MailLine(string opName, string engineType, out DataTable dt)
        {
            bool isSubLine;
            isSubLine = false;
            GetEngineID_Auto(opName, engineType, isSubLine, out  dt);
        }
        /// <summary>
        /// 获得分线发动机号
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineType"></param>
        /// <param name="dt">工件机型,机型代码,工件编号,壳体编号型号,工件流水号,QR码,基本流水号</param>
        static public void GetEngineID_SubLine(string opName, string engineType, out DataTable dt)
        {
            bool isSubLine;
            isSubLine = true;
            GetEngineID_Auto(opName, engineType, isSubLine, out  dt);
        }
        /// <summary>
        /// 电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码
        /// 工件机型,机型代码,工件编号,壳体编号型号,工件流水号,QR码,基本流水号
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineType">发动机型号</param>
        /// <param name="isSubLine">是否分线--@是否分线 = 0 总线线首（OP2010）；=1分线线首(OP1010,OP2100)</param>
        /// <param name="dt">工件机型,机型代码,工件编号,壳体编号型号,工件流水号,QR码,基本流水号</param>
        static public void GetEngineID_Auto(string opName, string engineType, bool isSubLine, out DataTable dt)
        {
            string procedureName;
            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("@是否分线", isSubLine);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineType">发动机型号</param>
        /// <param name="engineYear">年份</param>
        /// <param name="engineMoon">月份</param>
        /// <param name="engineDay">日期</param>
        /// <param name="engineNumber">流水号</param>
        /// <param name="dt"></param>
        static public void GetEngineID_Manual_MainLine(string opName, string engineType, string engineYear, string engineMoon, string engineDay, int engineNumber, out DataTable dt)
        {
            //@是否分线 bit=0 @是否分线 = 0 总线线首（OP2010）；=1分线线首(OP1010,OP2100)
            bool isSubLine = false;
            GetEngineID_Manual(opName, engineType, engineYear, engineMoon, engineDay, engineNumber, isSubLine, out  dt);
        }
        /// <summary>
        /// 电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineType">发动机型号</param>
        /// <param name="engineYear">年份</param>
        /// <param name="engineMoon">月份</param>
        /// <param name="engineDay">日期</param>
        /// <param name="engineNumber">流水号</param>
        /// <param name="dt"></param>
        static public void GetEngineID_Manual_SunLine(string opName, string engineType, string engineYear, string engineMoon, string engineDay, int engineNumber, out DataTable dt)
        {
            //@是否分线 bit=0 @是否分线 = 0 总线线首（OP2010）；=1分线线首(OP1010,OP2100)
            bool isSubLine = true;
            GetEngineID_Manual(opName, engineType, engineYear, engineMoon, engineDay, engineNumber, isSubLine, out  dt);
        }

        /// <summary>
        /// 电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineType">发动机型号</param>
        /// <param name="engineYear">年份</param>
        /// <param name="engineMoon">月份</param>
        /// <param name="engineDay">日期</param>
        /// <param name="engineNumber">流水号</param>
        /// <param name="isSubLine">@是否分线 bit=0 @是否分线 = 0 总线线首（OP2010）；=1分线线首(OP1010,OP2100)</param>
        /// <param name="dt"></param>
        static public void GetEngineID_Manual(string opName, string engineType, string engineYear, string engineMoon, string engineDay, int engineNumber, bool isSubLine, out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式";
            SqlParameter[] thisParms = new SqlParameter[7];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@年份", engineYear);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@月份", engineMoon);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@日期", engineDay);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@流水号", engineNumber);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否分线", isSubLine);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        /// <summary>
        /// 电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineType">发动机型号</param>
        /// <param name="engineYear">年份</param>
        /// <param name="engineMoon">月份</param>
        /// <param name="engineDay">日期</param>
        /// <param name="engineNumber">流水号</param>
        /// <param name="isSubLine">@是否分线 bit=0 @是否分线 = 0 总线线首（OP2010）；=1分线线首(OP1010,OP2100)</param>
        /// <param name="dt"></param>
        static public void GetEngineID_Manual_OldLineLoad(string opName, string engineType, string engineYear, string engineMoon, string engineDay, int engineNumber, bool isSubLine, out DataTable dt)
        {
            string procedureName;
            procedureName = "电子看板_发动机号_线首工位_创建线首发动机号_根据输入机型代码_手动方式_老线上线用";
            SqlParameter[] thisParms = new SqlParameter[7];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@年份", engineYear);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@月份", engineMoon);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@日期", engineDay);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@流水号", engineNumber);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否分线", isSubLine);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// [电子看板_发动机号_线首工位]信息手动用
        /// </summary>
        /// <param name="engineID">发动机号</param>
        /// <param name="engineTypeID">机型代码</param>
        /// <param name="partCode_Space">零件流水号带空格</param>
        /// <param name="partCode">零件流水号</param>
        /// <param name="shellCode">壳体编号型号</param>
        /// <param name="shellCode_Space">壳体编号型号带空格</param>
        /// <param name="QR_Code">QR码</param>
        /// <param name="engineCount">基本流水号</param>
        /// <param name="barCodeType">条码类型</param>
        /// <param name="engineTypeBase">基本机型</param>
        /// <param name="partCode_Text">流水号文本</param>
        /// <param name="partCode_BarCode">流水号条码</param>
        /// <param name="engineType_Text">型号文本</param>
        /// <param name="engineType_BarCode">型号条码</param>
        /// <param name="dt"></param>
        static public void GetEngineIDFromFirstOpName(out string engineID, out int engineTypeID, out string partCode_Space,
            out string partCode, out string shellCode, out string shellCode_Space, out string QR_Code,
            out int engineCount, out int barCodeType, out string engineTypeBase,
            out string partCode_Text, out string partCode_BarCode,
            out string engineType_Text, out string engineType_BarCode,
            DataTable dt)
        {
            engineID = "";
            engineTypeID = 0;
            partCode_Space="";
            partCode="";
            shellCode="";
            shellCode_Space="";
            QR_Code="";
            engineCount=0;
            barCodeType=0;
            engineTypeBase="";
            partCode_Text="";
            partCode_BarCode="";
            engineType_Text="";
            engineType_BarCode = "";

            engineID = dt.Rows[0]["发动机号"].ToString();
            engineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]);
            shellCode = dt.Rows[0]["壳体编号型号"].ToString();
            shellCode_Space = dt.Rows[0]["壳体编号型号带空格"].ToString();
            partCode = dt.Rows[0]["零件流水号"].ToString();
            partCode_Space = dt.Rows[0]["零件流水号带空格"].ToString();
            QR_Code = dt.Rows[0]["QR码"].ToString();
            engineCount = Convert.ToInt32(dt.Rows[0]["基本流水号"]);
            engineTypeBase = dt.Rows[0]["基本机型"].ToString();
            barCodeType = Convert.ToInt32(dt.Rows[0]["条码类型"]);
            partCode_Text = dt.Rows[0]["流水号文本"].ToString();
            partCode_BarCode = dt.Rows[0]["流水号条码"].ToString();
            engineType_Text = dt.Rows[0]["型号文本"].ToString();
            engineType_BarCode = dt.Rows[0]["型号条码"].ToString();

        }

        /// <summary>
        /// [电子看板_发动机号_线首工位]信息自动用
        /// </summary>
        /// <param name="engineID">发动机号</param>
        /// <param name="engineTypeID">机型代码</param>
        /// <param name="partCode_Space">零件流水号带空格</param>
        /// <param name="partCode">零件流水号</param>
        /// <param name="shellCode">壳体编号型号</param>
        /// <param name="shellCode_Space">壳体编号型号带空格</param>
        /// <param name="QR_Code">QR码</param>
        /// <param name="engineCount">基本流水号</param>
        /// <param name="barCodeType">条码类型</param>
        /// <param name="engineTypeBase">基本机型</param>
        /// <param name="partCode_Text">流水号文本</param>
        /// <param name="partCode_BarCode">流水号条码</param>
        /// <param name="engineType_Text">型号文本</param>
        /// <param name="engineType_BarCode">型号条码</param>
        /// <param name="dt"></param>
        static public void GetEngineIDFromFirstOpName_Auto(out string engineID, out int engineTypeID, out string partCode_Space,
            out string partCode, out string shellCode, out string shellCode_Space, out string QR_Code,
            out int engineCount, out int barCodeType, out string engineTypeBase,
            out string partCode_Text, out string partCode_BarCode,
            out string engineType_Text, out string engineType_BarCode,out string  CodeCreatetime,
            DataTable dt)
        {
            engineID = "";
            engineTypeID = 0;
            partCode_Space = "";
            partCode = "";
            shellCode = "";
            shellCode_Space = "";
            QR_Code = "";
            engineCount = 0;
            barCodeType = 0;
            engineTypeBase = "";
            partCode_Text = "";
            partCode_BarCode = "";
            engineType_Text = "";
            engineType_BarCode = "";

            engineID = dt.Rows[0]["发动机号"].ToString();
            engineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]);
            shellCode = dt.Rows[0]["壳体编号型号"].ToString();
            shellCode_Space = dt.Rows[0]["壳体编号型号带空格"].ToString();
            partCode = dt.Rows[0]["零件流水号"].ToString();
            partCode_Space = dt.Rows[0]["零件流水号带空格"].ToString();
            QR_Code = dt.Rows[0]["QR码"].ToString();
            engineCount = Convert.ToInt32(dt.Rows[0]["基本流水号"]);
            engineTypeBase = dt.Rows[0]["基本机型"].ToString();
            barCodeType = Convert.ToInt32(dt.Rows[0]["条码类型"]);
            partCode_Text = dt.Rows[0]["流水号文本"].ToString();
            partCode_BarCode = dt.Rows[0]["流水号条码"].ToString();
            engineType_Text = dt.Rows[0]["型号文本"].ToString();
            engineType_BarCode = dt.Rows[0]["型号条码"].ToString();
            CodeCreatetime = dt.Rows[0]["条码创建时间"].ToString();

        }
        /// <summary>
        /// [电子看板_发动机号_线首工位]信息
        /// </summary>
        /// <param name="engineID">发动机号</param>
        /// <param name="engineTypeID">机型代码</param>
        /// <param name="partCode_Space">零件流水号带空格</param>
        /// <param name="partCode">零件流水号</param>
        /// <param name="shellCode">壳体编号型号</param>
        /// <param name="shellCode_Space">壳体编号型号带空格</param>
        /// <param name="QR_Code">QR码</param>
        /// <param name="engineCount">基本流水号</param>
        /// <param name="barCodeType">条码类型</param>
        /// <param name="engineTypeBase">基本机型</param>
        /// <param name="partCode_Text">流水号文本</param>
        /// <param name="partCode_BarCode">流水号条码</param>
        /// <param name="engineType_Text">型号文本</param>
        /// <param name="engineType_BarCode">型号条码</param>
        /// <param name="partCode_Repair">零件流水号_返修</param>
        /// <param name="dt"></param>
        static public void GetEngineIDFromFirstOpName(out string engineID, out int engineTypeID, out string partCode_Space,
            out string partCode, out string shellCode, out string shellCode_Space, out string QR_Code,
            out int engineCount, out int barCodeType, out string engineTypeBase,
            out string partCode_Text, out string partCode_BarCode,
            out string engineType_Text, out string engineType_BarCode, out string partCode_Repair,
            DataTable dt)
        {
            engineID = "";
            engineTypeID = 0;
            partCode_Space = "";
            partCode = "";
            shellCode = "";
            shellCode_Space = "";
            QR_Code = "";
            engineCount = 0;
            barCodeType = 0;
            engineTypeBase = "";
            partCode_Text = "";
            partCode_BarCode = "";
            engineType_Text = "";
            engineType_BarCode = "";

            engineID = dt.Rows[0]["发动机号"].ToString();
            engineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]);
            shellCode = dt.Rows[0]["壳体编号型号"].ToString();
            shellCode_Space = dt.Rows[0]["壳体编号型号带空格"].ToString();
            partCode = dt.Rows[0]["零件流水号"].ToString();
            partCode_Space = dt.Rows[0]["零件流水号带空格"].ToString();
            QR_Code = dt.Rows[0]["QR码"].ToString();
            engineCount = Convert.ToInt32(dt.Rows[0]["基本流水号"]);
            engineTypeBase = dt.Rows[0]["基本机型"].ToString();
            barCodeType = Convert.ToInt32(dt.Rows[0]["条码类型"]);
            partCode_Text = dt.Rows[0]["流水号文本"].ToString();
            partCode_BarCode = dt.Rows[0]["流水号条码"].ToString();
            engineType_Text = dt.Rows[0]["型号文本"].ToString();
            engineType_BarCode = dt.Rows[0]["型号条码"].ToString();
            partCode_Repair = dt.Rows[0]["零件流水号_返修"].ToString();

        }
    }
}
