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>
        /// MES_计划BOM_工位与名称_查询
        /// 
        /// </summary>
        static public void GetOpNameByOpName(string opName,out DataTable dt)
        {
            string procedureName;
            procedureName = "MES_计划BOM_工位与名称_查询_根据工位号";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms,out dt); 
        }
        /// <summary>
        /// MES_计划BOM_工位与名称_查询
        /// MES_计划BOM_工位与名称_查询_根据工位号
        /// </summary>
        static public void GetOpName(out DataTable dt)
        {
            string sql;
            sql =  "exec MES_计划BOM_工位与名称_查询";
            DataAccess.ExecuteDataTable(sql, out  dt);
        }
        /// <summary>
        /// MES_计划BOM_工位与名称_查询_工位号_有工位计算机
        /// </summary>
        static public void GetOpName_IsMEsPC(out DataTable dt)
        {
            string sql;
            sql =  "exec MES_计划BOM_工位与名称_查询_工位号_有工位计算机";
            DataAccess.ExecuteDataTable(sql, out  dt);
        }
        /// <summary>
        /// MES_计划BOM_工位与名称_查询_工位号_是否有测量数据_有拧紧数据
        /// </summary>
        static public void GetOpName_IsNinJinOpName(out DataTable dt)
        {
            string sql;
            sql =  "exec MES_计划BOM_工位与名称_查询_工位号_是否有测量数据_有拧紧数据";
            DataAccess.ExecuteDataTable(sql, out  dt);
        }
        /// <summary>
        /// MES_基本变量_基本机型_查询
        /// </summary>
        static public void GetEngineBasicType(out DataTable dt)
        {
            string sql;
            sql = " exec MES_基本变量_基本机型_查询";
            DataAccess.ExecuteDataTable(sql, out  dt);
        }
        /// <summary>
        /// 电子看板_工位名称与产品型号产品图片_保存图片
        /// @工位号 nvarchar(50),
        /// @产品型号代码 int =null,
        /// @产品图片 image
        /// </summary>
        static public void SaveImageFile(string opName, int engineTypeID, byte[] pic)
        {
            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("@产品图片", pic);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);        
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="pic"></param>
        static public void GetImageFile(string opName, string engineTypeID, out byte[] pic)
        {
            string sql;
            DataTable dt;
            pic = null;
            sql = "exec 电子看板_工位名称与产品型号产品图片_查询 '" + opName + "'," + engineTypeID;
            DataAccess.ExecuteDataTable(sql, out  dt);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    pic = (byte[])dt.Rows[0]["产品图片"];
                }
            }
        }
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="dt"></param>
        static public void ShaftPositionSelect(string opName, string engineTypeID, out DataTable dt)
        {
            string sql;
            sql =  "exec 电子看板_工位机型_质量数据测量位置_查询 '" + opName + "'," + engineTypeID;
            DataAccess.ExecuteDataTable(sql, out  dt);
        }
        
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_套筒号_查询
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="dt"></param>
        static public void ShaftPositionSelect_BoltCode(string opName, string engineTypeID, out DataTable dt)
        {
            string sql;
            sql = "exec 电子看板_工位机型_质量数据测量位置_套筒号_查询 '" + opName + "'," + engineTypeID;
            DataAccess.ExecuteDataTable(sql, out  dt);
        }

        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_保存数据
        /// 完成增加和修改数据
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="shaftSN"></param>
        /// <param name="workGroup"></param>
        /// <param name="xPosition"></param>
        /// <param name="yPosition"></param>
        /// <param name="workStep"></param>
        /// <param name="taoTongHao"></param>
        static public void ShaftPositionSaveData(string opName, 
            int engineTypeID, int shaftSN,int workGroup,
            int xPosition, int yPosition, int workStep, int taoTongHao, string Torque)
        {
            string procedureName;
            procedureName = "电子看板_工位机型_质量数据测量位置_保存数据";
            SqlParameter[] thisParms = new SqlParameter[9];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@序号", shaftSN);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@组号", workGroup);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@测量位置X", xPosition);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@测量位置Y", yPosition);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@工作顺序", workStep);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@套筒号", taoTongHao);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@扭矩", Torque);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);  
        }
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_修改
        ///  修改数据 电子看板_工位机型_质量数据测量位置_修改_修改序号
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="engineTypeID">产品型号代码</param>
        /// <param name="shaftSN">序号</param>
        /// <param name="workGroup">组号</param>
        /// <param name="xPosition">测量位置X</param>
        /// <param name="yPosition">测量位置Y</param>
        /// <param name="workStep">工作顺序</param>
        /// <param name="taoTongHao">工作顺序</param>
        static public void ShaftPositionSaveUpdate(string opName, 
            int engineTypeID, int shaftSN, int workGroup,int xPosition,
            int yPosition, int workStep, int taoTongHao, string Torque)
        {
            string procedureName;
            procedureName = "电子看板_工位机型_质量数据测量位置_修改";
            SqlParameter[] thisParms = new SqlParameter[9];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@序号", shaftSN);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@组号", workGroup);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@测量位置X", xPosition);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@测量位置Y", yPosition);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@工作顺序", workStep);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@套筒号", taoTongHao);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@扭矩", Torque);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_修改_修改序号
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="shaftSN"></param>
        static public void ShaftPositionSaveUpdate_OnlySN(int id,string opName, int engineTypeID, int shaftSN)
        {
            string procedureName;
            procedureName = "电子看板_工位机型_质量数据测量位置_修改_修改序号";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@ID", id);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@序号", shaftSN);

            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_删除
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="shaftSN"></param>
        static public void ShaftPositionSaveDelete(string opName, int engineTypeID, int shaftSN)
        {
            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("@序号", shaftSN);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// 电子看板_工位机型_质量数据测量位置_修改_修改扭矩
        /// </summary>
        /// <param name="id"></param>
        /// <param name="opName"></param>
        /// <param name="engineTypeID"></param>
        /// <param name="shaftSN"></param>
        static public void ShaftPositionSaveUpdate_OnlyTorque(int shaftSN, string opName, int engineTypeID, string Torque)
        {
            string procedureName;
            procedureName = "电子看板_工位机型_质量数据测量位置_修改_修改扭矩";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@序号", shaftSN);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@扭矩", Torque);

            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

    }
}
