예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckData() == false)
            {
                Utility.ShowCannotSaveMessage();
                return;
            }
            SaveFormDataToUDTDef();

            // log
            LogData();

            string studStr = "學號:" + _studRec.StudentNumber + ",姓名:" + _studRec.Name + ",";

            if (_accessType == accessType.Insert)
            {
                // 檢查是否可以新增 (立案日期+個案類別 不能重複)
                List <DAO.UDT_CounselCareRecordDef> CareRecList = _UDTTransfer.GetCareRecordsByStudentID(_studRec.ID);
                bool pass = true;
                foreach (DAO.UDT_CounselCareRecordDef rec in CareRecList)
                {
                    if (rec.FileDate.HasValue && _CounselCareRecord.FileDate.HasValue)
                    {
                        if (rec.FileDate.Value.ToShortDateString() == _CounselCareRecord.FileDate.Value.ToShortDateString())
                        {
                            if (rec.CaseCategory == _CounselCareRecord.CaseCategory)
                            {
                                pass = false;
                            }
                        }
                    }
                }

                if (pass)
                {
                    // log
                    _LogTransfer.SaveInsertLog("學生.優先關懷紀錄-新增", "新增", studStr, "", "student", _studRec.ID);
                    _UDTTransfer.InsertCareRecord(_CounselCareRecord);
                }
                else
                {
                    FISCA.Presentation.Controls.MsgBox.Show("已有相同的立案日期與個案類別,無法新增。");
                    return;
                }
            }
            else
            {
                // log
                _LogTransfer.SaveChangeLog("學生.優先關懷紀錄-修改", "修改", studStr, "", "student", _studRec.ID);

                _UDTTransfer.UpdateCareRecord(_CounselCareRecord);
            }

            Utility.ShowSavedMessage();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }