示例#1
0
        void item_Click(object sender, EventArgs e)
        {
            StudentRecord stud = null;
            ButtonItem    bt   = sender as ButtonItem;

            if (bt != null)
            {
                stud = bt.Tag as StudentRecord;
            }
            if (stud != null && _TeacherEntityID.HasValue)
            {
                // 檢查是否加入
                int sid = int.Parse(stud.ID);
                if (!_StudDict.ContainsKey(sid))
                {
                    List <DAO.UDT_CounselStudent_ListDef> dataList = new List <DAO.UDT_CounselStudent_ListDef>();
                    DAO.UDT_CounselStudent_ListDef        data     = new DAO.UDT_CounselStudent_ListDef();
                    data.StudentID    = sid;
                    data.TeacherTagID = _TeacherEntityID.Value;
                    dataList.Add(data);
                    _UDTTransfer.InsertCounselStudentList(dataList);
                    _BGRun();
                }
            }
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            List <DAO.UDT_CounselStudent_ListDef> InsertData = new List <DAO.UDT_CounselStudent_ListDef>();

            foreach (ListViewItem lvi in lvTeacherName.CheckedItems)
            {
                DAO.CounselTeacherRecord ctr = lvi.Tag as DAO.CounselTeacherRecord;
                if (ctr == null)
                {
                    continue;
                }

                foreach (int id in _StudentIDList)
                {
                    // 檢查是否已經指定過
                    int hasDataCount = (from data in _hasCounselStudent_List where data.StudentID == id && data.TeacherTagID == ctr.TeacherTag_ID select data).ToList().Count;
                    // 沒有設定
                    if (hasDataCount == 0)
                    {
                        DAO.UDT_CounselStudent_ListDef data = new DAO.UDT_CounselStudent_ListDef();
                        data.StudentID    = id;
                        data.TeacherTagID = ctr.TeacherTag_ID;
                        InsertData.Add(data);
                    }
                }
            }
            if (InsertData.Count > 0)
            {
                _UDTTransfer.InsertCounselStudentList(InsertData);
            }
            if (lvTeacherName.CheckedItems.Count > 0)
            {
                FISCA.Presentation.Controls.MsgBox.Show("指定完成.");
            }

            EventHub.OnCounselChanged();
            Close();
        }