예제 #1
0
        private bool IsValid()
        {
            DateTime?s = null, e = null;

            if (string.IsNullOrEmpty(txtSDate.Text))
            {
                _error.SetIconPadding(txtSDate, -10);
                _error.SetError(txtSDate, "日期格式錯誤");
            }
            else
            {
                s = DateTime.Parse(txtSDate.Text);
            }

            if (string.IsNullOrEmpty(txtEDate.Text))
            {
                _error.SetIconPadding(txtEDate, -10);
                _error.SetError(txtEDate, "日期格式錯誤");
            }
            else
            {
                e = DateTime.Parse(txtEDate.Text);
            }

            if (s.HasValue && e.HasValue)
            {
                if (e.Value < s.Value)
                {
                    _error.SetIconPadding(txtEDate, -10);
                    _error.SetError(txtEDate, "統計期間錯誤");
                }
            }

            return(!_error.HasError);
        }
예제 #2
0
        private void CheckZipCode()
        {
            string zipcode = "";

            if (txtZipcode.Text.Length > 3)
            {
                zipcode = txtZipcode.Text.Remove(3);
            }
            else
            {
                zipcode = txtZipcode.Text;
            }

            KeyValuePair <string, string> ctPair = Framework.Feature.Config.FindTownByZipCode(zipcode);

            if (ctPair.Key == null)
            {
                _warnings.SetError(txtZipcode, "查無此郵遞區號對應縣市鄉鎮資料。");
            }
            else
            {
                _warnings.SetError(txtZipcode, string.Empty);

                string county = ctPair.Key;
                string town   = ctPair.Value;

                cboCounty.SetComboBoxText(county);
                cboTown.SetComboBoxText(town);
            }
        }
예제 #3
0
        private void txtZipcode_TextChanged(object sender, EventArgs e)
        {
            ShowFullAddress();
            if (_date_updating)
            {
                return;
            }

            decimal d;

            if (!string.IsNullOrEmpty(txtZipcode.Text) && !decimal.TryParse(txtZipcode.Text, out d))
            {
                _errors.SetError(txtZipcode, "郵遞區號必須為數字形態");
                return;
            }
            else
            {
                _errors.SetError(txtZipcode, ""); //清除錯誤。
            }
            if (btnAddressType.Text == "戶籍地址")
            {
                AddressRec.Permanent.ZipCode = txtZipcode.Text;
            }

            if (btnAddressType.Text == "聯絡地址")
            {
                AddressRec.Mailing.ZipCode = txtZipcode.Text;
            }

            if (btnAddressType.Text == "其它地址")
            {
                AddressRec.Address1.ZipCode = txtZipcode.Text;
            }
        }
예제 #4
0
        /// <summary>
        /// 檢查批次異動輸入年月
        /// </summary>
        /// <param name="Year"></param>
        /// <param name="Month"></param>
        /// <param name="Errors"></param>
        /// <returns></returns>
        public static string checkYearAndMonthInput(TextBox Year, ComboBox Month, EnhancedErrorProvider Errors)
        {
            string strEnrrolSchoolYear = string.Empty, cMonth = string.Empty;
            string cYear = "";

            cYear = strIntCheckA(Year.Text);
            if (string.IsNullOrEmpty(cYear) || cYear.Length != 4)
            {
                Errors.SetError(Year, "請檢查學年度是否是西元年");
            }
            else
            {
                strEnrrolSchoolYear = cYear;
            }

            cMonth = strIntCheckA(Month.Text);
            if (string.IsNullOrEmpty(cMonth))
            {
                Errors.SetError(Year, "請選擇月份");
            }
            else
            {
                strEnrrolSchoolYear += cMonth;
            }


            // 200901
            if (strEnrrolSchoolYear.Length != 6)
            {
                strEnrrolSchoolYear = "";
            }

            return(strEnrrolSchoolYear);
        }
예제 #5
0
        private void textBoxX1_TextChanged(object sender, EventArgs e)
        {
            _error.SetError(textBoxX1, "");

            decimal d;

            if (!decimal.TryParse(textBoxX1.Text, out d))
            {
                _error.SetError(textBoxX1, "必須為數字");
            }
        }
예제 #6
0
        private void SchoolYearAndSemester_TextChanged(object sender, EventArgs e)
        {
            ComboBox cbo = sender as ComboBox;
            int      i;

            if (!int.TryParse(cbo.Text, out i))
            {
                _error.SetError(cbo, "必須為整數");
            }
            else
            {
                _error.SetError(cbo, "");
            }
        }
예제 #7
0
        private void txtLongtitude_TextChanged(object sender, EventArgs e)
        {
            decimal d;

            if (!string.IsNullOrEmpty(txtLongtitude.Text) && !decimal.TryParse(txtLongtitude.Text, out d))
            {
                _errors.SetError(txtLongtitude, "經度必須為數字形態。");
                return;
            }
            else
            {
                _errors.SetError(txtLongtitude, string.Empty);
            }
        }
예제 #8
0
        private void ValidateStudentNumber()
        {
            if (string.IsNullOrEmpty(txtStudentID.Text))
            {
                _errors.SetError(txtStudentID, string.Empty);
                return; //空白不檢查。
            }

            if (QueryStudent.StudentNumberExists(RunningID, txtStudentID.Text))
            {
                _errors.SetError(txtStudentID, "學號重覆,請確認資料。");
            }
            else
            {
                _errors.SetError(txtStudentID, string.Empty);
            }
        }
        //private void txtStartTime_Validating(object sender, CancelEventArgs e)
        //{
        //    ValidTextTime(txtStartTime, PaddingMethod.First);
        //}

        //private void txtEndTime_Validating(object sender, CancelEventArgs e)
        //{
        //    ValidTextTime(txtEndTime, PaddingMethod.Last);
        //}

        private void ValidTextTime(TextBoxX textbox, PaddingMethod method)
        {
            if (textbox.Text == string.Empty)
            {
                _errors.SetError(textbox, "");
            }
            else
            {
                DateTime?objStart = DateTimeHelper.ParseGregorian(textbox.Text, method);
                if (!objStart.HasValue)
                {
                    _errors.SetError(textbox, "您必須輸入合法的日期格式。");
                }
                else
                {
                    _errors.SetError(textbox, "");
                }
            }
        }
예제 #10
0
        private void CheckZipCode()
        {
            // KeyValuePair<string, string> ctPair = Framework.Feature.Config.FindTownByZipCode(txtZipcode.Text);

            KeyValuePair <string, string> ctPair = _CountyTown.GetTownCountyNameDict(txtZipcode.Text);

            if (ctPair.Key == null)
            {
                _warnings.SetError(txtZipcode, "查無此郵遞區號對應縣市鄉鎮資料。");
            }
            else
            {
                _warnings.SetError(txtZipcode, string.Empty);

                string county = ctPair.Key;
                string town   = ctPair.Value;

                cboCounty.Text = county;
                cboTown.Text   = town;
            }
        }
예제 #11
0
        private void ComboBoxEx_TextChanged(object sender, EventArgs e)
        {
            ComboBoxEx cbo = sender as ComboBoxEx;

            if (cbo.FindStringExact(cbo.Text) < 0)
            {
                _error.SetError(cbo, "不可以指定清單以外的值");
            }
            else
            {
                _error.SetError(cbo, "");
            }
        }
예제 #12
0
        private bool IsValid()
        {
            Errors.Clear();
            bool hasError = false;

            if (rdoCalcTrue.Checked)
            {
                ComboBoxItem item = cboAssessmentSetup.SelectedItem as ComboBoxItem;
                if (item == null || (item.Tag + "") == string.Empty)
                {
                    Errors.SetError(cboAssessmentSetup, "如果要列入學期成績,您必需指定一種「評量設定」。");
                    hasError = true;
                }
            }

            return(!hasError);
        }
예제 #13
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            SetFormDataToDALRec();

            // 檢查生日


            // 檢查性別
            List <string> checkGender = new List <string>();

            checkGender.Add("男");
            checkGender.Add("");
            checkGender.Add("女");

            if (!checkGender.Contains(cboGender.Text))
            {
                _errors.SetError(cboGender, "性別錯誤,請確認資料。");
                return;
            }

            DateTime dt;

            if (!string.IsNullOrEmpty(txtBirthDate.Text))
            {
                if (!DateTime.TryParse(txtBirthDate.Text, out dt))
                {
                    _errors.SetError(txtBirthDate, "日期錯誤,請確認資料。");
                    return;
                }
            }
            else
            {
                _StudRec.Birthday = null;
            }

            List <string> checkID  = new List <string>();
            List <string> checkSSN = new List <string>();


            foreach (JHStudentRecord studRec in JHStudent.SelectAll())
            {
                checkID.Add(studRec.SALoginName);
                checkSSN.Add(studRec.IDNumber);
            }
            if (!string.IsNullOrEmpty(_StudRec.SALoginName))
            {
                if (checkID.Contains(_StudRec.SALoginName))
                {
                    if (_defaultLoginID != _StudRec.SALoginName)
                    {
                        _errors.SetError(txtLoginID, "學生登入帳號重覆,請確認資料。");
                        return;
                    }
                }
            }
            if (!string.IsNullOrEmpty(_StudRec.IDNumber))
            {
                if (checkSSN.Contains(_StudRec.IDNumber))
                {
                    if (_defaultIDNumber != _StudRec.IDNumber)
                    {
                        _errors.SetError(txtSSN, "身分證號重覆,請確認資料。");
                        return;
                    }
                }
            }

            JHStudent.Update(_StudRec);
            SetAfterEditLog();
            Student.Instance.SyncDataBackground(PrimaryKey);
            _errors.Clear();
            //BindDataToForm();
        }
예제 #14
0
        private void checkInItem(object sender, EventArgs e)
        {
            ComboBox cbox = (ComboBox)sender;

            if (!cbox.Items.Contains(cbox.Text))
            {
                _errors.SetError(cbox, "輸入值不被允許。");
            }
            else
            {
                _errors.SetError(cbox, "");
            }
            buttonX1.Enabled = !_errors.HasError;
        }
예제 #15
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            DateTime dt;

            //入學日期檢查
            if (!string.IsNullOrEmpty(txtEntranceDate.Text))
            {
                if (DateTime.TryParse(txtEntranceDate.Text, out dt))
                {
                    _errors.SetError(txtEntranceDate, string.Empty);
                }
                else
                {
                    _errors.SetError(txtEntranceDate, "入學日期錯誤,請確認資料。");
                    return;
                }
            }

            //離校日期檢查
            if (!string.IsNullOrEmpty(txtLeavingDate.Text))
            {
                if (DateTime.TryParse(txtLeavingDate.Text, out dt))
                {
                    _errors.SetError(txtLeavingDate, string.Empty);
                }
                else
                {
                    _errors.SetError(txtLeavingDate, "離校日期錯誤,請確認資料。");
                    return;
                }
            }

            SetFormDataToDALRec();

            // 檢查生日


            // 檢查性別
            List <string> checkGender = new List <string>();

            checkGender.Add("男");
            checkGender.Add("");
            checkGender.Add("女");

            if (!checkGender.Contains(cboGender.Text))
            {
                _errors.SetError(cboGender, "性別錯誤,請確認資料。");
                return;
            }

            //DateTime dt;

            if (!string.IsNullOrEmpty(txtBirthDate.Text))
            {
                if (!DateTime.TryParse(txtBirthDate.Text, out dt))
                {
                    _errors.SetError(txtBirthDate, "日期錯誤,請確認資料。");
                    return;
                }
            }
            else
            {
                _StudRec.Birthday = null;
            }

            List <string> checkID  = new List <string>();
            List <string> checkSSN = new List <string>();


            foreach (JHStudentRecord studRec in JHStudent.SelectAll())
            {
                checkID.Add(studRec.SALoginName);
                checkSSN.Add(studRec.IDNumber);
            }
            if (!string.IsNullOrEmpty(_StudRec.SALoginName))
            {
                if (checkID.Contains(_StudRec.SALoginName))
                {
                    if (_defaultLoginID != _StudRec.SALoginName)
                    {
                        _errors.SetError(txtLoginID, "學生登入帳號重覆,請確認資料。");
                        return;
                    }
                }
            }
            if (!string.IsNullOrEmpty(_StudRec.IDNumber))
            {
                if (checkSSN.Contains(_StudRec.IDNumber))
                {
                    if (_defaultIDNumber != _StudRec.IDNumber)
                    {
                        _errors.SetError(txtSSN, "身分證號重覆,請確認資料。");
                        return;
                    }
                }
            }

            //儲存延伸資料
            List <StudentRecord_Ext> list = new List <StudentRecord_Ext>();

            list.Add(_StudRec_Ext);
            if (!string.IsNullOrEmpty(_StudRec_Ext.UID))
            {
                tool._A.UpdateValues(list);
            }
            else
            {
                tool._A.InsertValues(list);
            }

            UpdateUDTData();

            eh(null, EventArgs.Empty);


            JHStudent.Update(_StudRec);
            SetAfterEditLog();
            JHSchool.Student.Instance.SyncDataBackground(PrimaryKey);
            _errors.Clear();
            //BindDataToForm();
        }