リビジョン 208
請求データ作成ツールアップ(テスト中)
| branches/ddl/CreateBilling/CreateBilling/App.config | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
| 2 |
<configuration> |
|
| 3 |
<startup> |
|
| 4 |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|
| 5 |
</startup> |
|
| 6 |
</configuration> |
|
| branches/ddl/CreateBilling/CreateBilling/Common/CommonMotions.cs | ||
|---|---|---|
| 1 |
using System; |
|
| 2 |
using System.Collections.Generic; |
|
| 3 |
using System.Linq; |
|
| 4 |
using System.Text; |
|
| 5 |
using System.Diagnostics; |
|
| 6 |
using System.Windows.Forms; |
|
| 7 |
using System.Drawing; |
|
| 8 |
using System.IO; |
|
| 9 |
using System.Text.RegularExpressions; |
|
| 10 |
using System.Data; |
|
| 11 |
using System.Security.Cryptography; |
|
| 12 |
using System.Globalization; |
|
| 13 |
using System.Runtime.InteropServices; |
|
| 14 |
using System.Collections; |
|
| 15 |
|
|
| 16 |
using Microsoft.VisualBasic; //for StrConv |
|
| 17 |
|
|
| 18 |
using log4net; |
|
| 19 |
using log4net.Appender; |
|
| 20 |
using log4net.Repository.Hierarchy; |
|
| 21 |
|
|
| 22 |
using ProcessManagement.DataModel; |
|
| 23 |
using ProcessManagement.DB.IOAccess; |
|
| 24 |
|
|
| 25 |
namespace ProcessManagement.Common |
|
| 26 |
{
|
|
| 27 |
/// <summary> |
|
| 28 |
/// 工事管理システム共通クラス |
|
| 29 |
/// </summary> |
|
| 30 |
public static class CommonMotions |
|
| 31 |
{
|
|
| 32 |
#region 定義部 |
|
| 33 |
/// <summary> |
|
| 34 |
/// log4netログを使用する |
|
| 35 |
/// </summary> |
|
| 36 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
| 37 |
#endregion |
|
| 38 |
|
|
| 39 |
#region 変数 |
|
| 40 |
/// <summary> |
|
| 41 |
/// 定義ファイル読込クラス定義 |
|
| 42 |
/// </summary> |
|
| 43 |
//private static DefinitionFileRead m_dfr_model = null; |
|
| 44 |
|
|
| 45 |
/// <summary> |
|
| 46 |
/// 管理マスタデータ保持領域 |
|
| 47 |
/// </summary> |
|
| 48 |
private static SystemMaster m_systemMaster = new SystemMaster(); |
|
| 49 |
|
|
| 50 |
/// <summary> |
|
| 51 |
/// ログインユーザー担当者データ |
|
| 52 |
/// </summary> |
|
| 53 |
private static PersonInChargeMaster m_LoginUserData = new PersonInChargeMaster(); |
|
| 54 |
|
|
| 55 |
/// <summary> |
|
| 56 |
/// ログインユーザー参照部署データ |
|
| 57 |
/// </summary> |
|
| 58 |
private static List<PersonDepartmentMaster> m_LoginUserDepartment = new List<PersonDepartmentMaster>(); |
|
| 59 |
|
|
| 60 |
/// <summary> |
|
| 61 |
/// ログインユーザーセキュリティ区分 |
|
| 62 |
/// </summary> |
|
| 63 |
private static SecurityMaster m_LoginUserSecurity = new SecurityMaster(); |
|
| 64 |
|
|
| 65 |
/// <summary> |
|
| 66 |
/// ログインユーザー処理起動区分 |
|
| 67 |
/// </summary> |
|
| 68 |
private static List<ProcessExcute> m_LoginUserProcExe = new List<ProcessExcute>(); |
|
| 69 |
|
|
| 70 |
/// <summary> |
|
| 71 |
/// システム初回起動チェック処理クラス |
|
| 72 |
/// </summary> |
|
| 73 |
//private static ClsSystemOnceExecute m_CheckProc = null; |
|
| 74 |
|
|
| 75 |
/// <summary> |
|
| 76 |
/// 製品ファイルバージョン格納エリア |
|
| 77 |
/// </summary> |
|
| 78 |
private static FileVersionInfo m_ProductVersionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); |
|
| 79 |
|
|
| 80 |
#endregion |
|
| 81 |
|
|
| 82 |
#region コンストラクタ |
|
| 83 |
/// <summary> |
|
| 84 |
/// 何もしない |
|
| 85 |
/// </summary> |
|
| 86 |
#endregion |
|
| 87 |
|
|
| 88 |
#region プロパティ |
|
| 89 |
/// <summary> |
|
| 90 |
/// 本稼働フラグ |
|
| 91 |
/// </summary> |
|
| 92 |
public static bool ProductionExecution |
|
| 93 |
{
|
|
| 94 |
get { return CommonDefine.m_ProductionExecution; }
|
|
| 95 |
} |
|
| 96 |
/// <summary> |
|
| 97 |
/// 定義ファイル読込クラス |
|
| 98 |
/// </summary> |
|
| 99 |
//public static DefinitionFileRead DFRModel |
|
| 100 |
//{
|
|
| 101 |
// get { return m_dfr_model; }
|
|
| 102 |
//} |
|
| 103 |
|
|
| 104 |
/// <summary> |
|
| 105 |
/// 管理マスタデータ |
|
| 106 |
/// </summary> |
|
| 107 |
public static SystemMaster SystemMasterData |
|
| 108 |
{
|
|
| 109 |
get { return m_systemMaster; }
|
|
| 110 |
set { m_systemMaster = value; }
|
|
| 111 |
} |
|
| 112 |
|
|
| 113 |
/// <summary> |
|
| 114 |
/// ログインユーザー担当者データ |
|
| 115 |
/// </summary> |
|
| 116 |
public static PersonInChargeMaster LoginUserData |
|
| 117 |
{
|
|
| 118 |
get { return m_LoginUserData; }
|
|
| 119 |
set { m_LoginUserData = value; }
|
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
/// <summary> |
|
| 123 |
/// ログインユーザー参照部署データ |
|
| 124 |
/// </summary> |
|
| 125 |
public static List<PersonDepartmentMaster> LoginUserDepartment |
|
| 126 |
{
|
|
| 127 |
get { return m_LoginUserDepartment; }
|
|
| 128 |
set { m_LoginUserDepartment = value; }
|
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
/// <summary> |
|
| 132 |
/// ログインユーザーセキュリティ区分 |
|
| 133 |
/// </summary> |
|
| 134 |
public static SecurityMaster LoginUserSecurity |
|
| 135 |
{
|
|
| 136 |
get { return m_LoginUserSecurity; }
|
|
| 137 |
set { m_LoginUserSecurity = value; }
|
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
/// <summary> |
|
| 141 |
/// ログインユーザー処理起動区分 |
|
| 142 |
/// </summary> |
|
| 143 |
public static List<ProcessExcute> LoginUserProcExe |
|
| 144 |
{
|
|
| 145 |
get { return m_LoginUserProcExe; }
|
|
| 146 |
set { m_LoginUserProcExe = value; }
|
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
/// <summary> |
|
| 150 |
/// 製品ファイルバージョン格納エリア |
|
| 151 |
/// </summary> |
|
| 152 |
public static FileVersionInfo ProductVersionInfo |
|
| 153 |
{
|
|
| 154 |
get { return m_ProductVersionInfo; }
|
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
/// <summary> |
|
| 158 |
/// システム起動チェック処理クラス |
|
| 159 |
/// </summary> |
|
| 160 |
//public static ClsSystemOnceExecute CheckProc |
|
| 161 |
//{
|
|
| 162 |
// get { return m_CheckProc; }
|
|
| 163 |
//} |
|
| 164 |
|
|
| 165 |
#endregion |
|
| 166 |
|
|
| 167 |
#region 初期化 |
|
| 168 |
/// <summary> |
|
| 169 |
/// 初期化 |
|
| 170 |
/// </summary> |
|
| 171 |
//public static void Initialize() |
|
| 172 |
//{
|
|
| 173 |
// try |
|
| 174 |
// {
|
|
| 175 |
// // 定義ファイル読込 |
|
| 176 |
// DefinitionFileInit(); |
|
| 177 |
|
|
| 178 |
// // 他共通クラス初期化 |
|
| 179 |
// DBCommon.Instance.Initialize(); |
|
| 180 |
|
|
| 181 |
// // 管理マスタ取得 |
|
| 182 |
// SetSystemMaster(); |
|
| 183 |
|
|
| 184 |
// // 起動チェッククラス初期化 |
|
| 185 |
// m_CheckProc = new ClsSystemOnceExecute(); |
|
| 186 |
// } |
|
| 187 |
// catch (Exception ex) |
|
| 188 |
// {
|
|
| 189 |
// logger.ErrorFormat("初期化エラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 190 |
// } |
|
| 191 |
//} |
|
| 192 |
#endregion |
|
| 193 |
|
|
| 194 |
#region 定義ファイル読込 |
|
| 195 |
///// <summary> |
|
| 196 |
///// 定義ファイル読込 |
|
| 197 |
///// </summary> |
|
| 198 |
//private static void DefinitionFileInit() |
|
| 199 |
//{
|
|
| 200 |
// try |
|
| 201 |
// {
|
|
| 202 |
// //定義ファイル読込 |
|
| 203 |
// System.IO.FileStream fs = new System.IO.FileStream(CommonDefine.s_DefinitionFileName, System.IO.FileMode.Open); |
|
| 204 |
// System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(DefinitionFileRead)); |
|
| 205 |
// m_dfr_model = (DefinitionFileRead)serializer.Deserialize(fs); |
|
| 206 |
// } |
|
| 207 |
// catch (Exception ex) |
|
| 208 |
// {
|
|
| 209 |
// logger.ErrorFormat("定義ファイル読込エラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 210 |
// } |
|
| 211 |
//} |
|
| 212 |
|
|
| 213 |
#endregion |
|
| 214 |
|
|
| 215 |
#region 管理マスタ取得 |
|
| 216 |
/// <summary> |
|
| 217 |
/// 管理マスタ取得 |
|
| 218 |
/// </summary> |
|
| 219 |
public static bool SetSystemMaster() |
|
| 220 |
{
|
|
| 221 |
// 管理マスタクラス |
|
| 222 |
IOMSystem ocDB = new IOMSystem(); |
|
| 223 |
try |
|
| 224 |
{
|
|
| 225 |
// 管理マスタ取得 |
|
| 226 |
// 1レコードだけなので取り出す |
|
| 227 |
string strSQL = " Where SystemCode = 1"; |
|
| 228 |
if (!ocDB.SelectAction(strSQL, ref m_systemMaster)) return false; |
|
| 229 |
|
|
| 230 |
return true; |
|
| 231 |
} |
|
| 232 |
catch (Exception ex) |
|
| 233 |
{
|
|
| 234 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 235 |
return false; |
|
| 236 |
} |
|
| 237 |
finally |
|
| 238 |
{
|
|
| 239 |
ocDB.close(); ocDB = null; |
|
| 240 |
} |
|
| 241 |
} |
|
| 242 |
#endregion |
|
| 243 |
|
|
| 244 |
#region メソッド名を取得する |
|
| 245 |
/// <summary> |
|
| 246 |
/// メソッド名を取得する |
|
| 247 |
/// </summary> |
|
| 248 |
/// <param name="StackCnt"></param> |
|
| 249 |
/// <returns></returns> |
|
| 250 |
public static string GetMethodName(int stackCnt = 1) |
|
| 251 |
{
|
|
| 252 |
try |
|
| 253 |
{
|
|
| 254 |
StringBuilder sb = new StringBuilder(); |
|
| 255 |
|
|
| 256 |
// 一つ前のスタック情報 |
|
| 257 |
StackFrame stackFrame = new StackFrame(stackCnt); |
|
| 258 |
|
|
| 259 |
// 呼び出し元メソッドの情報出力 |
|
| 260 |
System.Reflection.MethodBase method = stackFrame.GetMethod(); |
|
| 261 |
|
|
| 262 |
// Method取得失敗は戻る |
|
| 263 |
if (method == null) return string.Empty; |
|
| 264 |
|
|
| 265 |
// 正しく取得できているかの判定 |
|
| 266 |
if (method.DeclaringType != null && !string.IsNullOrEmpty(method.DeclaringType.Name)) |
|
| 267 |
{
|
|
| 268 |
// 型名 |
|
| 269 |
sb.AppendFormat("[TYPE]{0}", method.DeclaringType.Name);
|
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
if (!string.IsNullOrEmpty(method.Name)) |
|
| 273 |
{
|
|
| 274 |
// 編集済みの場合は区切りを入れる |
|
| 275 |
if (0 < sb.Length) sb.Append('/');
|
|
| 276 |
|
|
| 277 |
// メソッド名 |
|
| 278 |
sb.AppendFormat("[METHOD]{0}", method.Name);
|
|
| 279 |
} |
|
| 280 |
return sb.ToString(); |
|
| 281 |
} |
|
| 282 |
catch (Exception ex) |
|
| 283 |
{
|
|
| 284 |
logger.ErrorFormat(ex.Message); |
|
| 285 |
} |
|
| 286 |
return string.Empty; |
|
| 287 |
} |
|
| 288 |
#endregion |
|
| 289 |
|
|
| 290 |
#region 日付より年を取得する |
|
| 291 |
/// <summary> |
|
| 292 |
/// 日付より年を取得する |
|
| 293 |
/// </summary> |
|
| 294 |
/// <returns></returns> |
|
| 295 |
public static int DateToPeriodYear(DateTime TargetDate) |
|
| 296 |
{
|
|
| 297 |
try |
|
| 298 |
{
|
|
| 299 |
// 今の年を取得する |
|
| 300 |
int iYear = DateTime.Now.Year; |
|
| 301 |
// 今年の期首日を取得する |
|
| 302 |
DateTime BeginninDate = DateTime.Parse(iYear.ToString() + "/" + CommonMotions.SystemMasterData.BusinessBeginningDate); |
|
| 303 |
// 日付を今年の期首日と比較して小さい場合は今の年より-1して期首年を求める |
|
| 304 |
if (TargetDate.Date < BeginninDate.Date) |
|
| 305 |
--iYear; |
|
| 306 |
|
|
| 307 |
return iYear; |
|
| 308 |
} |
|
| 309 |
catch (Exception ex) |
|
| 310 |
{
|
|
| 311 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 312 |
return 0; |
|
| 313 |
} |
|
| 314 |
} |
|
| 315 |
#endregion |
|
| 316 |
|
|
| 317 |
#region 期数から期の年を取得する |
|
| 318 |
/// <summary> |
|
| 319 |
/// 期数から期の年を取得する |
|
| 320 |
/// </summary> |
|
| 321 |
/// <param name="PeriodCount"></param> |
|
| 322 |
/// <returns></returns> |
|
| 323 |
public static int PeriodCountToYear(int PeriodCount) |
|
| 324 |
{
|
|
| 325 |
try |
|
| 326 |
{
|
|
| 327 |
// 今の年を取得する |
|
| 328 |
int iYear = DateTime.Now.Year; |
|
| 329 |
// 今年の期首日を取得する |
|
| 330 |
DateTime BeginninDate = DateTime.Parse(iYear.ToString() + "/" + CommonMotions.SystemMasterData.BusinessBeginningDate); |
|
| 331 |
// 今日を今年の期首日と比較して小さい場合は今の年より-1して期首年を求める |
|
| 332 |
if (DateTime.Now.Date < BeginninDate.Date) |
|
| 333 |
--iYear; |
|
| 334 |
|
|
| 335 |
// 管理マスタの期数と比較して年を計算する |
|
| 336 |
if (PeriodCount < CommonMotions.SystemMasterData.BusinessPeriod) |
|
| 337 |
{
|
|
| 338 |
iYear -= (CommonMotions.SystemMasterData.BusinessPeriod - PeriodCount); |
|
| 339 |
} |
|
| 340 |
else if (PeriodCount > CommonMotions.SystemMasterData.BusinessPeriod) |
|
| 341 |
{
|
|
| 342 |
iYear += (PeriodCount - CommonMotions.SystemMasterData.BusinessPeriod); |
|
| 343 |
} |
|
| 344 |
|
|
| 345 |
return iYear; |
|
| 346 |
} |
|
| 347 |
catch (Exception ex) |
|
| 348 |
{
|
|
| 349 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 350 |
return 0; |
|
| 351 |
} |
|
| 352 |
} |
|
| 353 |
#endregion |
|
| 354 |
|
|
| 355 |
#region 期の最大・最少を取得する |
|
| 356 |
/// <summary> |
|
| 357 |
/// 期の最大・最少を取得する |
|
| 358 |
/// </summary> |
|
| 359 |
/// <param name="StartDate"></param> |
|
| 360 |
/// <returns></returns> |
|
| 361 |
public static void GetPeriodYear(ref int min, ref int max) |
|
| 362 |
{
|
|
| 363 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
|
| 364 |
try |
|
| 365 |
{
|
|
| 366 |
string strSQL = "SELECT MIN(CONSTRUCTIONPERIOD), MAX(CONSTRUCTIONPERIOD) FROM CONSTRUCTIONBASEINFO"; |
|
| 367 |
ArrayList arList = new ArrayList(); |
|
| 368 |
if (!cbiDB.ExecuteReader(strSQL, ref arList)) return; |
|
| 369 |
object[] wrkobj = (object[])arList[0]; |
|
| 370 |
min = cnvInt(wrkobj[0]); |
|
| 371 |
max = cnvInt(wrkobj[1]); |
|
| 372 |
|
|
| 373 |
} |
|
| 374 |
catch (Exception ex) |
|
| 375 |
{
|
|
| 376 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 377 |
} |
|
| 378 |
finally |
|
| 379 |
{
|
|
| 380 |
cbiDB.close(); cbiDB = null; |
|
| 381 |
} |
|
| 382 |
} |
|
| 383 |
#endregion |
|
| 384 |
|
|
| 385 |
#region データ変換メソッド |
|
| 386 |
#region 西暦を和暦に変換する |
|
| 387 |
/// <summary> |
|
| 388 |
/// 西暦を和暦に変換する |
|
| 389 |
/// </summary> |
|
| 390 |
/// <returns></returns> |
|
| 391 |
public static string cnvJapaneseCalendar(DateTime Terget) |
|
| 392 |
{
|
|
| 393 |
try |
|
| 394 |
{
|
|
| 395 |
CultureInfo culture = new CultureInfo("ja-JP", true);
|
|
| 396 |
culture.DateTimeFormat.Calendar = new JapaneseCalendar(); |
|
| 397 |
|
|
| 398 |
return Terget.ToString("ggyy年M月d日", culture);
|
|
| 399 |
} |
|
| 400 |
catch (Exception ex) |
|
| 401 |
{
|
|
| 402 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 403 |
return string.Empty; |
|
| 404 |
} |
|
| 405 |
} |
|
| 406 |
#endregion |
|
| 407 |
|
|
| 408 |
#region 今の年号を取得する |
|
| 409 |
/// <summary> |
|
| 410 |
/// 今の年号を取得する |
|
| 411 |
/// </summary> |
|
| 412 |
/// <returns></returns> |
|
| 413 |
public static string GetNameOfAnEra(DateTime TargetDate) |
|
| 414 |
{
|
|
| 415 |
try |
|
| 416 |
{
|
|
| 417 |
string strRet = string.Empty; |
|
| 418 |
|
|
| 419 |
CultureInfo culture = new CultureInfo("ja-JP", true);
|
|
| 420 |
culture.DateTimeFormat.Calendar = new JapaneseCalendar(); |
|
| 421 |
|
|
| 422 |
string result = TargetDate.ToString("ggyy年M月d日", culture);
|
|
| 423 |
|
|
| 424 |
int strLength = 0; |
|
| 425 |
foreach (char c in result) |
|
| 426 |
{
|
|
| 427 |
if (char.IsNumber(c)) break; |
|
| 428 |
|
|
| 429 |
strLength++; |
|
| 430 |
} |
|
| 431 |
|
|
| 432 |
strRet = result.Substring(0, strLength); |
|
| 433 |
|
|
| 434 |
return strRet; |
|
| 435 |
} |
|
| 436 |
catch (Exception ex) |
|
| 437 |
{
|
|
| 438 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 439 |
return string.Empty; |
|
| 440 |
} |
|
| 441 |
} |
|
| 442 |
#endregion |
|
| 443 |
|
|
| 444 |
#region Int値より文字列に変化して指定位置に指定文字を入れる。(工事番号編集) |
|
| 445 |
/// <summary> |
|
| 446 |
/// Int値より文字列に変化して指定位置に指定文字を入れる。 |
|
| 447 |
/// </summary> |
|
| 448 |
/// <param name="strCode"></param> |
|
| 449 |
/// <returns></returns> |
|
| 450 |
public static string cnvStringCodeFromInt(int IntCode, string strCode, int iPoint) |
|
| 451 |
{
|
|
| 452 |
try |
|
| 453 |
{
|
|
| 454 |
// 文字列変換 |
|
| 455 |
string strWork = IntCode.ToString(); |
|
| 456 |
// 指定位置が文字列長を超えている場合はエラー |
|
| 457 |
if (strWork.Length <= iPoint) return string.Empty; |
|
| 458 |
// 文字挿入 |
|
| 459 |
strWork = strWork.Substring(0, iPoint) + strCode + strWork.Substring(iPoint); |
|
| 460 |
return strWork; |
|
| 461 |
} |
|
| 462 |
catch (System.Exception ex) |
|
| 463 |
{
|
|
| 464 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 465 |
return string.Empty; |
|
| 466 |
} |
|
| 467 |
} |
|
| 468 |
#endregion |
|
| 469 |
|
|
| 470 |
#region 文字列より指定文字を除去してInt値に変換する |
|
| 471 |
/// <summary> |
|
| 472 |
/// 文字列より指定文字を除去してInt値に変換する |
|
| 473 |
/// </summary> |
|
| 474 |
/// <param name="strCode"></param> |
|
| 475 |
/// <returns></returns> |
|
| 476 |
public static int cnvIntFromStringCode(string strCode, string strRemove) |
|
| 477 |
{
|
|
| 478 |
try |
|
| 479 |
{
|
|
| 480 |
// 文字列除去後変換 |
|
| 481 |
return cnvInt(strCode.Replace(strRemove, "")); |
|
| 482 |
} |
|
| 483 |
catch (System.Exception ex) |
|
| 484 |
{
|
|
| 485 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 486 |
return 0; |
|
| 487 |
} |
|
| 488 |
} |
|
| 489 |
#endregion |
|
| 490 |
|
|
| 491 |
#region 日付返還変換 |
|
| 492 |
/// <summary> |
|
| 493 |
/// 日付返還変換 |
|
| 494 |
/// </summary> |
|
| 495 |
/// <param name="sendData"></param> |
|
| 496 |
/// <returns></returns> |
|
| 497 |
public static DateTime cnvDate(object sendData) |
|
| 498 |
{
|
|
| 499 |
DateTime dtDateWork = DateTime.MinValue; |
|
| 500 |
try |
|
| 501 |
{
|
|
| 502 |
// 空判定 |
|
| 503 |
if (sendData == null) return dtDateWork; |
|
| 504 |
if (sendData.ToString().Length == 0) return dtDateWork; |
|
| 505 |
|
|
| 506 |
// 変換 |
|
| 507 |
bool bRet = DateTime.TryParse(sendData.ToString(), out dtDateWork); |
|
| 508 |
|
|
| 509 |
return dtDateWork; |
|
| 510 |
} |
|
| 511 |
catch (System.Exception ex) |
|
| 512 |
{
|
|
| 513 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 514 |
return dtDateWork; |
|
| 515 |
} |
|
| 516 |
} |
|
| 517 |
#endregion |
|
| 518 |
|
|
| 519 |
#region 文字列より数値変換(long) |
|
| 520 |
/// <summary> |
|
| 521 |
/// 文字列より数値変換(long) |
|
| 522 |
/// </summary> |
|
| 523 |
/// <param name="sendData"></param> |
|
| 524 |
/// <returns></returns> |
|
| 525 |
public static long cnvLong(object sendData) |
|
| 526 |
{
|
|
| 527 |
try |
|
| 528 |
{
|
|
| 529 |
long retData = 0; |
|
| 530 |
|
|
| 531 |
// 空判定 |
|
| 532 |
if (sendData == null) return retData; |
|
| 533 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 534 |
|
|
| 535 |
// 変換 |
|
| 536 |
long.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 537 |
|
|
| 538 |
return retData; |
|
| 539 |
} |
|
| 540 |
catch (System.Exception ex) |
|
| 541 |
{
|
|
| 542 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 543 |
return 0; |
|
| 544 |
} |
|
| 545 |
} |
|
| 546 |
#endregion |
|
| 547 |
|
|
| 548 |
#region 文字列より数値変換(int) |
|
| 549 |
/// <summary> |
|
| 550 |
/// 文字列より数値変換(int) |
|
| 551 |
/// </summary> |
|
| 552 |
/// <param name="sendData"></param> |
|
| 553 |
/// <returns></returns> |
|
| 554 |
public static int cnvInt(object sendData) |
|
| 555 |
{
|
|
| 556 |
try |
|
| 557 |
{
|
|
| 558 |
int retData = 0; |
|
| 559 |
|
|
| 560 |
// 空判定 |
|
| 561 |
if (sendData == null) return retData; |
|
| 562 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 563 |
|
|
| 564 |
// 変換 |
|
| 565 |
int.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 566 |
|
|
| 567 |
return retData; |
|
| 568 |
} |
|
| 569 |
catch (System.Exception ex) |
|
| 570 |
{
|
|
| 571 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 572 |
return 0; |
|
| 573 |
} |
|
| 574 |
} |
|
| 575 |
#endregion |
|
| 576 |
|
|
| 577 |
#region 文字列より数値変換(string) |
|
| 578 |
/// <summary> |
|
| 579 |
/// 文字列より数値変換(string) |
|
| 580 |
/// </summary> |
|
| 581 |
/// <param name="sendData"></param> |
|
| 582 |
/// <returns></returns> |
|
| 583 |
public static string cnvString(object sendData) |
|
| 584 |
{
|
|
| 585 |
try |
|
| 586 |
{
|
|
| 587 |
string retData = string.Empty; |
|
| 588 |
|
|
| 589 |
// 空判定 |
|
| 590 |
if (sendData == null) return retData; |
|
| 591 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 592 |
|
|
| 593 |
|
|
| 594 |
// 変換 |
|
| 595 |
retData = sendData.ToString(); |
|
| 596 |
|
|
| 597 |
return retData; |
|
| 598 |
} |
|
| 599 |
catch (System.Exception ex) |
|
| 600 |
{
|
|
| 601 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 602 |
return ""; |
|
| 603 |
} |
|
| 604 |
} |
|
| 605 |
#endregion |
|
| 606 |
|
|
| 607 |
#region 文字列より数値変換(double) |
|
| 608 |
/// <summary> |
|
| 609 |
/// 文字列より数値変換(double) |
|
| 610 |
/// </summary> |
|
| 611 |
/// <param name="sendData"></param> |
|
| 612 |
/// <returns></returns> |
|
| 613 |
public static double cnvDouble(object sendData) |
|
| 614 |
{
|
|
| 615 |
try |
|
| 616 |
{
|
|
| 617 |
double retData = 0; |
|
| 618 |
|
|
| 619 |
// 空判定 |
|
| 620 |
if (sendData == null) return retData; |
|
| 621 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 622 |
|
|
| 623 |
|
|
| 624 |
// 変換 |
|
| 625 |
double.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 626 |
|
|
| 627 |
return retData; |
|
| 628 |
} |
|
| 629 |
catch (System.Exception ex) |
|
| 630 |
{
|
|
| 631 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 632 |
return 0; |
|
| 633 |
} |
|
| 634 |
} |
|
| 635 |
#endregion |
|
| 636 |
|
|
| 637 |
#region 文字列より数値変換(float) |
|
| 638 |
/// <summary> |
|
| 639 |
/// 文字列より数値変換(float) |
|
| 640 |
/// </summary> |
|
| 641 |
/// <param name="sendData"></param> |
|
| 642 |
/// <returns></returns> |
|
| 643 |
public static float cnvFloat(object sendData) |
|
| 644 |
{
|
|
| 645 |
try |
|
| 646 |
{
|
|
| 647 |
float retData = 0; |
|
| 648 |
|
|
| 649 |
// 空判定 |
|
| 650 |
if (sendData == null) return retData; |
|
| 651 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 652 |
|
|
| 653 |
|
|
| 654 |
// 変換 |
|
| 655 |
float.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 656 |
|
|
| 657 |
return retData; |
|
| 658 |
} |
|
| 659 |
catch (System.Exception ex) |
|
| 660 |
{
|
|
| 661 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 662 |
return 0; |
|
| 663 |
} |
|
| 664 |
} |
|
| 665 |
#endregion |
|
| 666 |
|
|
| 667 |
#region 文字列より数値変換(decimal) |
|
| 668 |
/// <summary> |
|
| 669 |
/// 文字列より数値変換(decimal) |
|
| 670 |
/// </summary> |
|
| 671 |
/// <param name="sendData"></param> |
|
| 672 |
/// <returns></returns> |
|
| 673 |
public static decimal cnvDecimal(object sendData) |
|
| 674 |
{
|
|
| 675 |
try |
|
| 676 |
{
|
|
| 677 |
decimal retData = 0; |
|
| 678 |
|
|
| 679 |
// 空判定 |
|
| 680 |
if (sendData == null) return retData; |
|
| 681 |
if (sendData.ToString().Trim().Length == 0) return retData; |
|
| 682 |
|
|
| 683 |
|
|
| 684 |
// 変換 |
|
| 685 |
decimal.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 686 |
|
|
| 687 |
return retData; |
|
| 688 |
} |
|
| 689 |
catch (System.Exception ex) |
|
| 690 |
{
|
|
| 691 |
Console.WriteLine("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 692 |
return 0; |
|
| 693 |
} |
|
| 694 |
} |
|
| 695 |
#endregion |
|
| 696 |
|
|
| 697 |
#region 四捨五入 |
|
| 698 |
/// <summary> |
|
| 699 |
/// 四捨五入 |
|
| 700 |
/// </summary> |
|
| 701 |
/// <param name="InputData"></param> |
|
| 702 |
/// <returns></returns> |
|
| 703 |
public static int cnvRound(double InputData) |
|
| 704 |
{
|
|
| 705 |
int retRoundData = 0; |
|
| 706 |
try |
|
| 707 |
{
|
|
| 708 |
retRoundData = (int)Math.Round(InputData, MidpointRounding.AwayFromZero); |
|
| 709 |
|
|
| 710 |
return retRoundData; |
|
| 711 |
} |
|
| 712 |
catch (System.Exception ex) |
|
| 713 |
{
|
|
| 714 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 715 |
return retRoundData; |
|
| 716 |
} |
|
| 717 |
} |
|
| 718 |
#endregion |
|
| 719 |
|
|
| 720 |
#region 切り上げ |
|
| 721 |
/// <summary> |
|
| 722 |
/// 切り上げ |
|
| 723 |
/// </summary> |
|
| 724 |
/// <param name="InputData"></param> |
|
| 725 |
/// <returns></returns> |
|
| 726 |
public static int cnvRoundUp(double InputData) |
|
| 727 |
{
|
|
| 728 |
int retRoundData = 0; |
|
| 729 |
try |
|
| 730 |
{
|
|
| 731 |
retRoundData = (int)Math.Ceiling(InputData); |
|
| 732 |
|
|
| 733 |
return retRoundData; |
|
| 734 |
} |
|
| 735 |
catch (System.Exception ex) |
|
| 736 |
{
|
|
| 737 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 738 |
return retRoundData; |
|
| 739 |
} |
|
| 740 |
} |
|
| 741 |
#endregion |
|
| 742 |
|
|
| 743 |
#region 切り捨て |
|
| 744 |
/// <summary> |
|
| 745 |
/// 切り捨て |
|
| 746 |
/// </summary> |
|
| 747 |
/// <param name="InputData"></param> |
|
| 748 |
/// <returns></returns> |
|
| 749 |
public static int cnvTruncate(double InputData) |
|
| 750 |
{
|
|
| 751 |
int retRoundData = 0; |
|
| 752 |
try |
|
| 753 |
{
|
|
| 754 |
retRoundData = (int)Math.Truncate(InputData); |
|
| 755 |
|
|
| 756 |
return retRoundData; |
|
| 757 |
} |
|
| 758 |
catch (System.Exception ex) |
|
| 759 |
{
|
|
| 760 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 761 |
return retRoundData; |
|
| 762 |
} |
|
| 763 |
} |
|
| 764 |
#endregion |
|
| 765 |
|
|
| 766 |
#region 四捨五入(四捨五入位置指定) |
|
| 767 |
/// <summary> |
|
| 768 |
/// 四捨五入(四捨五入位置指定) |
|
| 769 |
/// </summary> |
|
| 770 |
/// <param name="value"></param> |
|
| 771 |
/// <param name="pos"></param> |
|
| 772 |
/// <returns></returns> |
|
| 773 |
public static int IntRound(double value, int pos) |
|
| 774 |
{
|
|
| 775 |
// 何乗かを求める |
|
| 776 |
int posion = (int)Math.Pow(10, (pos + 1)); |
|
| 777 |
|
|
| 778 |
int upperval = (int)(value / posion); |
|
| 779 |
upperval *= posion; |
|
| 780 |
int lowerval = (int)(value % posion); |
|
| 781 |
int chkval = (int)(lowerval / Math.Pow(10, pos)); |
|
| 782 |
if (chkval > 4) upperval += (1 * posion); |
|
| 783 |
|
|
| 784 |
return upperval; |
|
| 785 |
} |
|
| 786 |
#endregion |
|
| 787 |
|
|
| 788 |
#region 切り捨て(切り捨て位置指定) |
|
| 789 |
/// <summary> |
|
| 790 |
/// 切り捨て(切り捨て位置指定) |
|
| 791 |
/// </summary> |
|
| 792 |
/// <param name="value"></param> |
|
| 793 |
/// <param name="pos"></param> |
|
| 794 |
/// <returns></returns> |
|
| 795 |
public static int IntRoundDown(double value, int pos) |
|
| 796 |
{
|
|
| 797 |
// 何乗かを求める |
|
| 798 |
int posion = (int)Math.Pow(10, (pos + 1)); |
|
| 799 |
|
|
| 800 |
int upperval = (int)(value / posion); |
|
| 801 |
upperval *= posion; |
|
| 802 |
|
|
| 803 |
return upperval; |
|
| 804 |
} |
|
| 805 |
#endregion |
|
| 806 |
|
|
| 807 |
#region 切り上げ(切り上げ位置指定) |
|
| 808 |
/// <summary> |
|
| 809 |
/// 切り上げ(切り上げ位置指定) |
|
| 810 |
/// </summary> |
|
| 811 |
/// <param name="value"></param> |
|
| 812 |
/// <param name="pos"></param> |
|
| 813 |
/// <returns></returns> |
|
| 814 |
public static int IntRoundUp(double value, int pos) |
|
| 815 |
{
|
|
| 816 |
// 何乗かを求める |
|
| 817 |
int posion = (int)Math.Pow(10, (pos + 1)); |
|
| 818 |
|
|
| 819 |
int upperval = (int)(value / posion); |
|
| 820 |
upperval *= posion; |
|
| 821 |
int lowerval = (int)(value % posion); |
|
| 822 |
int chkval = (int)(lowerval / Math.Pow(10, pos)); |
|
| 823 |
if (chkval > 0) upperval += (1 * posion); |
|
| 824 |
|
|
| 825 |
return upperval; |
|
| 826 |
} |
|
| 827 |
#endregion |
|
| 828 |
|
|
| 829 |
#region 0~26までの数字をA~Zに変換する |
|
| 830 |
/// <summary> |
|
| 831 |
/// 0~26までの数字をA~Zに変換する |
|
| 832 |
/// </summary> |
|
| 833 |
/// <param name="num"></param> |
|
| 834 |
/// <returns></returns> |
|
| 835 |
public static string cnvNumberToAlphaCharacter(int num) |
|
| 836 |
{
|
|
| 837 |
try |
|
| 838 |
{
|
|
| 839 |
// ----- 16進数文字列 -> 数値 |
|
| 840 |
int CnvCode = Convert.ToInt32("0041", 16); // 'A'
|
|
| 841 |
int LastCode = Convert.ToInt32("005A", 16); // 'Z'
|
|
| 842 |
|
|
| 843 |
// 'Z'を超えたら余剰を使って変換する |
|
| 844 |
int work = (CnvCode + num); |
|
| 845 |
if (work <= LastCode) |
|
| 846 |
{
|
|
| 847 |
// 変換値を加算する |
|
| 848 |
CnvCode += num; |
|
| 849 |
} |
|
| 850 |
else |
|
| 851 |
{
|
|
| 852 |
CnvCode += (work % LastCode); |
|
| 853 |
} |
|
| 854 |
// 'Z'を超えたら採番しない |
|
| 855 |
//if (CnvCode > LastCode) return string.Empty; |
|
| 856 |
|
|
| 857 |
// 数値(文字コード) -> 文字 |
|
| 858 |
char c = Convert.ToChar(CnvCode); |
|
| 859 |
// 英字「文字列」 |
|
| 860 |
string newChar = c.ToString(); |
|
| 861 |
|
|
| 862 |
return newChar; |
|
| 863 |
} |
|
| 864 |
catch (System.Exception ex) |
|
| 865 |
{
|
|
| 866 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 867 |
return ""; |
|
| 868 |
} |
|
| 869 |
} |
|
| 870 |
#endregion |
|
| 871 |
|
|
| 872 |
#region 日付が最小値ならば"未定"文字を返す |
|
| 873 |
/// <summary> |
|
| 874 |
/// 日付が最小値ならば"未定"文字を返す |
|
| 875 |
/// </summary> |
|
| 876 |
/// <param name="srcDate"></param> |
|
| 877 |
/// <returns></returns> |
|
| 878 |
public static string cnvDateToUndecidedString(DateTime srcDate) |
|
| 879 |
{
|
|
| 880 |
try |
|
| 881 |
{
|
|
| 882 |
string work = ""; |
|
| 883 |
if (srcDate.Equals(DateTime.MinValue)) |
|
| 884 |
work = CommonDefine.s_UndecidedString; |
|
| 885 |
else |
|
| 886 |
work = srcDate.ToShortDateString(); |
|
| 887 |
|
|
| 888 |
return work; |
|
| 889 |
} |
|
| 890 |
catch (System.Exception ex) |
|
| 891 |
{
|
|
| 892 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 893 |
return ""; |
|
| 894 |
} |
|
| 895 |
} |
|
| 896 |
#endregion |
|
| 897 |
|
|
| 898 |
#region 文字列から日付を返す(文字列が"未定"文字ならば日付最小値を返す) |
|
| 899 |
/// <summary> |
|
| 900 |
/// 文字列から日付を返す |
|
| 901 |
/// 文字列が"未定"文字ならば日付最小値を返す |
|
| 902 |
/// </summary> |
|
| 903 |
/// <param name="srcDate"></param> |
|
| 904 |
/// <returns></returns> |
|
| 905 |
public static DateTime cnvUndecidedStringToDate(object srcDate) |
|
| 906 |
{
|
|
| 907 |
DateTime work = DateTime.MinValue; |
|
| 908 |
try |
|
| 909 |
{
|
|
| 910 |
if (!srcDate.Equals(CommonDefine.s_UndecidedString)) |
|
| 911 |
work = cnvDate(srcDate); |
|
| 912 |
|
|
| 913 |
return work; |
|
| 914 |
} |
|
| 915 |
catch (System.Exception ex) |
|
| 916 |
{
|
|
| 917 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 918 |
return work; |
|
| 919 |
} |
|
| 920 |
} |
|
| 921 |
#endregion |
|
| 922 |
|
|
| 923 |
#region 文字列から数値(文字列が"未定"文字ならば0を返す) |
|
| 924 |
/// <summary> |
|
| 925 |
/// 文字列から数値 |
|
| 926 |
/// 文字列が"未定"文字ならば0を返す |
|
| 927 |
/// </summary> |
|
| 928 |
/// <param name="srcDate"></param> |
|
| 929 |
/// <returns></returns> |
|
| 930 |
public static double cnvUndecidedStringToDouble(object srcDate) |
|
| 931 |
{
|
|
| 932 |
double work = 0; |
|
| 933 |
try |
|
| 934 |
{
|
|
| 935 |
if (!srcDate.Equals(CommonDefine.s_UndecidedString)) |
|
| 936 |
work = cnvDouble(srcDate); |
|
| 937 |
|
|
| 938 |
return work; |
|
| 939 |
} |
|
| 940 |
catch (System.Exception ex) |
|
| 941 |
{
|
|
| 942 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 943 |
return work; |
|
| 944 |
} |
|
| 945 |
} |
|
| 946 |
#endregion |
|
| 947 |
|
|
| 948 |
#region 色指定文字列より色を返す |
|
| 949 |
/// <summary> |
|
| 950 |
/// 色指定文字列より色を返す |
|
| 951 |
/// </summary> |
|
| 952 |
/// <param name="strColor"></param> |
|
| 953 |
/// <returns></returns> |
|
| 954 |
public static Color cnvStringToColor(string strColor) |
|
| 955 |
{
|
|
| 956 |
Color ColorRet = Color.White; |
|
| 957 |
try |
|
| 958 |
{
|
|
| 959 |
// 色文字列チェック |
|
| 960 |
if (!CommonMotions.chkObjectIsNull(strColor) && strColor.Length != 0) |
|
| 961 |
{
|
|
| 962 |
ColorRet = ColorTranslator.FromHtml(strColor); |
|
| 963 |
} |
|
| 964 |
return ColorRet; |
|
| 965 |
} |
|
| 966 |
catch (System.Exception ex) |
|
| 967 |
{
|
|
| 968 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 969 |
return ColorRet; |
|
| 970 |
} |
|
| 971 |
} |
|
| 972 |
#endregion |
|
| 973 |
|
|
| 974 |
#region 色指定文字列より色を返す・設定無しは指定場所のデフォルトを返す |
|
| 975 |
/// <summary> |
|
| 976 |
/// 色指定文字列より色を返す・設定無しは指定場所のデフォルトを返す |
|
| 977 |
/// </summary> |
|
| 978 |
/// <param name="strColor"></param> |
|
| 979 |
/// <param name="point"></param> |
|
| 980 |
/// <returns></returns> |
|
| 981 |
public static Color getBackForeColor(string strColor, CommonDefine.PalceOfColor point) |
|
| 982 |
{
|
|
| 983 |
Color ColorRet = Color.White; |
|
| 984 |
try |
|
| 985 |
{
|
|
| 986 |
// デフォルトセット |
|
| 987 |
if (point == CommonDefine.PalceOfColor.BackColor) |
|
| 988 |
{ // 背景
|
|
| 989 |
ColorRet = Color.White; |
|
| 990 |
} |
|
| 991 |
else if (point == CommonDefine.PalceOfColor.ForeColor) |
|
| 992 |
{ // 文字色
|
|
| 993 |
ColorRet = Color.Black; |
|
| 994 |
} |
|
| 995 |
else |
|
| 996 |
{
|
|
| 997 |
ColorRet = Color.Transparent; |
|
| 998 |
} |
|
| 999 |
|
|
| 1000 |
if (!chkObjectIsNull(strColor) && strColor.Length != 0) |
|
| 1001 |
{
|
|
| 1002 |
} |
|
| 1003 |
else |
|
| 1004 |
{
|
|
| 1005 |
strColor = String.Format("0x{0:X2}{1:X2}{2:X2}", ColorRet.R, ColorRet.G, ColorRet.B);
|
|
| 1006 |
} |
|
| 1007 |
|
|
| 1008 |
ColorRet = cnvStringToColor(strColor); |
|
| 1009 |
|
|
| 1010 |
return ColorRet; |
|
| 1011 |
} |
|
| 1012 |
catch (System.Exception ex) |
|
| 1013 |
{
|
|
| 1014 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1015 |
return ColorRet; |
|
| 1016 |
} |
|
| 1017 |
} |
|
| 1018 |
#endregion |
|
| 1019 |
|
|
| 1020 |
#region 補色を取得する |
|
| 1021 |
/// <summary> |
|
| 1022 |
/// 補色を取得する |
|
| 1023 |
/// </summary> |
|
| 1024 |
/// <param name="color"></param> |
|
| 1025 |
/// <returns></returns> |
|
| 1026 |
public static Color GetComplementaryColor(Color color) |
|
| 1027 |
{
|
|
| 1028 |
try |
|
| 1029 |
{
|
|
| 1030 |
byte r = (byte)~color.R; |
|
| 1031 |
byte g = (byte)~color.G; |
|
| 1032 |
byte b = (byte)~color.B; |
|
| 1033 |
|
|
| 1034 |
return Color.FromArgb(r, g, b); |
|
| 1035 |
} |
|
| 1036 |
catch (System.Exception ex) |
|
| 1037 |
{
|
|
| 1038 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1039 |
return color; |
|
| 1040 |
} |
|
| 1041 |
} |
|
| 1042 |
#endregion |
|
| 1043 |
|
|
| 1044 |
#region 指定桁数の数値最大値を返す |
|
| 1045 |
/// <summary> |
|
| 1046 |
/// 指定桁数の数値最大値を返す |
|
| 1047 |
/// </summary> |
|
| 1048 |
/// <param name="NumLen"></param> |
|
| 1049 |
/// <returns></returns> |
|
| 1050 |
public static int CreateMaxNumeric(int NumLen) |
|
| 1051 |
{
|
|
| 1052 |
try |
|
| 1053 |
{
|
|
| 1054 |
string strNum = string.Empty; |
|
| 1055 |
for (int i = 0; i < NumLen; i++) |
|
| 1056 |
{
|
|
| 1057 |
strNum += "9"; |
|
| 1058 |
} |
|
| 1059 |
|
|
| 1060 |
return cnvInt(strNum); |
|
| 1061 |
} |
|
| 1062 |
catch (System.Exception ex) |
|
| 1063 |
{
|
|
| 1064 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1065 |
return 0; |
|
| 1066 |
} |
|
| 1067 |
} |
|
| 1068 |
#endregion |
|
| 1069 |
|
|
| 1070 |
#region オブジェクト配列の指定位置よりInt値を取得する |
|
| 1071 |
/// <summary> |
|
| 1072 |
/// オブジェクト配列の指定位置よりInt値を取得する |
|
| 1073 |
/// </summary> |
|
| 1074 |
/// <param name="objArrary"></param> |
|
| 1075 |
/// <param name="DataCnt"></param> |
|
| 1076 |
/// <returns></returns> |
|
| 1077 |
public static int ObjectToInt(object[] objArrary, int DataCnt) |
|
| 1078 |
{
|
|
| 1079 |
int iRet = 0; |
|
| 1080 |
try |
|
| 1081 |
{
|
|
| 1082 |
iRet = CommonMotions.cnvInt(objArrary[DataCnt]); |
|
| 1083 |
|
|
| 1084 |
return iRet; |
|
| 1085 |
} |
|
| 1086 |
catch (Exception ex) |
|
| 1087 |
{
|
|
| 1088 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 1089 |
return iRet; |
|
| 1090 |
} |
|
| 1091 |
} |
|
| 1092 |
#endregion |
|
| 1093 |
|
|
| 1094 |
#region オブジェクト配列の指定位置よりString値を取得する |
|
| 1095 |
/// <summary> |
|
| 1096 |
/// オブジェクト配列の指定位置よりString値を取得する |
|
| 1097 |
/// </summary> |
|
| 1098 |
/// <param name="objArrary"></param> |
|
| 1099 |
/// <param name="DataCnt"></param> |
|
| 1100 |
/// <returns></returns> |
|
| 1101 |
public static string ObjectToString(object[] objArrary, int DataCnt) |
|
| 1102 |
{
|
|
| 1103 |
string strRet = string.Empty; |
|
| 1104 |
try |
|
| 1105 |
{
|
|
| 1106 |
strRet = CommonMotions.cnvString(objArrary[DataCnt]); |
|
| 1107 |
|
|
| 1108 |
return strRet; |
|
| 1109 |
} |
|
| 1110 |
catch (Exception ex) |
|
| 1111 |
{
|
|
| 1112 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 1113 |
return strRet; |
|
| 1114 |
} |
|
| 1115 |
} |
|
| 1116 |
#endregion |
|
| 1117 |
|
|
| 1118 |
#region オブジェクト配列の指定位置よりDateTime値を取得する |
|
| 1119 |
/// <summary> |
|
| 1120 |
/// オブジェクト配列の指定位置よりDateTime値を取得する |
|
| 1121 |
/// </summary> |
|
| 1122 |
/// <param name="objArrary"></param> |
|
| 1123 |
/// <param name="DataCnt"></param> |
|
| 1124 |
/// <returns></returns> |
|
| 1125 |
public static DateTime ObjectToDateTime(object[] objArrary, int DataCnt) |
|
| 1126 |
{
|
|
| 1127 |
DateTime dtRet = DateTime.Now; |
|
| 1128 |
try |
|
| 1129 |
{
|
|
| 1130 |
dtRet = CommonMotions.cnvDate(objArrary[DataCnt]); |
|
| 1131 |
|
|
| 1132 |
return dtRet; |
|
| 1133 |
} |
|
| 1134 |
catch (Exception ex) |
|
| 1135 |
{
|
|
| 1136 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 1137 |
return dtRet; |
|
| 1138 |
} |
|
| 1139 |
} |
|
| 1140 |
#endregion |
|
| 1141 |
|
|
| 1142 |
#region オブジェクト配列の指定位置よりdouble値を取得する |
|
| 1143 |
/// <summary> |
|
| 1144 |
/// オブジェクト配列の指定位置よりdouble値を取得する |
|
| 1145 |
/// </summary> |
|
| 1146 |
/// <param name="objArrary"></param> |
|
| 1147 |
/// <param name="DataCnt"></param> |
|
| 1148 |
/// <returns></returns> |
|
| 1149 |
public static double ObjectToDouble(object[] objArrary, int DataCnt) |
|
| 1150 |
{
|
|
| 1151 |
double dRet = 0; |
|
| 1152 |
try |
|
| 1153 |
{
|
|
| 1154 |
dRet = CommonMotions.cnvDouble(objArrary[DataCnt]); |
|
| 1155 |
|
|
| 1156 |
return dRet; |
|
| 1157 |
} |
|
| 1158 |
catch (Exception ex) |
|
| 1159 |
{
|
|
| 1160 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 1161 |
return dRet; |
|
| 1162 |
} |
|
| 1163 |
} |
|
| 1164 |
#endregion |
|
| 1165 |
|
|
| 1166 |
#endregion |
|
| 1167 |
|
|
| 1168 |
#region データチェックメソッド |
|
| 1169 |
#region ディレクトリの存在チェック |
|
| 1170 |
/// <summary> |
|
| 1171 |
/// ディレクトリの存在チェック |
|
| 1172 |
/// </summary> |
|
| 1173 |
/// <param name="DirectryName">フォルダパス</param> |
|
| 1174 |
/// <returns></returns> |
|
| 1175 |
public static bool ChkDirPath(string DirectryName, bool CreateFlg = false) |
|
| 1176 |
{
|
|
| 1177 |
try |
|
| 1178 |
{
|
|
| 1179 |
// フォルダ (ディレクトリ) が存在しているかどうか確認する |
|
| 1180 |
if (!Directory.Exists(@DirectryName)) |
|
| 1181 |
{
|
|
| 1182 |
// 作成フラグOffならばエラー |
|
| 1183 |
if (!CreateFlg) return false; |
|
| 1184 |
|
|
| 1185 |
// ディレクトリを作成する |
|
| 1186 |
Directory.CreateDirectory(@DirectryName); |
|
| 1187 |
} |
|
| 1188 |
|
|
| 1189 |
return true; |
|
| 1190 |
} |
|
| 1191 |
catch (Exception ex) |
|
| 1192 |
{
|
|
| 1193 |
logger.ErrorFormat(ex.Message); |
|
| 1194 |
return false; |
|
| 1195 |
} |
|
| 1196 |
} |
|
| 1197 |
#endregion |
|
| 1198 |
|
|
| 1199 |
#region オブジェクトのNullチェック |
|
| 1200 |
/// <summary> |
|
| 1201 |
/// オブジェクトのNullチェック |
|
| 1202 |
/// </summary> |
|
| 1203 |
/// <param name="sendData">オブジェクト</param> |
|
| 1204 |
/// <returns></returns> |
|
| 1205 |
public static bool chkObjectIsNull(Object sendData) |
|
| 1206 |
{
|
|
| 1207 |
try |
|
| 1208 |
{
|
|
| 1209 |
if (sendData == null) return true; |
|
| 1210 |
|
|
| 1211 |
return false; |
|
| 1212 |
} |
|
| 1213 |
catch (System.Exception ex) |
|
| 1214 |
{
|
|
| 1215 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1216 |
return false; |
|
| 1217 |
} |
|
| 1218 |
} |
|
| 1219 |
#endregion |
|
| 1220 |
|
|
| 1221 |
#region 数値チェック |
|
| 1222 |
/// <summary> |
|
| 1223 |
/// 数値チェック |
|
| 1224 |
/// </summary> |
|
| 1225 |
/// <param name="data">Long文字列</param> |
|
| 1226 |
/// <param name="indispensable">入力必須チェック</param> |
|
| 1227 |
/// <returns>true:正常 false:異常</returns> |
|
| 1228 |
public static bool chkNumeric(object CheckData, bool indispensable = false) |
|
| 1229 |
{
|
|
| 1230 |
try |
|
| 1231 |
{
|
|
| 1232 |
if (chkObjectIsNull(CheckData)) return false; |
|
| 1233 |
|
|
| 1234 |
string RecvData = cnvString(CheckData); |
|
| 1235 |
double revData = 0; |
|
| 1236 |
// 必須入力チェック |
|
| 1237 |
if (indispensable) |
|
| 1238 |
{
|
|
| 1239 |
if (RecvData.Replace(",", "").Replace("\\", "").Trim().Length == 0) return false;
|
|
| 1240 |
} |
|
| 1241 |
// Nullが入っていなくてレングスが0は数値として扱う |
|
| 1242 |
if (RecvData.Replace(",", "").Replace("\\", "").Trim().Length == 0) return true;
|
|
| 1243 |
|
|
| 1244 |
return double.TryParse(RecvData.Replace(",", "").Replace("\\", "").Trim(), out revData);
|
|
| 1245 |
} |
|
| 1246 |
catch (System.Exception ex) |
|
| 1247 |
{
|
|
| 1248 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1249 |
return false; |
|
| 1250 |
} |
|
| 1251 |
} |
|
| 1252 |
#endregion |
|
| 1253 |
|
|
| 1254 |
#region 数値チェック(long) |
|
| 1255 |
/// <summary> |
|
| 1256 |
/// 数値チェック(long) |
|
| 1257 |
/// </summary> |
|
| 1258 |
/// <param name="data">Long文字列</param> |
|
| 1259 |
/// <param name="indispensable">入力必須チェック</param> |
|
| 1260 |
/// <returns>true:正常 false:異常</returns> |
|
| 1261 |
public static bool chkNumeric(object sendData, ref long retData, bool indispensable = false) |
|
| 1262 |
{
|
|
| 1263 |
try |
|
| 1264 |
{
|
|
| 1265 |
// 必須入力チェック |
|
| 1266 |
if (indispensable) |
|
| 1267 |
{
|
|
| 1268 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false;
|
|
| 1269 |
} |
|
| 1270 |
|
|
| 1271 |
return long.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 1272 |
} |
|
| 1273 |
catch (System.Exception ex) |
|
| 1274 |
{
|
|
| 1275 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1276 |
return false; |
|
| 1277 |
} |
|
| 1278 |
} |
|
| 1279 |
#endregion |
|
| 1280 |
|
|
| 1281 |
#region 数値チェック(int) |
|
| 1282 |
/// <summary> |
|
| 1283 |
/// 数値チェック(int) |
|
| 1284 |
/// </summary> |
|
| 1285 |
/// <param name="data">Long文字列</param> |
|
| 1286 |
/// <param name="indispensable">入力必須チェック</param> |
|
| 1287 |
/// <returns>true:正常 false:異常</returns> |
|
| 1288 |
public static bool chkNumeric(object sendData, ref int retData, bool indispensable = false) |
|
| 1289 |
{
|
|
| 1290 |
try |
|
| 1291 |
{
|
|
| 1292 |
// 必須入力チェック |
|
| 1293 |
if (indispensable) |
|
| 1294 |
{
|
|
| 1295 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false;
|
|
| 1296 |
} |
|
| 1297 |
|
|
| 1298 |
return int.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 1299 |
} |
|
| 1300 |
catch (System.Exception ex) |
|
| 1301 |
{
|
|
| 1302 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1303 |
return false; |
|
| 1304 |
} |
|
| 1305 |
} |
|
| 1306 |
#endregion |
|
| 1307 |
|
|
| 1308 |
#region 数値チェック(double) |
|
| 1309 |
/// <summary> |
|
| 1310 |
/// 数値チェック(double) |
|
| 1311 |
/// </summary> |
|
| 1312 |
/// <param name="data">Long文字列</param> |
|
| 1313 |
/// <param name="indispensable">入力必須チェック</param> |
|
| 1314 |
/// <returns>true:正常 false:異常</returns> |
|
| 1315 |
public static bool chkNumeric(object sendData, ref double retData, bool indispensable = false) |
|
| 1316 |
{
|
|
| 1317 |
try |
|
| 1318 |
{
|
|
| 1319 |
// 必須入力チェック |
|
| 1320 |
if (indispensable) |
|
| 1321 |
{
|
|
| 1322 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false;
|
|
| 1323 |
} |
|
| 1324 |
|
|
| 1325 |
return double.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData);
|
|
| 1326 |
} |
|
| 1327 |
catch (System.Exception ex) |
|
| 1328 |
{
|
|
| 1329 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1330 |
return false; |
|
| 1331 |
} |
|
| 1332 |
} |
|
| 1333 |
#endregion |
|
| 1334 |
|
|
| 1335 |
#region 文字列長さチェック(UTF-8) |
|
| 1336 |
/// <summary> |
|
| 1337 |
/// 文字列長さチェック(UTF-8) |
|
| 1338 |
/// </summary> |
|
| 1339 |
/// <param name="strData">対象文字列</param> |
|
| 1340 |
/// <param name="lngMaxLen">最大長</param> |
|
| 1341 |
/// <param name="indispensable">入力必須チェック</param> |
|
| 1342 |
/// <returns>true:正常 false:異常</returns> |
|
| 1343 |
public static bool chkStringLength(string strData, int lngMaxLen, bool indispensable = false) |
|
| 1344 |
{
|
|
| 1345 |
bool bRet = true; |
|
| 1346 |
//int lngLen = 0; |
|
| 1347 |
try |
|
| 1348 |
{
|
|
| 1349 |
|
|
| 1350 |
//Encoding sjis = Encoding.GetEncoding("shift-jis");
|
|
| 1351 |
Encoding utf8 = Encoding.GetEncoding("utf-8");
|
|
| 1352 |
|
|
| 1353 |
// 必須入力チェック |
|
| 1354 |
if (indispensable) |
|
| 1355 |
{
|
|
| 1356 |
if (strData.Length == 0) bRet = false; |
|
| 1357 |
} |
|
| 1358 |
// S-Jisチェック |
|
| 1359 |
//lngLen = sjis.GetByteCount(strData); |
|
| 1360 |
// UTF-8チェック |
|
| 1361 |
//lngLen = utf8.GetByteCount(strData); |
|
| 1362 |
//if (lngLen > lngMaxLen) bRet = false; |
|
| 1363 |
// C#内はUTFなので文字長だけをチェックする |
|
| 1364 |
if (strData.Length > lngMaxLen) bRet = false; |
|
| 1365 |
} |
|
| 1366 |
catch (System.Exception ex) |
|
| 1367 |
{
|
|
| 1368 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message);
|
|
| 1369 |
bRet = false; |
|
| 1370 |
} |
|
| 1371 |
|
|
| 1372 |
return bRet; |
|
| 1373 |
} |
|
| 1374 |
#endregion |
|
| 1375 |
|
|
| 1376 |
#region 郵便番号チェック |
|
| 1377 |
/// <summary> |
|
| 1378 |
/// 郵便番号チェック |
|
| 1379 |
/// </summary> |
|
| 1380 |
/// <param name="strData">郵便番号文字列</param> |
|
| 1381 |
/// <returns>true:正常 false:異常</returns> |
|
| 1382 |
public static bool chkZipcode(string strdata) |
|
| 1383 |
{
|
|
| 1384 |
bool bRet = false; |
|
| 1385 |
|
|
| 1386 |
Regex regex = new Regex("^[0-9]{3}[-][0-9]{4}$");
|
|
| 1387 |
if (regex.IsMatch(strdata)) |
|
| 1388 |
{
|
|
| 1389 |
bRet = true; |
|
| 1390 |
} |
|
| 1391 |
return bRet; |
|
| 1392 |
} |
|
| 1393 |
#endregion |
|
| 1394 |
|
|
| 1395 |
#region 電話番号/FAX番号チェック |
|
| 1396 |
/// <summary> |
|
| 1397 |
/// 電話番号/FAX番号チェック |
|
| 1398 |
/// </summary> |
|
| 1399 |
/// <param name="data">電話番号文字列</param> |
|
| 1400 |
/// <returns>true:正常 false:異常</returns> |
|
| 1401 |
public static bool chkPhoneNumber(string strdata) |
|
| 1402 |
{
|
|
| 1403 |
bool bRet = false; |
|
| 1404 |
|
|
| 1405 |
Regex regex = new Regex("^[0-9]{2,5}-[0-9]{1,4}-[0-9]{3,4}$");
|
|
| 1406 |
if (regex.IsMatch(strdata)) |
|
| 1407 |
{
|
|
| 1408 |
bRet = true; |
|
| 1409 |
} |
|
| 1410 |
return bRet; |
|
| 1411 |
} |
|
| 1412 |
#endregion |
|
| 1413 |
|
|
| 1414 |
#region メールアドレスチェック |
|
| 1415 |
/// <summary> |
|
| 1416 |
/// メールアドレスチェック |
|
| 1417 |
/// </summary> |
|
| 1418 |
/// <param name="data">電話番号文字列</param> |
|
| 1419 |
/// <returns>true:正常 false:異常</returns> |
|
| 1420 |
public static bool chkMailAddress(string strdata) |
|
| 1421 |
{
|
|
| 1422 |
bool bRet = false; |
|
| 1423 |
|
|
| 1424 |
Regex regex = new Regex(@"\A\P{Cc}+@\P{Cc}+\z");
|
|
| 1425 |
if (regex.IsMatch(strdata)) |
|
| 1426 |
{
|
|
| 1427 |
bRet = true; |
|
| 1428 |
} |
|
| 1429 |
return bRet; |
|
| 1430 |
} |
|
| 1431 |
#endregion |
|
| 1432 |
|
|
| 1433 |
#region 日付チェック |
|
| 1434 |
/// <summary> |
|
| 1435 |
/// 日付チェック |
|
| 1436 |
/// </summary> |
|
| 1437 |
/// <param name="data">日付文字列</param> |
|
| 1438 |
/// <returns>true:正常 false:異常</returns> |
|
| 1439 |
public static bool chkDate(string strdata) |
|
| 1440 |
{
|
|
| 1441 |
bool bRet = true; |
|
| 1442 |
try |
|
| 1443 |
{
|
|
| 1444 |
DateTime dtwork = DateTime.MinValue; |
|
| 1445 |
|
|
| 1446 |
return DateTime.TryParse(strdata, out dtwork); |
|
| 1447 |
} |
|
| 1448 |
catch (System.Exception ex) |
|
| 1449 |
{
|
|
| 1450 |
logger.DebugFormat("chkDate Error message:{0}", ex.Message);
|
|
| 1451 |
bRet = false; |
|
| 1452 |
} |
|
| 1453 |
return bRet; |
|
| 1454 |
} |
|
| 1455 |
#endregion |
|
| 1456 |
|
|
| 1457 |
#region 対象が空かどうかをチェックする |
|
| 1458 |
/// <summary> |
|
| 1459 |
/// 対象が空かどうかをチェックする |
|
| 1460 |
/// </summary> |
|
| 1461 |
/// <param name="objCell"></param> |
|
| 1462 |
/// <param name="iColumn"></param> |
|
| 1463 |
/// <returns>true:空 flase:有効</returns> |
|
| 1464 |
public static bool chkCellBlank(object objCell) |
|
| 1465 |
{
|
|
| 1466 |
try |
|
| 1467 |
{
|
|
| 1468 |
if (chkObjectIsNull(objCell)) return true; |
|
| 1469 |
if (objCell.ToString().Length == 0) return true; |
|
| 1470 |
|
|
| 1471 |
return false; |
|
| 1472 |
} |
|
| 1473 |
catch (System.Exception ex) |
|
| 1474 |
{
|
|
| 1475 |
logger.DebugFormat("chkDate Error message:{0}", ex.Message);
|
|
| 1476 |
return true; |
|
| 1477 |
} |
|
| 1478 |
} |
|
| 1479 |
#endregion |
|
| 1480 |
|
|
| 1481 |
#region 画面フィールド入力必須チェック |
|
| 1482 |
/// <summary> |
|
| 1483 |
/// 画面フィールド入力必須チェック |
|
| 1484 |
/// </summary> |
|
他の形式にエクスポート: Unified diff