Esempio n. 1
0
        private void buttonX3_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            int xm, ym;

            xm         = (this.Width - panelEx3.Width - 20) / 2;
            ym         = (this.Height - panelEx3.Height - 40) / 2;
            this.Top  += ym;
            this.Left += xm;
            this.SuspendLayout();
            panelEx1.SuspendLayout();
            panelEx2.SuspendLayout();
            panelEx3.SuspendLayout();
            this.Height      = panelEx3.Height + 40;
            this.Width       = panelEx3.Width + 20;
            panelEx1.Visible = false;
            panelEx2.Visible = false;
            panelEx3.Visible = true;
            panelEx1.Dock    = DockStyle.None;
            panelEx2.Dock    = DockStyle.None;
            panelEx3.Dock    = DockStyle.Fill;
            this.Visible     = true;
            panelEx1.ResumeLayout();
            panelEx2.ResumeLayout();
            panelEx3.ResumeLayout();

            this.ResumeLayout();

            // log
            JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
            string desc = "新增" + comboBoxEx1.Text + "學年度,第" + comboBoxEx2.Text + "學期," + txtNameListName.Text + "名冊";

            prlp.SaveLog("教務.名冊", "新增", desc);
        }
Esempio n. 2
0
        private void btnSave1_Click(object sender, EventArgs e)
        {
            if (chkSaveYes.Checked == true)
            {
                List <JHSchool.Data.JHCourseRecord> courseRecs = new List <JHSchool.Data.JHCourseRecord>();
                foreach (DAL.AttendCourseEntity ace in studAttendCourseEntitys)
                {
                    if (ace.CousreAttendType == DAL.AttendCourseEntity.AttendType.學生未修)
                    {
                        courseRecs.Add(ace.CourseRec);
                    }
                }
                // 待加入儲存
                if (courseRecs.Count > 0)
                {
                    DAL.DALTransfer2.SetStudentAttendCourse(studRec.ID, courseRecs);

                    string CourseName = "";

                    foreach (JHCourseRecord cor in courseRecs)
                    {
                        CourseName += cor.Name + ",";
                    }

                    // log
                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學籍.學生轉入異動", "新增學生課程", "新增學生" + studRec.Name + "的課程,課程名稱:" + CourseName);
                }
            }
            this.Close();
        }
Esempio n. 3
0
 void _WriteDataWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
     prlp.SaveLog("學籍.批次畢業異動", "批次新增畢業異動", "批次新增" + StudUpdateRecsList.Count + "筆資料.");
     MsgBox.Show("新增批次畢業異動完成.");
     btnAddData.Enabled = true;
     this.Close();
 }
        private void btnNext_Click(object sender, EventArgs e)
        {
            // log
            JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
            prlp.SaveLog("學生.轉入異動", "新增學期成績與領域資料", "新增學期成績與領域資料,姓名:" + studRec.Name + ",學號:" + studRec.StudentNumber);

            this.Close();
        }
Esempio n. 5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string id         = "";
            string batchName  = "";
            string schoolYear = "";
            string semester   = "";

            if (itmPanelLeft.SelectedItems.Count < 1)
            {
                return;
            }
            //if (lstList.FocusedItem == null)
            //    return;
            foreach (ButtonItem item in itmPanelLeft.SelectedItems)
            {
                if (item.Checked == true)
                {
                    id = item.Tag.ToString();
                }
            }


            if (id != "")
            {
                DSResponse dsrsp = QueryStudent.GetUpdateRecordBatch(id);

                DSXmlHelper helper = dsrsp.GetContent();

                //填上名冊的 學年、學期、名稱
                foreach (XmlNode node in helper.GetElements("UpdateRecordBatch"))
                {
                    schoolYear = node.SelectSingleNode("SchoolYear").InnerText;
                    semester   = node.SelectSingleNode("Semester").InnerText;
                    batchName  = node.SelectSingleNode("Name").InnerText;
                }

                if (MsgBox.Show("您確定刪除該名冊及其內容?", "確定", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    UpdateRecordBatch.DeleteBatch(id);

                    // log,2018/3/1 穎驊新增,因應高雄 [10-03][01] 整個學年度核准過的文號的異動名冊全部不見了 項目
                    // 本異動名冊 原只有新增會有系統紀錄,現在調整刪除、登打文號都會有紀錄
                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    string desc = "刪除" + schoolYear + "學年度,第" + semester + "學期," + batchName + "名冊";
                    prlp.SaveLog("教務.名冊", "刪除", desc);
                    Initialize();
                    LoadBatchList();
                }
            }
        }
Esempio n. 6
0
        // 儲存 log
        private void SaveLog()
        {
            foreach (DAL.ExamScoreEntity ese in ExamScoreEntityList)
            {
                string Key = ese.ExamName + "_" + ese.CourseName + "_";
                if (_ScoreType == JHPermrec.UpdateRecord.DAL.DALTransfer2.ScoreType.HsinChu)
                {
                    if (ese.HC_JHSCETakeRecord != null)
                    {
                        if (ese.HC_JHSCETakeRecord.Score.HasValue)
                        {
                            prlp.SetAfterSaveText(Key + "定期分數", ese.HC_JHSCETakeRecord.Score.Value + "");
                        }

                        if (ese.HC_JHSCETakeRecord.AssignmentScore.HasValue)
                        {
                            prlp.SetAfterSaveText(Key + "平時分數", ese.HC_JHSCETakeRecord.AssignmentScore.Value + "");
                        }

                        prlp.SetAfterSaveText(Key + "文字描述", ese.HC_JHSCETakeRecord.Text);
                    }
                }

                if (_ScoreType == JHPermrec.UpdateRecord.DAL.DALTransfer2.ScoreType.KaoHsiung)
                {
                    if (ese.KH_JHSCETakeRecord != null)
                    {
                        if (ese.KH_JHSCETakeRecord.Score.HasValue)
                        {
                            prlp.SetAfterSaveText(Key + "分數評量", ese.KH_JHSCETakeRecord.Score.Value + "");
                        }

                        if (ese.KH_JHSCETakeRecord.Effort.HasValue)
                        {
                            prlp.SetAfterSaveText(Key + "努力程度", ese.KH_JHSCETakeRecord.Effort.Value + "");
                        }

                        prlp.SetAfterSaveText(Key + "文字描述", ese.KH_JHSCETakeRecord.Text);
                    }
                }
            }
            prlp.SetActionBy("學籍", "學生學期課程成績輸入");
            prlp.SetAction("修改學生學期課程成績," + lblStudMsg.Text);
            prlp.SaveLog("", "", "student", studRec.ID);
        }
Esempio n. 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ParentRec != null)
            {
                JHSchool.Data.JHParent.Update(ParentRec);
            }

            if (AddressRec != null)
            {
                JHSchool.Data.JHAddress.Update(AddressRec);
            }

            // log
            JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
            prlp.SaveLog("學生.轉入異動", "新增", "新增地址與父母監護人資料..");

            this.Close();
        }
Esempio n. 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (chkSaveYes.Checked == true)
            {
                List <JHSchool.Data.JHCourseRecord> courseRecs = new List <JHSchool.Data.JHCourseRecord>();
                foreach (DAL.AttendCourseEntity ace in studAttendCourseEntitys)
                {
                    if (ace.CousreAttendType == DAL.AttendCourseEntity.AttendType.學生未修)
                    {
                        courseRecs.Add(ace.CourseRec);
                    }
                }
                // 待加入儲存
                if (courseRecs.Count > 0)
                {
                    DAL.DALTransfer2.SetStudentAttendCourse(studRec.ID, courseRecs);

                    string CourseName = "";

                    foreach (JHCourseRecord cor in courseRecs)
                    {
                        CourseName += cor.Name + ",";
                    }

                    // log
                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學籍.學生轉入異動", "新增學生課程", "新增學生" + studRec.Name + "的課程,課程名稱:" + CourseName);
                }
            }

            // 學生課程成績輸入
            AddTransStudCourseScore ATSCS = new AddTransStudCourseScore(studRec);

            this.Visible        = false;
            ATSCS.StartPosition = FormStartPosition.CenterParent;
            ATSCS.ShowDialog();
        }
Esempio n. 9
0
        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;
            }
        }
Esempio n. 10
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 學生
            Dictionary <string, JHStudentRecord> students = new Dictionary <string, JHStudentRecord>();

            // 畢業資訊
            Dictionary <string, JHLeaveInfoRecord> StudJHLeaveInfoRecordDic = new Dictionary <string, JHLeaveInfoRecord>();


            // 可匯入項目
            List <string> ImportItemList = new List <string>();

            ImportItemList.Add("畢業學年度");
            ImportItemList.Add("畢業資格");
            ImportItemList.Add("畢業證書字號");
            ImportItemList.Add("畢業相關訊息");

            // 取得可加入學生 TagName
            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange(ImportItemList);
            wizard.RequiredFields.AddRange();
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                // 取得學生資料
                students = JHStudent.SelectByIDs(e.List).ToDictionary(x => x.ID);
                // 取得畢業資訊
                StudJHLeaveInfoRecordDic = JHLeaveIfno.SelectByStudentIDs(e.List).ToDictionary(x => x.RefStudentID);
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int i = 0;

                // 檢查學生是否存在
                JHStudentRecord studRec = null;
                if (students.ContainsKey(e.Data.ID))
                {
                    studRec = students[e.Data.ID];
                }
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }
            };

            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                    {
                        id_Rows.Add(data.ID, new List <RowData>());
                    }
                    id_Rows[data.ID].Add(data);
                }

                List <JHLeaveInfoRecord> UpdateList = new List <JHLeaveInfoRecord>();

                foreach (string id in id_Rows.Keys)
                {
                    if (StudJHLeaveInfoRecordDic.ContainsKey(id))
                    {
                        foreach (RowData data in id_Rows[id])
                        {
                            foreach (string field in e.ImportFields)
                            {
                                if (field == "畢業學年度")
                                {
                                    int SchoolYear;
                                    if (int.TryParse(data[field], out SchoolYear))
                                    {
                                        StudJHLeaveInfoRecordDic[id].SchoolYear = SchoolYear;
                                    }
                                    else
                                    {
                                        StudJHLeaveInfoRecordDic[id].SchoolYear = null;
                                    }
                                }

                                if (field == "畢業資格")
                                {
                                    StudJHLeaveInfoRecordDic[id].Reason = data[field];
                                }

                                if (field == "畢業證書字號")
                                {
                                    StudJHLeaveInfoRecordDic[id].DiplomaNumber = data[field];
                                }

                                if (field == "畢業相關訊息")
                                {
                                    StudJHLeaveInfoRecordDic[id].Memo = data[field];
                                }
                            }
                        }
                    }
                }

                UpdateList = StudJHLeaveInfoRecordDic.Values.ToList();

                try
                {
                    if (UpdateList.Count > 0)
                    {
                        Update(UpdateList);
                    }

                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學生.匯入畢業資訊", "匯入學生畢業資訊", "匯入學生畢業資訊:共更新:" + UpdateList.Count + "筆資料");
                    JHSchool.Student.Instance.SyncAllBackground();
                    JHSchool.StudentTag.Instance.SyncAllBackground();
                    JHSchool.Data.JHStudent.RemoveAll();
                    JHSchool.Data.JHStudent.SelectAll();
                }
                catch (Exception ex) { }
            };
        }
Esempio n. 11
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            Dictionary <string, JHStudentRecord>            students      = new Dictionary <string, JHStudentRecord>();
            Dictionary <string, List <JHStudentTagRecord> > StudTagRecDic = new Dictionary <string, List <JHStudentTagRecord> > ();

            Dictionary <string, Dictionary <string, string> > StudTagNameDic = DAL.DALTransfer.GetStudentTagNameDic();

            // 取得可加入學生 TagName
            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange(ImportItemList);
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                // 取得學生資料
                foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(e.List))
                {
                    if (!students.ContainsKey(studRec.ID))
                    {
                        students.Add(studRec.ID, studRec);
                        StudTagRecDic.Add(studRec.ID, new List <JHStudentTagRecord>());
                    }
                }



                // 取得學生類別
                foreach (JHStudentTagRecord studTag in JHStudentTag.SelectByStudentIDs(students.Keys))
                {
                    //if (!StudTagRecDic.ContainsKey(studTag.RefStudentID))
                    //{
                    //    List<JHStudentTagRecord> rec = new List<JHStudentTagRecord> ();
                    //    rec.Add(studTag );
                    //    StudTagRecDic.Add(studTag.RefStudentID,rec);
                    //}
                    //else
                    if (StudTagRecDic.ContainsKey(studTag.RefStudentID))
                    {
                        StudTagRecDic[studTag.RefStudentID].Add(studTag);
                    }
                }
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int i = 0;

                // 檢查學生是否存在
                JHStudentRecord studRec = null;
                if (students.ContainsKey(e.Data.ID))
                {
                    studRec = students[e.Data.ID];
                }
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }

                // 驗證資料
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();

                    // 驗證$無法匯入
                    if (value.IndexOf('$') > -1)
                    {
                        e.ErrorFields.Add(field, "儲存格有$無法匯入.");
                        break;
                    }


                    if (field == "類別名稱")
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            e.ErrorFields.Add(field, "不允許空白");
                        }
                    }
                }
            };

            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                // 目前學生類別管理,沒有新增標示類別,有的就不更動跳過。

                Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                    {
                        id_Rows.Add(data.ID, new List <RowData>());
                    }
                    id_Rows[data.ID].Add(data);
                }

                List <JHStudentTagRecord> InsertList = new List <JHStudentTagRecord>();
//                List<JHStudentTagRecord> UpdateList = new List<JHStudentTagRecord>();

                // 放需要新增的學生類別
                Dictionary <string, List <string> > NeedAddPrefixName = new Dictionary <string, List <string> >();

                // 檢查用 List
                List <string> CheckStudTagName = new List <string>();

                foreach (KeyValuePair <string, Dictionary <string, string> > data in StudTagNameDic)
                {
                    foreach (KeyValuePair <string, string> data1 in data.Value)
                    {
                        CheckStudTagName.Add(data.Key + data1.Key);
                    }
                }

                // 檢查類別是否已經存在
                foreach (string id in id_Rows.Keys)
                {
                    if (!StudTagRecDic.ContainsKey(id))
                    {
                        continue;
                    }
                    foreach (RowData data in id_Rows[id])
                    {
                        string strPrefix = string.Empty, strName = string.Empty;

                        if (data.ContainsKey("群組"))
                        {
                            strPrefix = data["群組"];
                        }

                        if (data.ContainsKey("類別名稱"))
                        {
                            strName = data["類別名稱"];
                        }

                        string FullName = strPrefix + strName;

                        // 需要新增的,
                        if (!CheckStudTagName.Contains(FullName))
                        {
                            CheckStudTagName.Add(FullName);
                            if ((NeedAddPrefixName.ContainsKey(strPrefix)))
                            {
                                NeedAddPrefixName[strPrefix].Add(strName);
                            }
                            else
                            {
                                List <string> Names = new List <string>();
                                Names.Add(strName);
                                NeedAddPrefixName.Add(strPrefix, Names);
                            }
                        }
                    }
                }

                // 新增至學生類別管理
                List <JHTagConfigRecord> Recs = new List <JHTagConfigRecord>();
                foreach (KeyValuePair <string, List <string> > data in NeedAddPrefixName)
                {
                    foreach (string data1 in data.Value)
                    {
                        JHTagConfigRecord rec = new JHTagConfigRecord();
                        rec.Category = "Student";
                        rec.Prefix   = data.Key;
                        rec.Name     = data1;
                        rec.Color    = System.Drawing.Color.White;
                        Recs.Add(rec);
                    }
                }
                JHTagConfig.Insert(Recs);

                StudTagNameDic.Clear();

                // 重新取得
                StudTagNameDic = DAL.DALTransfer.GetStudentTagNameDic();

                foreach (string id in id_Rows.Keys)
                {
                    if (!StudTagRecDic.ContainsKey(id))
                    {
                        continue;
                    }
                    foreach (RowData data in id_Rows[id])
                    {
                        string strPrefix = string.Empty, strName = string.Empty;

                        if (data.ContainsKey("群組"))
                        {
                            strPrefix = data["群組"];
                        }

                        if (data.ContainsKey("類別名稱"))
                        {
                            strName = data["類別名稱"];
                        }


                        // 欄位有在 Tag Prefix 內
                        bool isInsert = true;

                        foreach (JHStudentTagRecord rec in StudTagRecDic[id])
                        {
                            if (rec.Prefix == strPrefix && rec.Name == strName)
                            {
                                isInsert = false;
                                break;
                            }
                        }

                        if (isInsert)
                        {
                            // 學生類別管理名稱對照
                            if (StudTagNameDic.ContainsKey(strPrefix))
                            {
                                if (StudTagNameDic[strPrefix].ContainsKey(strName))
                                {
                                    JHStudentTagRecord StudTag = new JHStudentTagRecord();
                                    StudTag.RefEntityID = id;
                                    StudTag.RefTagID    = StudTagNameDic[strPrefix][strName];
                                    InsertList.Add(StudTag);
                                }
                            }
                        }
                    }
                }

                try
                {
                    if (InsertList.Count > 0)
                    {
                        Insert(InsertList);
                    }

                    //if (UpdateList.Count > 0)
                    //    Update(UpdateList);

                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學生.匯入類別", "匯入學生類別", "匯入學生類別:共新增" + InsertList.Count + "筆資料");
                    JHSchool.Student.Instance.SyncAllBackground();
                    JHSchool.StudentTag.Instance.SyncAllBackground();
                    JHSchool.Data.JHStudent.RemoveAll();
                    JHSchool.Data.JHStudent.SelectAll();
                }
                catch (Exception ex) {}
            };
        }
Esempio n. 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNewName.Text.Trim() == "")
                {
                    MsgBox.Show("姓名必填");
                    return;
                }

                if (string.IsNullOrEmpty(cbotStudentNumber.Text))
                {
                    Errors.SetError(cbotStudentNumber, "學號空白!");
                }

                string sid = string.Empty;
                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 (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);
                            }
                        }
                    }
                }

                if (chkSum.ContainsKey(cbotStudentNumber.Text))
                {
                    if (chkSum[cbotStudentNumber.Text] > 1)
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("學號重複請檢查");
                        return;
                    }
                }

                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 (cboClass.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;


                if (_status == AddTransStudStatus.Added)
                {
                }

                JHSchool.Data.JHStudent.Update(_student);
                JHSchool.Data.JHPhone.Update(_StudentPhone);


                //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();
            }
            catch (Exception ex)
            {
                FISCA.Presentation.Controls.MsgBox.Show(ex.Message);
                return;
            }
        }
Esempio n. 13
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            IUpdateRecordInfo IU;

            if (UpdateRecordEditorPanle.Controls.Count > 0)
            {
                IU = UpdateRecordEditorPanle.Controls[0] as IUpdateRecordInfo;
                _StudUpdateRecordEntity = IU.GetStudUpdateRecordData();
            }


            // 當新增時才處理
            if (cbxSel.Enabled)
            {
                if (cbxSel.Text == "新生")
                {
                    bool checkSameUpdateCode1 = DAL.DALTransfer2.checkStudentSameUpdateCode(RunningID, _StudUpdateRecordEntity, "1");

                    if (checkSameUpdateCode1)
                    {
                        MsgBox.Show("已有1筆新生異動,請刪除後再新增");
                        return;
                    }
                }

                if (cbxSel.Text == "畢業")
                {
                    bool checkSameUpdateCode2 = DAL.DALTransfer2.checkStudentSameUpdateCode(RunningID, _StudUpdateRecordEntity, "2");

                    if (checkSameUpdateCode2)
                    {
                        MsgBox.Show("已有1筆畢業異動,請刪除後再新增");
                        return;
                    }
                }

                // 檢查同一天是否有相同異動
                bool checkSameUpdateDateAndCode = false;
                checkSameUpdateDateAndCode = DAL.DALTransfer2.checkStudentSameUpdateCode(RunningID, _StudUpdateRecordEntity);

                if (checkSameUpdateDateAndCode)
                {
                    if (MsgBox.Show("此異動日期已有相同異動,請問是否新增?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }
                }
            }


            // 儲存學年度學期 年級
            _StudUpdateRecordEntity.SchoolYear = intSchoolYear.Value;
            _StudUpdateRecordEntity.Semester   = intSemester.Value;
            _StudUpdateRecordEntity.SetGradeYear(intGradeYear.Text);

            // 儲存異動資料
            DAL.DALTransfer2.SetStudUpdateRecordEntity(_StudUpdateRecordEntity);


            // Log
            string strItemName = "學生姓名:" + JHSchool.Data.JHStudent.SelectByID(RunningID).Name + "," + prlp.GetAction() + ":";

            if (_StudUpdateRecordEntity.checkSameUpdateCode("1"))
            {
                strItemName += "新生異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("2"))
            {
                strItemName += "畢業異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("3"))
            {
                strItemName += "轉入異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("4"))
            {
                strItemName += "轉出異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("5"))
            {
                strItemName += "休學異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("6"))
            {
                strItemName += "復學異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("7"))
            {
                strItemName += "中輟異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("8"))
            {
                strItemName += "續讀異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("9"))
            {
                strItemName += "更正學籍異動";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("10"))
            {
                strItemName += "延長修業年限";
            }
            if (_StudUpdateRecordEntity.checkSameUpdateCode("11"))
            {
                strItemName += "死亡";
            }

            prlp.SetActionBy("學生", strItemName);
            prlp.SaveLog("", ":", "student", RunningID);

            JHSchool.Data.JHStudentRecord studRec = JHSchool.Data.JHStudent.SelectByID(RunningID);
            bool checkUpdateStudStatus            = false;

            List <string> tmpList0 = new List <string>();
            List <string> tmpList1 = new List <string>();
            List <string> tmpList2 = new List <string>();
            List <string> tmpList3 = new List <string>();

            foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectAll())
            {
                if (stud.Status == K12.Data.StudentRecord.StudentStatus.一般)
                {
                    tmpList0.Add(stud.IDNumber);
                }

                if (stud.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校)
                {
                    tmpList1.Add(stud.IDNumber);
                }
                if (stud.Status == K12.Data.StudentRecord.StudentStatus.休學)
                {
                    tmpList2.Add(stud.IDNumber);
                }
                if (stud.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    tmpList3.Add(stud.IDNumber);
                }
            }

            // 轉出
            if (_StudUpdateRecordEntity.checkSameUpdateCode("4") || _StudUpdateRecordEntity.checkSameUpdateCode("11"))
            {
                if (MessageBox.Show("請問是否更改學生狀態成 離校?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (tmpList1.Contains(studRec.IDNumber))
                    {
                        MsgBox.Show("學生狀態 離校 有重複身分證號,請檢查後變更.");
                        return;
                    }
                    studRec.Status        = JHSchool.Data.JHStudentRecord.StudentStatus.畢業或離校;
                    checkUpdateStudStatus = true;
                    strItemName          += ",更改學生狀態成 離校";
                }
            }

            // 休學
            if (_StudUpdateRecordEntity.checkSameUpdateCode("5"))
            {
                if (MessageBox.Show("請問是否更改學生狀態成 休學?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (tmpList2.Contains(studRec.IDNumber))
                    {
                        MsgBox.Show("學生狀態 休學 有重複身分證號,請檢查後變更.");
                        return;
                    }

                    studRec.Status        = JHSchool.Data.JHStudentRecord.StudentStatus.休學;
                    checkUpdateStudStatus = true;
                    strItemName          += "更改學生狀態成 休學";
                }
            }

            // 中輟

            if (_StudUpdateRecordEntity.checkSameUpdateCode("7"))
            {
                if (MessageBox.Show("請問是否更改學生狀態成 輟學?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (tmpList3.Contains(studRec.IDNumber))
                    {
                        MsgBox.Show("學生狀態 輟學 有重複身分證號,請檢查後變更.");
                        return;
                    }

                    studRec.Status        = JHSchool.Data.JHStudentRecord.StudentStatus.輟學;
                    checkUpdateStudStatus = true;
                    strItemName          += "更改學生狀態成 輟學";
                }
            }


            // 處理復學轉成一般
            if (_StudUpdateRecordEntity.checkSameUpdateCode("6"))
            {
                if (MessageBox.Show("請問是否更改學生狀態成 一般?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (tmpList0.Contains(studRec.IDNumber))
                    {
                        MsgBox.Show("學生狀態 一般 有重複身分證號,請檢查後變更.");
                        return;
                    }

                    studRec.Status        = JHSchool.Data.JHStudentRecord.StudentStatus.一般;
                    checkUpdateStudStatus = true;
                    strItemName          += "更改學生狀態成 一般";
                }
            }



            //  prlp.SaveLog("學生.異動資料", prlp.GetAction(),"學生",RunningID , strItemName);

            if (checkUpdateStudStatus)
            {
                JHSchool.Data.JHStudent.Update(studRec);
                JHSchool.Student.Instance.SyncDataBackground(RunningID);
            }
            JHSchool.Permrec.UpdateRecord.Instance.SyncAllBackground();
            JHSchool.Student.Instance.SyncDataBackground(RunningID);

            prlp = null;
        }
Esempio n. 14
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            // 驗證身份證號
            if (!string.IsNullOrEmpty(txtNewIDNumber.Text))
            {
                if (StudCheckTool.CheckStudIDNumberSame(txtNewIDNumber.Text, _StudentID))
                {
                    FISCA.Presentation.Controls.MsgBox.Show("身分證號重覆請檢查.");
                    return;
                }
            }
            // 呼叫異動並帶入相對資料
            DAL.StudUpdateRecordEntity sure = DAL.DALTransfer2.AddStudUpdateRecordEntity(_StudentID, JHPermrec.UpdateRecord.DAL.DALTransfer2.UpdateType.更正學籍, DateTime.Now.ToShortDateString());

            if (isNameEnable)
            {
                sure.SetNewName(txtNewName.Text);
            }

            if (isIDNumberEnable)
            {
                sure.SetNewIDNumber(txtNewIDNumber.Text);
            }

            if (isBirthdayEnable)
            {
                sure.SetNewBirthday(dtNewBirthday.Text);
            }

            if (isGenderEnable)
            {
                sure.SetNewGender(cboNewGender.Text);
            }


            if (sure == null)
            {
                return;
            }


            UpdateRecordItemForm form = new UpdateRecordItemForm(UpdateRecordItemForm.actMode.修改, sure, _StudentID);

            form.StartPosition = FormStartPosition.CenterParent;
            this.Hide();
            this.Close();
            this.Location = new Point(-100, -100);
            form.ShowDialog(FISCA.Presentation.MotherForm.Form);


            // 當使用這按確定
            if (form.DialogResult == DialogResult.OK)
            {
                // Log
                JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                prlp.SetBeforeSaveText("姓名", sure.GetName());
                prlp.SetBeforeSaveText("身分證號", sure.GetIDNumber());

                if (sure.GetBirthday().HasValue)
                {
                    prlp.SetBeforeSaveText("生日", sure.GetBirthday().Value.ToShortDateString());
                }

                prlp.SetBeforeSaveText("性別", sure.GetGender());

                JHSchool.Data.JHStudentRecord studRec = JHSchool.Data.JHStudent.SelectByID(_StudentID);

                // 更正資料
                if (isNameEnable && string.IsNullOrEmpty(sure.GetNewName()) == false)
                {
                    studRec.Name = sure.GetNewName();
                }

                if (isIDNumberEnable && string.IsNullOrEmpty(sure.GetNewIDNumber()) == false)
                {
                    studRec.IDNumber = sure.GetNewIDNumber();
                }

                if (isBirthdayEnable && sure.GetNewBirthday().HasValue)
                {
                    studRec.Birthday = sure.GetNewBirthday();
                }

                if (isGenderEnable && string.IsNullOrEmpty(sure.GetNewGender()) == false)
                {
                    studRec.Gender = sure.GetNewGender();
                }

                if (isNameEnable == true || isIDNumberEnable == true || isBirthdayEnable == true || isGenderEnable == true)
                {
                    JHSchool.Data.JHStudent.Update(studRec);
                    JHSchool.Student.Instance.SyncAllBackground();
                }
                prlp.SetAfterSaveText("姓名", studRec.Name);
                prlp.SetAfterSaveText("身分證號", studRec.IDNumber);
                if (studRec.Birthday.HasValue)
                {
                    prlp.SetAfterSaveText("生日", studRec.Birthday.Value.ToShortDateString());
                }

                prlp.SetAfterSaveText("性別", studRec.Gender);

                prlp.SetActionBy("學生學籍", "學生更正學籍功能");
                prlp.SetDescTitle("學生姓名:" + sure.GetName() + ",更改資料:");
                prlp.SaveLog("", "", "student", _StudentID);
                this.Close();
            }
            //else
            //form.Dispose();
        }
Esempio n. 15
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 取得學生資料
            Dictionary <string, JHStudentRecord> Students = new Dictionary <string, JHStudentRecord>();

            // 取得異動資料
            Dictionary <string, List <JHUpdateRecordRecord> > UpdateRecs = new Dictionary <string, List <JHUpdateRecordRecord> >();

            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange("學年度", "學期", "異動學號", "異動姓名", "異動生日", "異動身分證號", "異動性別", "異動類別", "異動日期", "原因及事項", "轉入前學校", "轉出後學校", "學籍核准日期", "學籍核准文號", "核准日期", "核准文號", "備註", "新生日", "新身分證號", "新姓名", "新性別", "出生地", "異動年級", "異動地址", "異動班級", "異動座號");
            wizard.RequiredFields.AddRange("異動類別", "異動日期", "學年度", "學期");
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                Students.Clear();
                UpdateRecs.Clear();

                // 取得學生資料
                foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(e.List))
                {
                    if (!Students.ContainsKey(studRec.ID))
                    {
                        Students.Add(studRec.ID, studRec);
                    }
                }
                foreach (string str in Students.Keys)
                {
                    List <JHUpdateRecordRecord> UpdRecList = new List <JHUpdateRecordRecord>();
                    UpdateRecs.Add(str, UpdRecList);
                }


                // 取得異動
                MultiThreadWorker <string> loader1 = new MultiThreadWorker <string>();
                loader1.MaxThreads     = 3;
                loader1.PackageSize    = 250;
                loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs <string> e1)
                {
                    foreach (JHUpdateRecordRecord UpdRec in JHUpdateRecord.SelectByStudentIDs(e.List))
                    {
                        // 非新生或畢業濾除
                        if (UpdRec.UpdateCode == "1" || UpdRec.UpdateCode == "2")
                        {
                            continue;
                        }

                        if (UpdateRecs.ContainsKey(UpdRec.StudentID))
                        {
                            UpdateRecs[UpdRec.StudentID].Add(UpdRec);
                        }
                    }
                };
                loader1.Run(e.List);
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int      i = 0;
                DateTime dt;
                // 檢查學生是否存在
                JHStudentRecord studRec = null;
                if (Students.ContainsKey(e.Data.ID))
                {
                    studRec = Students[e.Data.ID];
                }
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }

                // 驗證格式資料
                bool InputFormatPass = true;
                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();
                    //// 驗證$無法匯入
                    //if (value.IndexOf('$') > -1)
                    //{
                    //    e.ErrorFields.Add(field, "儲存格有$無法匯入.");
                    //    break;
                    //}
                    switch (field)
                    {
                    default:
                        break;

                    case "異動類別":
                        // 對應不到時
                        if (DAL.DALTransfer2.GetUpdateRecCodeByString39(value) == "")
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入正確異動類別");
                        }
                        break;

                    case "學年度":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數");
                        }

                        break;

                    case "學期":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數");
                        }

                        if (i > 2)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數,1或2");
                        }

                        break;

                    case "異動年級":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.WarningFields.Add(field, "請填入整數");
                        }
                        break;

                    case "異動座號":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            e.WarningFields.Add(field, "請填入整數");
                        }
                        break;

                    case "異動日期":
                        if (string.IsNullOrEmpty(value) || DateTime.TryParse(value, out dt) == false)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                        }
                        break;

                    case "異動生日":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "學籍核准日期":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;


                    case "核准日期":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "異動新生日":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "異動新性別":
                        if (value == "男" || value == "女" || value == "")
                        {
                        }
                        else
                        {
                            e.WarningFields.Add(field, "請填入男或女");
                        }
                        break;

                    case "異動性別":
                        if (value == "男" || value == "女" || value == "")
                        {
                        }
                        else
                        {
                            e.WarningFields.Add(field, "請填入男或女");
                        }
                        break;

                    case "新生日":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "新性別":
                        if (value == "男" || value == "女" || value == "")
                        {
                        }
                        else
                        {
                            e.WarningFields.Add(field, "請填入男或女");
                        }
                        break;
                    }
                }
            };


            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                    {
                        id_Rows.Add(data.ID, new List <RowData>());
                    }
                    id_Rows[data.ID].Add(data);
                }

                List <JHUpdateRecordRecord> InsertList = new List <JHUpdateRecordRecord>();
                List <JHUpdateRecordRecord> UpdateList = new List <JHUpdateRecordRecord>();


                foreach (string id in id_Rows.Keys)
                {
                    int      schoolYear, Semester;
                    string   GrYear = "";
                    DateTime dt;

                    foreach (RowData data in id_Rows[id])
                    {
                        if (!UpdateRecs.ContainsKey(id))
                        {
                            continue;
                        }
                        int.TryParse(data["學年度"], out schoolYear);
                        int.TryParse(data["學期"], out Semester);
                        DateTime.TryParse(data["異動日期"], out dt);
                        if (data.ContainsKey("異動年級"))
                        {
                            GrYear = data["異動年級"];
                        }

                        // 異動類別
                        string UpdateType = string.Empty;
                        if (data.ContainsKey("異動類別"))
                        {
                            UpdateType = data["異動類別"];
                        }

                        // 取得原因及事項
                        string UpdateDesc = string.Empty;
                        if (data.ContainsKey("原因及事項"))
                        {
                            UpdateDesc = data["原因及事項"];
                        }

                        //// 檢查更正學籍
                        //string checkUpdateCode09Str=string.Empty;

                        //if (data.ContainsKey("新生日"))
                        //    checkUpdateCode09Str += data["新生日"].Trim();
                        //if (data.ContainsKey("新身分證號"))
                        //    checkUpdateCode09Str += data["新身分證號"].Trim();
                        //if (data.ContainsKey("新姓名"))
                        //    checkUpdateCode09Str += data["新姓名"].Trim();
                        //if (data.ContainsKey("新性別"))
                        //    checkUpdateCode09Str += data["新性別"].Trim();


                        JHUpdateRecordRecord updateRec = null;
                        // 判斷學年度+學期+異動日期+異動類別 (如果相同有當更新,不同就新增)
                        foreach (JHUpdateRecordRecord urr in UpdateRecs[id])
                        {
                            string UpdateStr = DAL.DALTransfer2.GetUpdateRecCodeString(urr.UpdateCode);
                            if (urr.SchoolYear == schoolYear && urr.Semester == Semester && UpdateType == UpdateStr)
                            {
                                DateTime dt1;
                                DateTime.TryParse(urr.UpdateDate, out dt1);
                                if (dt == dt1)
                                {
                                    // 使用原因及事項當作Key
                                    if (UpdateDesc == urr.UpdateDescription)
                                    {
                                        updateRec = urr;
                                    }

                                    ////判斷當異動類別是更正學籍,加入(新生日、新身分證號、新姓名、新性別)判斷,四項內容只要有一個不同就當作新的一筆可匯入。
                                    //if (urr.UpdateCode == "9")
                                    //{
                                    //    string strKey = urr.NewBirthday.Trim() + urr.NewIDNumber.Trim() + urr.NewName.Trim() + urr.NewGender.Trim ();
                                    //    if (checkUpdateCode09Str == strKey)
                                    //        updateRec = urr;
                                    //}
                                    //else
                                    //    updateRec = urr;
                                }
                            }
                        }
                        bool isInsert = true;

                        if (updateRec == null)
                        {
                            updateRec           = new JHUpdateRecordRecord();
                            updateRec.StudentID = id;
                        }
                        else
                        {
                            isInsert = false;
                        }

                        bool checkData = false;

                        string Ur03School = "", Ur04School = "";

                        foreach (string field in e.ImportFields)
                        {
                            string value = data[field].Trim();
                            switch (field)
                            {
                            case "異動類別":
                                string UrCode = DAL.DALTransfer2.GetUpdateRecCodeByString39(value);
                                if (UrCode != "")
                                {
                                    updateRec.UpdateCode = UrCode;
                                }

                                break;

                            case "學年度":
                                int scYear;
                                if (int.TryParse(value, out scYear))
                                {
                                    updateRec.SchoolYear = scYear;
                                    checkData            = true;
                                }
                                break;

                            case "學期":
                                int Sems;
                                if (int.TryParse(value, out Sems))
                                {
                                    updateRec.Semester = Sems;
                                    checkData          = true;
                                }
                                break;

                            case "異動年級":
                                updateRec.GradeYear = GrYear;
                                break;

                            case "異動日期":
                                DateTime dtd;
                                if (DateTime.TryParse(value, out dtd))
                                {
                                    updateRec.UpdateDate = dtd.ToShortDateString();
                                }
                                break;

                            case "備註":
                                updateRec.Comment = value;
                                break;

                            case "學籍核准日期":
                                DateTime dtLD;
                                if (DateTime.TryParse(value, out dtLD))
                                {
                                    updateRec.LastADDate = dtLD.ToShortDateString();
                                }
                                break;

                            case "學籍核准文號":
                                updateRec.LastADNumber = value;
                                break;

                            case "異動班級":
                                updateRec.OriginClassName = value;
                                break;

                            case "異動姓名":
                                updateRec.StudentName = value;
                                break;

                            case "異動身分證號":
                                updateRec.IDNumber = value;
                                break;


                            case "異動學號":
                                updateRec.StudentNumber = value;
                                break;

                            case "異動性別":
                                if (value == "男" || value == "女" || value == "")
                                {
                                    updateRec.Gender = value;
                                }
                                break;

                            case "異動生日":
                                DateTime dtb;
                                if (DateTime.TryParse(value, out dtb))
                                {
                                    updateRec.Birthdate = dtb.ToShortDateString();
                                }
                                break;

                            case "異動座號":
                                int no;
                                if (int.TryParse(value, out no))
                                {
                                    updateRec.SeatNo = no + "";
                                }
                                break;

                            case "核准日期":
                                DateTime dtAd;
                                if (DateTime.TryParse(value, out dtAd))
                                {
                                    updateRec.ADDate = dtAd.ToShortDateString();
                                }
                                break;

                            case "核准文號":
                                updateRec.ADNumber = value;
                                break;

                            case "異動新生日":
                                DateTime dtNB;
                                if (DateTime.TryParse(value, out dtNB))
                                {
                                    updateRec.NewBirthday = dtNB.ToShortDateString();
                                }
                                break;

                            case "異動新身分證號":
                                updateRec.NewIDNumber = value;
                                break;

                            case "異動新姓名":
                                updateRec.NewName = value;
                                break;

                            case "異動新性別":
                                if (value == "男" || value == "女" || value == "")
                                {
                                    updateRec.NewGender = value;
                                }
                                break;

                            case "新生日":
                                DateTime dtNB1;
                                if (DateTime.TryParse(value, out dtNB1))
                                {
                                    updateRec.NewBirthday = dtNB1.ToShortDateString();
                                }
                                break;

                            case "新身分證號":
                                updateRec.NewIDNumber = value;
                                break;

                            case "新姓名":
                                updateRec.NewName = value;
                                break;

                            case "新性別":
                                if (value == "男" || value == "女" || value == "")
                                {
                                    updateRec.NewGender = value;
                                }
                                break;

                            case "出生地":
                                updateRec.BirthPlace = value;
                                break;

                            case "原因及事項":
                                updateRec.UpdateDescription = value;
                                break;

                            case "異動地址":
                                updateRec.OriginAddress = value;
                                break;

                            case "轉入前學校":
                                Ur03School = value;
                                break;

                            case "轉出後學校":
                                Ur04School = value;
                                break;
                            }
                        }

                        // 轉換轉出入學校
                        if (updateRec.UpdateCode == "3")
                        {
                            updateRec.ImportExportSchool = Ur03School;
                        }

                        if (updateRec.UpdateCode == "4")
                        {
                            updateRec.ImportExportSchool = Ur04School;
                        }

                        if (string.IsNullOrEmpty(updateRec.StudentID) || string.IsNullOrEmpty(updateRec.UpdateDate) || string.IsNullOrEmpty(updateRec.UpdateCode))
                        {
                            continue;
                        }
                        else
                        {
                            if (isInsert)
                            {
                                InsertList.Add(updateRec);
                            }
                            else
                            {
                                UpdateList.Add(updateRec);
                            }
                        }
                    }
                }

                try
                {
                    if (InsertList.Count > 0)
                    {
                        Insert(InsertList);
                    }

                    if (UpdateList.Count > 0)
                    {
                        Update(UpdateList);
                    }

                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學生.匯入異動", "匯入學籍異動", "匯入學籍異動:共新增" + InsertList.Count + "筆資料,共更新:" + UpdateList.Count + "筆資料");
                    JHSchool.Student.Instance.SyncAllBackground();
                }
                catch (Exception ex) { }
            };
        }
Esempio n. 16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SemesterHistoryRecord.SemesterHistoryItems.Clear();

            List <string> checkData = new List <string>();

            foreach (DataGridViewRow dr in dgSemestrHistory.Rows)
            {
                if (dr.IsNewRow)
                {
                    continue;
                }

                if (dr.Cells["學年度"].Value == null || dr.Cells["學期"].Value == null || dr.Cells["年級"].Value == null)
                {
                    MessageBox.Show("資料輸入不完整");
                    return;
                }

                string str = "" + dr.Cells["學年度"].Value + dr.Cells["學期"].Value + dr.Cells["年級"].Value;
                if (checkData.Contains(str))
                {
                    MessageBox.Show("學年度+學期+年級有重複");
                    return;
                }
                else
                {
                    checkData.Add(str);
                }
            }


            foreach (DataGridViewRow dr in dgSemestrHistory.Rows)
            {
                if (dr.IsNewRow)
                {
                    continue;
                }

                int tmpInt;
                K12.Data.SemesterHistoryItem sshe = new K12.Data.SemesterHistoryItem();
                tmpInt = 0;
                int.TryParse(dr.Cells["學年度"].Value.ToString(), out tmpInt);
                sshe.SchoolYear = tmpInt;

                tmpInt = 0;
                int.TryParse(dr.Cells["學期"].Value.ToString(), out tmpInt);
                sshe.Semester = tmpInt;

                tmpInt = 0;
                int.TryParse(dr.Cells["年級"].Value.ToString(), out tmpInt);
                sshe.GradeYear = tmpInt;
                if (dr.Cells["班級"].Value != null)
                {
                    sshe.ClassName = dr.Cells["班級"].Value.ToString();
                }

                if (dr.Cells["班導師"].Value != null)
                {
                    sshe.Teacher = dr.Cells["班導師"].Value.ToString();
                }

                if (dr.Cells["座號"].Value != null)
                {
                    int seatNo;
                    if (int.TryParse(dr.Cells["座號"].Value.ToString(), out seatNo))
                    {
                        sshe.SeatNo = seatNo;
                    }
                }
                if (dr.Cells["上課天數"].Value != null)
                {
                    int DayCount;
                    if (int.TryParse(dr.Cells["上課天數"].Value.ToString(), out DayCount))
                    {
                        sshe.SchoolDayCount = DayCount;
                    }
                }

                SemesterHistoryRecord.SemesterHistoryItems.Add(sshe);
            }

            // 儲存學期歷程
            JHSchool.Data.JHSemesterHistory.Update(SemesterHistoryRecord);

            // log
            JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
            prlp.SaveLog("學生.轉入異動", "新增", "新增 學生:" + studRec.Name + " 學期歷程資料..");

            this.Close();
        }
        public override void  InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 取得學生資料
            Dictionary <string, JHStudentRecord> Students = new Dictionary <string, JHStudentRecord>();

            // 取得異動資料
            Dictionary <string, List <JHUpdateRecordRecord> > UpdateRecs = new Dictionary <string, List <JHUpdateRecordRecord> >();

            wizard.PackageLimit = 3000;
            //wizard.ImportableFields.AddRange("學年度", "學期", "異動年級", "異動日期", "入學年月", "畢業年月", "畢修業別", "備註", "學籍核准日期", "學籍核准文號", "畢業證書字號", "異動班級", "異動姓名", "異動身分證號", "異動出生地", "異動學號", "異動性別", "異動生日", "核准日期", "核准文號", "異動類別", "畢(結)業證書字號");
            //wizard.RequiredFields.AddRange("異動類別", "異動日期", "學年度", "學期");
            wizard.ImportableFields.AddRange("學年度", "學期", "異動年級", "異動日期", "入學年月", "畢業年月", "畢修業別", "備註", "學籍核准日期", "學籍核准文號", "畢業證書字號", "異動班級", "異動姓名", "異動身分證號", "異動出生地", "異動學號", "異動性別", "異動生日", "核准日期", "核准文號", "畢(結)業證書字號");
            wizard.RequiredFields.AddRange("異動日期", "學年度", "學期");

            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                Students.Clear();
                UpdateRecs.Clear();

                // 取得學生資料
                foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(e.List))
                {
                    if (!Students.ContainsKey(studRec.ID))
                    {
                        Students.Add(studRec.ID, studRec);
                    }
                }

                foreach (string str in Students.Keys)
                {
                    List <JHUpdateRecordRecord> UpdRecList = new List <JHUpdateRecordRecord>();
                    UpdateRecs.Add(str, UpdRecList);
                }


                // 取得異動
                MultiThreadWorker <string> loader1 = new MultiThreadWorker <string>();
                loader1.MaxThreads     = 3;
                loader1.PackageSize    = 250;
                loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs <string> e1)
                {
                    foreach (JHUpdateRecordRecord UpdRec in JHUpdateRecord.SelectByStudentIDs(e.List))
                    {
                        // 畢業
                        if (UpdRec.UpdateCode == "2")
                        {
                            if (UpdateRecs.ContainsKey(UpdRec.StudentID))
                            {
                                UpdateRecs[UpdRec.StudentID].Add(UpdRec);
                            }
                        }
                    }
                };
                loader1.Run(e.List);
            };

            wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e)
            {
                int      i = 0;
                DateTime dt;
                // 檢查學生是否存在
                JHStudentRecord studRec = null;
                if (Students.ContainsKey(e.Data.ID))
                {
                    studRec = Students[e.Data.ID];
                }
                else
                {
                    e.ErrorMessage = "沒有這位學生" + e.Data.ID;
                    return;
                }

                // 驗證格式資料
                bool InputFormatPass = true;
                CheckHasData = false;



                foreach (string field in e.SelectFields)
                {
                    string value = e.Data[field].Trim();

                    //// 驗證$無法匯入
                    //if (value.IndexOf('$') > -1)
                    //{
                    //    e.ErrorFields.Add(field, "儲存格有$無法匯入.");
                    //    break;
                    //}

                    // 檢查系統內是否已經有畢業異動
                    if (CheckHasData == false)
                    {
                        if (UpdateRecs.ContainsKey(e.Data.ID))
                        {
                            if (UpdateRecs[e.Data.ID].Count > 0)
                            {
                                e.WarningFields.Add(field, "系統內已有畢業異動,匯入將會取代系統內畢業異動");
                                CheckHasData = true;
                            }
                        }
                    }

                    switch (field)
                    {
                    default:
                        break;

                    //case "異動類別":
                    //    if (value != "畢業")
                    //    {
                    //        InputFormatPass &= false;
                    //        e.ErrorFields.Add(field, "必須填入畢業");
                    //    }
                    //    if (value == "畢業")
                    //    {
                    //        if (UpdateRecs.ContainsKey(e.Data.ID))
                    //            if (UpdateRecs[e.Data.ID].Count > 0)
                    //            {
                    //                e.WarningFields.Add(field, "系統內已有畢業異動,匯入將會取代系統內畢業異動");
                    //            }
                    //    }
                    //    break;

                    case "學年度":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數");
                        }

                        break;

                    case "學期":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數");
                        }

                        if (i > 2)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入整數,1或2");
                        }

                        break;

                    case "異動年級":
                        int.TryParse(value, out i);
                        if (string.IsNullOrEmpty(value) || i < 1)
                        {
                            InputFormatPass &= false;
                            e.WarningFields.Add(field, "請填入整數");
                        }
                        break;

                    case "異動日期":
                        if (string.IsNullOrEmpty(value) || DateTime.TryParse(value, out dt) == false)
                        {
                            InputFormatPass &= false;
                            e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                        }
                        break;

                    case "入學年月":
                        int.TryParse(value, out i);
                        if (!string.IsNullOrEmpty(value) && i < 1)
                        {
                            e.WarningFields.Add(field, "必須填入年月格式,例如200901");
                        }
                        break;

                    case "畢業年月":
                        int.TryParse(value, out i);
                        if (!string.IsNullOrEmpty(value) && i < 1)
                        {
                            e.WarningFields.Add(field, "必須填入年月格式,例如200901");
                        }
                        break;

                    case "異動生日":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "學籍核准日期":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "核准日期":
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (DateTime.TryParse(value, out dt) == false)
                            {
                                InputFormatPass &= false;
                                e.ErrorFields.Add(field, "必須填入日期,例如2009/1/1");
                            }
                        }
                        break;

                    case "異動性別":
                        if (value == "男" || value == "女" || value == "")
                        {
                        }
                        else
                        {
                            e.WarningFields.Add(field, "請填入男或女");
                        }
                        break;
                    }
                }
            };


            wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
            {
                Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >();
                foreach (RowData data in e.Items)
                {
                    if (!id_Rows.ContainsKey(data.ID))
                    {
                        id_Rows.Add(data.ID, new List <RowData> ());
                    }
                    id_Rows[data.ID].Add(data);
                }

                List <JHUpdateRecordRecord> InsertList = new List <JHUpdateRecordRecord>();
                List <JHUpdateRecordRecord> UpdateList = new List <JHUpdateRecordRecord>();
                List <JHUpdateRecordRecord> DelList    = new List <JHUpdateRecordRecord>();

                foreach (string id in id_Rows.Keys)
                {
                    int      schoolYear, Semester;
                    string   GrYear = "";
                    DateTime dt;

                    foreach (RowData data in id_Rows[id])
                    {
                        if (!UpdateRecs.ContainsKey(id))
                        {
                            continue;
                        }
                        int.TryParse(data["學年度"], out schoolYear);
                        int.TryParse(data["學期"], out Semester);
                        DateTime.TryParse(data["異動日期"], out dt);
                        if (data.ContainsKey("異動年級"))
                        {
                            GrYear = data["異動年級"];
                        }
                        JHUpdateRecordRecord updateRec = null;
                        foreach (JHUpdateRecordRecord urr in UpdateRecs[id])
                        {
                            if (urr.UpdateCode == "2")
                            {
                                DelList.Add(urr);
                            }
                            //if (urr.SchoolYear == schoolYear && urr.Semester == Semester && urr.GradeYear == GrYear)
                            //{
                            //    DateTime dt1;
                            //    DateTime.TryParse(urr.UpdateDate, out dt1);
                            //    if (dt == dt1)
                            //        updateRec = urr;
                            //}
                        }
                        bool isInsert = true;

                        if (updateRec == null)
                        {
                            updateRec           = new JHUpdateRecordRecord();
                            updateRec.StudentID = id;
                        }
                        else
                        {
                            isInsert = false;
                        }

                        updateRec.UpdateCode = "2";

                        // 當已經有畢業異動使用新增方式
                        if (CheckHasData)
                        {
                            isInsert = true;
                        }

                        bool checkData = false;
                        foreach (string field in e.ImportFields)
                        {
                            string value = data[field].Trim();

                            switch (field)
                            {
                            //case "異動類別":
                            //    if (value == "畢業")
                            //    {
                            //        updateRec.UpdateCode = "2";
                            //        checkData = true;
                            //    }
                            //    break;
                            case "學年度":
                                int scYear;
                                if (int.TryParse(value, out scYear))
                                {
                                    updateRec.SchoolYear = scYear;
                                    checkData            = true;
                                }
                                break;

                            case "學期":
                                int Sems;
                                if (int.TryParse(value, out Sems))
                                {
                                    updateRec.Semester = Sems;
                                    checkData          = true;
                                }
                                break;

                            case "異動年級":
                                updateRec.GradeYear = GrYear;
                                break;

                            case "異動日期":
                                DateTime dtd;
                                if (DateTime.TryParse(value, out dtd))
                                {
                                    updateRec.UpdateDate = dtd.ToShortDateString();
                                }
                                break;

                            case "入學年月":
                                if (string.IsNullOrEmpty(value))
                                {
                                    updateRec.EnrollmentSchoolYear = string.Empty;
                                }
                                else
                                {
                                    updateRec.EnrollmentSchoolYear = value;
                                }
                                break;

                            case "畢業年月":
                                if (string.IsNullOrEmpty(value))
                                {
                                    updateRec.GraduateSchoolYear = string.Empty;
                                }
                                else
                                {
                                    updateRec.GraduateSchoolYear = value;
                                }
                                break;

                            case "畢修業別":
                                updateRec.Graduate = value;
                                break;

                            case "備註":
                                updateRec.Comment = value;
                                break;

                            case "學籍核准日期":
                                DateTime dtLD;
                                if (DateTime.TryParse(value, out dtLD))
                                {
                                    updateRec.LastADDate = dtLD.ToShortDateString();
                                }
                                break;

                            case "學籍核准文號":
                                updateRec.LastADNumber = value;
                                break;

                            case "畢業證書字號":
                                updateRec.GraduateCertificateNumber = value;
                                break;

                            case "畢(結)業證書字號":
                                updateRec.GraduateCertificateNumber = value;
                                break;

                            case "異動班級":
                                updateRec.OriginClassName = value;
                                break;

                            case "異動姓名":
                                updateRec.StudentName = value;
                                break;

                            case "異動身分證號":
                                updateRec.IDNumber = value;
                                break;

                            case "異動出生地":
                                updateRec.BirthPlace = value;
                                break;

                            case "異動學號":
                                updateRec.StudentNumber = value;
                                break;

                            case "異動性別":
                                if (value == "男" || value == "女" || value == "")
                                {
                                    updateRec.Gender = value;
                                }
                                break;

                            case "異動生日":
                                DateTime dtb;
                                if (DateTime.TryParse(value, out dtb))
                                {
                                    updateRec.Birthdate = dtb.ToShortDateString();
                                }
                                break;

                            case "核准日期":
                                DateTime dtAd;
                                if (DateTime.TryParse(value, out dtAd))
                                {
                                    updateRec.ADDate = dtAd.ToShortDateString();
                                }

                                break;

                            case "核准文號":
                                updateRec.ADNumber = value;
                                break;
                            }
                        }

                        if (string.IsNullOrEmpty(updateRec.StudentID) || string.IsNullOrEmpty(updateRec.UpdateDate) || string.IsNullOrEmpty(updateRec.UpdateCode))
                        {
                            continue;
                        }
                        else
                        {
                            if (isInsert)
                            {
                                InsertList.Add(updateRec);
                            }
                            else
                            {
                                UpdateList.Add(updateRec);
                            }
                        }
                    }
                }

                try
                {
                    // 先清空舊
                    if (DelList.Count > 0)
                    {
                        Delete(DelList);
                    }

                    if (InsertList.Count > 0)
                    {
                        Insert(InsertList);
                    }

                    if (UpdateList.Count > 0)
                    {
                        Update(UpdateList);
                    }


                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學生.匯入異動", "匯入畢業異動", "匯入畢業異動:共新增" + InsertList.Count + "筆資料,共更新:" + UpdateList.Count + "筆資料");
                    JHSchool.Student.Instance.SyncAllBackground();
                }
                catch (Exception ex) {}
            };
        }
Esempio n. 18
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNumber.Text))
            {
                MsgBox.Show("請輸入核準文號。");
                return;
            }

            DateTime date;

            if (!DateTime.TryParse(dtpDate.DateString, out date))
            {
                MsgBox.Show("日期格式不正確。");
                return;
            }

            // 修改名冊本身的日期與文號
            DSXmlHelper helper = new DSXmlHelper("AuthorizeBatchRequest");

            helper.AddElement("AuthorizeBatch");
            helper.AddElement("AuthorizeBatch", "Field");
            helper.AddElement("AuthorizeBatch/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("AuthorizeBatch/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("AuthorizeBatch", "Condition");
            helper.AddElement("AuthorizeBatch/Condition", "ID", _provider.ID);

            try
            {
                EditStudent.ModifyUpdateRecordBatch(new DSRequest(helper));
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }

            // 修改其包含的異動紀錄文號
            helper = new DSXmlHelper("UpdateRequest");
            helper.AddElement("UpdateRecord");
            helper.AddElement("UpdateRecord", "Field");
            helper.AddElement("UpdateRecord/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("UpdateRecord/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("UpdateRecord", "Condition");

            if (_provider.GetEntities().Length <= 0) //名冊中沒有任何學生,就不更新學生的核準文號了。
            {
                return;
            }

            foreach (IEntryFormat entity in _provider.GetEntities())
            {
                helper.AddElement("UpdateRecord/Condition", "ID", entity.ID);
            }

            try
            {
                EditStudent.ModifyUpdateRecord(new DSRequest(helper));
                if (DataSaved != null)
                {
                    DataSaved(this, null);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }


            string batchName  = "";
            string schoolYear = "";
            string semester   = "";

            if (_provider.ID != "")
            {
                DSResponse dsrsp = QueryStudent.GetUpdateRecordBatch(_provider.ID);

                DSXmlHelper helper_ = dsrsp.GetContent();

                //填上名冊的 學年、學期、名稱
                foreach (XmlNode node in helper_.GetElements("UpdateRecordBatch"))
                {
                    schoolYear = node.SelectSingleNode("SchoolYear").InnerText;
                    semester   = node.SelectSingleNode("Semester").InnerText;
                    batchName  = node.SelectSingleNode("Name").InnerText;
                }
                // log,2018/3/1 穎驊新增,因應高雄 [10-03][01] 整個學年度核准過的文號的異動名冊全部不見了 項目
                // 本異動名冊 原只有新增會有系統紀錄,現在調整刪除、登打文號都會有紀錄
                JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                string desc = "登錄文號" + schoolYear + "學年度,第" + semester + "學期," + batchName + "名冊,日期:" + dtpDate.DateString + ",文號:" + txtNumber.Text;
                prlp.SaveLog("教務.名冊", "登錄文號", desc);
            }



            this.Close();
        }
Esempio n. 19
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            wizard.ExportableFields.AddRange(ExportItemList);
            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                Dictionary <string, List <DAL.StudUpdateRecordEntity> > StudUpdateRecordEntityListDic = DAL.DALTransfer2.GetStudListUpdateRecordEntityListByUpdateType(e.List, JHPermrec.UpdateRecord.DAL.DALTransfer2.UpdateType.中輟);
                int ExportCount = 0;
                foreach (KeyValuePair <string, List <DAL.StudUpdateRecordEntity> > sureKey in StudUpdateRecordEntityListDic)
                {
                    foreach (DAL.StudUpdateRecordEntity sure in sureKey.Value)
                    {
                        RowData row = new RowData();

                        row.ID = sure.StudentID;

                        foreach (string field in e.ExportFields)
                        {
                            if (wizard.ExportableFields.Contains(field))
                            {
                                switch (field)
                                {
                                case "學年度":
                                    if (sure.SchoolYear > 0)
                                    {
                                        row.Add(field, "" + sure.SchoolYear);
                                    }
                                    break;

                                case "學期":
                                    if (sure.Semester > 0)
                                    {
                                        row.Add(field, "" + sure.Semester);
                                    }
                                    break;

                                case "異動年級": row.Add(field, "" + sure.GetGradeYear()); break;

                                case "異動日期":
                                    if (sure.GetUpdateDate().HasValue)
                                    {
                                        row.Add(field, sure.GetUpdateDate().Value.ToShortDateString());
                                    }
                                    break;

                                case "原因及事項": row.Add(field, sure.GetUpdateDescription()); break;

                                case "備註": row.Add(field, sure.GetComment()); break;

                                case "異動班級": row.Add(field, sure.GetClassName()); break;

                                case "異動姓名": row.Add(field, sure.GetName()); break;

                                case "異動身分證號": row.Add(field, sure.GetIDNumber()); break;

                                case "異動學號": row.Add(field, sure.GetStudentNumber()); break;

                                case "異動性別": row.Add(field, sure.GetGender()); break;

                                case "異動生日":
                                    if (sure.GetBirthday().HasValue)
                                    {
                                        row.Add(field, sure.GetBirthday().Value.ToShortDateString());
                                    }
                                    break;

                                case "異動地址": row.Add(field, sure.GetAddress()); break;

                                case "核准日期":
                                    if (sure.GetADDate().HasValue)
                                    {
                                        row.Add(field, sure.GetADDate().Value.ToShortDateString());
                                    }
                                    break;

                                case "核准文號": row.Add(field, sure.GetADNumber()); break;

                                case "學籍核准日期":
                                    if (sure.GetLastADDate().HasValue)
                                    {
                                        row.Add(field, sure.GetLastADDate().Value.ToShortDateString());
                                    }
                                    break;

                                case "學籍核准文號": row.Add(field, sure.GetLastADNumber()); break;

                                case "異動座號": row.Add(field, sure.GetSeatNo()); break;

                                case "異動類別": row.Add(field, "中輟"); break;
                                }
                            }
                        }
                        ExportCount++;
                        e.Items.Add(row);
                    }
                }
                JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                prlp.SaveLog("學生.匯出異動", "匯出中輟異動", "共匯出中輟異動" + ExportCount + "筆資料.");
            };
        }
Esempio n. 20
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            _StudUpdateRecordEntity.SetUpdateDate(dtUpdateDate.Text);
            _StudUpdateRecordEntity.SetComment(txtComment.Text);
            _StudUpdateRecordEntity.SetClassName(txtClass.Text);
            _StudUpdateRecordEntity.SetName(txtName.Text);
            _StudUpdateRecordEntity.SetIDNumber(txtIDNumber.Text);
            _StudUpdateRecordEntity.SetStudentNumber(txtStudentNumber.Text);
            _StudUpdateRecordEntity.SetGender(cboGender.Text);
            _StudUpdateRecordEntity.SetBirthday(dtBirthday.Text);
            _StudUpdateRecordEntity.SetAddress(txtAddress.Text);
            _StudUpdateRecordEntity.SetImportExportSchool(txtExportSchool.Text);
            _StudUpdateRecordEntity.SetLastADDate(dtLastADDate.Text);
            _StudUpdateRecordEntity.SetLastADNumber(txtLastADNumber.Text);
            _StudUpdateRecordEntity.SetADDate(dtADDate.Text);
            _StudUpdateRecordEntity.SetADNumber(txtADNumber.Text);
            _StudUpdateRecordEntity.SetUpdateDescription(cboUpdateDescription.Text);
            int intSchoolYear, intSemester;

            int.TryParse(JHSchool.School.DefaultSchoolYear, out intSchoolYear);
            int.TryParse(JHSchool.School.DefaultSemester, out intSemester);
            _StudUpdateRecordEntity.SchoolYear = intSchoolYear;
            _StudUpdateRecordEntity.Semester   = intSemester;
            _StudUpdateRecordEntity.SetUpdateCode("3");

            // 檢查相同學年度學期異動日期
            List <JHUpdateRecordRecord> StudUpRecList = JHUpdateRecord.SelectByStudentID(_StudUpdateRecordEntity.StudentID);

            foreach (JHUpdateRecordRecord urr in StudUpRecList)
            {
                // 轉入
                if (urr.UpdateCode == "3" && urr.SchoolYear == intSchoolYear && urr.Semester == intSemester)
                {
                    DateTime dtA, dtB;
                    DateTime.TryParse(urr.UpdateDate, out dtA);
                    DateTime.TryParse(dtUpdateDate.Text, out dtB);
                    // 相同異動日期
                    if (dtA == dtB)
                    {
                        if (FISCA.Presentation.Controls.MsgBox.Show("已有一筆相同學年度、學期、異動日期的轉入異動,請問是否覆蓋?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            JHUpdateRecord.Delete(urr);
                            _StudUpdateRecordEntity.UID = string.Empty;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            // Save
            DAL.DALTransfer2.SetStudUpdateRecordEntity(_StudUpdateRecordEntity);

            // log
            JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
            prlp.SaveLog("學生.轉入異動", "新增轉入異動", "新增轉入異動資料,姓名:" + _StudUpdateRecordEntity.GetName() + ",學號:" + _StudUpdateRecordEntity.GetStudentNumber());

            this.Close();
        }