示例#1
0
        //────────────────────────────────────────
        /// <summary>
        /// NOフィールドの値で指定したレコードを返します。なければヌルです。
        /// </summary>
        /// <param name="exceptedNo"></param>
        /// <returns></returns>
        public Record_Humaninput SelectByNo(
            Int_HumaninputImpl valueint_No,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();
            log_Method.BeginMethod(Info_Table.Name_Library, this, "SelectByNo",log_Reports);
            //

            Record_Humaninput result;

            if (valueint_No.IsSpaces())
            {
                // 空白なら中断。
                result = null;
                goto gt_Error_Spaces;
            }
            else if (!valueint_No.IsValidated)
            {
                // エラーデータなら中断。
                result = null;
                goto gt_Error_Invalid;
            }

            int nExpectedNo;
            bool bParsed = Int_HumaninputImpl.TryParse(
                valueint_No,
                out nExpectedNo,
                EnumOperationIfErrorvalue.Error,
                null,
                log_Reports
                );
            if (!log_Reports.Successful)
            {
                // 既エラー
                result = null;
                goto gt_EndMethod;
            }

            if (bParsed)
            {

                foreach (DataRow dataRow in this.DataTable.Rows)
                {
                    if (dataRow.Table.Columns.Contains("NO"))
                    {
                        // NO列があれば

                        Value_Humaninput valueH = (Value_Humaninput)dataRow["NO"];

                        if (valueH is Int_HumaninputImpl)
                        {
                            Int_HumaninputImpl intH = (Int_HumaninputImpl)valueH;

                            if (intH.IsSpaces())
                            {
                                // 空白なら無視
                            }
                            else if (!intH.IsValidated)
                            {
                                // エラーデータなら無視
                            }
                            else
                            {
                                int int_No;

                                bool isParsed2 = Int_HumaninputImpl.TryParse(
                                    intH,
                                    out int_No,
                                    EnumOperationIfErrorvalue.Error,
                                    null,
                                    log_Reports
                                    );
                                if (!log_Reports.Successful)
                                {
                                    // 既エラー
                                    result = null;
                                    goto gt_EndMethod;
                                }

                                if (isParsed2)
                                {
                                    if (nExpectedNo == int_No)
                                    {
                                        // 一致すれば。
                                        result = new Record_HumaninputImpl( int_No.ToString(), dataRow, this);
                                        goto gt_EndMethod;
                                    }
                                }
                            }
                        }
                    }
                }

            }

            result = null;
            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_Spaces:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー641!", log_Method);
                r.Message = "(空白なので中断)";
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_Invalid:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー642!", log_Method);
                r.Message = "(エラーデータなので中断)";
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return result;
        }
示例#2
0
        //────────────────────────────────────────
        /// <summary>
        /// 指定のInt型フィールドの値で指定したレコードを返します。なければヌルです。
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="expectedInt"></param>
        /// <returns>一致しなければヌル。</returns>
        public Record_Humaninput SelectByInt(
            string name_Field,
            Int_HumaninputImpl expectedIntParam,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();
            log_Method.BeginMethod(Info_Table.Name_Library, this, "SelectByInt",log_Reports);

            //
            //
            //
            //

            Record_Humaninput result;

            if (expectedIntParam.IsSpaces())
            {
                // 空白なら中断。
                result = null;
                goto gt_Error_Spaces;
            }
            else if (!expectedIntParam.IsValidated)
            {
                // エラーデータなら中断。
                result = null;
                goto gt_Error_Invalid;
            }

            int int_Expected;

            bool isParsed = Int_HumaninputImpl.TryParse(
                expectedIntParam,
                out int_Expected,
                EnumOperationIfErrorvalue.Error,
                null,
                log_Reports
                );
            if (!log_Reports.Successful || !isParsed)
            {
                // 既エラー
                result = null;
                goto gt_EndMethod;
            }

            Exception err_Excp;
            try
            {
                foreach (DataRow dataRow in this.DataTable.Rows)
                {

                    Value_Humaninput valueH = (Value_Humaninput)dataRow[name_Field];

                    if (valueH is Int_HumaninputImpl)
                    {
                        Int_HumaninputImpl intH = (Int_HumaninputImpl)valueH;

                        if (intH.IsSpaces())
                        {
                            // 空白なら無視
                        }
                        else if (!intH.IsValidated)
                        {
                            // エラーデータなら無視
                        }
                        else
                        {
                            int int_Exists;

                            bool isParsed2 = Int_HumaninputImpl.TryParse(
                                intH,
                                out int_Exists,
                                EnumOperationIfErrorvalue.Error,
                                null,
                                log_Reports
                                );
                            if (!log_Reports.Successful)
                            {
                                // 既エラー
                                result = null;
                                goto gt_EndMethod;
                            }

                            if (isParsed2)
                            {
                                if (int_Expected == int_Exists)
                                {
                                    // 一致すれば。
                                    result = new Record_HumaninputImpl( log_Method.Fullname, dataRow, this);
                                    // 正常
                                    goto gt_EndMethod;
                                }
                            }
                        }
                    }
                    //}
                }
            }
            catch (Exception e)
            {
                // ArgumentException: 指定した名前の列がなかった場合など。
                err_Excp = e;
                result = null;
                goto gt_Error_Exception;
            }

            result = null;
            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
            gt_Error_Spaces:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー651!", log_Method);
                r.Message = "<空白で中断>";
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_Invalid:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー652!", log_Method);
                r.Message = "<エラーデータで中断>";
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            gt_Error_Exception:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー653!", log_Method);
                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append(r.Message_SException(err_Excp));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
            gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return result;
        }