リビジョン 492
オリジナル Rev 649
Ver 1.0.2.51
ソース互換へ修正
| trunk/src/ProcessManagement/ProcessManagement/Common/CommonDefine.cs | ||
|---|---|---|
| 683 | 683 |
{11, "非 受 注"}, // 工事基本情報ラジオボタン:3
|
| 684 | 684 |
{12, "総務入金確認"}, // 工事基本情報ラジオボタン:12
|
| 685 | 685 |
{13, "担当者入金確認完了"}, // 工事基本情報ラジオボタン:13
|
| 686 |
{14, ""}, // 工事基本情報ラジオボタン:14
|
|
| 687 |
{15, ""}, // 工事基本情報ラジオボタン:15
|
|
| 686 |
{14, ""}, // 工事基本情報ラジオボタン:14
|
|
| 687 |
{15, ""}, // 工事基本情報ラジオボタン:15
|
|
| 688 | 688 |
{16, "空家補修工事"}, // 工事基本情報ラジオボタン:16
|
| 689 | 689 |
{17, "Hit'sV工事"}, // 工事基本情報ラジオボタン:17
|
| 690 | 690 |
}; |
| trunk/src/ProcessManagement/ProcessManagement/Common/CommonMotions.cs | ||
|---|---|---|
| 636 | 636 |
int retRoundData = 0; |
| 637 | 637 |
try |
| 638 | 638 |
{
|
| 639 |
retRoundData = (int)Math.Round(InputData, MidpointRounding.AwayFromZero); |
|
| 639 |
retRoundData = (int)Math.Round(InputData, 0, MidpointRounding.AwayFromZero);
|
|
| 640 | 640 |
|
| 641 | 641 |
return retRoundData; |
| 642 | 642 |
} |
| ... | ... | |
| 4283 | 4283 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(nTargetYear, true); |
| 4284 | 4284 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(nTargetYear, false); |
| 4285 | 4285 |
|
| 4286 |
strSQL.Append("Select");
|
|
| 4286 |
strSQL.Append("Select ");
|
|
| 4287 | 4287 |
strSQL.AppendFormat(" {0}", IOMPersonInCharge.CreateFieldNameList("A."));
|
| 4288 | 4288 |
strSQL.Append(" From personinchargemaster As A");
|
| 4289 | 4289 |
strSQL.Append(" Left Join chgchargedep As B");
|
| ... | ... | |
| 4467 | 4467 |
/// 経費率リストを取得する |
| 4468 | 4468 |
/// </summary> |
| 4469 | 4469 |
/// <returns></returns> |
| 4470 |
public static bool GetExpensesList(int Preiod, int DepartmentCode, ref ArrayList ExpensesList) |
|
| 4470 |
public static bool GetExpensesList(int Preiod, int DepartmentCode, ref ArrayList ExpensesList, bool bNotZero = true)
|
|
| 4471 | 4471 |
{
|
| 4472 | 4472 |
IOMDepartmentExpenses expDB = new IOMDepartmentExpenses(); |
| 4473 | 4473 |
try |
| ... | ... | |
| 4501 | 4501 |
strSQL.Append(" WHERE");
|
| 4502 | 4502 |
strSQL.AppendFormat(" A.DIVISIONCODE = {0}", (int)DivisionMaster.DivisionMasterCodeDef.ConstructionExpenses);
|
| 4503 | 4503 |
strSQL.AppendFormat(" AND A.DeleteFlg = {0}", (int)CommonDefine.DataDeleteDef.Exists);
|
| 4504 |
//strSQL.Append(" And B.EXPENSESRAITO > 0.00");
|
|
| 4504 |
if(bNotZero) strSQL.Append(" And B.EXPENSESRAITO > 0.00");
|
|
| 4505 | 4505 |
|
| 4506 | 4506 |
strSQL.Append(" ORDER BY A.DISPLAYORDER, C.DISPLAYORDER");
|
| 4507 | 4507 |
} |
| ... | ... | |
| 4525 | 4525 |
strSQL.Append(" WHERE");
|
| 4526 | 4526 |
strSQL.AppendFormat(" B.EXPENSESPERIOD = {0}", Preiod);
|
| 4527 | 4527 |
if (DepartmentCode > 0) strSQL.AppendFormat(" AND B.DEPARTMENTCODE = {0}", DepartmentCode);
|
| 4528 |
//strSQL.Append(" And B.EXPENSESRAITO > 0.00");
|
|
| 4528 |
if (bNotZero) strSQL.Append(" And B.EXPENSESRAITO > 0.00");
|
|
| 4529 | 4529 |
|
| 4530 | 4530 |
strSQL.Append(" ORDER BY D.DeleteFlg, C.DISPLAYORDER, B.DISPLAYORDER");
|
| 4531 | 4531 |
} |
| trunk/src/ProcessManagement/ProcessManagement/Common/Office/UsedExcel.cs | ||
|---|---|---|
| 1 | 1 |
using System; |
| 2 | 2 |
using System.Collections.Generic; |
| 3 |
using System.Diagnostics; |
|
| 4 |
using System.Drawing; |
|
| 5 |
using System.Linq; |
|
| 3 | 6 |
using System.Reflection; |
| 7 |
using System.Runtime.InteropServices; |
|
| 8 |
using System.Threading.Tasks; |
|
| 4 | 9 |
using System.Windows.Forms; |
| 5 |
using System.Drawing; |
|
| 10 |
|
|
| 6 | 11 |
using ProcessManagement.DataModel; |
| 7 | 12 |
|
| 8 | 13 |
namespace ProcessManagement.Common |
| ... | ... | |
| 162 | 167 |
|
| 163 | 168 |
#region EXCEL オブジェクト |
| 164 | 169 |
// EXCELオブジェクト |
| 165 |
private object xlsApp = null;
|
|
| 170 |
private object m_XlsApp = null;
|
|
| 166 | 171 |
|
| 167 | 172 |
//ワークブックコレクションオブジェクト |
| 168 |
private object xlsBooks = null;
|
|
| 173 |
private object m_XlsBooks = null;
|
|
| 169 | 174 |
//ワークブックコレクションオブジェクト |
| 170 |
private object xlsWorkBooks = null;
|
|
| 175 |
private object m_XlsWorkBooks = null;
|
|
| 171 | 176 |
|
| 172 | 177 |
//ワークブックオブジェクト |
| 173 |
private object xlsBook = null;
|
|
| 178 |
private object m_XlsBook = null;
|
|
| 174 | 179 |
//作業ブックオブジェクト |
| 175 |
private object xlsWorkBook = null;
|
|
| 180 |
private object m_XlsWorkBook = null;
|
|
| 176 | 181 |
|
| 177 | 182 |
//シート's オブジェクト |
| 178 |
private object xlsSheets = null;
|
|
| 183 |
private object m_XlsSheets = null;
|
|
| 179 | 184 |
//作業シート's オブジェクト |
| 180 |
private object xlsWorkSheets = null;
|
|
| 185 |
private object m_XlsWorkSheets = null;
|
|
| 181 | 186 |
|
| 182 | 187 |
//シートオブジェクト |
| 183 |
private object xlsSheet = null;
|
|
| 188 |
private object m_XlsSheet = null;
|
|
| 184 | 189 |
//作業シートオブジェクト |
| 185 |
private object xlsWorkSheet = null;
|
|
| 190 |
private object m_XlsWorkSheet = null;
|
|
| 186 | 191 |
|
| 187 | 192 |
#endregion |
| 188 | 193 |
|
| ... | ... | |
| 196 | 201 |
{
|
| 197 | 202 |
//オブジェクト取得 |
| 198 | 203 |
Type classType = Type.GetTypeFromProgID("Excel.Application");
|
| 199 |
xlsApp = Activator.CreateInstance(classType);
|
|
| 204 |
m_XlsApp = Activator.CreateInstance(classType);
|
|
| 200 | 205 |
|
| 201 |
if (xlsApp == null) return;
|
|
| 206 |
if (m_XlsApp == null) return;
|
|
| 202 | 207 |
|
| 208 |
GetExcelProcessID(); |
|
| 209 |
|
|
| 203 | 210 |
// EXCELバージョンチェック |
| 204 |
object versionObj = xlsApp.GetType().InvokeMember("Version", BindingFlags.GetProperty, null, xlsApp, null);
|
|
| 211 |
object versionObj = m_XlsApp.GetType().InvokeMember("Version", BindingFlags.GetProperty, null, m_XlsApp, null);
|
|
| 205 | 212 |
string version = versionObj.ToString(); |
| 206 | 213 |
|
| 207 | 214 |
if ("11.0".Equals(version))
|
| ... | ... | |
| 238 | 245 |
} |
| 239 | 246 |
#endregion |
| 240 | 247 |
|
| 248 |
#region ウィンドウハンドルよりプロセスIDを取得する |
|
| 249 |
/// <summary> |
|
| 250 |
/// ウィンドウハンドルよりプロセスIDを取得する |
|
| 251 |
/// </summary> |
|
| 252 |
/// <returns></returns> |
|
| 253 |
[DllImport("user32.dll")]
|
|
| 254 |
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint lpdw); |
|
| 255 |
#endregion |
|
| 256 |
|
|
| 257 |
#region オブジェクトよりウィンドウハンドルを取得する |
|
| 258 |
/// <summary> |
|
| 259 |
/// オブジェクトよりウィンドウハンドルを取得する |
|
| 260 |
/// </summary> |
|
| 261 |
uint m_ProcID = 0; |
|
| 262 |
private void GetExcelProcessID() |
|
| 263 |
{
|
|
| 264 |
try |
|
| 265 |
{
|
|
| 266 |
int _HWND = (int)m_XlsApp.GetType().InvokeMember("Hwnd",
|
|
| 267 |
BindingFlags.GetProperty, |
|
| 268 |
null, |
|
| 269 |
m_XlsApp, |
|
| 270 |
null); |
|
| 271 |
GetWindowThreadProcessId((IntPtr)_HWND, ref m_ProcID); |
|
| 272 |
} |
|
| 273 |
catch (Exception ex) |
|
| 274 |
{
|
|
| 275 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 276 |
} |
|
| 277 |
} |
|
| 278 |
#endregion |
|
| 279 |
|
|
| 280 |
#region EXECLプロセスKill終了処理 |
|
| 281 |
/// <summary> |
|
| 282 |
/// EXECLプロセスKill終了処理 |
|
| 283 |
/// </summary> |
|
| 284 |
public void KillExcelProcess() |
|
| 285 |
{
|
|
| 286 |
try |
|
| 287 |
{
|
|
| 288 |
if (System.Diagnostics.Process.GetProcesses().Any(x => x.Id == m_ProcID)) |
|
| 289 |
{
|
|
| 290 |
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById((int)m_ProcID); |
|
| 291 |
p.Kill(); |
|
| 292 |
} |
|
| 293 |
} |
|
| 294 |
catch (Exception ex) |
|
| 295 |
{
|
|
| 296 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 297 |
} |
|
| 298 |
} |
|
| 299 |
#endregion |
|
| 300 |
|
|
| 241 | 301 |
#region デストラクタ |
| 242 | 302 |
/// <summary> |
| 243 | 303 |
/// 終了(EXCELオブジェクトを解放する) |
| ... | ... | |
| 247 | 307 |
try |
| 248 | 308 |
{
|
| 249 | 309 |
ExcelSheetRelease(); |
| 250 |
ExcelBookClose(); |
|
| 251 |
if (xlsApp == null) return; |
|
| 252 |
|
|
| 253 |
xlsApp.GetType().InvokeMember("Quit"
|
|
| 254 |
, BindingFlags.InvokeMethod |
|
| 255 |
, null |
|
| 256 |
, xlsApp |
|
| 257 |
, null); |
|
| 258 |
CommonMotions.ReleaseCom(ref xlsApp); |
|
| 259 |
|
|
| 310 |
ExcelBookClose(true); |
|
| 260 | 311 |
} |
| 261 | 312 |
catch (Exception ex) |
| 262 | 313 |
{
|
| ... | ... | |
| 280 | 331 |
try |
| 281 | 332 |
{
|
| 282 | 333 |
// 警告メッセージなどを表示しないようにする |
| 283 |
xlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 334 |
m_XlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 284 | 335 |
, BindingFlags.SetProperty |
| 285 | 336 |
, null |
| 286 |
, xlsApp
|
|
| 337 |
, m_XlsApp
|
|
| 287 | 338 |
, new object[] { false });
|
| 288 | 339 |
|
| 289 | 340 |
//ワークブックコレクションオブジェクト |
| 290 |
xlsBooks = xlsApp.GetType().InvokeMember("Workbooks"
|
|
| 341 |
m_XlsBooks = m_XlsApp.GetType().InvokeMember("Workbooks"
|
|
| 291 | 342 |
, BindingFlags.GetProperty |
| 292 | 343 |
, null |
| 293 |
, xlsApp
|
|
| 344 |
, m_XlsApp
|
|
| 294 | 345 |
, null); |
| 295 | 346 |
|
| 296 | 347 |
//Excelファイルのオープン |
| 297 |
xlsBook = xlsBooks.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, xlsBooks, new object[] {
|
|
| 348 |
m_XlsBook = m_XlsBooks.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, m_XlsBooks, new object[] {
|
|
| 298 | 349 |
@datapath |
| 299 | 350 |
, Type.Missing |
| 300 | 351 |
, Type.Missing |
| ... | ... | |
| 309 | 360 |
, Type.Missing |
| 310 | 361 |
, Type.Missing |
| 311 | 362 |
}); |
| 312 |
if (xlsBook == null) return false;
|
|
| 363 |
if (m_XlsBook == null) return false;
|
|
| 313 | 364 |
|
| 314 | 365 |
// 作業用ブックオープン |
| 315 | 366 |
ExcelNewWorkBookOpen(); |
| ... | ... | |
| 324 | 375 |
} |
| 325 | 376 |
#endregion |
| 326 | 377 |
|
| 378 |
#region ワークブックオープン |
|
| 379 |
/// <summary> |
|
| 380 |
/// 作業用ワークブックオープン(対象:ワークブック) |
|
| 381 |
/// </summary> |
|
| 382 |
/// <returns></returns> |
|
| 383 |
private bool ExcelNewWorkBookOpen() |
|
| 384 |
{
|
|
| 385 |
object wrksheet = null; |
|
| 386 |
|
|
| 387 |
try |
|
| 388 |
{
|
|
| 389 |
|
|
| 390 |
// 警告メッセージなどを表示しないようにする |
|
| 391 |
m_XlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 392 |
, BindingFlags.SetProperty |
|
| 393 |
, null |
|
| 394 |
, m_XlsApp |
|
| 395 |
, new object[] { false });
|
|
| 396 |
|
|
| 397 |
// 作業用ワークブックオープン |
|
| 398 |
m_XlsWorkBook = m_XlsBooks.GetType().InvokeMember("Add"
|
|
| 399 |
, BindingFlags.InvokeMethod |
|
| 400 |
, null |
|
| 401 |
, m_XlsBooks |
|
| 402 |
, null); |
|
| 403 |
if (m_XlsWorkBook == null) return false; |
|
| 404 |
|
|
| 405 |
//シートのコレクションを取得する |
|
| 406 |
CommonMotions.ReleaseCom(ref m_XlsWorkSheets); |
|
| 407 |
m_XlsWorkSheets = m_XlsWorkBook.GetType().InvokeMember("Worksheets"
|
|
| 408 |
, BindingFlags.GetProperty |
|
| 409 |
, null |
|
| 410 |
, m_XlsWorkBook |
|
| 411 |
, null); |
|
| 412 |
|
|
| 413 |
// いらないシートを最後から1枚を残して削除する |
|
| 414 |
object sheetCount = (int)m_XlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 415 |
, BindingFlags.GetProperty |
|
| 416 |
, null |
|
| 417 |
, m_XlsWorkSheets |
|
| 418 |
, null); |
|
| 419 |
for (int i = Convert.ToInt32(sheetCount); i > 1; i--) |
|
| 420 |
{
|
|
| 421 |
wrksheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 422 |
, BindingFlags.GetProperty |
|
| 423 |
, null |
|
| 424 |
, m_XlsWorkSheets |
|
| 425 |
, new object[] { i });
|
|
| 426 |
wrksheet.GetType().InvokeMember("Delete"
|
|
| 427 |
, BindingFlags.InvokeMethod |
|
| 428 |
, null |
|
| 429 |
, wrksheet |
|
| 430 |
, null); |
|
| 431 |
} |
|
| 432 |
|
|
| 433 |
return true; |
|
| 434 |
} |
|
| 435 |
catch (Exception ex) |
|
| 436 |
{
|
|
| 437 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 438 |
return false; |
|
| 439 |
} |
|
| 440 |
finally |
|
| 441 |
{
|
|
| 442 |
CommonMotions.ReleaseCom(ref wrksheet); |
|
| 443 |
} |
|
| 444 |
} |
|
| 445 |
#endregion |
|
| 446 |
|
|
| 327 | 447 |
#region シート印刷(プレビュー) |
| 328 | 448 |
/// <summary> |
| 329 | 449 |
/// エクセルシート印刷(対象:ワークブック) |
| ... | ... | |
| 334 | 454 |
try |
| 335 | 455 |
{
|
| 336 | 456 |
// Excelファイルの表示 |
| 337 |
xlsApp.GetType().InvokeMember("Visible"
|
|
| 457 |
m_XlsApp.GetType().InvokeMember("Visible"
|
|
| 338 | 458 |
, BindingFlags.SetProperty |
| 339 | 459 |
, null |
| 340 |
, xlsApp
|
|
| 460 |
, m_XlsApp
|
|
| 341 | 461 |
, new object[] { true });
|
| 342 | 462 |
|
| 343 | 463 |
//エクセルのプロセスを探す(他のEXCELが見つかってもそれが上がってしまうので注意) |
| ... | ... | |
| 349 | 469 |
} |
| 350 | 470 |
|
| 351 | 471 |
//ワークシートコレクションオブジェクト |
| 352 |
xlsWorkSheets = xlsWorkBook.GetType().InvokeMember("Sheets"
|
|
| 472 |
xlsWorkSheets = m_XlsWorkBook.GetType().InvokeMember("Sheets"
|
|
| 353 | 473 |
, BindingFlags.GetProperty |
| 354 | 474 |
, null |
| 355 |
, xlsWorkBook
|
|
| 475 |
, m_XlsWorkBook
|
|
| 356 | 476 |
, null); |
| 357 | 477 |
// プレビュー画面表示 |
| 358 | 478 |
xlsWorkSheets.GetType().InvokeMember("PrintPreview"
|
| ... | ... | |
| 362 | 482 |
, new object[] { false });
|
| 363 | 483 |
|
| 364 | 484 |
//画面表示OFF |
| 365 |
xlsApp.GetType().InvokeMember("Visible"
|
|
| 485 |
m_XlsApp.GetType().InvokeMember("Visible"
|
|
| 366 | 486 |
, BindingFlags.SetProperty |
| 367 | 487 |
, null |
| 368 |
, xlsApp
|
|
| 488 |
, m_XlsApp
|
|
| 369 | 489 |
, new object[] { false });
|
| 370 | 490 |
|
| 371 | 491 |
|
| ... | ... | |
| 399 | 519 |
Parameters[0] = FromColum; |
| 400 | 520 |
Parameters[1] = Missing.Value; |
| 401 | 521 |
if (ToColum.Length != 0) Parameters[1] = ToColum; |
| 402 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 522 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 403 | 523 |
, BindingFlags.GetProperty |
| 404 | 524 |
, null |
| 405 |
, xlsWorkSheet
|
|
| 525 |
, m_XlsWorkSheet
|
|
| 406 | 526 |
, Parameters); |
| 407 | 527 |
|
| 408 | 528 |
// データ貼り付け |
| ... | ... | |
| 416 | 536 |
} |
| 417 | 537 |
catch (Exception ex) |
| 418 | 538 |
{
|
| 419 |
logger.ErrorFormat("配列セットシステムエラー:{0}:{1}:{2}", ex.Message, FromColum, ToColum);
|
|
| 539 |
logger.ErrorFormat("配列セットシステムエラー:{0}:{1}:{2}:{3}", ex.Message, CommonMotions.GetMethodName(), FromColum, ToColum);
|
|
| 420 | 540 |
} |
| 421 | 541 |
finally |
| 422 | 542 |
{
|
| ... | ... | |
| 437 | 557 |
Parameters[0] = FromColum; |
| 438 | 558 |
Parameters[1] = Missing.Value; |
| 439 | 559 |
if (ToColum.Length != 0) Parameters[1] = ToColum; |
| 440 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 560 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 441 | 561 |
, BindingFlags.GetProperty |
| 442 | 562 |
, null |
| 443 |
, xlsWorkSheet
|
|
| 563 |
, m_XlsWorkSheet
|
|
| 444 | 564 |
, Parameters); |
| 445 | 565 |
|
| 446 | 566 |
// データ貼り付け |
| ... | ... | |
| 454 | 574 |
} |
| 455 | 575 |
catch (Exception ex) |
| 456 | 576 |
{
|
| 457 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}:{3}", ex.Message, FromColum, ToColum, strData);
|
|
| 577 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}:{3}:{4}", ex.Message, CommonMotions.GetMethodName(), FromColum, ToColum, strData);
|
|
| 458 | 578 |
} |
| 459 | 579 |
finally |
| 460 | 580 |
{
|
| ... | ... | |
| 483 | 603 |
Parameters[0] = FromColum; |
| 484 | 604 |
Parameters[1] = Missing.Value; |
| 485 | 605 |
if (ToColum.Length != 0) Parameters[1] = ToColum; |
| 486 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 606 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 487 | 607 |
, BindingFlags.GetProperty |
| 488 | 608 |
, null |
| 489 |
, xlsWorkSheet
|
|
| 609 |
, m_XlsWorkSheet
|
|
| 490 | 610 |
, Parameters); |
| 491 | 611 |
|
| 492 | 612 |
// データ取得 |
| ... | ... | |
| 508 | 628 |
} |
| 509 | 629 |
catch (Exception ex) |
| 510 | 630 |
{
|
| 511 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}:{3}", ex.Message, FromColum, ToColum, strData);
|
|
| 631 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}:{3}:{4}", ex.Message, CommonMotions.GetMethodName(), FromColum, ToColum, strData);
|
|
| 512 | 632 |
return strData; |
| 513 | 633 |
} |
| 514 | 634 |
finally |
| 515 | 635 |
{
|
| 516 | 636 |
CommonMotions.ReleaseCom(ref xlsRange); |
| 637 |
CommonMotions.ReleaseCom(ref cellData); |
|
| 517 | 638 |
} |
| 518 | 639 |
} |
| 519 | 640 |
#endregion |
| ... | ... | |
| 522 | 643 |
/// <summary> |
| 523 | 644 |
/// セルのアライメント |
| 524 | 645 |
/// </summary> |
| 525 |
/// <param name="ToColum">カラム</param>
|
|
| 646 |
/// <param name="FromColum">カラム</param>
|
|
| 526 | 647 |
/// <param name="Horizontal">水平位置</param> |
| 527 | 648 |
/// <param name="Vertical">垂直位置</param> |
| 528 | 649 |
/// <param name="WrapText">折り返して表示</param> |
| 529 | 650 |
/// <param name="ShrinkToFit">縮小して表示</param> |
| 530 |
public void ExcelCellAlignment(string ToColum, int Horizontal, int Vertical, bool WrapText, bool ShrinkToFit)
|
|
| 651 |
public void ExcelCellAlignment(string FromColum, int Horizontal, int Vertical, bool WrapText, bool ShrinkToFit, string ToColum = "")
|
|
| 531 | 652 |
{
|
| 532 | 653 |
object xlsRange = null; |
| 533 | 654 |
object[] Parameters = null; |
| ... | ... | |
| 535 | 656 |
{
|
| 536 | 657 |
// レンジでセルを指定 |
| 537 | 658 |
Parameters = new Object[2]; |
| 538 |
Parameters[0] = ToColum;
|
|
| 659 |
Parameters[0] = FromColum;
|
|
| 539 | 660 |
Parameters[1] = Missing.Value; |
| 540 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 661 |
if (ToColum.Length > 0) Parameters[1] = ToColum; |
|
| 662 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 541 | 663 |
, BindingFlags.GetProperty |
| 542 | 664 |
, null |
| 543 |
, xlsWorkSheet
|
|
| 665 |
, m_XlsWorkSheet
|
|
| 544 | 666 |
, Parameters); |
| 545 | 667 |
|
| 546 | 668 |
// 水平アライメント変更 |
| ... | ... | |
| 574 | 696 |
} |
| 575 | 697 |
catch (Exception ex) |
| 576 | 698 |
{
|
| 577 |
logger.ErrorFormat("システムエラー:{0}:{1}", ex.Message, ToColum);
|
|
| 699 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", ex.Message, CommonMotions.GetMethodName(), FromColum);
|
|
| 578 | 700 |
} |
| 579 | 701 |
finally |
| 580 | 702 |
{
|
| ... | ... | |
| 595 | 717 |
try |
| 596 | 718 |
{
|
| 597 | 719 |
// レンジでセルを指定 |
| 598 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 720 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 599 | 721 |
, BindingFlags.GetProperty |
| 600 | 722 |
, null |
| 601 |
, xlsWorkSheet
|
|
| 723 |
, m_XlsWorkSheet
|
|
| 602 | 724 |
, new object[] { FromColum, ToColum });
|
| 603 | 725 |
|
| 604 | 726 |
|
| ... | ... | |
| 610 | 732 |
} |
| 611 | 733 |
catch (Exception ex) |
| 612 | 734 |
{
|
| 613 |
logger.ErrorFormat("システムエラー:{0}:{1}", ex.Message, ToColum);
|
|
| 735 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", ex.Message, CommonMotions.GetMethodName(), ToColum);
|
|
| 614 | 736 |
} |
| 615 | 737 |
finally |
| 616 | 738 |
{
|
| ... | ... | |
| 632 | 754 |
{
|
| 633 | 755 |
//罫線を引くRangeを指定 |
| 634 | 756 |
string strRenge = string.Format("{0}:{1}", FromColum, ToColum);
|
| 635 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 757 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 636 | 758 |
, BindingFlags.GetProperty |
| 637 | 759 |
, null |
| 638 |
, xlsWorkSheet
|
|
| 760 |
, m_XlsWorkSheet
|
|
| 639 | 761 |
, new object[] { strRenge, Missing.Value });
|
| 640 | 762 |
|
| 641 | 763 |
//罫線達を取得。 |
| ... | ... | |
| 663 | 785 |
} |
| 664 | 786 |
catch (Exception ex) |
| 665 | 787 |
{
|
| 666 |
logger.ErrorFormat("システムエラー:{0}:{1}", ex.Message, ToColum);
|
|
| 788 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", ex.Message, CommonMotions.GetMethodName(), ToColum);
|
|
| 667 | 789 |
} |
| 668 | 790 |
finally |
| 669 | 791 |
{
|
| ... | ... | |
| 690 | 812 |
Parameters = new Object[2]; |
| 691 | 813 |
Parameters[0] = FromColum; |
| 692 | 814 |
Parameters[1] = Missing.Value; |
| 693 |
Parameters[1] = ToColum; |
|
| 694 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 815 |
if (ToColum.Length > 0) Parameters[1] = ToColum;
|
|
| 816 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 695 | 817 |
, BindingFlags.GetProperty |
| 696 | 818 |
, null |
| 697 |
, xlsWorkSheet
|
|
| 819 |
, m_XlsWorkSheet
|
|
| 698 | 820 |
, Parameters); |
| 699 | 821 |
|
| 700 | 822 |
// 背景色を変更する。 |
| ... | ... | |
| 711 | 833 |
} |
| 712 | 834 |
catch (Exception ex) |
| 713 | 835 |
{
|
| 714 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", ex.Message, FromColum, ToColum);
|
|
| 836 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}:{3}", ex.Message, CommonMotions.GetMethodName(), FromColum, ToColum);
|
|
| 715 | 837 |
} |
| 716 | 838 |
finally |
| 717 | 839 |
{
|
| ... | ... | |
| 732 | 854 |
try |
| 733 | 855 |
{
|
| 734 | 856 |
// シートコレクション取得 |
| 735 |
CommonMotions.ReleaseCom(ref xlsSheets);
|
|
| 736 |
xlsSheets = xlsBook.GetType().InvokeMember("WorkSheets"
|
|
| 857 |
CommonMotions.ReleaseCom(ref m_XlsSheets);
|
|
| 858 |
m_XlsSheets = m_XlsBook.GetType().InvokeMember("WorkSheets"
|
|
| 737 | 859 |
, BindingFlags.GetProperty |
| 738 | 860 |
, null |
| 739 |
, xlsBook
|
|
| 861 |
, m_XlsBook
|
|
| 740 | 862 |
, null); |
| 741 | 863 |
// シート取得 2016/02/05 回さなくても取れた |
| 742 |
xlsSheet = xlsSheets.GetType().InvokeMember("Item"
|
|
| 864 |
m_XlsSheet = m_XlsSheets.GetType().InvokeMember("Item"
|
|
| 743 | 865 |
, BindingFlags.GetProperty |
| 744 | 866 |
, null |
| 745 |
, xlsSheets
|
|
| 867 |
, m_XlsSheets
|
|
| 746 | 868 |
, new object[] { strSheetName });
|
| 747 | 869 |
|
| 748 | 870 |
// 作業シートコピー |
| ... | ... | |
| 750 | 872 |
} |
| 751 | 873 |
catch (Exception ex) |
| 752 | 874 |
{
|
| 753 |
logger.ErrorFormat("システムエラー:{0}:{1}", ex.Message, strSheetName);
|
|
| 875 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", ex.Message, CommonMotions.GetMethodName(), strSheetName);
|
|
| 754 | 876 |
} |
| 755 | 877 |
} |
| 756 | 878 |
#endregion |
| ... | ... | |
| 764 | 886 |
{
|
| 765 | 887 |
try |
| 766 | 888 |
{
|
| 767 |
if (xlsWorkSheet != null)
|
|
| 889 |
if (m_XlsWorkSheet != null)
|
|
| 768 | 890 |
{
|
| 769 |
CommonMotions.ReleaseCom(ref xlsWorkSheet);
|
|
| 891 |
CommonMotions.ReleaseCom(ref m_XlsWorkSheet);
|
|
| 770 | 892 |
} |
| 771 |
if (xlsWorkSheets != null)
|
|
| 893 |
if (m_XlsWorkSheets != null)
|
|
| 772 | 894 |
{
|
| 773 |
CommonMotions.ReleaseCom(ref xlsWorkSheets);
|
|
| 895 |
CommonMotions.ReleaseCom(ref m_XlsWorkSheets);
|
|
| 774 | 896 |
} |
| 775 |
if (xlsSheet != null)
|
|
| 897 |
if (m_XlsSheet != null)
|
|
| 776 | 898 |
{
|
| 777 |
CommonMotions.ReleaseCom(ref xlsSheet);
|
|
| 899 |
CommonMotions.ReleaseCom(ref m_XlsSheet);
|
|
| 778 | 900 |
} |
| 779 |
if (xlsSheets != null)
|
|
| 901 |
if (m_XlsSheets != null)
|
|
| 780 | 902 |
{
|
| 781 |
CommonMotions.ReleaseCom(ref xlsSheets);
|
|
| 903 |
CommonMotions.ReleaseCom(ref m_XlsSheets);
|
|
| 782 | 904 |
} |
| 783 | 905 |
} |
| 784 | 906 |
catch (Exception ex) |
| ... | ... | |
| 792 | 914 |
/// <summary> |
| 793 | 915 |
///ブッククローズ |
| 794 | 916 |
/// </summary> |
| 795 |
public void ExcelBookClose() |
|
| 917 |
public void ExcelBookClose(bool bEndProcess = false)
|
|
| 796 | 918 |
{
|
| 797 | 919 |
try |
| 798 | 920 |
{
|
| 799 |
// 警告メッセージなどを表示しないようにする |
|
| 800 |
xlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 921 |
if (m_XlsApp != null) |
|
| 922 |
{
|
|
| 923 |
// 警告メッセージなどを表示しないようにする |
|
| 924 |
m_XlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 801 | 925 |
, BindingFlags.SetProperty |
| 802 | 926 |
, null |
| 803 |
, xlsApp
|
|
| 927 |
, m_XlsApp
|
|
| 804 | 928 |
, new object[] { false });
|
| 805 |
if (xlsBooks != null) |
|
| 929 |
} |
|
| 930 |
//ワークブックコレクションオブジェクト |
|
| 931 |
if (m_XlsBooks != null) |
|
| 806 | 932 |
{
|
| 807 |
CommonMotions.ReleaseCom(ref xlsBooks);
|
|
| 933 |
CommonMotions.ReleaseCom(ref m_XlsBooks);
|
|
| 808 | 934 |
} |
| 809 |
if (xlsBook != null) |
|
| 935 |
//ワークブックオブジェクト |
|
| 936 |
if (m_XlsBook != null) |
|
| 810 | 937 |
{
|
| 811 |
xlsBook.GetType().InvokeMember("Close"
|
|
| 812 |
, BindingFlags.InvokeMethod |
|
| 813 |
, null |
|
| 814 |
, xlsBook |
|
| 815 |
, new object[] { Type.Missing, Type.Missing });
|
|
| 816 |
CommonMotions.ReleaseCom(ref xlsBook); |
|
| 938 |
CommonMotions.ReleaseCom(ref m_XlsBook); |
|
| 817 | 939 |
} |
| 818 |
if (xlsWorkBooks != null) |
|
| 940 |
//ワークブックコレクションオブジェクト |
|
| 941 |
if (m_XlsWorkBooks != null) |
|
| 819 | 942 |
{
|
| 820 |
CommonMotions.ReleaseCom(ref xlsWorkBooks);
|
|
| 943 |
CommonMotions.ReleaseCom(ref m_XlsWorkBooks);
|
|
| 821 | 944 |
} |
| 822 |
if (xlsWorkBook != null) |
|
| 945 |
//作業ブックオブジェクト |
|
| 946 |
if (m_XlsWorkBook != null) |
|
| 823 | 947 |
{
|
| 824 |
xlsWorkBook.GetType().InvokeMember("Close"
|
|
| 948 |
CommonMotions.ReleaseCom(ref m_XlsWorkBook); |
|
| 949 |
} |
|
| 950 |
// EXCELオブジェクト |
|
| 951 |
if (m_XlsApp != null) |
|
| 952 |
{
|
|
| 953 |
int nCnt = 0; |
|
| 954 |
while (System.Diagnostics.Process.GetProcessById((int)m_ProcID) != null) |
|
| 955 |
{
|
|
| 956 |
m_XlsApp.GetType().InvokeMember("Quit"
|
|
| 825 | 957 |
, BindingFlags.InvokeMethod |
| 826 | 958 |
, null |
| 827 |
, xlsWorkBook |
|
| 828 |
, new object[] { Type.Missing, Type.Missing });
|
|
| 829 |
CommonMotions.ReleaseCom(ref xlsWorkBook); |
|
| 959 |
, m_XlsApp |
|
| 960 |
, null); |
|
| 961 |
// ウェイト処理 |
|
| 962 |
CloseWait(); |
|
| 963 |
|
|
| 964 |
nCnt++; |
|
| 965 |
if (nCnt > 50) break; |
|
| 966 |
} |
|
| 967 |
CommonMotions.ReleaseCom(ref m_XlsApp); |
|
| 830 | 968 |
} |
| 969 |
|
|
| 970 |
if (!bEndProcess) return; |
|
| 971 |
|
|
| 972 |
// EXECLプロセスKill終了処理 |
|
| 973 |
KillExcelProcess(); |
|
| 831 | 974 |
} |
| 832 | 975 |
catch (Exception ex) |
| 833 | 976 |
{
|
| ... | ... | |
| 836 | 979 |
} |
| 837 | 980 |
#endregion |
| 838 | 981 |
|
| 839 |
#region ワークブックオープン
|
|
| 982 |
#region ウェイト処理
|
|
| 840 | 983 |
/// <summary> |
| 841 |
/// 作業用ワークブックオープン(対象:ワークブック)
|
|
| 984 |
/// ウェイト処理
|
|
| 842 | 985 |
/// </summary> |
| 843 |
/// <returns></returns> |
|
| 844 |
private bool ExcelNewWorkBookOpen() |
|
| 986 |
private async void CloseWait() |
|
| 845 | 987 |
{
|
| 846 |
object wrksheet = null; |
|
| 847 |
|
|
| 848 | 988 |
try |
| 849 | 989 |
{
|
| 850 |
|
|
| 851 |
// 警告メッセージなどを表示しないようにする |
|
| 852 |
xlsApp.GetType().InvokeMember("DisplayAlerts"
|
|
| 853 |
, BindingFlags.SetProperty |
|
| 854 |
, null |
|
| 855 |
, xlsApp |
|
| 856 |
, new object[] { false });
|
|
| 857 |
|
|
| 858 |
// 作業用ワークブックオープン |
|
| 859 |
xlsWorkBook = xlsBooks.GetType().InvokeMember("Add"
|
|
| 860 |
, BindingFlags.InvokeMethod |
|
| 861 |
, null |
|
| 862 |
, xlsBooks |
|
| 863 |
, null); |
|
| 864 |
if (xlsWorkBook == null) return false; |
|
| 865 |
|
|
| 866 |
//シートのコレクションを取得する |
|
| 867 |
CommonMotions.ReleaseCom(ref xlsWorkSheets); |
|
| 868 |
xlsWorkSheets = xlsWorkBook.GetType().InvokeMember("Worksheets"
|
|
| 869 |
, BindingFlags.GetProperty |
|
| 870 |
, null |
|
| 871 |
, xlsWorkBook |
|
| 872 |
, null); |
|
| 873 |
|
|
| 874 |
// いらないシートを最後から1枚を残して削除する |
|
| 875 |
object sheetCount = (int)xlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 876 |
, BindingFlags.GetProperty |
|
| 877 |
, null |
|
| 878 |
, xlsWorkSheets |
|
| 879 |
, null); |
|
| 880 |
for (int i = Convert.ToInt32(sheetCount); i > 1; i--) |
|
| 881 |
{
|
|
| 882 |
wrksheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 883 |
, BindingFlags.GetProperty |
|
| 884 |
, null |
|
| 885 |
, xlsWorkSheets |
|
| 886 |
, new object[] { i });
|
|
| 887 |
wrksheet.GetType().InvokeMember("Delete"
|
|
| 888 |
, BindingFlags.InvokeMethod |
|
| 889 |
, null |
|
| 890 |
, wrksheet |
|
| 891 |
, null); |
|
| 892 |
} |
|
| 893 |
|
|
| 894 |
return true; |
|
| 990 |
await Task.Delay(50); |
|
| 895 | 991 |
} |
| 896 | 992 |
catch (Exception ex) |
| 897 | 993 |
{
|
| 898 | 994 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
| 899 |
return false; |
|
| 900 | 995 |
} |
| 901 |
finally |
|
| 902 |
{
|
|
| 903 |
CommonMotions.ReleaseCom(ref wrksheet); |
|
| 904 |
} |
|
| 905 | 996 |
} |
| 906 | 997 |
#endregion |
| 907 | 998 |
|
| ... | ... | |
| 923 | 1014 |
try |
| 924 | 1015 |
{
|
| 925 | 1016 |
// シートコレクション取得 |
| 926 |
workSheets = xlsWorkBook.GetType().InvokeMember("WorkSheets"
|
|
| 1017 |
workSheets = m_XlsWorkBook.GetType().InvokeMember("WorkSheets"
|
|
| 927 | 1018 |
, BindingFlags.GetProperty |
| 928 | 1019 |
, null |
| 929 |
, xlsWorkBook
|
|
| 1020 |
, m_XlsWorkBook
|
|
| 930 | 1021 |
, null); |
| 931 | 1022 |
// シート枚数取得 |
| 932 | 1023 |
SheetCount = (int)workSheets.GetType().InvokeMember("Count"
|
| ... | ... | |
| 988 | 1079 |
try |
| 989 | 1080 |
{
|
| 990 | 1081 |
// シート枚数取得 |
| 991 |
SheetCount = (int)xlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 1082 |
SheetCount = (int)m_XlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 992 | 1083 |
, BindingFlags.GetProperty |
| 993 | 1084 |
, null |
| 994 |
, xlsWorkSheets
|
|
| 1085 |
, m_XlsWorkSheets
|
|
| 995 | 1086 |
, null); |
| 996 | 1087 |
// コピー先ブック、最終シートオブジェクト取得 |
| 997 |
CommonMotions.ReleaseCom(ref xlsWorkSheet);
|
|
| 998 |
xlsWorkSheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1088 |
CommonMotions.ReleaseCom(ref m_XlsWorkSheet);
|
|
| 1089 |
m_XlsWorkSheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 999 | 1090 |
, BindingFlags.GetProperty |
| 1000 | 1091 |
, null |
| 1001 |
, xlsWorkSheets
|
|
| 1092 |
, m_XlsWorkSheets
|
|
| 1002 | 1093 |
, new object[1] { SheetCount });
|
| 1003 | 1094 |
// シートコピー |
| 1004 |
xlsSheet.GetType().InvokeMember("Copy"
|
|
| 1095 |
m_XlsSheet.GetType().InvokeMember("Copy"
|
|
| 1005 | 1096 |
, BindingFlags.InvokeMethod |
| 1006 | 1097 |
, null |
| 1007 |
, xlsSheet
|
|
| 1008 |
, new object[2] { Type.Missing, xlsWorkSheet });
|
|
| 1098 |
, m_XlsSheet
|
|
| 1099 |
, new object[2] { Type.Missing, m_XlsWorkSheet });
|
|
| 1009 | 1100 |
|
| 1010 | 1101 |
// Sheet1が残っていたらシートを削除する |
| 1011 | 1102 |
// シート枚数取得 |
| 1012 |
SheetCount = (int)xlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 1103 |
SheetCount = (int)m_XlsWorkSheets.GetType().InvokeMember("Count"
|
|
| 1013 | 1104 |
, BindingFlags.GetProperty |
| 1014 | 1105 |
, null |
| 1015 |
, xlsWorkSheets
|
|
| 1106 |
, m_XlsWorkSheets
|
|
| 1016 | 1107 |
, null); |
| 1017 | 1108 |
if (Convert.ToInt32(SheetCount) == 2) |
| 1018 | 1109 |
{
|
| 1019 | 1110 |
// 先頭ページ取得 |
| 1020 |
OrgSheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1111 |
OrgSheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1021 | 1112 |
, BindingFlags.GetProperty |
| 1022 | 1113 |
, null |
| 1023 |
, xlsWorkSheets
|
|
| 1114 |
, m_XlsWorkSheets
|
|
| 1024 | 1115 |
, new object[1] { 1 });
|
| 1025 | 1116 |
// シート名取得 |
| 1026 | 1117 |
sheetName = OrgSheet.GetType().InvokeMember("Name"
|
| ... | ... | |
| 1033 | 1124 |
if (Convert.ToString(sheetName).Equals("Sheet1"))
|
| 1034 | 1125 |
{
|
| 1035 | 1126 |
// 先頭ページ取得 |
| 1036 |
OrgSheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1127 |
OrgSheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1037 | 1128 |
, BindingFlags.GetProperty |
| 1038 | 1129 |
, null |
| 1039 |
, xlsWorkSheets
|
|
| 1130 |
, m_XlsWorkSheets
|
|
| 1040 | 1131 |
, new object[1] { 1 });
|
| 1041 | 1132 |
// シート削除 |
| 1042 | 1133 |
OrgSheet.GetType().InvokeMember("Delete"
|
| ... | ... | |
| 1049 | 1140 |
// 現在シート数カウントアップ |
| 1050 | 1141 |
m_sPrintPage++; |
| 1051 | 1142 |
// 対象シートオブジェクトセット |
| 1052 |
CommonMotions.ReleaseCom(ref xlsWorkSheet);
|
|
| 1053 |
xlsWorkSheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1143 |
CommonMotions.ReleaseCom(ref m_XlsWorkSheet);
|
|
| 1144 |
m_XlsWorkSheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1054 | 1145 |
, BindingFlags.GetProperty |
| 1055 | 1146 |
, null, |
| 1056 |
xlsWorkSheets
|
|
| 1147 |
m_XlsWorkSheets
|
|
| 1057 | 1148 |
, new object[1] { m_sPrintPage });
|
| 1058 | 1149 |
// シート名が無ければ以下を処理しない |
| 1059 | 1150 |
if (strSheetName.Length == 0) return; |
| ... | ... | |
| 1064 | 1155 |
object NameSheet = null; |
| 1065 | 1156 |
for (int ix = (m_sPrintPage - 1); 0 < ix; ix--) |
| 1066 | 1157 |
{
|
| 1067 |
xlsNameSheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1158 |
xlsNameSheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1068 | 1159 |
, BindingFlags.GetProperty |
| 1069 | 1160 |
, null, |
| 1070 |
xlsWorkSheets
|
|
| 1161 |
m_XlsWorkSheets
|
|
| 1071 | 1162 |
, new object[1] { ix });
|
| 1072 | 1163 |
NameSheet = xlsNameSheet.GetType().InvokeMember("Name"
|
| 1073 | 1164 |
, BindingFlags.GetProperty |
| ... | ... | |
| 1075 | 1166 |
, xlsNameSheet |
| 1076 | 1167 |
, null); |
| 1077 | 1168 |
if (CommonMotions.cnvString(NameSheet).IndexOf(strSheetName) > -1) nNameCnt++; |
| 1169 |
|
|
| 1170 |
CommonMotions.ReleaseCom(ref xlsNameSheet); |
|
| 1171 |
CommonMotions.ReleaseCom(ref NameSheet); |
|
| 1078 | 1172 |
} |
| 1079 |
CommonMotions.ReleaseCom(ref xlsNameSheet); xlsNameSheet = null; |
|
| 1080 |
CommonMotions.ReleaseCom(ref NameSheet); NameSheet = null; |
|
| 1173 |
//CommonMotions.ReleaseCom(ref xlsNameSheet); xlsNameSheet = null;
|
|
| 1174 |
//CommonMotions.ReleaseCom(ref NameSheet); NameSheet = null;
|
|
| 1081 | 1175 |
|
| 1082 | 1176 |
string strSetName = strSheetName; |
| 1083 | 1177 |
if (nNameCnt > 0) strSetName = string.Format("{0}({1})", strSheetName, nNameCnt);
|
| 1084 | 1178 |
|
| 1085 | 1179 |
// シート名セット |
| 1086 |
xlsWorkSheet.GetType().InvokeMember("Name"
|
|
| 1180 |
m_XlsWorkSheet.GetType().InvokeMember("Name"
|
|
| 1087 | 1181 |
, BindingFlags.SetProperty |
| 1088 | 1182 |
, null |
| 1089 |
, xlsWorkSheet
|
|
| 1183 |
, m_XlsWorkSheet
|
|
| 1090 | 1184 |
, new object[1] { strSetName });
|
| 1091 | 1185 |
|
| 1092 | 1186 |
} |
| ... | ... | |
| 1109 | 1203 |
/// </summary> |
| 1110 | 1204 |
public void ExcelSaveConfirmation() |
| 1111 | 1205 |
{
|
| 1112 |
m_SaveSwitch = false; |
|
| 1113 |
//保存確認 |
|
| 1114 |
if (DialogResult.Yes != MessageBox.Show("ファイルを保存しますか?"
|
|
| 1115 |
, "確認" |
|
| 1116 |
, MessageBoxButtons.YesNo |
|
| 1117 |
, MessageBoxIcon.Question)) return; |
|
| 1118 |
// Yes時はtrue |
|
| 1119 |
m_SaveSwitch = true; |
|
| 1120 |
|
|
| 1206 |
try |
|
| 1207 |
{
|
|
| 1208 |
m_SaveSwitch = false; |
|
| 1209 |
//保存確認 |
|
| 1210 |
if (DialogResult.Yes != MessageBox.Show("ファイルを保存しますか?"
|
|
| 1211 |
, "確認" |
|
| 1212 |
, MessageBoxButtons.YesNo |
|
| 1213 |
, MessageBoxIcon.Question)) return; |
|
| 1214 |
// Yes時はtrue |
|
| 1215 |
m_SaveSwitch = true; |
|
| 1216 |
} |
|
| 1217 |
catch (Exception ex) |
|
| 1218 |
{
|
|
| 1219 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 1220 |
} |
|
| 1121 | 1221 |
} |
| 1122 | 1222 |
#endregion |
| 1123 | 1223 |
|
| ... | ... | |
| 1136 | 1236 |
if (!m_SaveSwitch) return; |
| 1137 | 1237 |
|
| 1138 | 1238 |
// シートコレクション取得 |
| 1139 |
CommonMotions.ReleaseCom(ref xlsSheets);
|
|
| 1140 |
xlsSheets = xlsWorkBook.GetType().InvokeMember("WorkSheets"
|
|
| 1239 |
CommonMotions.ReleaseCom(ref m_XlsSheets);
|
|
| 1240 |
m_XlsSheets = m_XlsWorkBook.GetType().InvokeMember("WorkSheets"
|
|
| 1141 | 1241 |
, BindingFlags.GetProperty |
| 1142 | 1242 |
, null |
| 1143 |
, xlsBook
|
|
| 1243 |
, m_XlsBook
|
|
| 1144 | 1244 |
, null); |
| 1145 | 1245 |
|
| 1146 | 1246 |
// 先頭ページ取得 |
| 1147 |
worksheet = xlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1247 |
worksheet = m_XlsWorkSheets.GetType().InvokeMember("Item"
|
|
| 1148 | 1248 |
, BindingFlags.GetProperty |
| 1149 | 1249 |
, null |
| 1150 |
, xlsWorkSheets
|
|
| 1250 |
, m_XlsWorkSheets
|
|
| 1151 | 1251 |
, new object[1] { 1 });
|
| 1152 | 1252 |
// シート選択 |
| 1153 | 1253 |
worksheet.GetType().InvokeMember("Select"
|
| ... | ... | |
| 1160 | 1260 |
Parameters[0] = @strFilePath + s_ExcelExtension[m_ExcelVersion]; |
| 1161 | 1261 |
|
| 1162 | 1262 |
// ワークブックを保存する |
| 1163 |
xlsWorkBook.GetType().InvokeMember("SaveAs"
|
|
| 1263 |
m_XlsWorkBook.GetType().InvokeMember("SaveAs"
|
|
| 1164 | 1264 |
, BindingFlags.InvokeMethod |
| 1165 | 1265 |
, null |
| 1166 |
, xlsWorkBook
|
|
| 1266 |
, m_XlsWorkBook
|
|
| 1167 | 1267 |
, Parameters); |
| 1168 | 1268 |
} |
| 1169 | 1269 |
catch (Exception ex) |
| ... | ... | |
| 1244 | 1344 |
try |
| 1245 | 1345 |
{
|
| 1246 | 1346 |
// レンジでセルを指定(ソース) |
| 1247 |
xlsSrcRange = xlsSheet.GetType().InvokeMember("Rows"
|
|
| 1347 |
xlsSrcRange = m_XlsSheet.GetType().InvokeMember("Rows"
|
|
| 1248 | 1348 |
, BindingFlags.GetProperty |
| 1249 | 1349 |
, null |
| 1250 |
, xlsSheet
|
|
| 1350 |
, m_XlsSheet
|
|
| 1251 | 1351 |
, new object[2] { SrcRow
|
| 1252 | 1352 |
, Missing.Value}); |
| 1253 | 1353 |
|
| 1254 | 1354 |
// レンジでセルを指定(デスト) |
| 1255 |
xlsDestRange = xlsWorkSheet.GetType().InvokeMember("Rows"
|
|
| 1355 |
xlsDestRange = m_XlsWorkSheet.GetType().InvokeMember("Rows"
|
|
| 1256 | 1356 |
, BindingFlags.GetProperty |
| 1257 | 1357 |
, null |
| 1258 |
, xlsWorkSheet
|
|
| 1358 |
, m_XlsWorkSheet
|
|
| 1259 | 1359 |
, new object[2] { DestRow
|
| 1260 | 1360 |
, Missing.Value}); |
| 1261 | 1361 |
|
| ... | ... | |
| 1267 | 1367 |
, new object[1] { xlsDestRange });
|
| 1268 | 1368 |
|
| 1269 | 1369 |
// 印刷頁数更新 |
| 1270 |
PageSetup = xlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1370 |
PageSetup = m_XlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1271 | 1371 |
, BindingFlags.GetProperty |
| 1272 | 1372 |
, null |
| 1273 |
, xlsWorkSheet
|
|
| 1373 |
, m_XlsWorkSheet
|
|
| 1274 | 1374 |
, null); |
| 1275 | 1375 |
|
| 1276 | 1376 |
PageSetup.GetType().InvokeMember("Zoom"
|
| ... | ... | |
| 1333 | 1433 |
//sheet = sheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, sheets, new object[] { sheetName });
|
| 1334 | 1434 |
|
| 1335 | 1435 |
// Shapeのあるシートをゲット |
| 1336 |
shapeSheet = xlsSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, xlsSheets, new object[] { ShapeDefine.ShapeSheetName });
|
|
| 1436 |
shapeSheet = m_XlsSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, m_XlsSheets, new object[] { ShapeDefine.ShapeSheetName });
|
|
| 1337 | 1437 |
|
| 1338 | 1438 |
// Shapeobjectをゲッツ |
| 1339 | 1439 |
shapesFrom = shapeSheet.GetType().InvokeMember("Shapes", BindingFlags.GetProperty, null, shapeSheet, null);
|
| ... | ... | |
| 1352 | 1452 |
newShape.GetType().InvokeMember("Cut", BindingFlags.InvokeMethod, null, newShape, null);
|
| 1353 | 1453 |
|
| 1354 | 1454 |
// 図形を貼り付ける |
| 1355 |
xlsWorkSheet.GetType().InvokeMember("Paste", BindingFlags.InvokeMethod, null, xlsWorkSheet, null);
|
|
| 1455 |
m_XlsWorkSheet.GetType().InvokeMember("Paste", BindingFlags.InvokeMethod, null, m_XlsWorkSheet, null);
|
|
| 1356 | 1456 |
|
| 1357 | 1457 |
// レンジでセルから位置・サイズ取得 |
| 1358 | 1458 |
object[] Parameters = new Object[2]; |
| ... | ... | |
| 1360 | 1460 |
Parameters[1] = Missing.Value; |
| 1361 | 1461 |
if (ToColum.Length != 0) Parameters[1] = ToColum; |
| 1362 | 1462 |
object Objwork = new object(); |
| 1363 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range", BindingFlags.GetProperty, null, xlsWorkSheet, Parameters);
|
|
| 1463 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range", BindingFlags.GetProperty, null, m_XlsWorkSheet, Parameters);
|
|
| 1364 | 1464 |
Objwork = xlsRange.GetType().InvokeMember("Top", BindingFlags.GetProperty, null, xlsRange, null);
|
| 1365 | 1465 |
float fTop = CommonMotions.cnvFloat(Objwork); |
| 1366 | 1466 |
Objwork = xlsRange.GetType().InvokeMember("Left", BindingFlags.GetProperty, null, xlsRange, null);
|
| ... | ... | |
| 1371 | 1471 |
float Height = CommonMotions.cnvFloat(Objwork); |
| 1372 | 1472 |
|
| 1373 | 1473 |
// 貼り付けた図形の配置 |
| 1374 |
shapesTo = xlsWorkSheet.GetType().InvokeMember("Shapes", BindingFlags.GetProperty, null, xlsWorkSheet, null);
|
|
| 1474 |
shapesTo = m_XlsWorkSheet.GetType().InvokeMember("Shapes", BindingFlags.GetProperty, null, m_XlsWorkSheet, null);
|
|
| 1375 | 1475 |
newShape2 = shapesTo.GetType().InvokeMember("Item", BindingFlags.InvokeMethod, null, shapesTo, new object[] { newItemName });
|
| 1376 | 1476 |
fTop += (Height - ShapeDefine.ShapeHeight) / 2; |
| 1377 | 1477 |
fLeft += (fWidth - ShapeDefine.ShapeWidth) / 2; |
| ... | ... | |
| 1436 | 1536 |
Parameters = new Object[2]; |
| 1437 | 1537 |
Parameters[0] = FromColum; |
| 1438 | 1538 |
Parameters[1] = Missing.Value; |
| 1439 |
xlsRange = xlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 1539 |
xlsRange = m_XlsWorkSheet.GetType().InvokeMember("Range"
|
|
| 1440 | 1540 |
, BindingFlags.GetProperty |
| 1441 | 1541 |
, null |
| 1442 |
, xlsWorkSheet
|
|
| 1542 |
, m_XlsWorkSheet
|
|
| 1443 | 1543 |
, Parameters); |
| 1444 | 1544 |
|
| 1445 | 1545 |
string strDirection = string.Empty; |
| ... | ... | |
| 1457 | 1557 |
} |
| 1458 | 1558 |
catch (Exception ex) |
| 1459 | 1559 |
{
|
| 1460 |
logger.ErrorFormat("配列セットシステムエラー:{0}:{1}:{2}", ex.Message, FromColum, dValue);
|
|
| 1560 |
logger.ErrorFormat("配列セットシステムエラー:{0}:{1}:{2}:{3}", ex.Message, CommonMotions.GetMethodName(), FromColum, dValue);
|
|
| 1461 | 1561 |
} |
| 1462 | 1562 |
finally |
| 1463 | 1563 |
{
|
| ... | ... | |
| 1478 | 1578 |
try |
| 1479 | 1579 |
{
|
| 1480 | 1580 |
// 印刷頁数更新 |
| 1481 |
PageSetup = xlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1581 |
PageSetup = m_XlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1482 | 1582 |
, BindingFlags.GetProperty |
| 1483 | 1583 |
, null |
| 1484 |
, xlsWorkSheet
|
|
| 1584 |
, m_XlsWorkSheet
|
|
| 1485 | 1585 |
, null); |
| 1486 | 1586 |
|
| 1587 |
PageSetup.GetType().InvokeMember("Zoom"
|
|
| 1588 |
, BindingFlags.SetProperty |
|
| 1589 |
, null |
|
| 1590 |
, PageSetup |
|
| 1591 |
, new object[1] { false });
|
|
| 1592 |
|
|
| 1487 | 1593 |
PageSetup.GetType().InvokeMember("FitToPagesTall"
|
| 1488 | 1594 |
, BindingFlags.SetProperty |
| 1489 | 1595 |
, null |
| ... | ... | |
| 1563 | 1669 |
try |
| 1564 | 1670 |
{
|
| 1565 | 1671 |
// 印刷頁セッティング取得 |
| 1566 |
PageSetup = xlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1672 |
PageSetup = m_XlsWorkSheet.GetType().InvokeMember("PageSetup"
|
|
| 1567 | 1673 |
, BindingFlags.GetProperty |
| 1568 | 1674 |
, null |
| 1569 |
, xlsWorkSheet
|
|
| 1675 |
, m_XlsWorkSheet
|
|
| 1570 | 1676 |
, null); |
| 1571 | 1677 |
|
| 1572 | 1678 |
// ----- 余白を取得する |
| trunk/src/ProcessManagement/ProcessManagement/Common/Process/ClsChangeLedgerData.cs | ||
|---|---|---|
| 54 | 54 |
/// 工事詳細台帳再計算処理(総支払額・粗利・給与・純利益が対象) |
| 55 | 55 |
/// </summary> |
| 56 | 56 |
/// <param name="ConstrCode"></param> |
| 57 |
public static bool LedgerRecalculate(IOConstructionLedgerExcute LedgerExcuteDB, List<int> ConstrCodeList) |
|
| 57 |
public static bool LedgerRecalculate(IOConstructionLedger LedgerDB, |
|
| 58 |
IOConstructionLedgerExcute LExecDB, |
|
| 59 |
List<int> ConstrCodeList) |
|
| 58 | 60 |
{
|
| 59 | 61 |
try |
| 60 | 62 |
{
|
| ... | ... | |
| 66 | 68 |
// 工事台帳実行データよりグループごとの合計金額を取得する |
| 67 | 69 |
strSQL.Clear(); |
| 68 | 70 |
strSQL.Append("SELECT");
|
| 69 |
strSQL.Append(" GROUPCOUNT");
|
|
| 70 |
strSQL.Append(", SUM(PAYMENTAMOUNT)");
|
|
| 71 |
strSQL.Append(" FROM CONSTRUCTIONLEDGEREXCUTE");
|
|
| 71 |
strSQL.Append(" A.GROUPCOUNT");
|
|
| 72 |
strSQL.Append(", SUM(A.PAYMENTAMOUNT)");
|
|
| 73 |
|
|
| 74 |
strSQL.Append(" FROM CONSTRUCTIONLEDGEREXCUTE As A");
|
|
| 75 |
|
|
| 76 |
strSQL.Append(" Inner Join constructionledgerdetail As B");
|
|
| 77 |
strSQL.Append(" On B.ConstructionCode = A.ConstructionCode");
|
|
| 78 |
strSQL.Append(" And B.GroupCount = A.GroupCount");
|
|
| 79 |
strSQL.Append(" And B.LineCount = A.LineCount");
|
|
| 80 |
strSQL.AppendFormat(" And B.InvalidLine = {0}", (int)ConstructionLedgerDetail.InvalidLineDef.ValidData);
|
|
| 81 |
|
|
| 72 | 82 |
strSQL.Append(" WHERE");
|
| 73 |
strSQL.AppendFormat(" CONSTRUCTIONCODE = {0}", ConstrCode);
|
|
| 74 |
strSQL.Append(" GROUP BY GROUPCOUNT");
|
|
| 75 |
strSQL.Append(" ORDER BY GROUPCOUNT");
|
|
| 83 |
strSQL.AppendFormat(" A.CONSTRUCTIONCODE = {0}", ConstrCode);
|
|
| 84 |
strSQL.Append(" GROUP BY A.GROUPCOUNT");
|
|
| 85 |
strSQL.Append(" ORDER BY A.GROUPCOUNT");
|
|
| 76 | 86 |
|
| 77 | 87 |
ArrayList InData = new ArrayList(); |
| 78 |
if (!LedgerExcuteDB.ExecuteReader(strSQL.ToString(), ref InData, false)) continue;
|
|
| 88 |
if (!LExecDB.ExecuteReader(strSQL.ToString(), ref InData, false)) continue;
|
|
| 79 | 89 |
|
| 80 | 90 |
// データ無は次のデータ |
| 81 | 91 |
if (InData.Count == 0) continue; |
| ... | ... | |
| 119 | 129 |
strSQL.AppendFormat(", NETPROFIT = {0}", (Billing - (Payment + Compensation + Allowance + PExpenses))); // ----- 純利益
|
| 120 | 130 |
strSQL.Append(" , UpdateDate = NOW()");
|
| 121 | 131 |
strSQL.AppendFormat(" WHERE CONSTRUCTIONCODE = {0}", ConstrCode);
|
| 122 |
if (!LedgerExcuteDB.ExecuteNonQuery(strSQL.ToString(), false))
|
|
| 132 |
if (!LedgerDB.ExecuteNonQuery(strSQL.ToString(), false)) |
|
| 123 | 133 |
{
|
| 124 | 134 |
bRet = false; |
| 125 | 135 |
break; |
| ... | ... | |
| 176 | 186 |
} |
| 177 | 187 |
#endregion |
| 178 | 188 |
|
| 189 |
#region 工事詳細台帳対象月カラム位置取得SQL |
|
| 190 |
/// <summary> |
|
| 191 |
/// 工事詳細台帳対象月カラム位置取得SQL |
|
| 192 |
/// </summary> |
|
| 193 |
/// <returns></returns> |
|
| 194 |
public static string SetLedgerColPoint(int TargetYM) |
|
| 195 |
{
|
|
| 196 |
StringBuilder strWork = new StringBuilder(); |
|
| 197 |
try |
|
| 198 |
{
|
|
| 199 |
int DefaultCol = GetLedgerColumnCount(); |
|
| 200 |
|
|
| 201 |
strWork.Append(" Case When AX.TargetMonth is not null Then");
|
|
| 202 |
strWork.AppendFormat(" PERIOD_DIFF({0}, DATE_FORMAT(AX.TargetMonth, '%Y%m')) + {1}", TargetYM, DefaultCol);
|
|
| 203 |
strWork.Append(" Else Case When ifnull(Cl.CONSTRUCTIONCODE, 0) = 0 Then 0");
|
|
| 204 |
strWork.AppendFormat(" Else PERIOD_DIFF({0}, DATE_FORMAT(Cl.ConstructionStart, '%Y%m')) + {1}", TargetYM, DefaultCol);
|
|
| 205 |
strWork.Append(" End");
|
|
| 206 |
strWork.Append(" End As ColPoint");
|
|
| 207 |
} |
|
| 208 |
catch (Exception ex) |
|
| 209 |
{
|
|
| 210 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 211 |
} |
|
| 212 |
return strWork.ToString(); |
|
| 213 |
} |
|
| 214 |
#endregion |
|
| 215 |
|
|
| 179 | 216 |
#region 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
| 180 | 217 |
/// <summary> |
| 181 | 218 |
/// 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
| ... | ... | |
| 186 | 223 |
try |
| 187 | 224 |
{
|
| 188 | 225 |
StringBuilder strSQL = new StringBuilder(); |
| 189 |
strSQL.Append("SELECT MIN(A.TargetMonth), MIN(A.ColumnCount) FROM ConstructionLedgerExcute AS A");
|
|
| 190 |
strSQL.AppendFormat(" WHERE A.ConstructionCode = {0}", ConstrCode);
|
|
| 191 |
strSQL.Append(" GROUP BY A.ConstructionCode");
|
|
| 226 |
int TargetYM = TargetMonth.Year * 100 + TargetMonth.Month; |
|
| 227 |
strSQL.Append("SELECT");
|
|
| 228 |
strSQL.Append(SetLedgerColPoint(TargetYM)); |
|
| 229 |
strSQL.Append(" From constructionledger as Cl");
|
|
| 230 |
strSQL.Append(" Left Join (Select A.ConstructionCode");
|
|
| 231 |
strSQL.Append(" , Min(A.ColumnCount) As ColumnCount");
|
|
| 232 |
strSQL.Append(" , Min(A.TargetMonth) As TargetMonth");
|
|
| 233 |
strSQL.Append(" From constructionledgerexcute As A");
|
|
| 234 |
strSQL.Append(" Group By A.ConstructionCode) As AX");
|
|
| 235 |
strSQL.Append(" On AX.ConstructionCode = Cl.ConstructionCode");
|
|
| 236 |
strSQL.Append(" Where");
|
|
| 237 |
strSQL.AppendFormat(" Cl.ConstructionCode = {0}", ConstrCode);
|
|
| 192 | 238 |
|
| 193 | 239 |
ArrayList arList = new ArrayList(); |
| 194 | 240 |
if (!execDB.ExecuteReader(strSQL.ToString(), ref arList, bConnect)) return 0; |
| 195 | 241 |
if (arList.Count < 1) return 0; |
| 196 | 242 |
|
| 197 | 243 |
object[] objRec = (object[])arList[0]; |
| 198 |
DateTime dtADate = CommonMotions.cnvDate(objRec[0]); |
|
| 199 |
int nAPoint = CommonMotions.cnvInt(objRec[1]); |
|
| 244 |
int Columncnt = CommonMotions.cnvInt(objRec[0]); |
|
| 200 | 245 |
|
| 201 |
int Columncnt = 0; |
|
| 202 |
DateTime dtBDate = new DateTime(TargetMonth.Year, TargetMonth.Month, 1); |
|
| 203 |
Columncnt = nAPoint + DateTimeUtil.GetElapsedMonths(dtADate, dtBDate); |
|
| 204 |
|
|
| 205 | 246 |
return Columncnt; |
| 206 | 247 |
} |
| 207 | 248 |
catch (Exception ex) |
| ... | ... | |
| 219 | 260 |
/// <returns></returns> |
| 220 | 261 |
public static bool CalculatePayment(List<ConstructionLedger> LedgerList) |
| 221 | 262 |
{
|
| 263 |
IOConstructionLedger LedgerDB = new IOConstructionLedger(); |
|
| 222 | 264 |
IOConstructionLedgerDetail LedgerDeDB = new IOConstructionLedgerDetail(); |
| 223 | 265 |
IOConstructionLedgerExcute LedgerExDB = new IOConstructionLedgerExcute(); |
| 224 | 266 |
IOMPersonInCharge PersonDB = new IOMPersonInCharge(); |
| ... | ... | |
| 227 | 269 |
bool bret = true; |
| 228 | 270 |
List<int> ConstrCodeList = new List<int>(); |
| 229 | 271 |
|
| 230 |
LedgerDeDB.connect(); LedgerDeDB.beginTran(); |
|
| 272 |
LedgerDB.connect(); LedgerDB.beginTran(); |
|
| 273 |
LedgerDeDB.connect(); |
|
| 231 | 274 |
LedgerExDB.connect(); LedgerExDB.beginTran(); |
| 232 |
PersonDB.connect(); PersonDB.beginTran();
|
|
| 275 |
PersonDB.connect(); |
|
| 233 | 276 |
|
| 234 | 277 |
StringBuilder DetailSQL = new StringBuilder(); |
| 235 | 278 |
foreach (ConstructionLedger LedgerRec in LedgerList) |
| ... | ... | |
| 283 | 326 |
if (bret) |
| 284 | 327 |
{
|
| 285 | 328 |
// 工事台帳更新 |
| 286 |
bret = LedgerRecalculate(LedgerExDB, ConstrCodeList); |
|
| 329 |
bret = LedgerRecalculate(LedgerDB, LedgerExDB, ConstrCodeList);
|
|
| 287 | 330 |
} |
| 288 | 331 |
|
| 289 | 332 |
// エラー時ロールバック |
| 290 |
if (!bret) LedgerExDB.rollback(); |
|
| 333 |
if (!bret) |
|
| 334 |
{
|
|
| 335 |
LedgerDB.rollback(); |
|
| 336 |
LedgerExDB.rollback(); |
|
| 337 |
} |
|
| 291 | 338 |
|
| 292 | 339 |
// DB Commit |
| 340 |
LedgerDB.commit(); |
|
| 293 | 341 |
LedgerExDB.commit(); |
| 294 | 342 |
|
| 295 | 343 |
return bret; |
| ... | ... | |
| 301 | 349 |
} |
| 302 | 350 |
finally |
| 303 | 351 |
{
|
| 352 |
LedgerDB.close(); LedgerDB = null; |
|
| 304 | 353 |
LedgerDeDB.close(); LedgerDeDB = null; |
| 305 | 354 |
LedgerExDB.close(); LedgerExDB = null; |
| 306 | 355 |
PersonDB.close(); PersonDB = null; |
| ... | ... | |
| 849 | 898 |
{
|
| 850 | 899 |
IOCostDataOfPerson CostDB = new IOCostDataOfPerson(); |
| 851 | 900 |
IOConstructionLedger LedgerDB = new IOConstructionLedger(); |
| 852 |
IOConstructionLedgerDetail LedgerDetailDB = new IOConstructionLedgerDetail();
|
|
| 853 |
IOConstructionLedgerExcute LedgerExcuteDB = new IOConstructionLedgerExcute();
|
|
| 901 |
IOConstructionLedgerDetail LDetailDB = new IOConstructionLedgerDetail(); |
|
| 902 |
IOConstructionLedgerExcute LExcuteDB = new IOConstructionLedgerExcute(); |
|
| 854 | 903 |
try |
| 855 | 904 |
{
|
| 856 | 905 |
List<int> ConstrCodeList = new List<int>(); |
| 857 | 906 |
|
| 858 | 907 |
// 一括処理で登録を行う |
| 859 | 908 |
CostDB.connect(); |
| 860 |
LedgerDB.connect(); |
|
| 861 |
LedgerDetailDB.connect();
|
|
| 862 |
LedgerExcuteDB.connect(); LedgerExcuteDB.beginTran();
|
|
| 909 |
LedgerDB.connect(); LedgerDB.beginTran();
|
|
| 910 |
LDetailDB.connect(); |
|
| 911 |
LExcuteDB.connect(); LExcuteDB.beginTran();
|
|
| 863 | 912 |
|
| 864 | 913 |
// 対象をまず削除する(対象月で削除する) |
| 865 | 914 |
StringBuilder strDelSQL = new StringBuilder(); |
| ... | ... | |
| 878 | 927 |
, GetConstructionLedgerGroupNo((int)CostDataOfPerson.DataNoDef.Lodging) |
| 879 | 928 |
, GetConstructionLedgerGroupNo((int)CostDataOfPerson.DataNoDef.DisposalCost)); |
| 880 | 929 |
strDelSQL.AppendFormat(" AND DATE(TARGETMONTH) = DATE('{0}{1}')", TargetMonth, "/01");
|
| 881 |
LedgerExcuteDB.ExecuteNonQuery(strDelSQL.ToString(), false);
|
|
| 930 |
LExcuteDB.ExecuteNonQuery(strDelSQL.ToString(), false); |
|
| 882 | 931 |
|
| 883 | 932 |
for (int i = (int)CostDataOfPerson.DataNoDef.Transport; i <= (int)CostDataOfPerson.DataNoDef.DisposalCost; i++) |
| 884 | 933 |
{
|
| ... | ... | |
| 921 | 970 |
int ColCnt = 0; |
| 922 | 971 |
// 台帳が無ければ処理しない |
| 923 | 972 |
if (!SearchTatgetConstructionLedger(LedgerDB, |
| 924 |
LedgerDetailDB,
|
|
| 925 |
LedgerExcuteDB,
|
|
| 973 |
LDetailDB, |
|
| 974 |
LExcuteDB, |
|
| 926 | 975 |
ConstructionCode, |
| 927 | 976 |
GroupNo, |
| 928 | 977 |
TargetMonth, |
| ... | ... | |
| 938 | 987 |
excRec.PaymentAmount = PaymentPrice; |
| 939 | 988 |
excRec.TargetMonth = CommonMotions.cnvDate(TargetMonth + "/01"); |
| 940 | 989 |
|
| 941 |
if (!LedgerExcuteDB.InsertAction(excRec, false))
|
|
| 990 |
if (!LExcuteDB.InsertAction(excRec, false)) |
|
| 942 | 991 |
{
|
| 943 |
LedgerExcuteDB.rollback();
|
|
| 992 |
LExcuteDB.rollback(); |
|
| 944 | 993 |
return false; |
| 945 | 994 |
} |
| 946 | 995 |
} |
| 947 | 996 |
} |
| 948 | 997 |
|
| 949 | 998 |
// 工事詳細台帳の更新 |
| 950 |
if (!LedgerRecalculate(LedgerExcuteDB, ConstrCodeList)) |
|
| 999 |
if (!LedgerRecalculate(LedgerDB, LExcuteDB, ConstrCodeList))
|
|
| 951 | 1000 |
{
|
| 952 |
LedgerExcuteDB.rollback(); |
|
| 1001 |
LedgerDB.rollback(); |
|
| 1002 |
LExcuteDB.rollback(); |
|
| 953 | 1003 |
return false; |
| 954 | 1004 |
} |
| 955 | 1005 |
|
| 956 | 1006 |
// DBコミット |
| 957 |
LedgerExcuteDB.commit(); |
|
| 1007 |
LedgerDB.commit(); |
|
| 1008 |
LExcuteDB.commit(); |
|
| 958 | 1009 |
|
| 959 | 1010 |
return true; |
| 960 | 1011 |
} |
| 961 | 1012 |
catch (System.Exception ex) |
| 962 | 1013 |
{
|
| 963 | 1014 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
| 964 |
LedgerExcuteDB.rollback(); |
|
| 1015 |
LedgerDB.rollback(); |
|
| 1016 |
LExcuteDB.rollback(); |
|
| 965 | 1017 |
return false; |
| 966 | 1018 |
} |
| 967 | 1019 |
finally |
| 968 | 1020 |
{
|
| 969 | 1021 |
CostDB.close(); CostDB = null; |
| 970 | 1022 |
LedgerDB.close(); LedgerDB = null; |
| 971 |
LedgerDetailDB.close(); LedgerDetailDB = null;
|
|
| 972 |
LedgerExcuteDB.close(); LedgerExcuteDB = null;
|
|
| 1023 |
LDetailDB.close(); LDetailDB = null;
|
|
| 1024 |
LExcuteDB.close(); LExcuteDB = null;
|
|
| 973 | 1025 |
} |
| 974 | 1026 |
} |
| 975 | 1027 |
#endregion |
| ... | ... | |
| 1214 | 1266 |
} |
| 1215 | 1267 |
#endregion |
| 1216 | 1268 |
|
| 1217 |
#region 工事詳細台帳支払いデータ一括登録(手間・業者支払用) |
|
| 1218 |
/// <summary> |
|
| 1219 |
/// 工事詳細台帳支払いデータ一括登録(手間・業者支払用) |
|
| 1220 |
/// </summary> |
|
| 1221 |
/// <param name="EntryList"></param> |
|
| 1222 |
/// <returns></returns> |
|
| 1223 |
public static bool EntryExecuteData(IOConstructionLedgerDetail DetailDB |
|
| 1224 |
, IOConstructionLedgerExcute ExecDB |
|
| 1225 |
, ArrayList EntryList) |
|
| 1226 |
{
|
|
| 1227 |
try |
|
| 1228 |
{
|
|
| 1229 |
StringBuilder strSQL = new StringBuilder(); |
|
| 1230 |
bool bExists = true; |
|
| 1231 |
bool bRet = true; |
|
| 1232 |
List<int> ConstrCodeList = new List<int>(); |
|
| 1233 |
ArrayList ExecList = new ArrayList(); |
|
| 1234 |
|
|
| 1235 |
foreach (object[] CurData in EntryList) |
|
| 1236 |
{
|
|
| 1237 |
|
|
| 1238 |
ConstructionLedgerDetail DetailRec = (ConstructionLedgerDetail)CurData[0]; |
|
| 1239 |
ConstructionLedgerExcute ExcuteRec = (ConstructionLedgerExcute)CurData[1]; |
|
| 1240 |
|
|
| 1241 |
// 工事番号が0の場合は処理しない |
|
| 1242 |
if (ExcuteRec.ConstructionCode == 0) continue; |
|
| 1243 |
// グループ番号が0の場合は処理しない |
|
| 1244 |
if (ExcuteRec.GroupCount == 0) continue; |
|
| 1245 |
|
|
| 1246 |
// SQL作成 |
|
| 1247 |
strSQL.Clear(); |
|
| 1248 |
strSQL.Append("Select");
|
|
| 1249 |
strSQL.Append(" A.ConstructionCode");
|
|
| 1250 |
strSQL.Append(", A.GroupCount");
|
|
| 1251 |
strSQL.Append(", A.LineCount");
|
|
| 1252 |
strSQL.Append(", B.ColumnCount");
|
|
| 1253 |
strSQL.Append(", B.TargetMonth");
|
|
| 1254 |
strSQL.Append(" From");
|
|
| 1255 |
strSQL.Append(" constructionledgerdetail AS A");
|
|
| 1256 |
strSQL.Append(" Left Join constructionledgerexcute AS B");
|
|
| 1257 |
strSQL.Append(" On B.ConstructionCode = A.ConstructionCode");
|
|
| 1258 |
strSQL.Append(" And B.GroupCount = A.GroupCount");
|
|
| 1259 |
strSQL.Append(" And B.LineCount = A.LineCount");
|
|
| 1260 |
strSQL.AppendFormat(" And B.ColumnCount = {0}", ExcuteRec.ColumnCount);
|
|
| 1261 |
|
|
| 1262 |
strSQL.AppendFormat(" Where A.ConstructionCode = {0}", ExcuteRec.ConstructionCode);
|
|
| 1263 |
strSQL.AppendFormat(" And A.GroupCount = {0}", ExcuteRec.GroupCount);
|
|
| 1264 |
strSQL.AppendFormat(" And A.DetailCount = {0}", DetailRec.DetailCount);
|
|
| 1265 |
|
|
| 1266 |
ExecList.Clear(); |
|
| 1267 |
if (!ExecDB.ExecuteReader(strSQL.ToString(), ref ExecList, false)) continue; |
|
| 1268 |
|
|
| 1269 |
bExists = false; |
|
| 1270 |
object[] objRec = (object[])ExecList[0]; |
|
| 1271 |
// 明細データが存在する場合 |
|
| 1272 |
if (ExecList.Count > 0) |
|
| 1273 |
{
|
|
| 1274 |
// 行番号をセットする |
|
| 1275 |
ExcuteRec.LineCount = CommonMotions.cnvInt(objRec[2]); |
|
| 1276 |
DetailRec.LineCount = ExcuteRec.LineCount; |
|
| 1277 |
// 実行データも存在する場合 |
|
| 1278 |
if (CommonMotions.cnvInt(objRec[3]) != 0) |
|
| 1279 |
{
|
|
| 1280 |
bExists = true; |
|
| 1281 |
} |
|
| 1282 |
} |
|
| 1283 |
|
|
| 1284 |
if (bExists) |
|
| 1285 |
{ // データ存在時は支払金額更新
|
|
| 1286 |
if (!ExecDB.UpdateFeild(ExcuteRec.ConstructionCode, |
|
| 1287 |
ExcuteRec.GroupCount, |
|
| 1288 |
ExcuteRec.LineCount, |
|
| 1289 |
ExcuteRec.ColumnCount, |
|
| 1290 |
(int)IOConstructionLedgerExcute.TableColumn.PaymentAmount, |
|
| 1291 |
ExcuteRec.PaymentAmount, |
|
| 1292 |
false)) |
|
| 1293 |
{
|
|
| 1294 |
bRet = false; |
|
| 1295 |
break; |
|
| 1296 |
} |
|
| 1297 |
} |
|
| 1298 |
else |
|
| 1299 |
{
|
|
| 1300 |
// キー項目取得条件作成 |
|
| 1301 |
strSQL.Clear(); |
|
| 1302 |
strSQL.Append(DetailDB.CreatePrimarykeyString(ExcuteRec.ConstructionCode, ExcuteRec.GroupCount)); |
|
| 1303 |
strSQL.AppendFormat(" And DetailCount = {0}", DetailRec.DetailCount);
|
|
| 1304 |
|
|
| 1305 |
// データがない場合は新規行番号を取得する |
|
| 1306 |
ExcuteRec.LineCount = DetailDB.SelectMaxLineCount(strSQL.ToString(), false) + 1; |
|
| 1307 |
DetailRec.LineCount = ExcuteRec.LineCount; |
|
| 1308 |
|
|
| 1309 |
// 明細データも実行データも存在しない |
|
| 1310 |
if (ExecList.Count < 1) |
|
| 1311 |
{
|
|
| 1312 |
// データがない場合は新規明細番号を取得する |
|
| 1313 |
DetailRec.DetailCount = DetailDB.SelectMaxDetailCount(strSQL.ToString(), false) + 1; |
|
| 1314 |
|
|
| 1315 |
// 明細データ新規作成 |
|
| 1316 |
if (!DetailDB.InsertAction(DetailRec, false)) |
|
| 1317 |
{
|
|
| 1318 |
bRet = false; |
|
| 1319 |
break; |
|
| 1320 |
} |
|
| 1321 |
} |
|
| 1322 |
|
|
| 1323 |
// 実行データ新規作成 |
|
| 1324 |
if (!ExecDB.InsertAction(ExcuteRec, false)) |
|
| 1325 |
{
|
|
| 1326 |
bRet = false; |
|
| 1327 |
break; |
|
| 1328 |
} |
|
| 1329 |
} |
|
| 1330 |
|
|
| 1331 |
// 更新対象リストへの追加処理 |
|
| 1332 |
bool bAddFlg = true; |
|
| 1333 |
foreach (int CurCode in ConstrCodeList) |
|
| 1334 |
{
|
|
| 1335 |
// 既に追加済みかを探す |
|
| 1336 |
if (CurCode == ExcuteRec.ConstructionCode) |
|
| 1337 |
{
|
|
| 1338 |
bAddFlg = false; |
|
| 1339 |
break; |
|
| 1340 |
} |
|
他の形式にエクスポート: Unified diff