// 入力チェック public override void InputCheckUpdate() { #region Field string errMessage = ""; string warnMessage = ""; int _selectIndex = 0; int _selectColumn = 0; bool IsDetailExists = false; Control errCtl = null; List <string> list_warn_commodity = new List <string>(); #endregion #region 必須チェック // 問い合わせ内容 if (string.IsNullOrEmpty(this.txtContent.Text.Trim())) { errMessage += "問い合わせ内容が入力されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtTitle; } } // 担当 if (this.cmbPerson.SelectedIndex == -1) { errMessage += "担当が選択されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.cmbPerson; } } #endregion #region 範囲チェック //if (ExCast.zCLng(_entityH._no) > 999999999999999) //{ // errMessage += "受注番号には15桁以内の正の整数を入力して下さい。" + Environment.NewLine; //} //if (ExCast.zCLng(_entityH._estimateno) > 999999999999999) //{ // errMessage += "見積番号には15桁以内の正の整数を入力して下さい。" + Environment.NewLine; // if (errCtl == null) errCtl = this.utlEstimateNo.txtID; //} if (ExString.LenB(this.txtContent.Text) > 1000) { errMessage += "問い合わせ内容には全角500桁文字以内(半角1000桁文字以内)を入力して下さい。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtContent; } } #endregion #region アップロードチェック if (this.tblUpload.Text == "※ファイルアップロードに失敗しました。") { warnMessage += "ファイルアップロードに失敗しています。" + Environment.NewLine; } #endregion #region エラー or 警告時処理 bool flg = true; if (!string.IsNullOrEmpty(errMessage)) { ExMessageBox.Show(errMessage, Dlg.MessageBox.MessageBoxIcon.Error); flg = false; } else { if (!string.IsNullOrEmpty(warnMessage)) { warnMessage += "このまま登録を続行してもよろしいですか?" + Environment.NewLine; ExMessageBox.ResultShow(this, errCtl, warnMessage); flg = false; // ResultMessageBoxにてResult処理 } } this.txtDummy.IsTabStop = false; if (flg == false) { if (errCtl != null) { ExBackgroundWorker.DoWork_Focus(errCtl, 10); } return; } #endregion #region 更新処理 UpdateData(Common.geUpdateType.Update); #endregion }
private bool InputCheck2(string _text) { string _strText = ""; string _chktext = ""; int _selectionStart = 0; switch (InputMode) { case geInputMode.Number: // 最大・最小入力値チェック _strText = this.Text; if (this.SelectedText != "") { _strText = this.Text.Replace(this.SelectedText, ""); } if (ExCast.zCDbl(_strText + _text) < this.MinNumber || ExCast.zCDbl(_strText + _text) > this.MaxNumber) { return(false); } double _dbl = ExCast.zCDbl(_strText + _text); string strText; string str; if (this.DecimalNum > 0) { if (this.DecimalNum == 1) { strText = _dbl.ToString("#,##0.00"); str = strText.Substring(strText.Length - 1, 1); if (str != "0") { return(false); } } else if (this.DecimalNum == 2) { strText = _dbl.ToString("#,##0.000"); str = strText.Substring(strText.Length - 1, 1); if (str != "0") { return(false); } } else { return(false); } } break; case geInputMode.ID: case geInputMode.Alphanumeric: case geInputMode.FullKana: case geInputMode.HalfKana: case geInputMode.FullShapeNative: if (ExCast.zCInt(this.MaxLengthB) != 0) { if (ExString.IsFullString(_text) || ExString.LenB(_text) >= 2) { // 最大入力バイト数チェック if (ExString.LenB(this.Text) - ExString.LenB(this.SelectedText) > ExCast.zCInt(this.MaxLengthB)) { _chktext = this.Text + this.SelectedText; for (int i = 1; i <= _chktext.Length; i++) { _chktext = _chktext.Substring(0, _chktext.Length - 1); if (ExString.LenB(_chktext) <= ExCast.zCInt(this.MaxLengthB)) { _selectionStart = this.SelectionStart + _text.Length; this.Text = _chktext; this.SelectionStart = _selectionStart; break; } } return(false); } } else { // 最大入力バイト数チェック if (ExString.LenB(this.Text + _text) - ExString.LenB(this.SelectedText) > ExCast.zCInt(this.MaxLengthB)) { _chktext = this.Text + _text + this.SelectedText; for (int i = 1; i <= _chktext.Length; i++) { _chktext = _chktext.Substring(0, _chktext.Length - 1); if (ExString.LenB(_chktext) <= ExCast.zCInt(this.MaxLengthB)) { this.Text = _chktext; break; } } return(false); } } } break; } // 全角チェック switch (InputMode) { case geInputMode.Number: case geInputMode.ID: case geInputMode.Alphanumeric: //case geInputMode.HalfKana: string strText = ""; for (int i = 1; i <= this.Text.Length; i++) { string str = this.Text.Substring(i - 1, 1); byte[] bytes = ExSjisEncoding.ucstojms(str); // 全角は除く if (bytes.Length == 1) { strText += str; } } if (strText != this.Text) { return(false); //this.Text = strText; } break; } // 0入力チェック switch (InputMode) { case geInputMode.ID: if (this.Text + _text == "0") { return(false); } break; } return(true); }
// 入力チェック(更新時) public override void InputCheckUpdate() { #region Field string errMessage = ""; string warnMessage = ""; int _selectIndex = 0; int _selectColumn = 0; Control errCtl = null; #endregion try { #region 必須チェック // ID if (this.cmbLoginId.SelectedIndex == -1) { errMessage += "ログインIDが選択されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.cmbLoginId; } } // 変更ログインID if (string.IsNullOrEmpty(_entity._after_login_id)) { errMessage += "変更ログインIDが入力されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginId; } } // ログインパスワード if (string.IsNullOrEmpty(_entity._login_password)) { errMessage += "ログインパスワードが入力されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginId; } } // ログインパスワード確認 if (string.IsNullOrEmpty(txtLoginPasswordConfirm.Password)) { errMessage += "ログインパスワード確認が入力されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginId; } } // 名称 if (string.IsNullOrEmpty(_entity._name)) { errMessage += "ユーザー名が入力されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtName; } } // 会社グループ if (string.IsNullOrEmpty(ExCast.zCStr(_entity._group_id))) { errMessage += "グループが入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlCompanyGroup.txtID; } } // デフォルト入力担当 if (string.IsNullOrEmpty(ExCast.zCStr(_entity._person_id))) { errMessage += "デフォルト入力担当が入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlPerson.txtID; } } //// 表示区分 //if (string.IsNullOrEmpty(ExCast.zCStr(_entity._display_division_id))) //{ // errMessage += "表示区分が入力(選択)されていません。" + Environment.NewLine; // if (errCtl == null) errCtl = this.utlDisplay.txtID; //} #endregion #region 適正値入力チェック // パスワード if (this.txtLoginPassword.Password != this.txtLoginPasswordConfirm.Password) { errMessage += "パスワードが一致しません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginPasswordConfirm; } } // 会社グループ if (ExCast.zCInt(_entity._group_id) != 0 && string.IsNullOrEmpty(_entity._group_nm)) { errMessage += "会社グループが適切に入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlCompanyGroup.txtID; } } // 担当 if (ExCast.zCInt(_entity._person_id) != 0 && string.IsNullOrEmpty(_entity._person_nm)) { errMessage += "デフォルト入力担当が適切に入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlPerson.txtID; } } // 表示区分 if (ExCast.zCInt(_entity._display_division_id) != 0 && string.IsNullOrEmpty(_entity._display_division_nm)) { errMessage += "表示区分が適切に入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlDisplay.txtID; } } #endregion #region 日付チェック //// 納入指定日 //if (string.IsNullOrEmpty(_entity.supply_ymd) == false) //{ // if (ExCast.IsDate(_entity.supply_ymd) == false) // { // errMessage += "納入指定日の形式が不正です。(yyyy/mm/dd形式で入力(選択)して下さい)" + Environment.NewLine; // if (errCtl == null) errCtl = this.datNokiYmd; // } //} #endregion #region 日付変換 // 受注日 //if (string.IsNullOrEmpty(_entity.order_ymd) == false) //{ // _entity.order_ymd = ExCast.zConvertToDate(_entity.order_ymd).ToString("yyyy/MM/dd"); //} #endregion #region 数値チェック #endregion #region 正数チェック #endregion #region 範囲チェック if (ExString.LenB(_entity._after_login_id) < 4) { errMessage += "変更ログインIDには半角英数4桁以上を入力して下さい。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginId; } } if (ExString.LenB(_entity._after_login_id) > 10) { errMessage += "変更ログインIDには半角英数10桁以内を入力して下さい。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginId; } } if (ExString.LenB(_entity._login_password) < 4) { errMessage += "ログインパスワードには半角英数4桁以上を入力して下さい。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginPassword; } } if (ExString.LenB(_entity._login_password) > 10) { errMessage += "ログインパスワードには半角英数20桁以内を入力して下さい。" + Environment.NewLine; if (errCtl == null) { errCtl = this.txtLoginPassword; } } #endregion #region エラー or 警告時処理 bool flg = true; if (!string.IsNullOrEmpty(errMessage)) { ExMessageBox.Show(errMessage, Dlg.MessageBox.MessageBoxIcon.Error); flg = false; } if (!string.IsNullOrEmpty(warnMessage)) { warnMessage += "このまま登録を続行してもよろしいですか?" + Environment.NewLine; ExMessageBox.ResultShow(this, errCtl, warnMessage); flg = false; //if (ExMessageBox.ResultShow(warnMessage) == MessageBoxResult.No) //{ // flg = false; //} } this.txtDummy.IsTabStop = false; if (flg == false) { if (errCtl != null) { ExBackgroundWorker.DoWork_Focus(errCtl, 10); } return; } #endregion #region 更新処理 switch (this.utlFunctionKey.gFunctionKeyEnable) { case Utl_FunctionKey.geFunctionKeyEnable.New: case Utl_FunctionKey.geFunctionKeyEnable.Init: //UpdateData(Common.geUpdateType.Insert); break; case Utl_FunctionKey.geFunctionKeyEnable.Upd: UpdateData(Common.geUpdateType.Update); break; default: break; } #endregion } finally { Common.gblnBtnProcLock = false; Common.gblnBtnDesynchronizeLock = false; } }