private void BeforeEnrollmentItem_Load(object sender, EventArgs e) { _BeforeEnrollmentRecord = SHBeforeEnrollment.SelectByStudentID(PrimaryKey); listener.Add(new TextBoxSource(txtSchool)); listener.Add(new TextBoxSource(txtSchoolLocation)); listener.Add(new TextBoxSource(txtClass)); listener.Add(new TextBoxSource(txtSeatNo)); listener.Add(new TextBoxSource(txtMemo)); listener.Add(new TextBoxSource(txtGraduateSchoolYear)); listener.Reset(); listener.StatusChanged += new EventHandler <ChangeEventArgs>(listener_StatusChanged); SHBeforeEnrollment.AfterUpdate += new EventHandler <K12.Data.DataChangedEventArgs>(SHBeforeEnrollment_AfterUpdate); _worker.DoWork += new DoWorkEventHandler(_worker_DoWork); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_worker_RunWorkerCompleted); Disposed += new EventHandler(BeforeEnrollmentItem_Disposed); }
/// <summary> /// 產生新生異動(傳入學生編號、異動日期、異動代碼、班別) /// </summary> /// <param name="StudentIDList"></param> /// <param name="UpdateDate"></param> /// <param name="UpdateCode"></param> /// <param name="ClassType"></param> /// <returns></returns> public bool Run(List <string> StudentIDList, string UpdateDate, string UpdateCode, string UpdateDesc, string ClassType) { bool pass = true; List <SHBeforeEnrollmentRecord> befRecList = SHBeforeEnrollment.SelectByStudentIDs(StudentIDList); Dictionary <string, DAL.SchoolData> schoolDataDict = new Dictionary <string, DAL.SchoolData> (); foreach (XElement elm in BL.Get.JHSchoolList().Elements("學校")) { DAL.SchoolData sd = new DAL.SchoolData(); sd.SchoolCode = elm.Attribute("代碼").Value; sd.SchoolLocation = elm.Attribute("所在地").Value; sd.SchoolName = elm.Attribute("名稱").Value; sd.SchoolLocationCode = elm.Attribute("所在地代碼").Value; if (sd.SchoolCode.Length > 3) { sd.SchoolType = sd.SchoolCode.Substring(2, 1); } string s1 = elm.Attribute("所在地").Value + elm.Attribute("名稱").Value; if (!schoolDataDict.ContainsKey(s1)) { schoolDataDict.Add(s1, sd); } if (!schoolDataDict.ContainsKey(sd.SchoolName)) { schoolDataDict.Add(sd.SchoolName, sd); } } int SchoolYear = 0, Semester = 0; int.TryParse(K12.Data.School.DefaultSchoolYear, out SchoolYear); int.TryParse(K12.Data.School.DefaultSemester, out Semester); List <string> _CheckCodeList = (from data in _UpdateCodeList select data.Substring(0, 3)).ToList(); List <SHUpdateRecordRecord> insertData = new List <SHUpdateRecordRecord>(); List <SHUpdateRecordRecord> WaitDeleteData = new List <SHUpdateRecordRecord>(); // 取得學生資料 List <SHStudentRecord> studRecList = SHStudent.SelectByIDs(StudentIDList); List <string> SIDList = new List <string>(); // 取得已有新生異動 foreach (SHUpdateRecordRecord rec in SHUpdateRecord.SelectByStudentIDs(StudentIDList)) { if (_CheckCodeList.Contains(rec.UpdateCode)) { WaitDeleteData.Add(rec); if (!SIDList.Contains(rec.StudentID)) { SIDList.Add(rec.StudentID); } } } bool checkdelData = true; // 已有資料是否覆蓋 if (SIDList.Count > 0) { WarningForm wf = new WarningForm(); wf.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; wf.SetStudentCount(SIDList.Count); wf.SetStudRec(studRecList); wf.SetUpdateRecList(WaitDeleteData); if (wf.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { checkdelData = false; pass = false; } } // 清掉舊資料 if (checkdelData) { SHUpdateRecord.Delete(WaitDeleteData); } // 取得新生異動 foreach (SHStudentRecord studRec in studRecList) { // 不刪除代表不需要新增,所以略過 if (checkdelData == false) { if (SIDList.Contains(studRec.ID)) { continue; } } SHUpdateRecordRecord NewUpdateRec = new SHUpdateRecordRecord(); if (SchoolYear > 0) { NewUpdateRec.SchoolYear = SchoolYear; } if (Semester > 0) { NewUpdateRec.Semester = Semester; } if (studRec.Class != null) { if (studRec.Class.GradeYear.HasValue) { NewUpdateRec.GradeYear = studRec.Class.GradeYear.Value.ToString(); } } NewUpdateRec.GraduateComment = ""; NewUpdateRec.UpdateCode = UpdateCode; NewUpdateRec.UpdateDescription = UpdateDesc; NewUpdateRec.UpdateDate = UpdateDate; NewUpdateRec.ClassType = ClassType; NewUpdateRec.SpecialStatus = DAL.DALTransfer.GetSpecialCode(studRec.ID); if (studRec.Department != null) { NewUpdateRec.Department = studRec.Department.FullName; } NewUpdateRec.StudentID = studRec.ID; NewUpdateRec.StudentName = studRec.Name; NewUpdateRec.StudentNumber = studRec.StudentNumber; NewUpdateRec.IDNumber = studRec.IDNumber; if (studRec.Birthday.HasValue) { NewUpdateRec.Birthdate = studRec.Birthday.Value.ToShortDateString(); } NewUpdateRec.Gender = studRec.Gender; if (int.Parse(UpdateCode) > 5) { NewUpdateRec.GraduateComment = "1"; } foreach (SHBeforeEnrollmentRecord brfRec in befRecList) { if (brfRec.RefStudentID == NewUpdateRec.StudentID) { NewUpdateRec.GraduateSchool = brfRec.School; NewUpdateRec.GraduateSchoolYear = brfRec.GraduateSchoolYear; // 用學校名稱解析 if (!string.IsNullOrEmpty(brfRec.School)) { string key = brfRec.SchoolLocation.Replace("台", "臺") + brfRec.School.Trim(); if (schoolDataDict.ContainsKey(key)) { NewUpdateRec.GraduateSchoolCode = schoolDataDict[key].SchoolCode; NewUpdateRec.GraduateSchoolLocationCode = schoolDataDict[key].SchoolLocationCode; } } } } insertData.Add(NewUpdateRec); } // 新增異動 SHUpdateRecord.Insert(insertData); return(pass); }
protected override void OnSaveButtonClick(EventArgs e) { _BeforeEnrollmentRecord.School = txtSchool.Text; _BeforeEnrollmentRecord.SchoolLocation = txtSchoolLocation.Text; _BeforeEnrollmentRecord.ClassName = txtClass.Text; int intSeatNo; if (string.IsNullOrEmpty(txtSeatNo.Text)) { _BeforeEnrollmentRecord.SeatNo = null; } else { if (int.TryParse(txtSeatNo.Text, out intSeatNo)) { _BeforeEnrollmentRecord.SeatNo = intSeatNo; } else { epSeatNo.SetError(txtSeatNo, "請填入數字."); return; } } _BeforeEnrollmentRecord.Memo = txtMemo.Text; int GSchoolYear; if (string.IsNullOrEmpty(txtGraduateSchoolYear.Text)) { _BeforeEnrollmentRecord.GraduateSchoolYear = null; } else { if (int.TryParse(txtGraduateSchoolYear.Text, out GSchoolYear)) { _BeforeEnrollmentRecord.GraduateSchoolYear = GSchoolYear.ToString(); } else { epSeatNo.SetError(txtGraduateSchoolYear, "請填入數字."); return; } } SHBeforeEnrollment.Update(_BeforeEnrollmentRecord); listener.Reset(); SaveButtonVisible = false; CancelButtonVisible = SaveButtonVisible; prlp.SetAfterSaveText("學校名稱", txtSchool.Text); prlp.SetAfterSaveText("所在地", txtSchoolLocation.Text); prlp.SetAfterSaveText("班級", txtClass.Text); prlp.SetAfterSaveText("座號", txtSeatNo.Text); prlp.SetAfterSaveText("備註", txtMemo.Text); prlp.SetAfterSaveText("國中畢業學年度", txtGraduateSchoolYear.Text); prlp.SetActionBy("學籍", "學生前級畢業資訊"); prlp.SetAction("修改學生前級畢業資訊"); SHStudentRecord studRec = SHStudent.SelectByID(PrimaryKey); prlp.SetDescTitle("學生姓名:" + studRec.Name + ",學號:" + studRec.StudentNumber + ","); prlp.SaveLog("", "", "student", PrimaryKey); }
private void GetData() { _BeforeEnrollmentRecord = SHBeforeEnrollment.SelectByStudentID(PrimaryKey); }
/// <summary> /// 新生異動 /// </summary> public UpdateRecordInfo03(SHUpdateRecordRecord UpdateRec, PermRecLogProcess prlp, List <XElement> UpdateCodeElms, bool isInsert) { InitializeComponent(); cbxGender.Items.Add("男"); cbxGender.Items.Add("女"); cbxClass.DropDownWidth = 300; _UpdateRec = UpdateRec; _prlp = prlp; _UpdateCodeElms = UpdateCodeElms; _UpdateCoodeList = (from x in _UpdateCodeElms select x.Element("代號").Value + " " + x.Element("原因及事項").Value).ToList(); _DeptList = SHDepartment.SelectAll(); _epUpdateCode = new ErrorProvider(); _UCodeDict = Utility.UITool.ConvertUpdateCodeDescDict(_UpdateCodeElms); _faldn = new UpdateRecordModule_SH_D.Utility.FormAndLogDataManager(_prlp); // 新增帶入預設 if (isInsert) { // 載入資料 // 載入預設前級畢業資訊 Dictionary <string, DAL.SchoolData> schoolDataDict = new Dictionary <string, DAL.SchoolData>(); foreach (XElement elm in BL.Get.JHSchoolList().Elements("學校")) { DAL.SchoolData sd = new DAL.SchoolData(); sd.SchoolCode = elm.Attribute("代碼").Value; sd.SchoolLocation = elm.Attribute("所在地").Value; sd.SchoolName = elm.Attribute("名稱").Value; sd.SchoolLocationCode = elm.Attribute("所在地代碼").Value; if (sd.SchoolCode.Length > 3) { sd.SchoolType = sd.SchoolCode.Substring(2, 1); } string s1 = elm.Attribute("所在地").Value + elm.Attribute("名稱").Value; if (!schoolDataDict.ContainsKey(s1)) { schoolDataDict.Add(s1, sd); } if (!schoolDataDict.ContainsKey(sd.SchoolName)) { schoolDataDict.Add(sd.SchoolName, sd); } } SHBeforeEnrollmentRecord brfRec = SHBeforeEnrollment.SelectByStudentID(_UpdateRec.StudentID); if (string.IsNullOrEmpty(_UpdateRec.GraduateSchool)) { _UpdateRec.GraduateSchool = brfRec.School; } if (string.IsNullOrEmpty(_UpdateRec.GraduateSchoolYear)) { _UpdateRec.GraduateSchoolYear = brfRec.GraduateSchoolYear; } // 用學校名稱解析 if (!string.IsNullOrEmpty(brfRec.School)) { string key = brfRec.SchoolLocation.Replace("台", "臺") + brfRec.School.Trim(); if (schoolDataDict.ContainsKey(key)) { if (string.IsNullOrEmpty(_UpdateRec.GraduateSchoolCode)) { _UpdateRec.GraduateSchoolCode = schoolDataDict[key].SchoolCode; _UpdateRec.GraduateSchoolLocationCode = schoolDataDict[key].SchoolLocationCode; } } } } cbxUpdateCode = _faldn.SetFormData(_UpdateRec.UpdateCode, cbxUpdateCode, "資格代碼"); txtDesc = _faldn.SetFormData(_UpdateRec.UpdateDescription, txtDesc, "原因及事項"); dtUpdateDate = _faldn.SetFormData(_UpdateRec.UpdateDate, dtUpdateDate, "異動日期"); txtMemo = _faldn.SetFormData(_UpdateRec.Comment, txtMemo, "備註"); cbxDept = _faldn.SetFormData(_UpdateRec.Department, cbxDept, "科別"); cbxClass = _faldn.SetFormData(_UpdateRec.ClassType, cbxClass, "班別"); txtSpecial = _faldn.SetFormData(_UpdateRec.SpecialStatus, txtSpecial, "特殊身分代碼"); txtName = _faldn.SetFormData(_UpdateRec.StudentName, txtName, "姓名"); txtStudentNumber = _faldn.SetFormData(_UpdateRec.StudentNumber, txtStudentNumber, "學號"); txtIDNumber = _faldn.SetFormData(_UpdateRec.IDNumber, txtIDNumber, "身分證字號"); dtBirthday = _faldn.SetFormData(_UpdateRec.Birthdate, dtBirthday, "生日"); txtIDNumber1 = _faldn.SetFormData(_UpdateRec.IDNumberComment, txtIDNumber1, "註1"); cbxGender = _faldn.SetFormData(_UpdateRec.Gender, cbxGender, "性別"); txtISchool = _faldn.SetFormData(_UpdateRec.GraduateSchool, txtISchool, "入學資格(畢業國中)"); txtISpaceCode = _faldn.SetFormData(_UpdateRec.GraduateSchoolLocationCode, txtISpaceCode, "所在地代碼"); txtISchoolCode = _faldn.SetFormData(_UpdateRec.GraduateSchoolCode, txtISchoolCode, "畢業國中學校代號"); txtIJHGradeYear = _faldn.SetFormData(_UpdateRec.GraduateSchoolYear, txtIJHGradeYear, "國中畢業年度"); dtADDate = _faldn.SetFormData(_UpdateRec.ADDate, dtADDate, "核准日期"); txtADDocNo = _faldn.SetFormData(_UpdateRec.ADNumber, txtADDocNo, "核准文號"); txtGradeDoc = _faldn.SetFormData(_UpdateRec.GraduateDocument, txtGradeDoc, "入學資格證明文件"); }