1 |
|
using System;
|
2 |
|
using System.Collections;
|
3 |
|
using System.Collections.Generic;
|
4 |
|
using System.ComponentModel;
|
5 |
|
using System.Data;
|
6 |
|
using System.Drawing;
|
7 |
|
using System.Linq;
|
8 |
|
using System.Text;
|
9 |
|
using System.Threading.Tasks;
|
10 |
|
using System.Windows.Forms;
|
11 |
|
|
12 |
|
using ProcessManagement.Common;
|
13 |
|
using ProcessManagement.DataModel;
|
14 |
|
using ProcessManagement.DB;
|
15 |
|
using ProcessManagement.DB.IOAccess;
|
16 |
|
using ProcessManagement.Forms.SubForms;
|
17 |
|
using ProcessManagement.Forms.ControlsAction;
|
18 |
|
|
19 |
|
|
20 |
|
namespace ProcessManagement.Forms.DataEntry
|
21 |
|
{
|
22 |
|
public partial class FrmRequestPrintSel
|
23 |
|
{
|
24 |
|
#region 定数
|
25 |
|
|
26 |
|
/// <summary>
|
27 |
|
/// Excelテンプレートファイル名
|
28 |
|
/// </summary>
|
29 |
|
//private static string s_ExcelRequestSheetFileName = @"\RequestSheet.xlsx";
|
30 |
|
private static string s_ExcelRequestSheetFileName = CommonDefine.s_ExcelOriginalFileName;
|
31 |
|
|
32 |
|
/// <summary>
|
33 |
|
/// デスクトップフォルダ名
|
34 |
|
/// </summary>
|
35 |
|
private static string s_ExecCurrentDirName = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
36 |
|
|
37 |
|
/// <summary>
|
38 |
|
/// シート名称カウント
|
39 |
|
/// </summary>
|
40 |
|
enum enumSheetName
|
41 |
|
{
|
42 |
|
Cover = 0,
|
43 |
|
List,
|
44 |
|
Detail,
|
45 |
|
}
|
46 |
|
|
47 |
|
/// <summary>
|
48 |
|
/// Excel シート名称
|
49 |
|
/// </summary>
|
50 |
|
private static readonly Dictionary<enumSheetName, string> s_DicSheetName = new Dictionary<enumSheetName, string>()
|
51 |
|
{
|
52 |
|
{ enumSheetName.Cover, "請求書(表紙)" },
|
53 |
|
{ enumSheetName.List, "請求書(一覧)" },
|
54 |
|
{ enumSheetName.Detail, "請求書(内訳)" },
|
55 |
|
};
|
56 |
|
|
57 |
|
/// <summary>
|
58 |
|
/// 図形置き場シート
|
59 |
|
/// </summary>
|
60 |
|
private const string s_shapeSheetName = "図形シート";
|
61 |
|
/// <summary>
|
62 |
|
/// 図形名称
|
63 |
|
/// </summary>
|
64 |
|
private const string s_shapeName = "EstimateSeal1"; // 積算見積表紙判子
|
65 |
|
/// <summary>
|
66 |
|
/// 図形サイズ【縦・横】(図形名称順)
|
67 |
|
/// </summary>
|
68 |
|
private static float[,] s_ShapeSize = new float[1, 2] { { 25.51f, 25.51f } }; // 積算見積表紙判子
|
69 |
|
/// <summary>
|
70 |
|
/// 積算見積表紙判子フォントサイズ
|
71 |
|
/// </summary>
|
72 |
|
private static float[] s_EstimateSeal1FontSize = { 16f, 8f, 8f, 8f, 6f };
|
73 |
|
/// <summary>
|
74 |
|
/// 表紙判子位置(Key:X Value:Y)
|
75 |
|
/// </summary>
|
76 |
|
private static float[,] s_CoverSealPoint = new float[4, 2] {{592.50f, 555.25f}, // 社長
|
77 |
|
{657.25f, 555.25f}, // 所属長
|
78 |
|
{721.00f, 555.25f}, // 営業
|
79 |
|
{784.00f, 555.25f} }; // 担当
|
80 |
|
|
81 |
|
#endregion
|
82 |
|
|
83 |
|
#region 変数
|
84 |
|
|
85 |
|
/// <summary>
|
86 |
|
/// Excel印刷クラスオブジェクト
|
87 |
|
/// </summary>
|
88 |
|
private UsedExcel m_UsedExcel = null;
|
89 |
|
|
90 |
|
/// <summary>
|
91 |
|
/// 保存時Excelパス
|
92 |
|
/// </summary>
|
93 |
|
private string m_SelectSaveExcel = "";
|
94 |
|
|
95 |
|
/// <summary>
|
96 |
|
/// 請求書データ
|
97 |
|
/// </summary>
|
98 |
|
private InvoiceData m_InvData = new InvoiceData();
|
99 |
|
|
100 |
|
/// <summary>
|
101 |
|
/// 請求データ
|
102 |
|
/// </summary>
|
103 |
|
private Dictionary<int, List<RequestData>> m_dicReqData = new Dictionary<int, List<RequestData>>();
|
104 |
|
|
105 |
|
/// <summary>
|
106 |
|
/// 工事基本情報データ
|
107 |
|
/// </summary>
|
108 |
|
private Dictionary<int, ConstructionBaseInfo> m_dicConstructionBaseInfo = new Dictionary<int, ConstructionBaseInfo>();
|
109 |
|
|
110 |
|
/// <summary>
|
111 |
|
/// 日付印刷
|
112 |
|
/// </summary>
|
113 |
|
private bool m_bDatePrintFlg = true;
|
114 |
|
|
115 |
|
/// <summary>
|
116 |
|
/// 印刷日付
|
117 |
|
/// </summary>
|
118 |
|
private DateTime m_bDatePrintOut = DateTime.Now;
|
119 |
|
|
120 |
|
#endregion
|
121 |
|
|
122 |
|
#region プロパティ
|
123 |
|
|
124 |
|
/// <summary>
|
125 |
|
/// 日付印刷フラグ
|
126 |
|
/// </summary>
|
127 |
|
public bool DatePrintFlg
|
128 |
|
{
|
129 |
|
get { return m_bDatePrintFlg; }
|
130 |
|
set { m_bDatePrintFlg = value; }
|
131 |
|
}
|
132 |
|
|
133 |
|
/// <summary>
|
134 |
|
/// 印刷日付
|
135 |
|
/// </summary>
|
136 |
|
public DateTime DatePrintOut
|
137 |
|
{
|
138 |
|
get { return m_bDatePrintOut; }
|
139 |
|
set { m_bDatePrintOut = value; }
|
140 |
|
}
|
141 |
|
|
142 |
|
#endregion
|
143 |
|
|
144 |
|
#region 請求書データの取得
|
145 |
|
/// <summary>
|
146 |
|
/// 請求書データの取得
|
147 |
|
/// </summary>
|
148 |
|
private bool GetInvoiceData()
|
149 |
|
{
|
150 |
|
IOInvoiceData ioInvData = new IOInvoiceData();
|
151 |
|
IORequestHead ioReqHead = new IORequestHead();
|
152 |
|
IORequestData ioReqData = new IORequestData();
|
153 |
|
|
154 |
|
try
|
155 |
|
{
|
156 |
|
string sql = "";
|
157 |
|
|
158 |
|
// 請求書データの取得
|
159 |
|
sql = ioInvData.CreatePrimarykeyString(m_nInvoiceNo);
|
160 |
|
if (ioInvData.SelectAction(sql, ref m_InvData) == false)
|
161 |
|
{
|
162 |
|
return false;
|
163 |
|
}
|
164 |
|
|
165 |
|
// 請求ヘッダの取得
|
166 |
|
m_lstReqHead.Clear();
|
167 |
|
sql = string.Format(" WHERE InvoiceNo = {0} ORDER BY ReqConstructionCode", m_nInvoiceNo);
|
168 |
|
if (ioReqHead.SelectAction(sql, ref m_lstReqHead) == false)
|
169 |
|
{
|
170 |
|
return false;
|
171 |
|
}
|
172 |
|
|
173 |
|
foreach (RequestHead ReqHead in m_lstReqHead)
|
174 |
|
{
|
175 |
|
// 請求ヘッダの取得
|
176 |
|
sql = string.Format(" WHERE RequestNo = {0} ORDER BY MainConstructionCode", ReqHead.RequestNo);
|
177 |
|
List<RequestData> lstReqData = new List<RequestData>();
|
178 |
|
if (ioReqData.SelectAction(sql, ref lstReqData) == false)
|
179 |
|
{
|
180 |
|
return false;
|
181 |
|
}
|
182 |
|
|
183 |
|
m_dicReqData.Add(ReqHead.RequestNo, lstReqData);
|
184 |
|
|
185 |
|
}
|
186 |
|
|
187 |
|
return true;
|
188 |
|
}
|
189 |
|
catch (Exception ex)
|
190 |
|
{
|
191 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
192 |
|
|
193 |
|
return false;
|
194 |
|
}
|
195 |
|
finally
|
196 |
|
{
|
197 |
|
ioInvData.close();
|
198 |
|
ioInvData = null;
|
199 |
|
ioReqHead.close();
|
200 |
|
ioReqHead = null;
|
201 |
|
ioReqData.close();
|
202 |
|
ioReqData = null;
|
203 |
|
}
|
204 |
|
|
205 |
|
}
|
206 |
|
#endregion
|
207 |
|
|
208 |
|
#region 工事基本情報の追加
|
209 |
|
private void AddConstructionBaseInfoDic(ConstructionBaseInfo Info)
|
210 |
|
{
|
211 |
|
ConstructionBaseInfo wrk = null;
|
212 |
|
|
213 |
|
if (m_dicConstructionBaseInfo.TryGetValue(Info.ConstructionCode, out wrk) == false)
|
214 |
|
{
|
215 |
|
m_dicConstructionBaseInfo.Add(Info.ConstructionCode, Info);
|
216 |
|
}
|
217 |
|
}
|
218 |
|
#endregion
|
219 |
|
|
220 |
|
#region 工事基本情報の取得
|
221 |
|
/// <summary>
|
222 |
|
/// 工事基本情報の取得
|
223 |
|
/// </summary>
|
224 |
|
private bool GetMainConstructionBaseInfo()
|
225 |
|
{
|
226 |
|
IOConstructionBaseInfo ioInfo = new IOConstructionBaseInfo();
|
227 |
|
|
228 |
|
foreach (RequestHead ReqHead in m_lstReqHead)
|
229 |
|
{
|
230 |
|
string sql = ioInfo.CreatePrimarykeyString(ReqHead.ReqConstructionCode);
|
231 |
|
ConstructionBaseInfo info = new ConstructionBaseInfo();
|
232 |
|
if (ioInfo.SelectAction(sql, ref info) == false)
|
233 |
|
{
|
234 |
|
return false;
|
235 |
|
}
|
236 |
|
|
237 |
|
AddConstructionBaseInfoDic(info);
|
238 |
|
}
|
239 |
|
|
240 |
|
List<int> lstKey = new List<int>(m_dicReqData.Keys);
|
241 |
|
try
|
242 |
|
{
|
243 |
|
foreach (int nRequestNo in lstKey)
|
244 |
|
{
|
245 |
|
List<RequestData> lstReqData = null;
|
246 |
|
|
247 |
|
if (m_dicReqData.TryGetValue(nRequestNo, out lstReqData) == false)
|
248 |
|
{
|
249 |
|
return false;
|
250 |
|
}
|
251 |
|
|
252 |
|
foreach (RequestData ReqData in lstReqData)
|
253 |
|
{
|
254 |
|
string sql = ioInfo.CreatePrimarykeyString(ReqData.MainConstructionCode);
|
255 |
|
ConstructionBaseInfo info = new ConstructionBaseInfo();
|
256 |
|
if (ioInfo.SelectAction(sql, ref info) == false)
|
257 |
|
{
|
258 |
|
return false;
|
259 |
|
}
|
260 |
|
|
261 |
|
AddConstructionBaseInfoDic(info);
|
262 |
|
}
|
263 |
|
|
264 |
|
}
|
265 |
|
|
266 |
|
return true;
|
267 |
|
}
|
268 |
|
catch (Exception ex)
|
269 |
|
{
|
270 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
271 |
|
|
272 |
|
return false;
|
273 |
|
}
|
274 |
|
finally
|
275 |
|
{
|
276 |
|
ioInfo.close();
|
277 |
|
ioInfo = null;
|
278 |
|
}
|
279 |
|
|
280 |
|
}
|
281 |
|
#endregion
|
282 |
|
|
283 |
|
#region DBアクセス処理
|
284 |
|
#region 請求データ取得
|
285 |
|
/// <summary>
|
286 |
|
/// 請求データ取得
|
287 |
|
/// </summary>
|
288 |
|
/// <param name="constCode">本工事番号</param>
|
289 |
|
/// <param name="data"></param>
|
290 |
|
/// <returns></returns>
|
291 |
|
private bool GetRequestData(int constCode, ref RequestData data)
|
292 |
|
{
|
293 |
|
//var cbDB = new IORequestData();
|
294 |
|
try
|
295 |
|
{
|
296 |
|
//// 請求データ取得クラス領域
|
297 |
|
//var wrk = new List<RequestData>();
|
298 |
|
|
299 |
|
//// 請求データ取得SQL
|
300 |
|
//string strSQL = cbDB.CreateSubkeyString(constCode);
|
301 |
|
|
302 |
|
//// 請求データ取得
|
303 |
|
//if (!cbDB.SelectAction(strSQL, ref wrk)) return false;
|
304 |
|
|
305 |
|
//if (wrk.Count != 1) return false;
|
306 |
|
|
307 |
|
//data = wrk[0];
|
308 |
|
}
|
309 |
|
catch (Exception ex)
|
310 |
|
{
|
311 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
312 |
|
return false;
|
313 |
|
}
|
314 |
|
finally
|
315 |
|
{
|
316 |
|
//cbDB.close(); cbDB = null;
|
317 |
|
}
|
318 |
|
|
319 |
|
return true;
|
320 |
|
}
|
321 |
|
#endregion
|
322 |
|
|
323 |
|
#region 請求書合計データ取得
|
324 |
|
/// <summary>
|
325 |
|
/// 請求書合計データ取得
|
326 |
|
/// </summary>
|
327 |
|
/// <param name="requestNo"></param>
|
328 |
|
/// <param name="datas"></param>
|
329 |
|
/// <returns></returns>
|
330 |
|
//private bool GetRequestTotalData(int requestNo, ref List<RequestTotalData> datas)
|
331 |
|
//{
|
332 |
|
// var cbDB = new IORequestTotalData();
|
333 |
|
// try
|
334 |
|
// {
|
335 |
|
// // 請求書合計データ取得クラス領域
|
336 |
|
// var wrk = new List<RequestTotalData>();
|
337 |
|
|
338 |
|
// // 請求書合計データ取得SQL
|
339 |
|
// string strSQL = cbDB.CreatePrimarykeyString(requestNo);
|
340 |
|
|
341 |
|
// // ソート条件追加
|
342 |
|
// strSQL += " ORDER BY REQUESTNO, ORDERNO";
|
343 |
|
|
344 |
|
// // 請求書合計データ取得
|
345 |
|
// if (!cbDB.SelectAction(strSQL, ref wrk)) return false;
|
346 |
|
|
347 |
|
// // 請求書合計データ取得クラス領域
|
348 |
|
// datas = wrk;
|
349 |
|
|
350 |
|
// }
|
351 |
|
// catch (Exception ex)
|
352 |
|
// {
|
353 |
|
// logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
354 |
|
// return false;
|
355 |
|
// }
|
356 |
|
// finally
|
357 |
|
// {
|
358 |
|
// cbDB.close(); cbDB = null;
|
359 |
|
// }
|
360 |
|
// return true;
|
361 |
|
//}
|
362 |
|
|
363 |
|
#endregion
|
364 |
|
|
365 |
|
#region 請求明細データ取得
|
366 |
|
/// <summary>
|
367 |
|
/// 請求明細データ取得
|
368 |
|
/// </summary>
|
369 |
|
/// <param name="requestNo"></param>
|
370 |
|
/// <param name="datas"></param>
|
371 |
|
/// <returns></returns>
|
372 |
|
private bool GetRequestDataDetail(int requestNo, ref Dictionary<int, Dictionary<int, RequestDataDetail>> datas)
|
373 |
|
{
|
374 |
|
var cbDB = new IORequestDataDetail();
|
375 |
|
try
|
376 |
|
{
|
377 |
|
//// 請求明細データ取得クラス領域
|
378 |
|
//var wrk = new List<RequestDataDetail>();
|
379 |
|
|
380 |
|
//// 請求明細データ取得SQL
|
381 |
|
//string strSQL = cbDB.CreatePrimarykeyString(requestNo);
|
382 |
|
|
383 |
|
//// 請求明細データ取得
|
384 |
|
//if (!cbDB.SelectAction(strSQL, ref wrk)) return false;
|
385 |
|
|
386 |
|
//foreach (var record in wrk)
|
387 |
|
//{
|
388 |
|
// if (!datas.ContainsKey(record.ConstructionCode))
|
389 |
|
// datas[record.ConstructionCode] = new Dictionary<int, RequestDataDetail>();
|
390 |
|
// datas[record.ConstructionCode][record.OrderNo] = record;
|
391 |
|
//}
|
392 |
|
}
|
393 |
|
catch (Exception ex)
|
394 |
|
{
|
395 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
396 |
|
return false;
|
397 |
|
}
|
398 |
|
finally
|
399 |
|
{
|
400 |
|
cbDB.close(); cbDB = null;
|
401 |
|
}
|
402 |
|
return true;
|
403 |
|
}
|
404 |
|
#endregion
|
405 |
|
|
406 |
|
#region 工事基本情報取得
|
407 |
|
/// <summary>
|
408 |
|
/// 工事基本情報取得
|
409 |
|
/// </summary>
|
410 |
|
/// <param name="constructionCode"></param>
|
411 |
|
/// <param name="data"></param>
|
412 |
|
/// <returns></returns>
|
413 |
|
private bool GetConstructionBaseInfo(int constructionCode, ref ConstructionBaseInfo data)
|
414 |
|
{
|
415 |
|
var cbDB = new IOConstructionBaseInfo();
|
416 |
|
try
|
417 |
|
{
|
418 |
|
// 工事基本情報取得クラス領域
|
419 |
|
var wrk = new ConstructionBaseInfo();
|
420 |
|
|
421 |
|
// 工事基本情報取得SQL
|
422 |
|
string strSQL = cbDB.CreatePrimarykeyString(constructionCode);
|
423 |
|
|
424 |
|
// 工事基本情報取得
|
425 |
|
if (!cbDB.SelectAction(strSQL, ref wrk)) return false;
|
426 |
|
|
427 |
|
// 工事基本情報取得クラス領域
|
428 |
|
data = wrk;
|
429 |
|
|
430 |
|
}
|
431 |
|
catch (Exception ex)
|
432 |
|
{
|
433 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
434 |
|
return false;
|
435 |
|
}
|
436 |
|
finally
|
437 |
|
{
|
438 |
|
cbDB.close(); cbDB = null;
|
439 |
|
}
|
440 |
|
return true;
|
441 |
|
}
|
442 |
|
#endregion
|
443 |
|
|
444 |
|
#region 結合親工事番号の取得
|
445 |
|
private int GetJoinParentConstructionCode(int nConstructionCode)
|
446 |
|
{
|
447 |
|
int nParentCode = -1;
|
448 |
|
IOConstructionLink ioLink = new IOConstructionLink();
|
449 |
|
|
450 |
|
try
|
451 |
|
{
|
452 |
|
string sql = string.Format(" WHERE FluctuationCode = {0} AND LinkType = 1 ", nConstructionCode);
|
453 |
|
List<ConstructionLink> lstWork = new List<ConstructionLink>();
|
454 |
|
|
455 |
|
if (ioLink.SelectAction(sql, ref lstWork) == false)
|
456 |
|
{
|
457 |
|
return nParentCode;
|
458 |
|
}
|
459 |
|
|
460 |
|
foreach (ConstructionLink Link in lstWork)
|
461 |
|
{
|
462 |
|
nParentCode = Link.ConstructionCode;
|
463 |
|
break;
|
464 |
|
}
|
465 |
|
return nParentCode;
|
466 |
|
}
|
467 |
|
catch (Exception ex)
|
468 |
|
{
|
469 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
470 |
|
return -1;
|
471 |
|
}
|
472 |
|
finally
|
473 |
|
{
|
474 |
|
ioLink.close();
|
475 |
|
ioLink = null;
|
476 |
|
}
|
477 |
|
|
478 |
|
}
|
479 |
|
#endregion
|
480 |
|
|
481 |
|
#region 工事基本情報明細
|
482 |
|
/// <summary>
|
483 |
|
/// 工事基本情報明細を工事基本情報明細テーブルから工事番号をキーに取得する関数
|
484 |
|
/// </summary>
|
485 |
|
/// <param name="datas"></param>
|
486 |
|
/// <returns></returns>
|
487 |
|
private bool GetConstructionBaseInfoDetail(List<int> lstConstCode, ref Dictionary<int, Dictionary<int, string>> datas)
|
488 |
|
{
|
489 |
|
var sbDB = new IOConstructionBaseInfoDetail();
|
490 |
|
try
|
491 |
|
{
|
492 |
|
// 工事基本情報明細取得クラス領域
|
493 |
|
var wrk = new List<ConstructionBaseInfoDetail>();
|
494 |
|
|
495 |
|
// 工事基本情報明細取得SQL
|
496 |
|
string strSQL = " Where ConstructionCode in ( ";
|
497 |
|
foreach (int constCode in lstConstCode)
|
498 |
|
{
|
499 |
|
strSQL += string.Format((lstConstCode.IndexOf(constCode) == 0) ? " {0}" : ", {0}", constCode);
|
500 |
|
}
|
501 |
|
strSQL += " )";
|
502 |
|
|
503 |
|
// 工事基本情報明細取得
|
504 |
|
if (!sbDB.SelectAction(strSQL, ref wrk)) return false;
|
505 |
|
|
506 |
|
datas.Clear();
|
507 |
|
|
508 |
|
foreach (var record in wrk)
|
509 |
|
{
|
510 |
|
if (!datas.ContainsKey(record.ConstructionCode))
|
511 |
|
datas[record.ConstructionCode] = new Dictionary<int, string>();
|
512 |
|
datas[record.ConstructionCode][record.DetailNo] = record.DetailString;
|
513 |
|
}
|
514 |
|
|
515 |
|
}
|
516 |
|
catch (Exception ex)
|
517 |
|
{
|
518 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
519 |
|
return false;
|
520 |
|
}
|
521 |
|
finally
|
522 |
|
{
|
523 |
|
sbDB.close();
|
524 |
|
sbDB = null;
|
525 |
|
}
|
526 |
|
|
527 |
|
return true;
|
528 |
|
}
|
529 |
|
#endregion
|
530 |
|
|
531 |
|
#region 工事増減情報取得
|
532 |
|
/// <summary>
|
533 |
|
/// 工事増減情報取得
|
534 |
|
/// </summary>
|
535 |
|
/// <param name="constructionCode"></param>
|
536 |
|
/// <param name="datas"></param>
|
537 |
|
/// <returns></returns>
|
538 |
|
private bool GetConstructionLink(int constructionCode, ref List<int> datas)
|
539 |
|
{
|
540 |
|
var sbDB = new IOConstructionLink();
|
541 |
|
try
|
542 |
|
{
|
543 |
|
// 工事増減情報取得クラス領域
|
544 |
|
var wrk = new List<ConstructionLink>();
|
545 |
|
|
546 |
|
// 工事増減情報取得SQL
|
547 |
|
string strSQL = sbDB.CreatePrimarykeyString(constructionCode);
|
548 |
|
|
549 |
|
// ソート条件追加
|
550 |
|
strSQL += " ORDER BY FLUCTUATIONCODE";
|
551 |
|
|
552 |
|
// 工事増減情報取得
|
553 |
|
if (!sbDB.SelectAction(strSQL, ref wrk)) return false;
|
554 |
|
|
555 |
|
foreach (var record in wrk)
|
556 |
|
{
|
557 |
|
datas.Add(record.FluctuationCode);
|
558 |
|
}
|
559 |
|
}
|
560 |
|
catch (Exception ex)
|
561 |
|
{
|
562 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
563 |
|
return false;
|
564 |
|
}
|
565 |
|
finally
|
566 |
|
{
|
567 |
|
sbDB.close();
|
568 |
|
sbDB = null;
|
569 |
|
}
|
570 |
|
|
571 |
|
return true;
|
572 |
|
}
|
573 |
|
#endregion
|
574 |
|
|
575 |
|
#region 工事詳細台帳データ取得
|
576 |
|
/// <summary>
|
577 |
|
/// 工事詳細台帳データ取得
|
578 |
|
/// </summary>
|
579 |
|
/// <param name="constructionCode"></param>
|
580 |
|
/// <param name="data"></param>
|
581 |
|
/// <returns></returns>
|
582 |
|
private bool GetConstructionLedger(int constructionCode, ref ConstructionLedger data)
|
583 |
|
{
|
584 |
|
var sbDB = new IOConstructionLedger();
|
585 |
|
try
|
586 |
|
{
|
587 |
|
// 工事詳細台帳データ取得クラス領域
|
588 |
|
var wrk = new ConstructionLedger();
|
589 |
|
|
590 |
|
// 工事詳細台帳データ取得SQL
|
591 |
|
string strSQL = sbDB.CreatePrimarykeyString(constructionCode);
|
592 |
|
|
593 |
|
// 工事詳細台帳データ取得
|
594 |
|
if (!sbDB.SelectAction(strSQL, ref wrk)) return false;
|
595 |
|
|
596 |
|
data = wrk;
|
597 |
|
|
598 |
|
}
|
599 |
|
catch (Exception ex)
|
600 |
|
{
|
601 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
602 |
|
return false;
|
603 |
|
}
|
604 |
|
finally
|
605 |
|
{
|
606 |
|
sbDB.close();
|
607 |
|
sbDB = null;
|
608 |
|
}
|
609 |
|
|
610 |
|
return true;
|
611 |
|
}
|
612 |
|
#endregion
|
613 |
|
#endregion
|
614 |
|
|
615 |
|
#region 印刷メイン
|
616 |
|
/// <summary>
|
617 |
|
/// 印刷メイン
|
618 |
|
/// </summary>
|
619 |
|
/// <param name="bPrint">true:印刷のみ,false:保存のみ</param>
|
620 |
|
public void PrintMain(bool bPrint)
|
621 |
|
{
|
622 |
|
try
|
623 |
|
{
|
624 |
|
// 印刷クラス
|
625 |
|
m_UsedExcel = new UsedExcel();
|
626 |
|
|
627 |
|
// エクセルブックオープン
|
628 |
|
if (!m_UsedExcel.ExcelBookOpen(System.Environment.CurrentDirectory + s_ExcelRequestSheetFileName))
|
629 |
|
{
|
630 |
|
return;
|
631 |
|
}
|
632 |
|
|
633 |
|
// 表紙印刷
|
634 |
|
CommonDefine.RetunAnswer rtAns = PrintCover();
|
635 |
|
if (rtAns != CommonDefine.RetunAnswer.Answer0)
|
636 |
|
{
|
637 |
|
return;
|
638 |
|
}
|
639 |
|
|
640 |
|
// 一覧印刷
|
641 |
|
rtAns = PrintList();
|
642 |
|
if (rtAns != CommonDefine.RetunAnswer.Answer0)
|
643 |
|
{
|
644 |
|
return;
|
645 |
|
}
|
646 |
|
|
647 |
|
int no = 1;
|
648 |
|
foreach (RequestHead ReqHead in m_lstReqHead)
|
649 |
|
{
|
650 |
|
List<RequestData> lstReqData = null;
|
651 |
|
if (m_dicReqData.TryGetValue(ReqHead.RequestNo, out lstReqData) == false)
|
652 |
|
{
|
653 |
|
return;
|
654 |
|
}
|
655 |
|
|
656 |
|
foreach (RequestData ReqData in lstReqData)
|
657 |
|
{
|
658 |
|
ConstructionBaseInfo Info = null;
|
659 |
|
|
660 |
|
if (m_dicConstructionBaseInfo.TryGetValue(ReqData.MainConstructionCode, out Info) == false)
|
661 |
|
{
|
662 |
|
return;
|
663 |
|
}
|
664 |
|
|
665 |
|
long lRequestAmount = ReqData.RequestAmount0;
|
666 |
|
lRequestAmount += ReqData.RequestAmount1;
|
667 |
|
lRequestAmount += ReqData.RequestAmount2;
|
668 |
|
lRequestAmount += ReqData.RequestAmount3;
|
669 |
|
lRequestAmount += ReqData.RequestAmount4;
|
670 |
|
lRequestAmount += ReqData.RequestAmount5;
|
671 |
|
lRequestAmount += ReqData.RequestAmount6;
|
672 |
|
lRequestAmount += ReqData.UnpaidAmount;
|
673 |
|
|
674 |
|
if (lRequestAmount == 0)
|
675 |
|
{
|
676 |
|
continue;
|
677 |
|
}
|
678 |
|
|
679 |
|
rtAns = PrintDetail(no, ReqHead, ReqData, Info);
|
680 |
|
if (rtAns != CommonDefine.RetunAnswer.Answer0)
|
681 |
|
{
|
682 |
|
return;
|
683 |
|
}
|
684 |
|
}
|
685 |
|
|
686 |
|
}
|
687 |
|
|
688 |
|
if (bPrint)
|
689 |
|
{
|
690 |
|
// 印刷処理
|
691 |
|
m_UsedExcel.ExcelSheetPrint();
|
692 |
|
}
|
693 |
|
else
|
694 |
|
{
|
695 |
|
// 保存処理
|
696 |
|
SaveExcelFile();
|
697 |
|
}
|
698 |
|
}
|
699 |
|
catch (System.Exception ex)
|
700 |
|
{
|
701 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
702 |
|
}
|
703 |
|
finally
|
704 |
|
{
|
705 |
|
// Excel開放
|
706 |
|
if (m_UsedExcel != null)
|
707 |
|
{
|
708 |
|
m_UsedExcel.ExcelBookClose();
|
709 |
|
}
|
710 |
|
m_UsedExcel = null;
|
711 |
|
|
712 |
|
// ガーベージコレクト
|
713 |
|
GC.Collect();
|
714 |
|
}
|
715 |
|
|
716 |
|
}
|
717 |
|
#endregion
|
718 |
|
|
719 |
|
#region Excelファイル保存処理
|
720 |
|
/// <summary>
|
721 |
|
/// Excelファイル保存処理
|
722 |
|
/// </summary>
|
723 |
|
private void SaveExcelFile()
|
724 |
|
{
|
725 |
|
try
|
726 |
|
{
|
727 |
|
string filePath = @m_SelectSaveExcel;
|
728 |
|
|
729 |
|
// ファイルパスの存在をチェック
|
730 |
|
if (CommonMotions.ChkDirPath(filePath, true))
|
731 |
|
{
|
732 |
|
// ファイル名を作成
|
733 |
|
string wrkFile = m_InvData.RequestName + "様 請求書";
|
734 |
|
|
735 |
|
// ファイル名に使用できない文字を取り除く
|
736 |
|
foreach (var badCh in m_UsedExcel.ExcelBadCharcter)
|
737 |
|
{
|
738 |
|
wrkFile = wrkFile.Replace(badCh, "");
|
739 |
|
}
|
740 |
|
|
741 |
|
// ファイル名作成
|
742 |
|
filePath += @"\" + @wrkFile;
|
743 |
|
|
744 |
|
// ファイル保存
|
745 |
|
m_UsedExcel.SaveSwitch = true;
|
746 |
|
m_UsedExcel.ExcelSaveBook(filePath);
|
747 |
|
|
748 |
|
}
|
749 |
|
}
|
750 |
|
catch (System.Exception ex)
|
751 |
|
{
|
752 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
753 |
|
}
|
754 |
|
|
755 |
|
}
|
756 |
|
#endregion
|
757 |
|
|
758 |
|
#region エリアスを付けた担当者マスタのフィールド文を作成する
|
759 |
|
/// <summary>
|
760 |
|
/// エリアスを付けた担当者マスタのフィールド文を作成する
|
761 |
|
/// </summary>
|
762 |
|
/// <param name="Alias"></param>
|
763 |
|
/// <param name="strSQL"></param>
|
764 |
|
private string CreatePersonSQL(string Alias)
|
765 |
|
{
|
766 |
|
try
|
767 |
|
{
|
768 |
|
StringBuilder strcmd = new StringBuilder();
|
769 |
|
|
770 |
|
bool bColFirst = true;
|
771 |
|
string strWork = string.Empty;
|
772 |
|
foreach (var gender in Enum.GetValues(typeof(IOMPersonInCharge.ColumnCnt)))
|
773 |
|
{
|
774 |
|
strWork = gender.ToString();
|
775 |
|
if (!bColFirst) strcmd.Append(", ");
|
776 |
|
if (strWork.Equals("StartDate") || strWork.Equals("EndDate"))
|
777 |
|
{
|
778 |
|
strcmd.AppendFormat(" DATE_FORMAT({0}{1}, '%Y/%m/%d')", Alias, strWork);
|
779 |
|
}
|
780 |
|
else if (strWork.Equals("EntryDate") || strWork.Equals("UpdateDate"))
|
781 |
|
{
|
782 |
|
strcmd.AppendFormat(" DATE_FORMAT({0}{1}, '%Y/%m/%d %H:%i:%s')", Alias, strWork);
|
783 |
|
}
|
784 |
|
else
|
785 |
|
{
|
786 |
|
strcmd.AppendFormat(" {0}{1}", Alias, strWork);
|
787 |
|
}
|
788 |
|
bColFirst = false;
|
789 |
|
}
|
790 |
|
|
791 |
|
return strcmd.ToString();
|
792 |
|
}
|
793 |
|
catch (Exception ex)
|
794 |
|
{
|
795 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
796 |
|
return string.Empty;
|
797 |
|
}
|
798 |
|
}
|
799 |
|
#endregion
|
800 |
|
|
801 |
|
#region 表紙印鑑表示
|
802 |
|
/// <summary>
|
803 |
|
/// 表紙印鑑表示
|
804 |
|
/// </summary>
|
805 |
|
private void PrintCoverSeal(int PersonCode)
|
806 |
|
{
|
807 |
|
IOMPersonInCharge picDB = new IOMPersonInCharge();
|
808 |
|
IOProcessApproval paDB = new IOProcessApproval();
|
809 |
|
try
|
810 |
|
{
|
811 |
|
ArrayList arlist = new ArrayList();
|
812 |
|
|
813 |
|
// 承認データ読込
|
814 |
|
StringBuilder strSQLSeal = new StringBuilder();
|
815 |
|
strSQLSeal.Append("SELECT");
|
816 |
|
strSQLSeal.Append(CreatePersonSQL("B."));
|
817 |
|
strSQLSeal.Append(", C.SECRANK FROM PROCESSAPPROVAL A, PERSONINCHARGEMASTER B, SECURITYMASTER C");
|
818 |
|
strSQLSeal.Append(paDB.CreatePrimarykeyString(m_lstReqHead[0].ReqConstructionCode, (int)ClsExcute.ApprovalListNo.OrderBillingApproval, m_lstReqHead[0].OrderNo));
|
819 |
|
strSQLSeal.Append(" AND A.PERSONCODE = B.PERSONCODE");
|
820 |
|
strSQLSeal.Append(" AND C.SECCODE = B.SECCODE");
|
821 |
|
strSQLSeal.Append(" Order By C.SecRank ASC");
|
822 |
|
if (!paDB.ExecuteReader(strSQLSeal.ToString(), ref arlist)) return;
|
823 |
|
|
824 |
|
// 印刷テーブル作成
|
825 |
|
int[] PorsonCode = new int[4] { 0, 0, 0, 0 };
|
826 |
|
List<string> NameTable = new List<string>();
|
827 |
|
for (int i = 0; i < PorsonCode.Length; i++) NameTable.Add("");
|
828 |
|
string[] OrderOfPrecedenceTable = new string[4];
|
829 |
|
|
830 |
|
int PersonDataCnt = Enum.GetNames(typeof(IOMPersonInCharge.ColumnCnt)).Length;
|
831 |
|
// 承認データより担当者その他を取得する
|
832 |
|
for (int i = 0; i < arlist.Count; i++)
|
833 |
|
{
|
834 |
|
// エクセルの枠より多い場合は処理を抜ける
|
835 |
|
if (i > 3) break;
|
836 |
|
|
837 |
|
object[] readObj = (object[])arlist[i];
|
838 |
|
PersonInChargeMaster PersonRec = new PersonInChargeMaster();
|
839 |
|
picDB.Reader2Struct(readObj, ref PersonRec);
|
840 |
|
|
841 |
|
// セキュリティデータチェック
|
842 |
|
int SecRank = CommonMotions.cnvInt(readObj[PersonDataCnt]);
|
843 |
|
int SRank = (int)CommonDefine.SecurityRankPos.SpecialAuthority; // 特別権限
|
844 |
|
int FRank = (int)CommonDefine.SecurityRankPos.FreeAuthority; // 統括者権限
|
845 |
|
int LRank = (int)CommonDefine.SecurityRankPos.LimitedAuthority; // 所属長権限
|
846 |
|
|
847 |
|
// 担当者以外は役職がある
|
848 |
|
if (SecRank == CommonDefine.SecurityRankList[SRank].Key
|
849 |
|
|| SecRank == CommonDefine.SecurityRankList[FRank].Key
|
850 |
|
|| SecRank == CommonDefine.SecurityRankList[LRank].Key)
|
851 |
|
{
|
852 |
|
// コードと名前と役職を取得する
|
853 |
|
PorsonCode[i] = PersonRec.PersonCode;
|
854 |
|
NameTable[i] = PersonRec.SealPrintName;
|
855 |
|
// 7文字以上は文字が見えないので省略
|
856 |
|
if (PersonRec.DisplayString.Length > 7)
|
857 |
|
{
|
858 |
|
OrderOfPrecedenceTable[i] = PersonRec.DisplayString.Substring(0, 7);
|
859 |
|
}
|
860 |
|
else if (PersonRec.DisplayString.Length < 1)
|
861 |
|
{
|
862 |
|
OrderOfPrecedenceTable[i] = "担 当";
|
863 |
|
}
|
864 |
|
else
|
865 |
|
{
|
866 |
|
OrderOfPrecedenceTable[i] = PersonRec.DisplayString;
|
867 |
|
}
|
868 |
|
}
|
869 |
|
else
|
870 |
|
{ // 担当者
|
871 |
|
// コードと名前を取得する
|
872 |
|
PorsonCode[3] = PersonRec.PersonCode;
|
873 |
|
NameTable[3] = PersonRec.SealPrintName;
|
874 |
|
OrderOfPrecedenceTable[3] = "担 当";
|
875 |
|
}
|
876 |
|
}
|
877 |
|
// テーブル内に同じコードが無いか後から調べる
|
878 |
|
for (int i = 0; i < PorsonCode.Length - 1; i++)
|
879 |
|
{
|
880 |
|
if (PorsonCode[i] == 0) continue;
|
881 |
|
for (int ii = 0; ii < PorsonCode.Length; ii++)
|
882 |
|
{
|
883 |
|
if (i == ii) continue;
|
884 |
|
if (PorsonCode[i] != PorsonCode[ii]) continue;
|
885 |
|
|
886 |
|
PorsonCode[ii] = 0;
|
887 |
|
NameTable[ii] = string.Empty;
|
888 |
|
OrderOfPrecedenceTable[ii] = string.Empty;
|
889 |
|
break;
|
890 |
|
}
|
891 |
|
}
|
892 |
|
|
893 |
|
// 印鑑を描画する
|
894 |
|
OfficeShapeDefine shapedef = new OfficeShapeDefine();
|
895 |
|
shapedef.ShapeSheetName = s_shapeSheetName; // 図形シート名称
|
896 |
|
shapedef.ShapeName = s_shapeName; // 図形名称
|
897 |
|
shapedef.ShapeWidth = s_ShapeSize[0, 0]; // 図形描画サイズ Width
|
898 |
|
shapedef.ShapeHeight = s_ShapeSize[0, 1]; // 図形描画サイズ Height
|
899 |
|
|
900 |
|
for (int i = 0; i < 4; i++)
|
901 |
|
{
|
902 |
|
//
|
903 |
|
if (PorsonCode[i] != 0)
|
904 |
|
{
|
905 |
|
shapedef.ShapeDrowPointX = s_CoverSealPoint[i, 0]; // 図形描画位置 X
|
906 |
|
shapedef.ShapeDrowPointY = s_CoverSealPoint[i, 1]; // 図形描画位置 Y
|
907 |
|
shapedef.DrowText = NameTable[i]; // 描画文字列
|
908 |
|
int ifontSize = NameTable[i].Length - 1;
|
909 |
|
if (ifontSize > 4) ifontSize = 4;
|
910 |
|
shapedef.FontSize = s_EstimateSeal1FontSize[ifontSize]; // フォントサイズ
|
911 |
|
// 図形描画
|
912 |
|
m_UsedExcel.ExcelCopyShape(shapedef);
|
913 |
|
}
|
914 |
|
// 役職を印字する(M~)
|
915 |
|
int orgNumber = 11 + i;
|
916 |
|
string strAlpha = CommonMotions.cnvNumberToAlphaCharacter(orgNumber);
|
917 |
|
m_UsedExcel.ExcelCellSet(string.Format("{0}25", strAlpha), OrderOfPrecedenceTable[i]);
|
918 |
|
}
|
919 |
|
}
|
920 |
|
catch (Exception ex)
|
921 |
|
{
|
922 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
923 |
|
}
|
924 |
|
finally
|
925 |
|
{
|
926 |
|
paDB.close(); paDB = null;
|
927 |
|
picDB.close(); picDB = null;
|
928 |
|
}
|
929 |
|
}
|
930 |
|
#endregion
|
931 |
|
|
932 |
|
#region 請求書(表紙)作成
|
933 |
|
/// <summary>
|
934 |
|
/// 請求書(表紙)作成
|
935 |
|
/// </summary>
|
936 |
|
/// <returns></returns>
|
937 |
|
private CommonDefine.RetunAnswer PrintCover()
|
938 |
|
{
|
939 |
|
try
|
940 |
|
{
|
941 |
|
//// 請求書表紙シートの取得
|
942 |
|
m_UsedExcel.ExcelSheetGet(s_DicSheetName[enumSheetName.Cover]);
|
943 |
|
|
944 |
|
//// 請求書No(4行目 N列)
|
945 |
|
string strInvNo = (m_InvData.InvoiceNo / 1000).ToString();
|
946 |
|
strInvNo += "-";
|
947 |
|
strInvNo += (m_InvData.InvoiceNo % 1000).ToString("00");
|
948 |
|
|
949 |
|
ExcelPrintData InvNoData = new ExcelPrintData();
|
950 |
|
InvNoData.AddPrintData("N", 3, strInvNo).ExcelCellSet(m_UsedExcel);
|
951 |
|
|
952 |
|
|
953 |
|
//// ③ 請求日(5行目 M列)
|
954 |
|
if (m_bDatePrintFlg == true)
|
955 |
|
{
|
956 |
|
ExcelPrintData reqDate = new ExcelPrintData();
|
957 |
|
reqDate.AddPrintData("M", 4, m_bDatePrintOut.ToString("yyyy/MM/dd")).ExcelCellSet(m_UsedExcel);
|
958 |
|
}
|
959 |
|
else
|
960 |
|
{
|
961 |
|
ExcelPrintData reqDate = new ExcelPrintData();
|
962 |
|
reqDate.AddPrintData("M", 4, " 年 月 日").ExcelCellSet(m_UsedExcel);
|
963 |
|
}
|
964 |
|
|
965 |
|
//// ④ 請求先名称(9行目 C列)
|
966 |
|
ExcelPrintData nameData = new ExcelPrintData();
|
967 |
|
string str = m_InvData.RequestName + " 様";
|
968 |
|
nameData.AddPrintData("C", 8, str).ExcelCellSet(m_UsedExcel);
|
969 |
|
|
970 |
|
//// ⑤ 請求金額(13行目 C列)
|
971 |
|
ExcelPrintData priceData = new ExcelPrintData();
|
972 |
|
priceData.AddPrintData("C", 12, m_InvData.TotalAmount.ToString("#,0")).ExcelCellSet(m_UsedExcel);
|
973 |
|
|
974 |
|
//// ⑥ 消費税(14行目 C列)
|
975 |
|
ExcelPrintData taxData = new ExcelPrintData();
|
976 |
|
taxData.AddPrintData("C", 13, m_InvData.TaxAmount.ToString("#,0")).ExcelCellSet(m_UsedExcel);
|
977 |
|
|
978 |
|
//// 工事名(16行目 D列)
|
979 |
|
// ExcelPrintData cnstnameData = new ExcelPrintData();
|
980 |
|
// cnstnameData.AddPrintData("D", 15, m_lstReqHead[0].ReqConstructionName).ExcelCellSet(m_UsedExcel);
|
981 |
|
|
982 |
|
//// 会社名
|
983 |
|
string strCompany = CommonMotions.SystemMasterData.CompanyName1;
|
984 |
|
if (CommonMotions.SystemMasterData.CompanyName2 != string.Empty)
|
985 |
|
{
|
986 |
|
strCompany += " " + CommonMotions.SystemMasterData.CompanyName2;
|
987 |
|
}
|
988 |
|
|
989 |
|
// 代表者名
|
990 |
|
string strPresident = string.Format("{0} {1}", CommonMotions.SystemMasterData.CEOPositionName.Trim()
|
991 |
|
, CommonMotions.SystemMasterData.CEOName.Trim());
|
992 |
|
|
993 |
|
//// 郵便番号
|
994 |
|
string strZip = "〒" + CommonMotions.SystemMasterData.ZipCode;
|
995 |
|
|
996 |
|
//// 住所
|
997 |
|
string strAddr = CommonMotions.SystemMasterData.Address1;
|
998 |
|
if (CommonMotions.SystemMasterData.Address2 != string.Empty)
|
999 |
|
{
|
1000 |
|
strAddr += CommonMotions.SystemMasterData.Address2;
|
1001 |
|
}
|
1002 |
|
if (CommonMotions.SystemMasterData.Address3 != string.Empty)
|
1003 |
|
{
|
1004 |
|
strAddr += CommonMotions.SystemMasterData.Address3;
|
1005 |
|
}
|
1006 |
|
|
1007 |
|
//// TEL/FAX
|
1008 |
|
|
1009 |
|
string strTelFax = "";
|
1010 |
|
|
1011 |
|
if (CommonMotions.SystemMasterData.PhoneNumber != string.Empty)
|
1012 |
|
{
|
1013 |
|
strTelFax = "TEL " + CommonMotions.SystemMasterData.PhoneNumber + "(代)";
|
1014 |
|
}
|
1015 |
|
if (CommonMotions.SystemMasterData.FaxNumber != string.Empty)
|
1016 |
|
{
|
1017 |
|
if (strTelFax.Length > 0)
|
1018 |
|
{
|
1019 |
|
strTelFax += " ";
|
1020 |
|
}
|
1021 |
|
strTelFax += "FAX " + CommonMotions.SystemMasterData.FaxNumber;
|
1022 |
|
}
|
1023 |
|
//// URL
|
1024 |
|
string strUrl = CommonMotions.SystemMasterData.HomePageURL;
|
1025 |
|
|
1026 |
|
ExcelPrintData companyData = new ExcelPrintData();
|
1027 |
|
companyData.AddPrintData("L", 17, strCompany); // 会社名(18行目 L列)
|
1028 |
|
companyData.AddPrintData("L", 18, strPresident); // 代表者名(19行目 L列)
|
1029 |
|
companyData.AddPrintData("L", 19, strZip); // 郵便番号(20行目 L列)
|
1030 |
|
companyData.AddPrintData("L", 20, strAddr); // 住所(21行目 L列)
|
1031 |
|
companyData.AddPrintData("L", 21, strTelFax); // TEL/FAX(22行目 L列)
|
1032 |
|
companyData.AddPrintData("L", 22, strUrl); // URL(23行目 L列)
|
1033 |
|
companyData.ExcelCellSet(m_UsedExcel);
|
1034 |
|
|
1035 |
|
ExcelPrintData commentData = new ExcelPrintData();
|
1036 |
|
commentData.AddPrintData("C", 17, m_InvData.Comment1); // コメント1(18行目 C列)
|
1037 |
|
commentData.AddPrintData("C", 18, m_InvData.Comment2); // コメント2(19行目 C列)
|
1038 |
|
commentData.AddPrintData("C", 19, m_InvData.Comment3); // コメント3(20行目 C列)
|
1039 |
|
commentData.AddPrintData("C", 20, m_InvData.Comment4); // コメント4(21行目 C列)
|
1040 |
|
commentData.AddPrintData("C", 21, m_InvData.Comment5); // コメント5(22行目 C列)
|
1041 |
|
commentData.ExcelCellSet(m_UsedExcel);
|
1042 |
|
|
1043 |
|
ConstructionBaseInfo Info = null;
|
1044 |
|
m_dicConstructionBaseInfo.TryGetValue(m_lstReqHead[0].ReqConstructionCode, out Info);
|
1045 |
|
|
1046 |
|
// 印鑑描画
|
1047 |
|
PrintCoverSeal(Info.ConstructionPersonCode);
|
1048 |
|
|
1049 |
|
return CommonDefine.RetunAnswer.Answer0;
|
1050 |
|
}
|
1051 |
|
catch (Exception ex)
|
1052 |
|
{
|
1053 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
1054 |
|
return CommonDefine.RetunAnswer.Answer1;
|
1055 |
|
}
|
1056 |
|
}
|
1057 |
|
#endregion
|
1058 |
|
|
1059 |
|
#region 請求書(一覧)作成
|
1060 |
|
/// <summary>
|
1061 |
|
/// 請求書(一覧)作成
|
1062 |
|
/// </summary>
|
1063 |
|
/// <returns></returns>
|
1064 |
|
private CommonDefine.RetunAnswer PrintList()
|
1065 |
|
{
|
1066 |
|
try
|
1067 |
|
{
|
1068 |
|
int trow = 4;
|
1069 |
|
ExcelPrintData ExcelPrnData = null;
|
1070 |
|
|
1071 |
|
//// 請求書表紙シートの取得
|
1072 |
|
m_UsedExcel.ExcelSheetGet(s_DicSheetName[enumSheetName.List]);
|
1073 |
|
|
1074 |
|
List<int> lstKey = new List<int>(m_dicReqData.Keys);
|
1075 |
|
|
1076 |
|
foreach (int nReqNo in lstKey)
|
1077 |
|
{
|
1078 |
|
List<RequestData> lstData = null;
|
1079 |
|
|
1080 |
|
if (m_dicReqData.TryGetValue(nReqNo, out lstData) == false)
|
1081 |
|
{
|
1082 |
|
continue;
|
1083 |
|
}
|
1084 |
|
|
1085 |
|
foreach (RequestData ReqData in lstData)
|
1086 |
|
{
|
1087 |
|
ConstructionBaseInfo Info = null;
|
1088 |
|
|
1089 |
|
if (m_dicConstructionBaseInfo.TryGetValue(ReqData.MainConstructionCode, out Info) == false)
|
1090 |
|
{
|
1091 |
|
continue;
|
1092 |
|
}
|
1093 |
|
|
1094 |
|
string strname = (ReqData.MainConstructionCode / 100).ToString();
|
1095 |
|
strname += "-";
|
1096 |
|
strname += (ReqData.MainConstructionCode % 100).ToString("00");
|
1097 |
|
strname += "\r\n";
|
1098 |
|
strname += ReqData.ConstructionName;
|
1099 |
|
|
1100 |
|
ExcelPrnData = new ExcelPrintData();
|
1101 |
|
ExcelPrnData.AddPrintData("B", trow, strname); // 工事件名
|
1102 |
|
ExcelPrnData.AddPrintData("C", trow, string.Format("{0}年{1}月{2}日"
|
1103 |
|
, Info.ConstructionPeriodStart.Year
|
1104 |
|
, Info.ConstructionPeriodStart.Month.ToString("00")
|
1105 |
|
, Info.ConstructionPeriodStart.Day.ToString("00"))); // 工期開始
|
1106 |
|
|
1107 |
|
string EndDate = string.Empty;
|
1108 |
|
string DateDescription = string.Empty;
|
1109 |
|
if (Info.RevCompleteDate != DateTime.MinValue)
|
1110 |
|
{ // 検査是正完了日
|
1111 |
|
EndDate = string.Format("{0}年{1}月{2}日"
|
1112 |
|
, Info.RevCompleteDate.Year
|
1113 |
|
, Info.RevCompleteDate.Month.ToString("00")
|
1114 |
|
, Info.RevCompleteDate.Day.ToString("00"));
|
1115 |
|
DateDescription = "(現場是正完了日)";
|
1116 |
|
}
|
1117 |
|
else
|
1118 |
|
{ // 請求確認日
|
1119 |
|
EndDate = string.Format("{0}年{1}月{2}日"
|
1120 |
|
, Info.BillingDate.Year
|
1121 |
|
, Info.BillingDate.Month.ToString("00")
|
1122 |
|
, Info.BillingDate.Day.ToString("00"));
|
1123 |
|
DateDescription = "(請求書確認日)";
|
1124 |
|
}
|
1125 |
|
ExcelPrnData.AddPrintData("C", trow + 1, string.Format("~ {0}", EndDate)); // 工期終了
|
1126 |
|
ExcelPrnData.AddPrintData("C", trow + 2, DateDescription); // 終了日説明
|
1127 |
|
|
1128 |
|
long lAmount = ReqData.RequestAmount0;
|
1129 |
|
lAmount += ReqData.RequestAmount1;
|
1130 |
|
lAmount += ReqData.RequestAmount2;
|
1131 |
|
lAmount += ReqData.RequestAmount3;
|
1132 |
|
lAmount += ReqData.RequestAmount4;
|
1133 |
|
lAmount += ReqData.RequestAmount5;
|
1134 |
|
lAmount += ReqData.RequestAmount6;
|
1135 |
|
lAmount += ReqData.TaxAmount;
|
1136 |
|
lAmount += ReqData.UnpaidAmount;
|
1137 |
|
|
1138 |
|
ExcelPrnData.AddPrintData("D", trow, lAmount.ToString("#,0")); // 請求金額
|
1139 |
|
|
1140 |
|
ExcelPrnData.AddPrintData("E", trow, ReqData.Note); // 備考
|
1141 |
|
ExcelPrnData.ExcelCellSet(m_UsedExcel);
|
1142 |
|
|
1143 |
|
trow += 3;
|
1144 |
|
|
1145 |
|
}
|
1146 |
|
}
|
1147 |
|
|
1148 |
|
return CommonDefine.RetunAnswer.Answer0;
|
1149 |
|
}
|
1150 |
|
catch (Exception ex)
|
1151 |
|
{
|
1152 |
|
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
1153 |
|
return CommonDefine.RetunAnswer.Answer1;
|
1154 |
|
}
|
1155 |
|
}
|
1156 |
|
#endregion
|
1157 |
|
|
1158 |
|
#region 請求書(内訳)作成
|
1159 |
|
/// <summary>
|
1160 |
|
/// 請求書(内訳)作成
|
1161 |
|
/// </summary>
|
1162 |
|
/// <param name="dicReqDetail"></param>
|
1163 |
|
/// <param name="constLedger"></param>
|
1164 |
|
/// <param name="lstConstLink"></param>
|
1165 |
|
/// <returns></returns>
|
1166 |
|
private CommonDefine.RetunAnswer PrintDetail(int no, RequestHead ReqHead, RequestData ReqData, ConstructionBaseInfo Info)
|
1167 |
|
{
|
1168 |
|
try
|
1169 |
|
{
|
1170 |
|
// 請求書内訳シートの取得
|
1171 |
|
m_UsedExcel.ExcelSheetGet(s_DicSheetName[enumSheetName.Detail]);
|
1172 |
|
|
1173 |
|
ExcelPrintData ExcelPrnData = null;
|
1174 |
|
|
1175 |
|
// ------------------------------- 工事名 -------------------------------
|
1176 |
|
// ① 工事件名
|
1177 |
|
ExcelPrnData = new ExcelPrintData();
|
1178 |
|
ExcelPrnData.AddPrintData("C", 2, ReqData.ConstructionName).ExcelCellSet(m_UsedExcel);
|
1179 |
|
|
1180 |
|
// ------------------------------- 請負金額 -------------------------------
|
1181 |
|
ExcelPrnData = new ExcelPrintData();
|
1182 |
|
ExcelPrnData.AddPrintData("A", 5, no.ToString());
|
1183 |
|
ExcelPrnData.AddPrintData("G", 5, ReqData.ContractAmount.ToString("#,0"));
|
1184 |
|
ExcelPrnData.ExcelCellSet(m_UsedExcel);
|
1185 |
|
|
1186 |
|
// ------------------------------- 前回ご請求分 -------------------------------
|
1187 |
|
// 分割払いの場合
|
1188 |
|
if (Info.BillingSplitFlg == (int)ConstructionBaseInfo.BillingSplitFlgDef.SplitBilling)
|
1189 |
|
{
|
1190 |
|
ExcelPrnData = new ExcelPrintData();
|
1191 |
|
ExcelPrnData.AddPrintData("B", 7, "前回ご請求済分");
|
1192 |
|
ExcelPrnData.AddPrintData("C", 7, "前回請求書参照※増減補正済み");
|
1193 |
|
ExcelPrnData.AddPrintData("D", 7, "1");
|
1194 |
|
ExcelPrnData.AddPrintData("E", 7, "式");
|
1195 |
|
ExcelPrnData.AddPrintData("G", 7, ReqData.PaidAmount.ToString("#,0"));
|
1196 |
|
ExcelPrnData.ExcelCellSet(m_UsedExcel);
|
1197 |
|
}
|
1198 |
|
|
1199 |
|
long lTotalAmount = 0;
|
1200 |
|
|
1201 |
|
// ------------------------------- 見積金額(本工事) -------------------------------
|
1202 |
|
ExcelPrnData = new ExcelPrintData();
|
1203 |
|
ExcelPrnData.AddPrintData("G", 9, ReqData.RequestAmount0.ToString("#,0"));
|
1204 |
|
ExcelPrnData.ExcelCellSet(m_UsedExcel);
|
1205 |
|
|
1206 |
|
lTotalAmount += ReqData.RequestAmount0;
|
1207 |
|
|
1208 |
|
// ------------------------------- 見積金額(増減工事) -------------------------------
|
1209 |
|
long[] lAmount = new long[] { ReqData.RequestAmount1, ReqData.RequestAmount2, ReqData.RequestAmount3, ReqData.RequestAmount4, ReqData.RequestAmount5, ReqData.RequestAmount6 };
|
1210 |
|
string[] strTitle = new string[] { "増減工事1", "増減工事2", "増減工事3", "増減工事4", "増減工事5", "増減工事6" };
|
1211 |
|
|
1212 |
|
for (int i = 0; i < 6; i++)
|
1213 |
|
{
|
1214 |
|
if (lAmount[i] > 0)
|
1215 |
|
{
|
1216 |
|
ExcelPrnData = new ExcelPrintData();
|
1217 |
|
ExcelPrnData.AddPrintData("B", 10 + i, strTitle[i]);
|
1218 |
|
ExcelPrnData.AddPrintData("C", 10 + i, "追加増減見積もり参照");
|
1219 |
|
ExcelPrnData.AddPrintData("D", 10 + i, "1");
|
1220 |
|
ExcelPrnData.AddPrintData("E", 10 + i, "式");
|
1221 |
|
ExcelPrnData.AddPrintData("G", 10 + i, lAmount[i].ToString("#,0"));
|
1222 |
|
ExcelPrnData.ExcelCellSet(m_UsedExcel);
|