Ejemplo n.º 1
0
        private dynamic GetAddressData()
        {
            XElement temp = XmlData.Element("StudentComplete");

            if (temp != null)
            {
                temp = temp.Element("PermanentAddress");
            }

            if (temp != null)
            {
                temp = temp.Element("AddressList");
            }

            if (temp != null)
            {
                temp = temp.Element("Address");
            }

            if (temp == null)
            {
                return(new DynamicXmlObject("Address"));
            }
            else
            {
                return((DynamicXmlObject)temp);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 載入表單
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StudentBrief_Load(object sender, EventArgs e)
        {
            try
            {
                Record  = Arguments[Consts.TransferInRecord] as TransferInRecord;
                XmlData = Arguments[Consts.XmlData] as XElement;
                dynamic briefSection = (DynamicXmlObject)XmlData.Element("Student");
                //取得地址資料
                dynamic permanentAddress = GetAddressData();
                //<PermanentAddress>
                //  <AddressList>
                //    <Address>
                //      <ZipCode>303</ZipCode>
                //      <County>新竹縣</County>
                //      <Town>湖口鄉</Town>
                //      <District />
                //      <Area />
                //      <DetailAddress>嶺尾8號</DetailAddress>
                //    </Address>
                //  </AddressList>
                //</PermanentAddress>

                string urAction = briefSection["@UpdateRecordAction"];
                if (!string.IsNullOrWhiteSpace(urAction))
                {
                    Arguments[Consts.UpdateRecordAction] = Enum.Parse(typeof(ContinueDirection), urAction);
                }

                SelectStudentAddressRecord(briefSection);

                if (SRecord != null)
                {
                    if (!string.IsNullOrWhiteSpace(SRecord.RefClassID))
                    {
                        CRecord = SRecord.Class;
                    }

                    FillStudentNumberLast(SRecord.StudentNumber);
                }
                else
                {
                    FillStudentNumberLast(string.Empty);
                }



                if (SRecord == null)
                {
                    SingleMode();
                }
                else
                {
                    FromOriginData();
                }

                NextButtonEnabled      = false;
                ClassRunning.IsRunning = true;
                ClassRunning.Visible   = true;
                Task task = Task.Factory.StartNew(() =>
                {
                    LoadClassRowSource();

                    TownList = K12.Data.Town.SelectAll();

                    CountyList = K12.Data.Town.SelectCountyList();
                }, new CancellationToken(), TaskCreationOptions.None, TaskScheduler.Default);

                task.ContinueWith(x =>
                {
                    if (x.IsFaulted)
                    {
                        RTOut.WriteError(x.Exception);
                        MessageBox.Show(x.Exception.Message);
                        NextButtonEnabled = false;
                    }

                    SuspenSelectedValueChanged = true;
                    cmbTown.DataSource         = TownList.Select(y => y.Area).ToList();
                    cmbCounty.DataSource       = CountyList;
                    FromTransferData(briefSection, permanentAddress);
                    //cboClass.DataSource = ClassRowSource;
                    //cboClass.ValueMember = "ID";
                    //cboClass.DisplayMember = "Name";
                    SuspenSelectedValueChanged = false;
                    cboGradeYear.Text          = "";
                    List <string> grList       = Utility.GetGradeYearList();
                    cboGradeYear.Items.AddRange(grList.ToArray());

                    if (SRecord != null)
                    {
                        cboSeatNo.Text        = SRecord.SeatNo + "";
                        cboStudentNumber.Text = SRecord.StudentNumber;

                        //if (CRecord != null)
                        //    cboClass.SelectedIndex = cboClass.FindStringExact(CRecord.Name);
                    }

                    // 如果學生是同校轉出又轉入,回到原班
                    if (CRecord != null)
                    {
                        // 2018/8/29 穎驊因應 高雄專案 [08-02][02]轉入學生編班  修正規則,
                        // 如果學生本為同校生,則會有有選項,讓使用者選擇是否要回原班級,或是依照局端規則,優先提供轉入班級
                        List <KH_HighConcernCalc.ClassStudent> grClassList = Utility.GetClassNameFirst_List("" + CRecord.GradeYear);

                        string msgString = "";
                        msgString        = @"本轉入生在本學校發現其原本班級:" + CRecord.Name + "(編班人數:" + grClassList.Find(c => c.ClassID == CRecord.ID).ClassStudentCount + ")" +
                                           "請問是否轉入原班級?" + "\r\n" + "若選擇為否,則會依局端系統規則優先轉入班級:" + grClassList[0].ClassName + "(編班人數:" + grClassList[0].ClassStudentCount + ")";


                        if (FISCA.Presentation.Controls.MsgBox.Show(msgString, "提醒!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            txtClass.Text = CRecord.Name;
                        }
                        else
                        {
                            txtClass.Text = grClassList[0].ClassName;
                        }
                    }


                    txtClass.ReadOnly = true;

                    ClassRunning.IsRunning = false;
                    ClassRunning.Visible   = false;
                    NextButtonEnabled      = true;
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                RTOut.WriteError(ex);
                WizardResult = ContinueDirection.Cancel;
                Close();
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }