protected override ContinueDirection?OnNextButtonClick() { try { string stuId = "0"; if (SRecord != null) { stuId = SRecord.ID; } errors.SetError(txtIDNumber, ""); if (IsIDNumberExists(stuId, txtIDNumber.Text)) { errors.SetError(txtIDNumber, "身分證號重覆!"); return(null); } errors.SetError(cboStudentNumber, ""); if (IsStudentNumberExists(stuId, cboStudentNumber.Text)) { errors.SetError(cboStudentNumber, "學號重覆!"); return(null); } errors.SetError(txtClass, ""); if (string.IsNullOrWhiteSpace(txtClass.Text)) { errors.SetError(txtClass, "班級必填!"); return(null); } //將資料寫回 XmlData。 XElement student = XmlData.Element("Student"); student.Element("Name").Value = txtName.Text; student.Element("IDNumber").Value = txtIDNumber.Text; student.Element("Birthdate").Value = dtBirthday.Text; student.Element("Gender").Value = cboGender.Text; XElement paddress = XmlData .Element("StudentComplete") .Element("PermanentAddress") .Element("AddressList"); if (paddress != null) { paddress = paddress.Element("Address"); if (paddress.Element("ZipCode") == null) { paddress.Add(new XElement("ZipCode", txtZipCode.Text)); } else { paddress.Element("ZipCode").Value = txtZipCode.Text; } if (paddress.Element("County") == null) { paddress.Add(new XElement("County", cmbCounty.Text)); } else { paddress.Element("County").Value = cmbCounty.Text; } if (paddress.Element("Town") == null) { paddress.Add(new XElement("Town", cmbTown.Text)); } else { paddress.Element("Town").Value = cmbTown.Text; } if (paddress.Element("District") == null) { paddress.Add(new XElement("District", txtDistrict.Text)); } else { paddress.Element("District").Value = txtDistrict.Text; } if (paddress.Element("Area") == null) { paddress.Add(new XElement("Area", txtArea.Text)); } else { paddress.Element("Area").Value = txtArea.Text; } if (paddress.Element("DetailAddress") == null) { paddress.Add(new XElement("DetailAddress", txtDetail.Text)); } else { paddress.Element("DetailAddress").Value = txtDetail.Text; } } else { paddress = new XElement("Address"); paddress.Add(new XElement("ZipCode", txtZipCode.Text)); paddress.Add(new XElement("County", cmbCounty.Text)); paddress.Add(new XElement("Town", cmbTown.Text)); paddress.Add(new XElement("District", txtDistrict.Text)); paddress.Add(new XElement("Area", txtArea.Text)); paddress.Add(new XElement("DetailAddress", txtDetail.Text)); XmlData .Element("StudentComplete") .Element("PermanentAddress").Add(new XElement("AddressList", paddress)); } //<StudentComplete Processor="StudentComplete"> // <PermanentAddress> // <AddressList> // <Address> // <ZipCode>310</ZipCode> // <County>新竹縣</County> // <Town>竹東鎮</Town> // <District /> // <Area /> // <DetailAddress>北岸19號</DetailAddress> // </Address> // </AddressList> // </PermanentAddress> // </StudentComplete> if (SRecord != null) { UpdateData(SRecord); K12.Data.Student.Update(SRecord); ARecord = K12.Data.Address.SelectByStudentID(SRecord.ID); #region 更新學生地址 ARecord.Permanent.ZipCode = txtZipCode.Text; ARecord.Permanent.County = cmbCounty.Text; ARecord.Permanent.Town = cmbTown.Text; ARecord.Permanent.District = txtDistrict.Text; ARecord.Permanent.Area = txtArea.Text; ARecord.Permanent.Detail = txtDetail.Text; K12.Data.Address.Update(ARecord); ARecord = K12.Data.Address.SelectByStudentID(ARecord.RefStudentID); #endregion student.SetAttributeValue("ID", SRecord.ID); //將 Xml 上標示新增的學生編號。 Arguments[Consts.StudentID] = SRecord.ID; } else { SRecord = new StudentRecord(); UpdateData(SRecord); string newid = K12.Data.Student.Insert(SRecord); ////新竹市的國中,需要多呼叫數位學生證資料同步的 Service。 ////新增的狀態下才呼叫,以免重覆呼叫。 //if (Program.CurrentMode == Program.Hsinchu) // CallTransferInWS(); #region 更新學生地址 ARecord = K12.Data.Address.SelectByStudentID(newid); ARecord.RefStudentID = newid; ARecord.Permanent.ZipCode = txtZipCode.Text; ARecord.Permanent.County = cmbCounty.Text; ARecord.Permanent.Town = cmbTown.Text; ARecord.Permanent.District = txtDistrict.Text; ARecord.Permanent.Area = txtArea.Text; ARecord.Permanent.Detail = txtDetail.Text; K12.Data.Address.Update(ARecord); ARecord = K12.Data.Address.SelectByStudentID(ARecord.RefStudentID); #endregion FISCA.Features.Invoke("StudentSyncAllBackground"); student.SetAttributeValue("ID", newid); //將 Xml 上標示新增的學生編號。 Arguments[Consts.StudentID] = newid; } //將最新狀況寫回資料庫中。 Record.ModifiedContent = XmlData.ToString(); Record.RefStudentID = Arguments[Consts.StudentID] + ""; Record.Save(); // 新增至班級學生變更 UDT_ClassSpecial StudSpec = UDTTransfer.AddClassSpecStudent(SRecord.ID, "", SRecord.RefClassID, "", txtClass.Text, txtClass.Text, "", ""); // 傳送至局端 string errMsg = Utility.SendData("自動轉入", SRecord.IDNumber, SRecord.StudentNumber, SRecord.Name, cboGender.Text, txtOClass.Text, cboSeatNo.Text, txtClass.Text, "", "", SRecord.ID, SRecord.RefClassID, StudSpec.ClassComment); if (errMsg != "") { FISCA.Presentation.Controls.MsgBox.Show(errMsg); } //設定所有 Processor 的學生編號。 foreach (TransferProcessor tp in TransferProcessor.Processors) { tp.SetStudentId(Arguments[Consts.StudentID] + ""); } //註冊一個事件引發模組 EventHandler eh = FISCA.InteractionService.PublishEvent("KH_StudentTransferStudentBriefItem"); eh(this, EventArgs.Empty); return(ContinueDirection.Next); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); return(null); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtNewName.Text.Trim() == "") { MsgBox.Show("姓名必填"); return; } if (lblNewClassName.Text.Trim() == "") { MsgBox.Show("班級必填"); return; } if (string.IsNullOrEmpty(cbotStudentNumber.Text)) { Errors.SetError(cbotStudentNumber, "學號空白!"); } MsgForm mf = new MsgForm(); string msg = "請問是否將班級由「" + lblClassName.Text + "」調整成「" + lblNewClassName.Text + "」,並傳送至局端備查?"; bool chkSend = false; mf.Text = "調整確認"; mf.SetMsg(msg); //if (FISCA.Presentation.Controls.MsgBox.Show(msg, "調整確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) if (mf.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { chkSend = true; } if (chkSend) { string sid = string.Empty; //if (StudCheckTool.CheckStudIDNumberSame(txtNewSSN.Text, sid)) //{ // FISCA.Presentation.Controls.MsgBox.Show("身分證號重複請檢查"); // return; //} Dictionary <string, int> chkSum = new Dictionary <string, int>(); foreach (JHSchool.Data.JHStudentRecord studRec in JHSchool.Data.JHStudent.SelectAll()) { if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般) { if (!string.IsNullOrEmpty(studRec.StudentNumber)) { if (chkSum.ContainsKey(studRec.StudentNumber)) { chkSum[studRec.StudentNumber]++; } else { chkSum.Add(studRec.StudentNumber, 1); } } } } bool chkDNumber = false; if (chkSum.ContainsKey(cbotStudentNumber.Text)) { if (chkSum[cbotStudentNumber.Text] > 0) { chkDNumber = true; } } Errors.SetError(cbotStudentNumber, ""); if (chkDNumber) { Errors.SetError(cbotStudentNumber, "學號重複請檢查!"); return; } if (_status == AddTransStudStatus.Added) { JHSchool.Data.JHStudentRecord NewStudRec = new JHSchool.Data.JHStudentRecord(); NewStudRec.Name = txtNewName.Text; NewStudRec.Gender = cboNewGender.Text; NewStudRec.IDNumber = txtNewSSN.Text; sid = JHSchool.Data.JHStudent.Insert(NewStudRec); _StudentPhone = JHSchool.Data.JHPhone.SelectByStudentID(sid); _StudentPhone.Contact = txtNewTel.Text; } if (!string.IsNullOrEmpty(sid)) { _student = JHSchool.Data.JHStudent.SelectByID(sid); } //_student.Name = txtNewName.Text; _student.IDNumber = txtNewSSN.Text; DateTime dt; if (DateTime.TryParse(dtNewBirthday.Text, out dt)) { _student.Birthday = dt; } //_student.Gender = cboNewGender.Text; _student.Nationality = cboNewNationality.Text; _student.BirthPlace = txtNewBirthPlace.Text; //_StudentPhone.Contact = txtNewTel.Text; //_student.EnglishName = txtNewEngName.Text; foreach (JHSchool.Data.JHClassRecord cr in JHSchool.Data.JHClass.SelectAll()) { if (lblNewClassName.Text == cr.Name) { _student.RefClassID = cr.ID; break; } } if (string.IsNullOrEmpty(cboSeatNo.Text)) { _student.SeatNo = null; } else { int no; int.TryParse(cboSeatNo.Text, out no); _student.SeatNo = no; } _student.StudentNumber = cbotStudentNumber.Text; string strGradeYear = ""; if (_student.Class != null) { if (_student.Class.GradeYear.HasValue) { strGradeYear = _student.Class.GradeYear.Value.ToString(); } } // 當學生狀態非一般調整學生狀態 if (_student.Status != K12.Data.StudentRecord.StudentStatus.一般) { _student.Status = K12.Data.StudentRecord.StudentStatus.一般; } try { JHSchool.Data.JHStudent.Update(_student); JHSchool.Data.JHPhone.Update(_StudentPhone); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("更新學生資料發生錯誤:" + ex.Message); } // 寫入班級學生變動 UDT_ClassSpecial StudSpec = UDTTransfer.AddClassSpecStudent(_student.ID, "", _student.RefClassID, lblClassName.Text, lblNewClassName.Text, lblNewClassName.Text, "", ""); // 傳送至局端 string errMsg = Utility.SendData("自動轉入", _student.IDNumber, _student.StudentNumber, _student.Name, strGradeYear, lblClassName.Text, cboSeatNo.Text, lblNewClassName.Text, "", "", _student.ID, _student.RefClassID, StudSpec.ClassComment); if (errMsg != "") { FISCA.Presentation.Controls.MsgBox.Show(errMsg); } //log JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess(); if (_status == AddTransStudStatus.Added) { prlp.SaveLog("學生.轉入異動", "新增班級資料", "修改轉入與班級資料."); } else { prlp.SaveLog("學生.轉入異動", "修改班級資料", "修改轉入與班級資料."); } AddTransBackgroundManager.SetStudent(_student); AddTransManagerForm atmf = new AddTransManagerForm(); this.Visible = false; atmf.StartPosition = FormStartPosition.CenterParent; atmf.ShowDialog(FISCA.Presentation.MotherForm.Form); this.Close(); JHSchool.Student.Instance.SyncAllBackground(); JHSchool.Data.JHStudent.RemoveAll(); JHSchool.Data.JHStudent.SelectAll(); //註冊一個事件引發模組 EventHandler eh = FISCA.InteractionService.PublishEvent("KH_StudentTransStudBase"); eh(this, EventArgs.Empty); } } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show(ex.Message); return; } }
private void lnkSend_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { SetClassNameSeatNoForm scnsf = new SetClassNameSeatNoForm(); string gradeYear = ""; string oldClassName = ""; string oldClassID = ""; // 有班級 if (objStudent.Class != null) { //// 不能修改年級,依學生本身班級年級 //scnsf.setCboGradeYearEnable(false); // 因需求調整年級可自由選 scnsf.setCboGradeYearEnable(true); // 放入可選年級 scnsf.SetCboGradeYearItems(Utility.GetGradeYearList()); // 原班級名稱 oldClassName = objStudent.Class.Name; oldClassID = objStudent.RefClassID; // 填入年級 if (objStudent.Class.GradeYear.HasValue) { gradeYear = objStudent.Class.GradeYear.Value.ToString(); } scnsf.SetCboGradeYearText(gradeYear); } else { scnsf.setCboGradeYearEnable(true); // 放入可選年級 scnsf.SetCboGradeYearItems(Utility.GetGradeYearList()); } scnsf.SetOldClassName(oldClassName); if (scnsf.ShowDialog() == DialogResult.OK) { string className = "", FirstClassName = "", SecondClassName = "", ThridClassName = ""; className = scnsf.GetClassName(); FirstClassName = scnsf.GetFirstClassName(); SecondClassName = scnsf.GetSecondClassName(); ThridClassName = scnsf.GetThridClassName(); _ClassNameIDDic = scnsf.GetClassNameDict(); int seatNo; // 修改學生班、座 if (_ClassNameIDDic.ContainsKey(className)) { objStudent.RefClassID = _ClassNameIDDic[className]; if (int.TryParse(scnsf.GetSeatNo(), out seatNo)) { objStudent.SeatNo = seatNo; } else { objStudent.SeatNo = null; } // 檢查是否傳送到局端,true才會送,主要修改當改座號不傳。 if (scnsf.GetChkSend()) { // 新增到班級學生變動紀錄 UDT_ClassSpecial StudSpec = UDTTransfer.AddClassSpecStudent(objStudent.ID, oldClassID, objStudent.RefClassID, oldClassName, className, FirstClassName, SecondClassName, ThridClassName); // 傳送檔案到局端 Utility.UploadFile(objStudent.ID, scnsf.GetBase64DataString(), scnsf.GetFileName(), "student"); // 傳送至局端 string errMsg = Utility.SendData("調整班級", objStudent.IDNumber, objStudent.StudentNumber, objStudent.Name, gradeYear, oldClassName, scnsf.GetSeatNo(), className, scnsf.GetMettingDate(), scnsf.GetMemo(), FirstClassName, scnsf.GetEDoc(), SecondClassName, ThridClassName, objStudent.ID, oldClassID, objStudent.RefClassID, StudSpec.OldClassComment, StudSpec.ClassComment); if (errMsg != "") { FISCA.Presentation.Controls.MsgBox.Show(errMsg); } } // 更新學生資料 K12.Data.Student.Update(objStudent); prlp.SetAfterSaveText("班級", lblClassName.Text); prlp.SetAfterSaveText("座號", lblSeatNo.Text); prlp.SetAfterSaveText("學號", txtStudentNumber.Text); prlp.SetActionBy("學籍", "學生班級資訊"); prlp.SetAction("修改學生班級資訊"); prlp.SetDescTitle("學生姓名:" + objStudent.Name + ",學號:" + objStudent.StudentNumber + ","); prlp.SaveLog("", "", "student", PrimaryKey); Student.Instance.SyncDataBackground(PrimaryKey); } EventHandler eh = FISCA.InteractionService.PublishEvent("KH_StudentClassItemContent"); eh(this, EventArgs.Empty); } }