Files
17168ERP/web/App_Code/StatusTransitionManager.cs
2025-09-09 16:25:28 +08:00

35 lines
1.2 KiB
C#

using System.Collections.Generic;
namespace Model
{
public static class StatusTransitionManager
{
private static readonly Dictionary<string, List<string>> transitions =
new Dictionary<string, List<string>>
{
// 掛單狀態
{ "401", new List<string> { "402", "404" } },
{ "402", new List<string> { "403" } },
{ "403", new List<string>() },
{ "404", new List<string>() },
// 床位狀態
{ "101", new List<string> {"101", "102","103"} },
{ "102", new List<string> { "101" } },
{ "103", new List<string> { "101" } },
};
public static bool CanTransition(string currentCode, string targetCode)
{
if (string.IsNullOrEmpty(currentCode))
{
return targetCode == "401" || targetCode == "402" || targetCode == "101";
}
if(string.IsNullOrEmpty(targetCode))
{ return false; }
return transitions.ContainsKey(currentCode) &&
transitions[currentCode].Contains(targetCode);
}
}
}