|
|
@@ -66,15 +66,15 @@ namespace FileWatcher
|
|
|
using (FileStream file = new FileStream(FilePath.Text, FileMode.Open, FileAccess.Read))
|
|
|
{
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
|
-
|
|
|
+ int detno = 1;
|
|
|
|
|
|
for (int i = 0; i < workbook.NumberOfSheets; i++)
|
|
|
{
|
|
|
ISheet sheet = workbook.GetSheetAt(i);
|
|
|
string sheetName = sheet.SheetName;
|
|
|
-
|
|
|
if (sheetName.Contains(todayDate))
|
|
|
{
|
|
|
+ OperateResult.AppendText(sheetName);
|
|
|
OperateResult.AppendText($"Processing sheet: {sheetName}\n");
|
|
|
//Console.WriteLine($"Processing sheet: {sheetName}");
|
|
|
|
|
|
@@ -98,7 +98,7 @@ namespace FileWatcher
|
|
|
ICell cell = headerRow.GetCell(colIndex);
|
|
|
if (cell != null)
|
|
|
{
|
|
|
- string headerValue = cell.ToString().Trim();
|
|
|
+ string headerValue = cell.ToString().Trim().Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
|
|
|
if (headerValue == "工作中心")
|
|
|
{
|
|
|
wccodeIndex = colIndex;
|
|
|
@@ -121,7 +121,7 @@ namespace FileWatcher
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (wccodeIndex == -1 || orderdetnoIndex == -1 || ordercodeIndex == -1 || planqtyIndex == -1||remarkIndex==-1)
|
|
|
{
|
|
|
Console.WriteLine("Required columns not found in the header.");
|
|
|
@@ -136,14 +136,18 @@ namespace FileWatcher
|
|
|
IRow row = sheet.GetRow(rowIndex);
|
|
|
if (row != null)
|
|
|
{
|
|
|
- string wccode = row.GetCell(wccodeIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();
|
|
|
+ string wccode = row.GetCell(wccodeIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue.ToString();
|
|
|
+ if (wccode == "")
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
string orderdetno = row.GetCell(orderdetnoIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();
|
|
|
string ordercode = row.GetCell(ordercodeIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();
|
|
|
string planqty = row.GetCell(planqtyIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).NumericCellValue.ToString();
|
|
|
string remark = row.GetCell(remarkIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();
|
|
|
if (!string.IsNullOrEmpty(wccode) && !string.IsNullOrEmpty(orderdetno) && !string.IsNullOrEmpty(ordercode))
|
|
|
{
|
|
|
- string insertQuery = "INSERT INTO MakePlanDetail (mpd_mpid,mpd_id,mpd_wccode, mpd_orderdetno, mpd_ordercode,mpd_outqty,mpd_remark) VALUES (" + id + ",MakePlanDetail_seq.nextval,:1, :2, :3,:4,:5)";
|
|
|
+ string insertQuery = "INSERT INTO MakePlanDetail (mpd_mpid,mpd_detno,mpd_id,mpd_wccode, mpd_orderdetno, mpd_ordercode,mpd_outqty,mpd_remark) VALUES (" + id + ","+ detno + ",MakePlanDetail_seq.nextval,:1, :2, :3,:4,:5)";
|
|
|
using (OracleCommand cmd = new OracleCommand(insertQuery, conn))
|
|
|
{
|
|
|
cmd.Parameters.Add(new OracleParameter(":1", wccode));
|
|
|
@@ -155,6 +159,7 @@ namespace FileWatcher
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ detno = detno + 1;
|
|
|
}
|
|
|
}
|
|
|
dh.ExecuteSql("delete from MakePlanDetail where mpd_orderdetno is null", "delete");
|