V4.5
This commit is contained in:
@@ -122,10 +122,8 @@ namespace AiQ_GUI
|
||||
|
||||
int rowsAffected = cmd.ExecuteNonQuery();
|
||||
// Execute the command and get the number of rows affected
|
||||
//if (rowsAffected > 0) // If one or more rows were updated
|
||||
// AddToActionsList($"Updated {TypeOfTest} for {modelNumber}");
|
||||
//else
|
||||
// AddToActionsList($"No rows found for {modelNumber}");
|
||||
if (rowsAffected == 0) // If one or more rows were updated
|
||||
MainForm.Instance.AddToActionsList($"No rows affected for {modelNumber}");
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
@@ -162,10 +160,8 @@ namespace AiQ_GUI
|
||||
int rows = cmd.ExecuteNonQuery();
|
||||
conn.Close();
|
||||
|
||||
//if (rows > 0)
|
||||
// AddToActionsList($"DiagsStats inserted ({rows} row) for model '{model}' on {DateTime.Now:yyyy-MM-dd}");
|
||||
//else
|
||||
// AddToActionsList("No rows inserted into DiagsStats (unexpected).");
|
||||
if (rows == 0)
|
||||
MainForm.Instance.AddToActionsList("No rows inserted into DiagsStats (unexpected).");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace AiQ_GUI
|
||||
DateTime? lastStatsRun = null;
|
||||
try
|
||||
{
|
||||
using (OleDbCommand cmdPeriod = new OleDbCommand("SELECT LastStatsRun FROM UniversalData", conn))
|
||||
using (OleDbCommand cmdPeriod = new("SELECT LastStatsRun FROM UniversalData", conn))
|
||||
{
|
||||
object res = cmdPeriod.ExecuteScalar();
|
||||
if (res != null && res != DBNull.Value)
|
||||
@@ -37,7 +37,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
|
||||
// ==================== MAIN STATS EXPORT ====================
|
||||
string selectColumns = @"
|
||||
const string selectColumns = @"
|
||||
ModelNumber,
|
||||
[Total Tests Run],
|
||||
[Pre Tests Passed],
|
||||
@@ -125,7 +125,7 @@ namespace AiQ_GUI
|
||||
DateTime monthStart = new(now.Year, now.Month, 1);
|
||||
DateTime nextMonth = monthStart.AddMonths(1);
|
||||
|
||||
string diagsQuery = @"
|
||||
const string diagsQuery = @"
|
||||
SELECT
|
||||
[Date],
|
||||
[Model],
|
||||
@@ -136,36 +136,33 @@ namespace AiQ_GUI
|
||||
FROM DiagsStats
|
||||
WHERE [Date] >= ? AND [Date] < ?";
|
||||
|
||||
using (OleDbCommand diagsCmd = new OleDbCommand(diagsQuery, conn))
|
||||
using (OleDbCommand diagsCmd = new(diagsQuery, conn))
|
||||
{
|
||||
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = monthStart });
|
||||
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = nextMonth });
|
||||
|
||||
using (OleDbDataAdapter diagsAdapter = new OleDbDataAdapter(diagsCmd))
|
||||
using OleDbDataAdapter diagsAdapter = new(diagsCmd);
|
||||
DataTable diagsTable = new();
|
||||
diagsAdapter.Fill(diagsTable);
|
||||
|
||||
if (diagsTable.Rows.Count > 0)
|
||||
{
|
||||
DataTable diagsTable = new();
|
||||
diagsAdapter.Fill(diagsTable);
|
||||
int startRow = (ws.LastRowUsed()?.RowNumber() ?? 0) + 3;
|
||||
|
||||
if (diagsTable.Rows.Count > 0)
|
||||
{
|
||||
int startRow = (ws.LastRowUsed()?.RowNumber() ?? 0) + 3;
|
||||
ws.Cell(startRow, 1).Value = "Diags Stats (Current Month)";
|
||||
ws.Cell(startRow, 1).Style.Font.Bold = true;
|
||||
ws.Cell(startRow, 1).Style.Font.FontSize = 12;
|
||||
|
||||
ws.Cell(startRow, 1).Value = "Diags Stats (Current Month)";
|
||||
ws.Cell(startRow, 1).Style.Font.Bold = true;
|
||||
ws.Cell(startRow, 1).Style.Font.FontSize = 12;
|
||||
ws.Cell(startRow + 1, 1).InsertTable(diagsTable, "Diags_Stats", true);
|
||||
ws.Columns().AdjustToContents();
|
||||
|
||||
ws.Cell(startRow + 1, 1).InsertTable(diagsTable, "Diags_Stats", true);
|
||||
ws.Columns().AdjustToContents();
|
||||
|
||||
MainForm.Instance.AddToActionsList($"Added DiagsStats ({diagsTable.Rows.Count} rows) starting at row {startRow}.");
|
||||
}
|
||||
MainForm.Instance.AddToActionsList($"Added DiagsStats ({diagsTable.Rows.Count} rows) starting at row {startRow}.");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== SAVE MAIN SHEET ====================
|
||||
workbook.SaveAs(exportPath);
|
||||
MainForm.Instance.AddToActionsList($"Added {sheetName} to workbook: {exportPath}");
|
||||
|
||||
workbook.Dispose();
|
||||
|
||||
// ==================== BACKUP TABLE (ALWAYS, BEFORE RESET) ====================
|
||||
@@ -199,7 +196,7 @@ namespace AiQ_GUI
|
||||
{
|
||||
try
|
||||
{
|
||||
string resetSql = @"
|
||||
const string resetSql = @"
|
||||
UPDATE AiQ SET
|
||||
[Total Tests Run] = 0,
|
||||
[Pre Tests Passed] = 0,
|
||||
|
||||
Reference in New Issue
Block a user