using System;
using System.Collections.Generic;
using Mirle.Def;
using System.Data;
using DataBase;
namespace DB.WMS.Fun
{
public class clsLocMst
{
/// <summary>
/// 確認儲位是否是外儲位
/// </summary>
/// <param name="sLoc"></param>
/// <param name="IsOutside"></param>
/// <param name="db"></param>
/// <returns></returns>
public int CheckLocIsOutside(string sLoc, ref bool IsOutside, ref string sLocDD, ref bool IsEmpty_DD, ref string BoxID_DD, DataBase.DB db)
{
try
{
int iRet = CheckLocIsOutside(sLoc, ref IsOutside, db);
if (iRet == DBResult.Success)
{
sLocDD = GetLocDD(sLoc, db);
if (string.IsNullOrWhiteSpace(sLocDD))
throw new Exception($"找不到{sLoc}的對照儲位!");
return CheckLocIsEmpty(sLocDD, ref IsEmpty_DD, ref BoxID_DD, db);
}
return iRet;
}
catch (Exception ex)
{
var cmet = System.Reflection.MethodBase.GetCurrentMethod();
clsWriLog.Log.subWriteExLog(cmet.DeclaringType.FullName + "." + cmet.Name, ex.Message);
return DBResult.Exception;
}
}
/// <summary>
/// 確認儲位是否是外儲位
/// </summary>
/// <param name="sLoc"></param>
/// <param name="IsOutside"></param>
/// <param name="db"></param>
/// <returns></returns>
public int CheckLocIsOutside(string sLoc, ref bool IsOutside, DataBase.DB db)
{
DataTable dtTmp = new DataTable();
try
{
string strEM = "";
string strSql = $"select IS_INSIDE from {Parameter.clsLocMst.TableName} where {Parameter.clsLocMst.Column.Loc} = '{sLoc}' ";
int iRet = db.GetDataTable(strSql, ref dtTmp, ref strEM);
if (iRet == DBResult.Success)
{
IsOutside = Convert.ToString(dtTmp.Rows[0][0]) == "N" ? true : false;
}
else
{
clsWriLog.Log.FunWriLog(WriLog.clsLog.Type.Error, $"{strSql} => {strEM}");
}
return iRet;
}
catch (Exception ex)
{
var cmet = System.Reflection.MethodBase.GetCurrentMethod();
clsWriLog.Log.subWriteExLog(cmet.DeclaringType.FullName + "." + cmet.Name, ex.Message);
return DBResult.Exception;
}
finally
{
dtTmp = null;
}
}
public bool FunTestConnection(DataBase.DB db)
{
DataTable dtTmp = new DataTable();
try
{
string strEM = "";
string strSql = $"select TOP (10) {Parameter.clsLocMst.Column.Loc} from {Parameter.clsLocMst.TableName} ";
int iRet = db.GetDataTable(strSql, ref dtTmp, ref strEM);
if (iRet == DBResult.Success)
{
return true;
}
else
{
clsWriLog.Log.FunWriLog(WriLog.clsLog.Type.Error, $"{strSql} => {strEM}");
return false;
}
}
catch (Exception ex)
{
var cmet = System.Reflection.MethodBase.GetCurrentMethod();
clsWriLog.Log.subWriteExLog(cmet.DeclaringType.FullName + "." + cmet.Name, ex.Message);
return false;
}
finally
{
dtTmp = null;
}
}
public string GetLocDD(string sLoc, DataBase.DB db)
{
DataTable dtTmp = new DataTable();
try
{
string strEM = "";
string strSql = $"select {Parameter.clsLocMs