This commit is contained in:
harid 2026-07-02 11:35:46 +07:00
parent c45627f575
commit 9f0b6039c1
2 changed files with 38 additions and 39 deletions

View file

@ -382,6 +382,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
AnnouncementEndDate = x.AnnouncementEndDate,
AnnouncementStartDate = x.AnnouncementStartDate,
AnnouncementDate = x.AnnouncementDate,
ScoreExpireDate = x.ScoreExpireDate,
CheckDisability = x.CheckDisability,
CheckDocument = x.CheckDocument,
Detail = x.Detail,

View file

@ -1144,8 +1144,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
for (int row = 4; row <= rowCount; row++)
{
System.Diagnostics.Debug.WriteLine(worksheet);
// if (worksheet.Cells[row, 2].Value != null)
// {
if (worksheet.Cells[row, 2].Value == null) continue;
list.Add(new RequestImportSeat
{
Number = worksheet.Cells[row, 1].Value != null ? worksheet.Cells[row, 1].Value.ToString() : null,
@ -1153,58 +1152,57 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
CitizenId = worksheet.Cells[row, 3].Value != null ? worksheet.Cells[row, 3].Value.ToString() : null,
SeatNumber = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 4].Value.ToString() : null,
PointPath1A = worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 9].Value.ToString() : null,
PointPath2A = worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 10].Value.ToString() : null,
PointPath3A = worksheet.Cells[row, 11].Value != null ? worksheet.Cells[row, 11].Value.ToString() : null,
PointPath1A = worksheet.Cells[row, 9].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 9].Value.ToString()) : null,
PointPath2A = worksheet.Cells[row, 10].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 10].Value.ToString()) : null,
PointPath3A = worksheet.Cells[row, 11].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 11].Value.ToString()) : null,
PointTotalA = worksheet.Cells[3, 12].Value != null ? ExtractFirstNumber(worksheet.Cells[3, 12].Value.ToString()) : null,
PointA = worksheet.Cells[row, 12].Value != null ? worksheet.Cells[row, 12].Value.ToString() : null,
PointPerA = worksheet.Cells[row, 13].Value != null ? worksheet.Cells[row, 13].Value.ToString() : null,
PointA = worksheet.Cells[row, 12].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 12].Value.ToString()) : null,
PointPerA = worksheet.Cells[row, 13].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 13].Value.ToString()) : null,
ResultA = worksheet.Cells[row, 14].Value != null ? worksheet.Cells[row, 14].Value.ToString() : null,
PointTotalB = worksheet.Cells[3, 15].Value != null ? ExtractFirstNumber(worksheet.Cells[3, 15].Value.ToString()) : null,
PointB = worksheet.Cells[row, 15].Value != null ? worksheet.Cells[row, 15].Value.ToString() : null,
PointPerB = worksheet.Cells[row, 16].Value != null ? worksheet.Cells[row, 16].Value.ToString() : null,
PointB = worksheet.Cells[row, 15].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 15].Value.ToString()) : null,
PointPerB = worksheet.Cells[row, 16].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 16].Value.ToString()) : null,
ResultB = worksheet.Cells[row, 17].Value != null ? worksheet.Cells[row, 17].Value.ToString() : null,
PointPath1C = worksheet.Cells[row, 18].Value != null ? worksheet.Cells[row, 18].Value.ToString() : null,
PointPath2C = worksheet.Cells[row, 19].Value != null ? worksheet.Cells[row, 19].Value.ToString() : null,
PointPath1C = worksheet.Cells[row, 18].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 18].Value.ToString()) : null,
PointPath2C = worksheet.Cells[row, 19].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 19].Value.ToString()) : null,
PointTotalC = worksheet.Cells[3, 20].Value != null ? ExtractFirstNumber(worksheet.Cells[3, 20].Value.ToString()) : null,
PointC = worksheet.Cells[row, 20].Value != null ? worksheet.Cells[row, 20].Value.ToString() : null,
PointPerC = worksheet.Cells[row, 21].Value != null ? worksheet.Cells[row, 21].Value.ToString() : null,
PointC = worksheet.Cells[row, 20].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 20].Value.ToString()) : null,
PointPerC = worksheet.Cells[row, 21].Value != null ? ExtractFirstNumber(worksheet.Cells[row, 21].Value.ToString()) : null,
ResultC = worksheet.Cells[row, 22].Value != null ? worksheet.Cells[row, 22].Value.ToString() : null,
Pass = worksheet.Cells[row, 23].Value != null ? worksheet.Cells[row, 23].Value.ToString() : null,
ExamReason = worksheet.Cells[row, 27].Value != null ? worksheet.Cells[row, 27].Value.ToString() : null,
});
if (!int.TryParse(worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 9].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 10].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 11].Value != null ? worksheet.Cells[row, 11].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 9].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ I)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 10].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ J)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 11].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ K)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[3, 12].Value?.ToString()) ?? "0", out _))
throw new Exception("รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกเป็นตัวเลข (คอลัมน์ L)");
if (!int.TryParse(worksheet.Cells[row, 12].Value != null ? worksheet.Cells[row, 12].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 13].Value != null ? worksheet.Cells[row, 13].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
throw new Exception($"รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกตัวเลขนำหน้า เช่น '100 คะเนน' หรือ '100' หรือเว้นว่างไว้ (แถวที่ 3 คอลัมน์ L)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 12].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ L)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 13].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ M)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[3, 15].Value?.ToString()) ?? "0", out _))
throw new Exception("รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกเป็นตัวเลข (คอลัมน์ O)");
if (!int.TryParse(worksheet.Cells[row, 15].Value != null ? worksheet.Cells[row, 15].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 16].Value != null ? worksheet.Cells[row, 16].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 18].Value != null ? worksheet.Cells[row, 18].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 19].Value != null ? worksheet.Cells[row, 19].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
throw new Exception($"รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกตัวเลขนำหน้า เช่น '100 คะเนน' หรือ '100' หรือเว้นว่างไว้ (แถวที่ 3 คอลัมน์ O)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 15].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ O)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 16].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ P)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 18].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ R)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 19].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ S)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[3, 20].Value?.ToString()) ?? "0", out _))
throw new Exception("รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกเป็นตัวเลข (คอลัมน์ T)");
if (!int.TryParse(worksheet.Cells[row, 20].Value != null ? worksheet.Cells[row, 20].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
if (!int.TryParse(worksheet.Cells[row, 21].Value != null ? worksheet.Cells[row, 21].Value.ToString() : "0", out _))
throw new Exception("กรอกจำนวนคะแนนไม่ถูกต้อง");
// }
throw new Exception($"รูปแบบคะแนนรวมไม่ถูกต้อง กรุณากรอกตัวเลขนำหน้า เช่น '100 คะเนน' หรือ '100' หรือเว้นว่างไว้ (แถวที่ 3 คอลัมน์ T)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 20].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ T)");
if (!int.TryParse(ExtractFirstNumber(worksheet.Cells[row, 21].Value?.ToString()) ?? "0", out _))
throw new Exception($"กรอกจำนวนคะแนนไม่ถูกต้อง (แถวที่ {row} คอลัมน์ U)");
}
}
}