private void GroupWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { picLoadingDgvXMakeUpGroup.Visible = false; lblIsDirty.Visible = false; // 解凍 畫面 控制項 ResumeAllLayout(); // 清除舊項目 dataGridViewX1.Rows.Clear(); foreach (UDT_MakeUpGroup groupRecord in _groupList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewX1); // row 的 Tag 為 補考群組的系統編號 row.Tag = groupRecord.UID; row.Cells[0].Value = groupRecord.MakeUp_Group; K12.Data.TeacherRecord tr = _teacherList.Find(t => t.ID == groupRecord.Ref_Teacher_ID); if (tr != null) { if (!string.IsNullOrEmpty(tr.Nickname)) { row.Cells[1].Value = tr.Name + "(" + tr.Nickname + ")"; } else { row.Cells[1].Value = tr.Name; } } else { row.Cells[1].Value = ""; } row.Cells[2].Value = groupRecord.StudentCount; row.Cells[3].Value = groupRecord.Description; dataGridViewX1.Rows.Add(row); } FISCA.Presentation.MotherForm.SetStatusBarMessage("取得補考群組完成"); }
private void btnUpdate_Click(object sender, EventArgs e) { if (dataGridViewX1.Rows.Count == 0) { FISCA.Presentation.Controls.MsgBox.Show("目前無任何補考群組可以儲存。"); return; } picLoadingDgvXMakeUpGroup.Visible = true; // LOG 資訊 string _actor = DSAServices.UserAccount;; string _client_info = ClientInfo.GetCurrentClientInfo().OutputResult().OuterXml; //拚SQL // 兜資料 List <string> dataList = new List <string>(); string sql = ""; // 更新的 foreach (DataGridViewRow row in dataGridViewX1.Rows) { UDT_MakeUpGroup groupRecord = _groupList.Find(g => g.UID == "" + row.Tag); // 再原有補考群組清單找不到, 就是 新增的 if (groupRecord == null) { } else { // 沒有改變的項目 也不必儲存 if (!groupRecord.IsDirty) { continue; } } // row 的 Tag 為 補考群組的系統編號 groupRecord.UID = "" + row.Tag; groupRecord.MakeUp_Group = "" + row.Cells[0].Value; groupRecord.Description = "" + row.Cells[3].Value; string logDetail = @" 高中補考 學年度「" + _schoolYear + @"」,學期「" + _semester + @"」, 補考梯次「 " + _selectedBatch.MakeUp_Batch + @"」, 補考群組「 " + groupRecord.MakeUp_Group + @"」 "; string old_teacher_name = ""; string new_teacher_name = ""; if (groupRecord.New_Ref_Teacher_ID != null) { K12.Data.TeacherRecord old_tr = _teacherList.Find(t => t.ID == groupRecord.Ref_Teacher_ID); K12.Data.TeacherRecord new_tr = _teacherList.Find(t => t.ID == groupRecord.New_Ref_Teacher_ID); if (old_tr != null) { if (!string.IsNullOrEmpty(old_tr.Nickname)) { old_teacher_name = old_tr.Name + "(" + old_tr.Nickname + ")"; } else { old_teacher_name = old_tr.Name; } } else { old_teacher_name = ""; } if (new_tr != null) { if (!string.IsNullOrEmpty(new_tr.Nickname)) { new_teacher_name = new_tr.Name + "(" + new_tr.Nickname + ")"; } else { new_teacher_name = new_tr.Name; } } else { new_teacher_name = ""; } } if (groupRecord.Ref_Teacher_ID != groupRecord.New_Ref_Teacher_ID) { logDetail += "閱卷老師由「 " + old_teacher_name + @"」, 更改為「 " + new_teacher_name + @"」"; // 更新統一用Ref_Teacher_ID groupRecord.Ref_Teacher_ID = groupRecord.New_Ref_Teacher_ID; } string data = string.Format(@" SELECT '{0}'::TEXT AS makeup_group ,'{1}'::TEXT AS school_year ,'{2}'::TEXT AS semester ,'{3}'::TEXT AS description ,'{4}'::TEXT AS log_detail ,'{5}'::TEXT AS ref_makeup_batch_id ,'{6}'::TEXT AS ref_teacher_id ,'{7}'::BIGINT AS uid ,'{8}'::TEXT AS action ,'{9}'::TEXT AS new_merge_group_id ", groupRecord.MakeUp_Group, _schoolYear, _semester, groupRecord.Description, logDetail, _selectedBatch.UID, groupRecord.Ref_Teacher_ID != null ? groupRecord.Ref_Teacher_ID : "", groupRecord.UID, groupRecord.Action, groupRecord.New_Merge_Group_ID); dataList.Add(data); } foreach (UDT_MakeUpGroup group in _groupList) { // 刪除的 if (group.Action == "刪除") { string logDetail = @" 高中補考 學年度「" + _schoolYear + @"」,學期「" + _semester + @"」, 補考梯次「 " + _selectedBatch.MakeUp_Batch + @"」, 補考群組「 " + group.MakeUp_Group + @"」 "; logDetail += " 刪除, 其下的補考學生將分派至【未分群組】"; string data = string.Format(@" SELECT '{0}'::TEXT AS makeup_group ,'{1}'::TEXT AS school_year ,'{2}'::TEXT AS semester ,'{3}'::TEXT AS description ,'{4}'::TEXT AS log_detail ,'{5}'::TEXT AS ref_makeup_batch_id ,'{6}'::TEXT AS ref_teacher_id ,'{7}'::BIGINT AS uid ,'{8}'::TEXT AS action ,'{9}'::TEXT AS new_merge_group_id ", group.MakeUp_Group, _schoolYear, _semester, group.Description, logDetail, _selectedBatch.UID, group.Ref_Teacher_ID != null ? group.Ref_Teacher_ID : "", group.UID, group.Action, group.New_Merge_Group_ID); dataList.Add(data); } // 合併的 if (group.Action == "合併") { string logDetail = @" 高中補考 學年度「" + _schoolYear + @"」,學期「" + _semester + @"」, 補考梯次「 " + _selectedBatch.MakeUp_Batch + @"」, 補考群組「 " + group.MakeUp_Group + @"」 "; logDetail += " 合併 至【" + group.New_Merge_Group_Name + "】群組。"; string data = string.Format(@" SELECT '{0}'::TEXT AS makeup_group ,'{1}'::TEXT AS school_year ,'{2}'::TEXT AS semester ,'{3}'::TEXT AS description ,'{4}'::TEXT AS log_detail ,'{5}'::TEXT AS ref_makeup_batch_id ,'{6}'::TEXT AS ref_teacher_id ,'{7}'::BIGINT AS uid ,'{8}'::TEXT AS action ,'{9}'::TEXT AS new_merge_group_id ", group.MakeUp_Group, _schoolYear, _semester, group.Description, logDetail, _selectedBatch.UID, group.Ref_Teacher_ID != null ? group.Ref_Teacher_ID : "", group.UID, group.Action, group.New_Merge_Group_ID); dataList.Add(data); } } string dataString = string.Join(" UNION ALL", dataList); sql = string.Format(@" WITH data_row AS( {0} ) ,update_group_data AS ( Update $make.up.group SET makeup_group = data_row.makeup_group ,description = data_row.description ,ref_teacher_id = data_row.ref_teacher_id FROM data_row WHERE $make.up.group.uid = data_row.uid AND data_row.action ='更新' ) ,delete_group_data AS ( DELETE FROM $make.up.group WHERE $make.up.group.uid IN ( SELECT data_row.uid FROM data_row WHERE data_row.action ='刪除' OR data_row.action ='合併' ) ),check_non_group_id AS ( --確認【未分群組】 的id 如果沒有 就幫他建立新的 INSERT INTO $make.up.group (Ref_MakeUp_Batch_ID, MakeUp_Group) SELECT '{3}', '未分群組' WHERE NOT EXISTS ( SELECT * FROM $make.up.group WHERE Ref_MakeUp_Batch_ID = '{3}' AND MakeUp_Group ='未分群組' ) RETURNING * ),non_group_id AS ( SELECT * FROM check_non_group_id UNION ALL SELECT * FROM $make.up.group WHERE Ref_MakeUp_Batch_ID = '{3}' AND MakeUp_Group ='未分群組' ),update_delete_data_data AS ( Update $make.up.data SET Ref_MakeUp_Group_ID = non_group_id.uid FROM data_row LEFT JOIN non_group_id ON data_row.action ='刪除' WHERE $make.up.data.Ref_MakeUp_Group_ID ::BIGINT = data_row.uid AND data_row.action ='刪除' ) ,update_merge_data_data AS ( Update $make.up.data SET Ref_MakeUp_Group_ID = data_row.new_merge_group_id FROM data_row WHERE $make.up.data.Ref_MakeUp_Group_ID ::BIGINT = data_row.uid AND data_row.action ='合併' ) INSERT INTO log( actor , action_type , action , target_category , target_id , server_time , client_info , action_by , description ) SELECT '{1}'::TEXT AS actor , 'Record' AS action_type , '編輯高中補考群組' AS action , ''::TEXT AS target_category , '' AS target_id , now() AS server_time , '{2}' AS client_info , '編輯高中補考群組'AS action_by ,data_row.log_detail AS description FROM data_row ", dataString, _actor, _client_info, _selectedBatch.UID); //沒有資料不處理 if (!string.IsNullOrWhiteSpace(dataString)) { try { K12.Data.UpdateHelper uh = new UpdateHelper(); //執行sql uh.Execute(sql); FISCA.Presentation.Controls.MsgBox.Show("儲存成功。"); // 儲存完畢 重新整理 介面 RefreshListView(); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("儲存失敗," + ex.Message); picLoadingDgvXMakeUpGroup.Visible = false; } } else { picLoadingDgvXMakeUpGroup.Visible = false; } }
// 更新 補考群組畫面, 僅是介面上的更新,並沒有做任何的儲存。 private void RefreshUIGroupListView() { // 清除舊項目 dataGridViewX1.Rows.Clear(); foreach (UDT_MakeUpGroup groupRecord in _groupList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewX1); // row 的 Tag 為 補考群組的系統編號 row.Tag = groupRecord.UID; row.Cells[0].Value = groupRecord.MakeUp_Group; if (groupRecord.New_Ref_Teacher_ID != null) { K12.Data.TeacherRecord tr = _teacherList.Find(t => t.ID == groupRecord.New_Ref_Teacher_ID); if (tr != null) { if (!string.IsNullOrEmpty(tr.Nickname)) { row.Cells[1].Value = tr.Name + "(" + tr.Nickname + ")"; } else { row.Cells[1].Value = tr.Name; } } else { row.Cells[1].Value = ""; } } else { K12.Data.TeacherRecord tr = _teacherList.Find(t => t.ID == groupRecord.Ref_Teacher_ID); if (tr != null) { if (!string.IsNullOrEmpty(tr.Nickname)) { row.Cells[1].Value = tr.Name + "(" + tr.Nickname + ")"; } else { row.Cells[1].Value = tr.Name; } } else { row.Cells[1].Value = ""; } } row.Cells[2].Value = groupRecord.StudentCount; row.Cells[3].Value = groupRecord.Description; // 只要有一筆 改變, 就顯示 『未儲存』 if (groupRecord.IsDirty) { lblIsDirty.Visible = true; } // 假如 補考群組 是準備要刪除、合併的 就不顯示了 if (groupRecord.Action == "刪除" || groupRecord.Action == "合併") { continue; } dataGridViewX1.Rows.Add(row); } }
void _BGWork_DoWork(object sender, DoWorkEventArgs e) { _AllTeacherNameDic.Clear(); _AllLogIDDic.Clear(); _AllIDNumberDict.Clear(); foreach (K12.Data.TeacherRecord TR in K12.Data.Teacher.SelectAll()) { _AllTeacherNameDic.Add(TR.Name + TR.Nickname, TR.ID); if (!string.IsNullOrEmpty(TR.TALoginName)) _AllLogIDDic.Add(TR.TALoginName, TR.ID); // 身分證號檢查 if (!string.IsNullOrWhiteSpace(TR.IDNumber)) if (!_AllIDNumberDict.ContainsKey(TR.IDNumber)) _AllIDNumberDict.Add(TR.IDNumber, TR.ID); } // 讀取教師資料 _TeacherRec = K12.Data.Teacher.SelectByID(PrimaryKey); }
// 載入資料到畫面 private void DataBindToForm() { if (_TeacherRec == null) _TeacherRec = new K12.Data.TeacherRecord(); _DataListener.SuspendListen(); txtName.Text = _TeacherRec.Name; txtIDNumber.Text = _TeacherRec.IDNumber; cboGender.Text = _TeacherRec.Gender; txtNickname.Text = _TeacherRec.Nickname; txtPhone.Text = _TeacherRec.ContactPhone; txtEmail.Text = _TeacherRec.Email; txtCategory.Text = _TeacherRec.Category; txtSTLoginAccount.Text = _TeacherRec.TALoginName; txtSTLoginPwd.Text = _TeacherRec.TAPassword; cboAccountType.Text = _TeacherRec.AccountType; try { pic1.Image = SchoolCore.Photo.ConvertFromBase64Encoding(_TeacherRec.Photo, pic1.Width, pic1.Height); } catch (Exception) { pic1.Image = pic1.InitialImage; } // Log prlp.SetBeforeSaveText("姓名", txtName.Text); prlp.SetBeforeSaveText("身分證號", txtIDNumber.Text); prlp.SetBeforeSaveText("性別", cboGender.Text); prlp.SetBeforeSaveText("暱稱", txtNickname.Text); prlp.SetBeforeSaveText("聯絡電話", txtPhone.Text); prlp.SetBeforeSaveText("電子信箱", txtEmail.Text); prlp.SetBeforeSaveText("教師類別", txtCategory.Text); prlp.SetBeforeSaveText("登入帳號", txtSTLoginAccount.Text); prlp.SetBeforeSaveText("登入密碼", txtSTLoginPwd.Text); prlp.SetBeforeSaveText("帳號類型", cboAccountType.Text); this.Loading = false; SaveButtonVisible = false; CancelButtonVisible = false; _DataListener.Reset(); _DataListener.ResumeListen(); }
// 修正模式 傳補考群組物件 public InsertUpdateMakeUpGroupForm(string school_year, string semester, string action, UDT_MakeUpGroup group) { InitializeComponent(); _school_year = school_year; _semester = semester; _dataList = new List <UDT_MakeUpData>(); _selected_dataList = new List <UDT_MakeUpData>(); _groupNameList = new List <string>(); var tList = K12.Data.Teacher.SelectAll(); _teacherList = new List <TeacherRecord>(); foreach (K12.Data.TeacherRecord rec in tList) { if (rec.Status == TeacherRecord.TeacherStatus.刪除) { continue; } _teacherList.Add(rec); } //_teacherList = K12.Data.Teacher.SelectAll(); // 老師 依教師姓名排序 _teacherList.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); }); // 加入空白教師,提供使用者可以取消 cboTeacher.Items.Add(""); //將教師加入清單 foreach (K12.Data.TeacherRecord teacher in _teacherList) { // 老師全名 if (!string.IsNullOrEmpty(teacher.Nickname)) { cboTeacher.Items.Add(teacher.Name + "(" + teacher.Nickname + ")"); } else { cboTeacher.Items.Add(teacher.Name); } } K12.Data.TeacherRecord groupTeacher = _teacherList.Find(t => t.ID == group.Ref_Teacher_ID); // 預設為群組的閱卷老師 if (groupTeacher != null) { if (!string.IsNullOrEmpty(groupTeacher.Nickname)) { cboTeacher.Text = groupTeacher.Name + "(" + groupTeacher.Nickname + ")"; } else { cboTeacher.Text = groupTeacher.Name; } } else { cboTeacher.Text = ""; } _dataWorker = new BackgroundWorker(); _dataWorker.DoWork += new DoWorkEventHandler(DataWorker_DoWork); _dataWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DataWorker_RunWorkerCompleted); _dataWorker.ProgressChanged += new ProgressChangedEventHandler(DataWorker_ProgressChanged); _dataWorker.WorkerReportsProgress = true; _action = action; _group = group; // 只有新增 模式 才可以讓使用者 編輯 if (_action == "新增群組") { } // 修改模式 使用者只能修改 if (_action == "修改群組") { this.Text = "管理補考群組"; txtGroupName.Text = _group.MakeUp_Group; txtDescription.Text = _group.Description; txtDate.Text = _group.MakeUp_Date; txtTime.Text = _group.MakeUp_Time; txtPlace.Text = _group.MakeUp_Place; txtGroupName.Enabled = false; txtDescription.Enabled = false; cboTeacher.Enabled = false; btnSave.Enabled = false; btnClose.Enabled = false; picLoading.Visible = true; _dataWorker.RunWorkerAsync(); } // 修改模式 使用者只能修改 if (_action == "管理補考成績") { this.Text = "管理補考成績"; txtGroupName.Text = _group.MakeUp_Group; txtDescription.Text = _group.Description; btnSwap.Enabled = false; txtGroupName.Enabled = false; txtDescription.Enabled = false; cboTeacher.Enabled = false; btnSave.Enabled = false; btnClose.Enabled = false; txtDate.Enabled = false; txtTime.Enabled = false; txtPlace.Enabled = false; picLoading.Visible = true; _dataWorker.RunWorkerAsync(); } }
// 儲存 private void btnSave_Click(object sender, EventArgs e) { // 管理補考成績 的專門驗證 if (_action == "管理補考成績") { } else { if (txtGroupName.Text == "") { FISCA.Presentation.Controls.MsgBox.Show("補考群組名稱必須輸入。"); return; } if (_groupNameList.Contains(txtGroupName.Text)) { FISCA.Presentation.Controls.MsgBox.Show("本補考梯次:『 " + _makeup_batch + "』已有相同補考群組名稱。"); return; } } // LOG 資訊 string _actor = DSAServices.UserAccount;; string _client_info = ClientInfo.GetCurrentClientInfo().OutputResult().OuterXml; //拚SQL // 兜資料 List <string> dataList = new List <string>(); string sql = ""; if (_action == "新增群組") { string logDetail = @" 高中補考 學年度「" + _school_year + @"」,學期「" + _semester + @"」, 補考梯次「 " + _batch.MakeUp_Batch + @"」, 新增補考群組「 " + txtGroupName.Text + "」,閱卷老師「 " + cboTeacher.Text + "」,群組說明「 " + txtDescription.Text + "」,補考日期「 " + txtDate.Text + "」,補考時間「 " + txtTime.Text + "」,補考地點「 " + txtPlace.Text + "」"; string ref_teacher_id = ""; foreach (TeacherRecord tr in _teacherList) { if (!string.IsNullOrEmpty(tr.Nickname)) { if (tr.Name + "(" + tr.Nickname + ")" == cboTeacher.Text) { ref_teacher_id = tr.ID; } } else { if (tr.Name == cboTeacher.Text) { ref_teacher_id = tr.ID; } } } string data = string.Format(@" SELECT '{0}'::TEXT AS makeup_group ,'{1}'::TEXT AS school_year ,'{2}'::TEXT AS semester ,'{3}'::TEXT AS description ,'{4}'::TEXT AS makeup_date ,'{5}'::TEXT AS makeup_time ,'{6}'::TEXT AS makeup_place ,'{7}'::TEXT AS log_detail ,'{8}'::TEXT AS ref_makeup_batch_id ,'{9}'::TEXT AS ref_teacher_id ", txtGroupName.Text, _school_year, _semester, txtDescription.Text, txtDate.Text, txtTime.Text, txtPlace.Text, logDetail, _batch.UID, ref_teacher_id); dataList.Add(data); string dataString = string.Join(" UNION ALL", dataList); sql = string.Format(@" WITH data_row AS( {0} ) ,insert_data AS ( INSERT INTO $make.up.group( makeup_group ,description ,makeup_date ,makeup_time ,makeup_place ,ref_makeup_batch_id ,ref_teacher_id ) SELECT data_row.makeup_group ,data_row.description ,data_row.makeup_date ,data_row.makeup_time ,data_row.makeup_place ,data_row.ref_makeup_batch_id ,data_row.ref_teacher_id FROM data_row ) INSERT INTO log( actor , action_type , action , target_category , target_id , server_time , client_info , action_by , description ) SELECT '{1}'::TEXT AS actor , 'Record' AS action_type , '新增高中補考群組' AS action , ''::TEXT AS target_category , '' AS target_id , now() AS server_time , '{2}' AS client_info , '新增高中補考群組'AS action_by ,data_row.log_detail AS description FROM data_row ", dataString, _actor, _client_info); } else if (_action == "修改群組") { string logDetail = @" 高中補考 學年度「" + _school_year + @"」,學期「" + _semester + @"」, 補考梯次「 " + _makeup_batch + @"」, 補考群組「 " + _group.MakeUp_Group + "」,"; string ref_teacher_id = ""; foreach (TeacherRecord tr in _teacherList) { if (!string.IsNullOrEmpty(tr.Nickname)) { if (tr.Name + "(" + tr.Nickname + ")" == cboTeacher.Text) { ref_teacher_id = tr.ID; } } else { if (tr.Name == cboTeacher.Text) { ref_teacher_id = tr.ID; } } } K12.Data.TeacherRecord oldTeacher = _teacherList.Find(t => _group.Ref_Teacher_ID == t.ID); string old_teacher_name = ""; if (oldTeacher != null) { if (!string.IsNullOrEmpty(oldTeacher.Nickname)) { old_teacher_name = oldTeacher.Name + "(" + oldTeacher.Nickname + ")"; } else { old_teacher_name = oldTeacher.Name; } } if (txtGroupName.Text != _group.MakeUp_Group) { logDetail += "名稱由「 " + _group.MakeUp_Group + "」更改為 「 " + txtGroupName.Text + "」 "; } if (ref_teacher_id != _group.Ref_Teacher_ID) { logDetail += "閱卷教師由「 " + old_teacher_name + "」更改為 「 " + cboTeacher.Text + "」 "; } if (txtDescription.Text != _group.Description) { logDetail += "群組說明由「 " + _group.Description + "」更改為 「 " + txtDescription.Text + "」 "; } if (txtDate.Text != _group.MakeUp_Date) { logDetail += "補考日期由「 " + _group.MakeUp_Date + "」更改為 「 " + txtDate.Text + "」 "; } if (txtTime.Text != _group.MakeUp_Time) { logDetail += "補考時間由「 " + _group.MakeUp_Time + "」更改為 「 " + txtTime.Text + "」 "; } if (txtPlace.Text != _group.MakeUp_Place) { logDetail += "補考地點由「 " + _group.MakeUp_Place + "」更改為 「 " + txtPlace.Text + "」 "; } string data = string.Format(@" SELECT '{0}'::TEXT AS makeup_group ,'{1}'::TEXT AS school_year ,'{2}'::TEXT AS semester ,'{3}'::TEXT AS description ,'{4}'::TEXT AS makeup_date ,'{5}'::TEXT AS makeup_time ,'{6}'::TEXT AS makeup_place ,'{7}'::TEXT AS log_detail ,'{8}'::BIGINT AS uid ,'{9}'::TEXT AS ref_teacher_id ", txtGroupName.Text, _school_year, _semester, txtDescription.Text, txtDate.Text, txtTime.Text, txtPlace.Text, logDetail, _group.UID, ref_teacher_id); dataList.Add(data); string dataString = string.Join(" UNION ALL", dataList); sql = string.Format(@" WITH data_row AS( {0} ) ,update_data AS ( Update $make.up.group SET makeup_group = data_row.makeup_group ,description = data_row.description ,makeup_date = data_row.makeup_date ,makeup_time = data_row.makeup_time ,makeup_place = data_row.makeup_place ,ref_teacher_id = data_row.ref_teacher_id FROM data_row WHERE $make.up.group.uid = data_row.uid ) INSERT INTO log( actor , action_type , action , target_category , target_id , server_time , client_info , action_by , description ) SELECT '{1}'::TEXT AS actor , 'Record' AS action_type , '高中補考群組更新' AS action , ''::TEXT AS target_category , '' AS target_id , now() AS server_time , '{2}' AS client_info , '高中補考群組更新'AS action_by ,data_row.log_detail AS description FROM data_row ", dataString, _actor, _client_info); } else if (_action == "管理補考成績") { foreach (UDT_MakeUpData input_data in _dataList) { // 假如分數沒有改變 則不更新 if (!input_data.HasNewMakeUpScore) { continue; } string logDetail = @" 高中補考 學年度「" + _group.MakeUpBatch.School_Year + @"」,學期「" + _group.MakeUpBatch.Semester + @"」, 補考梯次「 " + _group.MakeUpBatch.MakeUp_Batch + @"」, 補考群組「 " + _group.MakeUp_Group + @"」 補考資料 學生「 " + input_data.StudentName + "」,科別「 " + input_data.Department + "」,班級「 " + input_data.ClassName + "」,座號「 " + input_data.Seat_no + @"」, ,科目「 " + input_data.Subject + "」,級別「 " + input_data.Level + "」,學分「 " + input_data.Credit + "」,校部定「 " + input_data.C_Is_Required_By + "」,必選修「 " + input_data.C_Is_Required + @"」, ,成績分數「 " + input_data.Score + "」,及格標準「 " + input_data.Pass_Standard + "」,補考標準「 " + input_data.MakeUp_Standard + @"」 。補考分數 自「 " + input_data.MakeUp_Score + "」,更改為 「" + input_data.New_MakeUp_Score + "」。"; string data = string.Format(@" SELECT '{0}'::BIGINT AS uid ,'{1}'::TEXT AS makeup_score ,'{2}'::TEXT AS log_detail ", input_data.UID, input_data.New_MakeUp_Score, logDetail); dataList.Add(data); } string dataString = string.Join(" UNION ALL", dataList); sql = string.Format(@" WITH data_row AS( {0} ) ,update_data AS ( Update $make.up.data SET makeup_score = data_row.makeup_score FROM data_row WHERE $make.up.data.uid = data_row.uid ) INSERT INTO log( actor , action_type , action , target_category , target_id , server_time , client_info , action_by , description ) SELECT '{1}'::TEXT AS actor , 'Record' AS action_type , '高中補考補考分數輸入' AS action , ''::TEXT AS target_category , '' AS target_id , now() AS server_time , '{2}' AS client_info , '高中補考補考分數輸入'AS action_by ,data_row.log_detail AS description FROM data_row ", dataString, _actor, _client_info); } if (dataList.Count == 0) { FISCA.Presentation.Controls.MsgBox.Show("未修正任何補考成績。"); // 儲存後關閉 //this.Close(); this.DialogResult = DialogResult.Yes; } else { K12.Data.UpdateHelper uh = new UpdateHelper(); //執行sql uh.Execute(sql); FISCA.Presentation.Controls.MsgBox.Show("儲存成功。"); // 儲存後關閉 // this.Close(); this.DialogResult = DialogResult.Yes; } }