using System;
using System.Data;
using System.Data.SqlClient;

using System.Collections;
using System.Collections.Specialized;
//using SystemFramework;
using DataLinkMesWork;
namespace SystemFramework
{

}
namespace bizFacade
{
    /// <summary>
    /// 电子看板信息系统
    /// select 重量1,重量2,重量差,允许重量差,合格标志
    /// </summary>
    public partial class BaseDataSystemMES
    {

        /// <summary>
        /// 电子看板_发动机号_分线组件装配关系_增加
        /// </summary>
        /// <param name="engineID"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="engineType"></param>
        /// <param name="engineID_SubLine"></param>
        //static public void MailLineAndSubLineData_InsertAAAAA(string engineID, int engineTypeID, string engineType, string engineID_SubLine)
        //{
        //    string procedureName;
        //    procedureName = "电子看板_发动机号_分线组件装配关系_增加";
        //    SqlParameter[] thisParms = new SqlParameter[4];
        //    thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号_分线", engineID_SubLine);
        //    thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID);
        //    thisParms[2] = new System.Data.SqlClient.SqlParameter("@机型代码", engineTypeID);
        //    thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType);
        //    DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        //}

        /// <summary>
        /// 思源库位管理_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineID"></param>
        /// <param name="dt"></param>
        static public void GetUpLoadBarCode(string opName, out DataTable dt)
        {
            string procedureName;
            procedureName = "思源库位管理_查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// [思源库位管理_下线库位_根据机型_查询]
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineID"></param>
        /// <param name="dt"></param>
        static public void GetUpLoadWarehouseNoOpName02(string opName,string EngineIDType, out DataTable dt)
        {
            string procedureName;
            procedureName = "思源库位管理_下线库位_根据机型_查询";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机型号", EngineIDType);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 思源库位管理_下线库位查询  [思源库位管理_下线库位_根据机型_查询]
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineID"></param>
        /// <param name="dt"></param>
        static public void GetUnLoadWarehouseNo(string opName, out DataTable dt)
        {
            string procedureName;
            procedureName = "思源库位管理_下线库位查询";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        //[思源库位管理_上线发动机号订单号查询]
        static public void GetUpLoadEngineIDOrderForm(string opName,string kuweihao, out DataTable dt)
        {
            string procedureName;
            procedureName = "[思源库位管理_上线发动机号订单号查询]";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@库位号", kuweihao);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        static public void UpdateKuWeiStatus(string opName, string kuweihao)
        {
            string procedureName;
            procedureName = "[思源库位管理_上线更新状态_修改]";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@库位号", kuweihao);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        static public void GetUpLoadBarCodeEngineID(string opName, out DataTable dt)
        {
            string procedureName;
            procedureName = "[思源库位管理_上线发动机号查询]";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }

        static public void ClearOpCarData(string opName)
        {
            string procedureName;
            procedureName = "[思源库位管理_清空所有库位数据]";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        //        ALTER PROCEDURE[dbo].[思源库位管理_修改]
        //        @条码 nvarchar(50),
        //@ nvarchar(50)=NULL,
        //@ nvarchar(50),
        //@ nvarchar(50), 

        //@工位号 nvarchar(50),
        //@库位号 nvarchar(50)
        static public void GetUpLoadBarCode_Update(string opName,string kuweiNum ,string barCode,string orderForm,
            string EngineID, string EngineIDType, int typeID)
        {
            string procedureName;
            procedureName = "思源库位管理_修改";
            SqlParameter[] thisParms = new SqlParameter[7];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@库位号", kuweiNum);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@条码", barCode);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@发动机型号", EngineIDType);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@机型代码", typeID);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        static public void GetUpLoadBarCode_0utUpdate(string opName, string kuweiNum)
        {
            string procedureName;
            procedureName = "思源库位管理_出库修改";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@库位号", kuweiNum);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 上线工位 扫面零件码 判断是否当前要加工的零件
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="dt"></param>
        static public void CheckUpLoadPart(string partCode, string scanPosition, out DataTable dt)
        {
            string procedureName;
            procedureName = "SY_MES_计划BOM_判断工件是否匹配";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@partCode", partCode);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@抓取位置", scanPosition);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 线首工位自动查找生产订单
        /// </summary>
        /// <param name="dt"></param>
        static public void GetUpLoadPart(out DataTable dt)
        {
            string procedureName;
            procedureName = "SY_MES_计划BOM_线首工位自动查找生产订单";
            SqlParameter[] thisParms = new SqlParameter[0];
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 查询工位最大盆子数量
        /// </summary>
        /// <param name="OpName"></param>
        /// <param name="dt"></param>
        static public void GetMaxPartCount(string OpName, out DataTable dt)
        {
            string procedureName;
            procedureName = "测量数据发动机在线状态_工位绑定与上线盆子数";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        /// <summary>
        /// 测量数据发动机在线状态_与订单数比对
        /// </summary>
        /// <param name="OpName"></param>
        /// <param name="dt"></param>
        static public void GetStartGoCount(out DataTable dt)
        {
            string procedureName;
            procedureName = "测量数据发动机在线状态_与订单数比对";
            SqlParameter[] thisParms = new SqlParameter[0];
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
        }
        static public void UpdateOrderStatus(string orderCode)
        {
            string procedureName;
            procedureName = "SY_MES_计划BOM_更新订单生产状态";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", orderCode);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        //static public void SubLineLoadPartCountMatch_Select(string opName, out int SubLineLoadPartCountMatch)
        //{
        //    string procedureName;
        //    DataTable dt;
        //    procedureName = "MES_计划BOM_工位与名称_工步属性查询";
        //    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)
        //    {
        //        SubLineLoadPartCountMatch = Convert.ToInt32(dt.Rows[0][0]);
        //    }
        //    else
        //    {
        //        SubLineLoadPartCountMatch = 0;
        //    }
        //}

    }
}
