using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataLinkMesWork;
using System.Net.NetworkInformation;

namespace MesServerFunctions
{
    public class Db
    {
        public static bool OP051_OP050_NeedWork(string EngineID, string opName,string orderForm, out int MatchResult)
        {
            DataTable dt = new DataTable();
            MatchResult = 0;
            string produceName = "合力_OP050前停判断_下工位是否需要工作";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm);
            if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
            {
                if (dt.Rows.Count > 0)
                {
                    MatchResult = Convert.ToInt32(dt.Rows[0]["是否需要工作"]);
                    return true;
                }
            }
            return false;
        }
        public static bool OP051_OP050_NeedWork_Save(string EngineID, int MatchResult)
        {

            string produceName = "合力_OP050是否需要工作_插入";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否需要工作", MatchResult);
            return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms);
        }
        public static bool OPA90_TO_OP50_CheckTwoFinish(out int MainLineAllowWork)
        {
            DataTable dt;
            MainLineAllowWork = 2;
            string produceName = "合力_OP050是否允许工作_判断";
            SqlParameter[] thisParms = new SqlParameter[0];
            if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
            {
                if (dt.Rows.Count > 0)
                {
                    MainLineAllowWork = Convert.ToInt32(dt.Rows[0]["是否允许工作"]);
                    return true;
                }
            }
            return false;
        }
    }
}
