private void btnView_Click(object sender, EventArgs e)
        {
            StudentSemsSocreArchive sssa = listView1.SelectedItems[0].Tag as StudentSemsSocreArchive;

            ScoreEditor.SemesterScoreArchiveDetails viewer = new ScoreEditor.SemesterScoreArchiveDetails(this.PrimaryKey, sssa.Uid, sssa.RefEntryUid);
            viewer.ShowDialog();
        }
 private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (listView1.SelectedIndices.Count == 1)
     {
         StudentSemsSocreArchive sssa = listView1.SelectedItems[0].Tag as StudentSemsSocreArchive;
         ScoreEditor.SemesterScoreArchiveDetails viewer = new ScoreEditor.SemesterScoreArchiveDetails(this.PrimaryKey, sssa.Uid, sssa.RefEntryUid);
         viewer.ShowDialog();
     }
 }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            List <K12.Data.StudentRecord> studentList = K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource);
            Dictionary <string, K12.Data.StudentRecord> studentDic = new Dictionary <string, K12.Data.StudentRecord>();

            foreach (K12.Data.StudentRecord each in studentList)
            {
                if (!studentDic.ContainsKey(each.ID))
                {
                    studentDic.Add(each.ID, each);
                }
            }

            UpdateHelper updateHelper = new UpdateHelper();

            // QueryHelper qh = new QueryHelper();

            if (MsgBox.Show("您確定要刪除此學期成績(封存)?", "", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            foreach (string studentID in K12.Presentation.NLDPanels.Student.SelectedSource)
            {
                StudentSemsSocreArchive sssa = listView1.SelectedItems[0].Tag as StudentSemsSocreArchive;
                string sql  = "DELETE  FROM $semester_entry_score_archive WHERE uid={0} ;";
                string sql2 = "DELETE FROM $semester_subject_score_archive WHERE uid={0}";

                // 刪除分項成績
                sql = string.Format(sql, sssa.RefEntryUid);
                //刪除科目成績
                sql2 = string.Format(sql2, sssa.Uid);

                List <string> sqls = new List <string>();
                sqls.Add(sql);
                sqls.Add(sql2);
                //string sqls = sql + sql2;
                //qh.Select(sqls);

                updateHelper.Execute(sqls);

                // 刪除學期成績(封存) +封存時間log
                StringBuilder deleteDesc = new StringBuilder("");
                deleteDesc.AppendLine("學生姓名:" + studentDic[studentID].Name + " ");
                deleteDesc.AppendLine("刪除 " + listView1.SelectedItems[0].SubItems[0].Text + " 學年度 第 " + listView1.SelectedItems[0].SubItems[1].Text + " 學期 學期成績(封存)");
                FISCA.LogAgent.ApplicationLog.Log("學期成績(封存)", "刪除", "學生", this.PrimaryKey, deleteDesc.ToString());

                MsgBox.Show("刪除完成。");
                Changed();
            }
        }
        public void FillListView()
        {
            QueryHelper qh  = new QueryHelper();
            string      sql = @"SELECT 
a.uid
, a.ref_student_id
, a.school_year
, a.semester
, a.grade_year, array_to_string(xpath('//SemesterEntryScore/Entry[@分項=''學業'']/@成績', xmlparse(content b.score_info)), '')::text AS 學業成績
, a.last_update, a.ref_sems_entry_uid
FROM $semester_subject_score_archive a
LEFT JOIN $semester_entry_score_archive b
ON a.ref_sems_entry_uid=b.uid
WHERE a.ref_student_id={0}";

            sql = string.Format(sql, this.PrimaryKey);

            try
            {
                DataTable dt = qh.Select(sql);

                int i = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    StudentSemsSocreArchive sssa = new StudentSemsSocreArchive();
                    sssa.Uid         = dr["uid"].ToString();
                    sssa.RefEntryUid = dr["ref_sems_entry_uid"].ToString();

                    listView1.Items.Add(dr["school_year"].ToString());
                    listView1.Items[i].Tag = sssa;
                    listView1.Items[i].SubItems.Add(dr["semester"].ToString());
                    listView1.Items[i].SubItems.Add(dr["grade_year"].ToString());
                    listView1.Items[i].SubItems.Add(dr["學業成績"].ToString());
                    listView1.Items[i].SubItems.Add(dr["last_update"].ToString());
                    i++;
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show("取得學生學期成績(封存)發生錯誤。");
            }
            _ReloadArchiveData = false;     //Cyn
        }