Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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();
        }