Merge pull request 'feat: 年度課程執行狀況匯出移除計畫別並新增講師及滿意度欄位' (#1) from feature/annual-course-report-columns into master

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-09-14 13:14:38 +08:00
3 changed files with 93 additions and 42 deletions
@@ -481,8 +481,9 @@ namespace Education
{ {
DbCommand cmd = NewCommand(); DbCommand cmd = NewCommand();
cmd.CommandText = @" cmd.CommandText = @"
SELECT A.編號, A.訓練名稱, '' AS 訓練計畫別, A.訓練日期, A.訓練日期迄, A.訓練時數, '' AS 訓練場地, SELECT A.編號, A.訓練名稱, '' AS 講師姓名, A.訓練日期, A.訓練日期迄, A.訓練時數, '' AS 訓練場地,
0 AS 訓練人數, A.預估經費, 0 AS 實際經費, 0.0 AS 學員出席率, 0.0 AS 整體滿意度 0 AS 訓練人數, A.預估經費, 0 AS 實際經費, 0.0 AS 學員出席率, 0.0 AS 整體滿意度,
0.0 AS 講師滿意度, 0.0 AS 課程滿意度, 0.0 AS 行政滿意度, 0.0 AS 餐點滿意度, 0.0 AS 場地滿意度
FROM 訓練課程企劃 A FROM 訓練課程企劃 A
WHERE A.訓練日期 >= @訓練日期1 WHERE A.訓練日期 >= @訓練日期1
AND A.訓練日期 < @訓練日期2 AND A.訓練日期 < @訓練日期2
@@ -502,29 +503,42 @@ namespace Education
DAC_課程報名 Dao課程報名 = new DAC_課程報名(conn); DAC_課程報名 Dao課程報名 = new DAC_課程報名(conn);
DAC_課程經費 Dao課程經費 = new DAC_課程經費(conn); DAC_課程經費 Dao課程經費 = new DAC_課程經費(conn);
DAC_滿意度調查課程企劃 Dao滿意度調查課程企劃 = new DAC_滿意度調查課程企劃(conn); DAC_滿意度調查課程企劃 Dao滿意度調查課程企劃 = new DAC_滿意度調查課程企劃(conn);
DAC_滿意度調查 Dao滿意度調查 = new DAC_滿意度調查(conn);
DAC_訓練課程內容 Dao訓練課程內容 = new DAC_訓練課程內容(conn);
// 填入統計欄位 // 填入統計欄位
foreach (DataRow r in result.Rows) foreach (DataRow r in result.Rows)
{ {
int = DAC.GetInt32(r["編號"]); int = DAC.GetInt32(r["編號"]);
string = "";
// 取得訓練計畫別 // 取得講師姓名
DataTable Table = Dao課程報名.Select確定報名學員計畫(); string = "";
foreach (DataRow r1 in Table.Rows) HashSet<string> Names = new HashSet<string>();
List List = Dao訓練課程內容.SelectBy課程企劃();
foreach ( in List)
{ {
+= DAC.GetString(r1["計畫年度名稱"]) + "\r\n"; string = Select選定講師名稱(, .);
if (!string.IsNullOrEmpty() && Names.Add())
+= + "\r\n";
} }
if (.Length > 0) if (.Length > 0)
= .Trim(); = .Trim();
// 取得場地及滿意度 // 取得場地及滿意度
DataTable 滿Table = Dao滿意度調查課程企劃.Select滿意度統計(); DataTable 滿Table = Dao滿意度調查課程企劃.Select滿意度統計();
DataTable 滿Table = Dao滿意度調查.Select年度課程滿意度統計();
r["講師姓名"] = ;
r["訓練場地"] = Select選定場地名稱(); r["訓練場地"] = Select選定場地名稱();
r["訓練人數"] = Dao課程報名.Get出席人數(); r["訓練人數"] = Dao課程報名.Get出席人數();
r["實際經費"] = Dao課程經費.Get經費合計(); r["實際經費"] = Dao課程經費.Get經費合計();
r["學員出席率"] = Dao課程報名.Get出席率(); r["學員出席率"] = Dao課程報名.Get出席率();
r["整體滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["整體滿意度"]) : 0; r["整體滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["整體滿意度"]) : 0;
r["行政滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["行政滿意度"]) : 0;
r["餐點滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["餐點滿意度"]) : 0;
r["場地滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["場地滿意度"]) : 0;
r["講師滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["講師滿意度"]) : 0;
r["課程滿意度"] = 滿Table.Rows.Count > 0 ? DAC.GetDecimal(滿Table.Rows[0]["課程滿意度"]) : 0;
r.EndEdit(); r.EndEdit();
} }
result.AcceptChanges(); result.AcceptChanges();
@@ -194,6 +194,23 @@ namespace Education
return Select(cmdSelect); return Select(cmdSelect);
} }
///<summary>
/// 講師滿意度 = (講師的授課方式 + 講師的專業知識) / 2
/// 課程滿意度 = (課程的實用性 + 課程時數安排) / 2
/// 題目編號 1:課程的實用性 2:講師的授課方式 3:講師的專業知識 4:課程時數安排
///</summary>
public DataTable Select年度課程滿意度統計(int )
{
DbCommand cmdSelect = NewCommand(
@"SELECT
(SELECT ISNULL(AVG(CAST(分數 AS FLOAT)) * 20, 0) FROM 滿意度調查
WHERE 訓練課程企劃編號 = @訓練課程企劃編號 AND 課程序號 <> 0 AND 題目編號 IN (2, 3)) AS 講師滿意度,
(SELECT ISNULL(AVG(CAST(分數 AS FLOAT)) * 20, 0) FROM 滿意度調查
WHERE 訓練課程企劃編號 = @訓練課程企劃編號 AND 課程序號 <> 0 AND 題目編號 IN (1, 4)) AS 課程滿意度 ");
AddParam(cmdSelect, "訓練課程企劃編號", );
return Select(cmdSelect);
}
} }
///<summary> ///<summary>
@@ -24,9 +24,9 @@ namespace Education.Report
excel.Sheet = sheet; excel.Sheet = sheet;
// 報表抬頭 // 報表抬頭
excel.MergeCell(0, 0, 0, 10); excel.MergeCell(0, 0, 0, 15);
excel.SetCellValue(0, 0, , titleStyleCenter); excel.SetCellValue(0, 0, , titleStyleCenter);
excel.MergeCell(1, 0, 1, 10); excel.MergeCell(1, 0, 1, 15);
if (!) if (!)
excel.SetCellValue(1, 0, String.Format("{0}年度教育訓練課程執行狀況", ), titleStyleCenter); excel.SetCellValue(1, 0, String.Format("{0}年度教育訓練課程執行狀況", ), titleStyleCenter);
else else
@@ -39,26 +39,36 @@ namespace Education.Report
excel.SetCellValue(2, 0, "", bodyStyleCenter); excel.SetCellValue(2, 0, "", bodyStyleCenter);
excel.SetCellValue(2, 1, "訓練日期", bodyStyleCenter); excel.SetCellValue(2, 1, "訓練日期", bodyStyleCenter);
excel.SetCellValue(2, 2, "課程企劃編號名稱", bodyStyleCenter); excel.SetCellValue(2, 2, "課程企劃編號名稱", bodyStyleCenter);
excel.SetCellValue(2, 3, "訓練計畫別", bodyStyleCenter); excel.SetCellValue(2, 3, "講師姓名", bodyStyleCenter);
excel.SetCellValue(2, 4, "訓練時數", bodyStyleCenter); excel.SetCellValue(2, 4, "講師滿意度", bodyStyleCenter);
excel.SetCellValue(2, 5, "訓練場地", bodyStyleCenter); excel.SetCellValue(2, 5, "課程滿意度", bodyStyleCenter);
excel.SetCellValue(2, 6, "訓練人數", bodyStyleCenter); excel.SetCellValue(2, 6, "行政服務品質滿意度", bodyStyleCenter);
excel.SetCellValue(2, 7, "預估經費", bodyStyleCenter); excel.SetCellValue(2, 7, "餐點與茶飲滿意度", bodyStyleCenter);
excel.SetCellValue(2, 8, "實際經費", bodyStyleCenter); excel.SetCellValue(2, 8, "場地滿意度", bodyStyleCenter);
excel.SetCellValue(2, 9, "學員出席率", bodyStyleCenter); excel.SetCellValue(2, 9, "訓練時數", bodyStyleCenter);
excel.SetCellValue(2, 10, "整體滿意度", bodyStyleCenter); excel.SetCellValue(2, 10, "訓練場地", bodyStyleCenter);
excel.SetCellValue(2, 11, "訓練人數", bodyStyleCenter);
excel.SetCellValue(2, 12, "預估經費", bodyStyleCenter);
excel.SetCellValue(2, 13, "實際經費", bodyStyleCenter);
excel.SetCellValue(2, 14, "學員出席率", bodyStyleCenter);
excel.SetCellValue(2, 15, "整體滿意度", bodyStyleCenter);
excel.SetColumnWidthInChars(0, 12); excel.SetColumnWidthInChars(0, 12);
excel.SetColumnWidthInChars(1, 12); excel.SetColumnWidthInChars(1, 12);
excel.SetColumnWidthInChars(2, 45); excel.SetColumnWidthInChars(2, 45);
excel.SetColumnWidthInChars(3, 26); excel.SetColumnWidthInChars(3, 20);
excel.SetColumnWidthInChars(4, 12); excel.SetColumnWidthInChars(4, 15);
excel.SetColumnWidthInChars(5, 30); excel.SetColumnWidthInChars(5, 15);
excel.SetColumnWidthInChars(6, 12); excel.SetColumnWidthInChars(6, 22);
excel.SetColumnWidthInChars(7, 15); excel.SetColumnWidthInChars(7, 22);
excel.SetColumnWidthInChars(8, 15); excel.SetColumnWidthInChars(8, 15);
excel.SetColumnWidthInChars(9, 15); excel.SetColumnWidthInChars(9, 12);
excel.SetColumnWidthInChars(10, 15); excel.SetColumnWidthInChars(10, 30);
excel.SetColumnWidthInChars(11, 12);
excel.SetColumnWidthInChars(12, 15);
excel.SetColumnWidthInChars(13, 15);
excel.SetColumnWidthInChars(14, 15);
excel.SetColumnWidthInChars(15, 15);
excel.SetRowHeightInPoints(2, (int)Math.Truncate(BodyRowHeight * 2.0)); excel.SetRowHeightInPoints(2, (int)Math.Truncate(BodyRowHeight * 2.0));
int rowId = 1; int rowId = 1;
@@ -69,14 +79,19 @@ namespace Education.Report
excel.SetCellValue(rowId + 2, 0, rowId, bodyStyleCenter); excel.SetCellValue(rowId + 2, 0, rowId, bodyStyleCenter);
excel.SetCellValue(rowId + 2, 1, .Get訓練日期Str(DAC.GetDateTime(r["訓練日期"]), DAC.GetDateTime(r["訓練日期迄"]), "yyyyMMdd"), bodyStyleCenter); excel.SetCellValue(rowId + 2, 1, .Get訓練日期Str(DAC.GetDateTime(r["訓練日期"]), DAC.GetDateTime(r["訓練日期迄"]), "yyyyMMdd"), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 2, String.Format("[{0:000000}]{1}", r["編號"], r["訓練名稱"]), bodyStyleLeft); excel.SetCellValue(rowId + 2, 2, String.Format("[{0:000000}]{1}", r["編號"], r["訓練名稱"]), bodyStyleLeft);
excel.SetCellValue(rowId + 2, 3, DAC.GetString(r["訓練計畫別"]), bodyStyleLeft); excel.SetCellValue(rowId + 2, 3, DAC.GetString(r["講師姓名"]), bodyStyleLeft);
excel.SetCellValue(rowId + 2, 4, DAC.GetInt32(r["訓練時數"]), bodyStyleCenter); excel.SetCellValue(rowId + 2, 4, DAC.GetDouble(r["講師滿意度"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 5, DAC.GetString(r["訓練場地"]), bodyStyleCenter); excel.SetCellValue(rowId + 2, 5, DAC.GetDouble(r["課程滿意度"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 6, DAC.GetInt32(r["訓練人數"]), bodyStyleCenter); excel.SetCellValue(rowId + 2, 6, DAC.GetDouble(r["行政滿意度"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 7, DAC.GetInt32(r["預估經費"]), bodyStyleCenter); excel.SetCellValue(rowId + 2, 7, DAC.GetDouble(r["餐點滿意度"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 8, DAC.GetInt32(r["實際經費"]), bodyStyleCenter); excel.SetCellValue(rowId + 2, 8, DAC.GetDouble(r["場地滿意度"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 9, DAC.GetDouble(r["學員出席率"]), bodyPercentStyle); excel.SetCellValue(rowId + 2, 9, DAC.GetInt32(r["訓練時數"]), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 10, DAC.GetDouble(r["整體滿意度"]), bodyPercentStyle); excel.SetCellValue(rowId + 2, 10, DAC.GetString(r["訓練場地"]), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 11, DAC.GetInt32(r["訓練人數"]), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 12, DAC.GetInt32(r["預估經費"]), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 13, DAC.GetInt32(r["實際經費"]), bodyStyleCenter);
excel.SetCellValue(rowId + 2, 14, DAC.GetDouble(r["學員出席率"]), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 15, DAC.GetDouble(r["整體滿意度"]), bodyPercentStyle);
// excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 1.5)); // excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 1.5));
rowId++; rowId++;
@@ -87,13 +102,18 @@ namespace Education.Report
excel.SetCellValue(rowId + 2, 1, "", bodyStyleCenter); excel.SetCellValue(rowId + 2, 1, "", bodyStyleCenter);
excel.SetCellValue(rowId + 2, 2, "", bodyStyleLeft); excel.SetCellValue(rowId + 2, 2, "", bodyStyleLeft);
excel.SetCellValue(rowId + 2, 3, "", bodyStyleLeft); excel.SetCellValue(rowId + 2, 3, "", bodyStyleLeft);
excel.SetCellFormula(rowId + 2, 4, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 4), Excel.RCtoA1(rowId + 1, 4)), bodyStyleCenter); excel.SetCellFormula(rowId + 2, 4, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 4), Excel.RCtoA1(rowId + 1, 4)), bodyPercentStyle);
excel.SetCellValue(rowId + 2, 5, "", bodyStyleCenter); excel.SetCellFormula(rowId + 2, 5, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 5), Excel.RCtoA1(rowId + 1, 5)), bodyPercentStyle);
excel.SetCellFormula(rowId + 2, 6, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 6), Excel.RCtoA1(rowId + 1, 6)), bodyStyleCenter); excel.SetCellFormula(rowId + 2, 6, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 6), Excel.RCtoA1(rowId + 1, 6)), bodyPercentStyle);
excel.SetCellFormula(rowId + 2, 7, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 7), Excel.RCtoA1(rowId + 1, 7)), bodyStyleCenter); excel.SetCellFormula(rowId + 2, 7, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 7), Excel.RCtoA1(rowId + 1, 7)), bodyPercentStyle);
excel.SetCellFormula(rowId + 2, 8, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 8), Excel.RCtoA1(rowId + 1, 8)), bodyStyleCenter); excel.SetCellFormula(rowId + 2, 8, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 8), Excel.RCtoA1(rowId + 1, 8)), bodyPercentStyle);
excel.SetCellFormula(rowId + 2, 9, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 9), Excel.RCtoA1(rowId + 1, 9)), bodyPercentStyle); excel.SetCellFormula(rowId + 2, 9, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 9), Excel.RCtoA1(rowId + 1, 9)), bodyStyleCenter);
excel.SetCellFormula(rowId + 2, 10, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 10), Excel.RCtoA1(rowId + 1, 10)), bodyPercentStyle); excel.SetCellValue(rowId + 2, 10, "", bodyStyleCenter);
excel.SetCellFormula(rowId + 2, 11, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 11), Excel.RCtoA1(rowId + 1, 11)), bodyStyleCenter);
excel.SetCellFormula(rowId + 2, 12, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 12), Excel.RCtoA1(rowId + 1, 12)), bodyStyleCenter);
excel.SetCellFormula(rowId + 2, 13, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 13), Excel.RCtoA1(rowId + 1, 13)), bodyStyleCenter);
excel.SetCellFormula(rowId + 2, 14, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 14), Excel.RCtoA1(rowId + 1, 14)), bodyPercentStyle);
excel.SetCellFormula(rowId + 2, 15, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 15), Excel.RCtoA1(rowId + 1, 15)), bodyPercentStyle);
excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 2.0)); excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 2.0));
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
@@ -101,4 +121,4 @@ namespace Education.Report
return ms; return ms;
} }
} }
} }