chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using WebLib;
|
||||
|
||||
namespace Education
|
||||
{
|
||||
/// <summary>
|
||||
/// 領據匯入驗證類別
|
||||
/// </summary>
|
||||
public class 領據匯入驗證
|
||||
{
|
||||
/// <summary>
|
||||
/// 驗證憑證類別是否有效
|
||||
/// </summary>
|
||||
public static bool IsValidProofType(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return false;
|
||||
|
||||
var list = new string[] { "領據", "發票", "收據" };
|
||||
return list.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證計畫代號是否存在於 BPAA 表
|
||||
/// </summary>
|
||||
public static bool IsValidProjectCode(string planCode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(planCode))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var dac = new DAC_BPAA();
|
||||
var dataTable = dac.GetBpaaWithTYPlusNone();
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
if (row["BPPYN"].ToString() == planCode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證付款方式是否有效
|
||||
/// </summary>
|
||||
public static bool IsValidPaymentMethod(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return true; // 付款方式可以為空
|
||||
|
||||
var list = new string[] { "匯款", "支票", "現金" };
|
||||
return list.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證勞務費費用別是否有效
|
||||
/// </summary>
|
||||
public static bool IsValidLaborExpenseType(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return true; // 勞務費費用別可以為空
|
||||
|
||||
var list = new string[] { "講師費", "諮詢費", "工作人員費", "勞務費", "主持人費", "出席費", "演講費", "撰稿費" };
|
||||
return list.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證扣繳類別是否有效
|
||||
/// </summary>
|
||||
public static bool IsValidWithholdingCategory(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return true; // 扣繳類別可以為空
|
||||
|
||||
var list = new string[] { "50", "9A55", "9A70", "9A90", "9A92", "9B98A", "9B98B" };
|
||||
return list.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證日期格式
|
||||
/// </summary>
|
||||
public static bool IsValidDate(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return false;
|
||||
|
||||
if (DateTime.TryParse(value, out DateTime dt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 支援 Excel OADate 數值格式(如從 Excel 讀取的序號日期)
|
||||
if (double.TryParse(value, out double d))
|
||||
{
|
||||
// OADate 有效範圍:2020-01-01(43831.0)~ 9999-12-31(2958465.0)
|
||||
if (d >= ImportBase.MinOADate && d <= ImportBase.MaxOADate)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證數值格式
|
||||
/// </summary>
|
||||
public static bool IsValidDecimal(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return true; // 可選欄位
|
||||
|
||||
if (decimal.TryParse(value, out decimal d))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 驗證整數格式
|
||||
/// </summary>
|
||||
public static bool IsValidInt(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return true; // 可選欄位
|
||||
|
||||
if (int.TryParse(value, out int i))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user