예제 #1
0
        //*******************************************************************
        /// <summary>時刻チェック </summary>
        /// <param name="time">時刻</param>
        /// <return></return>
        //*******************************************************************
        private static int CheckTime(string time)
        {
            char[] delimiterChars = { ' ', '/', ':' };
            int    itY;
            int    itM;
            int    itD;
            int    itH;
            int    itMm;
            int    maxDay;

            string[] inTime = time.Split(delimiterChars);

            itY  = Convert.ToInt32(inTime[0]);  // 年
            itM  = Convert.ToInt32(inTime[1]);  // 月
            itD  = Convert.ToInt32(inTime[2]);  // 日
            itH  = Convert.ToInt32(inTime[3]);  // 時
            itMm = Convert.ToInt32(inTime[4]);  // 分


            // 月 の確認
            if (!(CheckUtil.IsMonth(itM)))
            {
                return(-1);
            }

            // 日 の確認
            switch (itM)
            {
            case 2:
                // 2月
                if (DateTime.IsLeapYear(itY))                       // 入力された年が閏年か?
                {
                    maxDay = 29;
                }
                else
                {
                    maxDay = 28;
                }
                break;

            case 4:
            case 6:
            case 9:
            case 11:
                // 小の月(4,6,9,11月)
                maxDay = 30;
                break;

            default:
                // 大の月
                maxDay = 31;
                break;
            }
            if ((itD < 1) || (itD > maxDay))
            {
                return(-2);                                     // 範囲外
            }
            // 時 の確認
            if (!(CheckUtil.IsHour(itH)))
            {
                return(-3);
            }

            // 分 の確認
            if (!(CheckUtil.IsMin(itMm)))
            {
                return(-4);
            }

            // 過去の日付でないか の確認
            DateTime dNow    = System.DateTime.Now;             // 現在の日時を取得
            DateTime dDate   = dNow.Date;                       // 現在の日付を取得
            DateTime dIntime = new DateTime(itY, itM, itD);     // 入力された日付

            if (!(dDate <= dIntime))
            {
                return(-5);
            }

            return(0);
        }
        //*******************************************************************
        /// <summary>検索項目チェック </summary>
        /// <returns>チェック結果</returns>
        //*******************************************************************
        private bool SearchItemCheck()
        {
            // 検索管理IDを取得
            string manageID = tbxManageId.Text;

            if (CheckUtil.IsNullOrEmpty(manageID))
            {
                // 検索From年を取得
                string fromYear = tbxFromYear.Text;
                // 入力の場合
                if (CheckUtil.IsNullOrEmpty(fromYear))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { Properties.Resources.err_message_search_from_year });
                    return(false);
                }

                // 半角数値かチェック
                if (!CheckUtil.IsHankakuNum(fromYear))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_007,
                                                 new string[] { Properties.Resources.err_message_search_from_year });
                    return(false);
                }

                // 4桁かチェック
                if (!CheckUtil.IsLen(fromYear, 4))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_012,
                                                 new string[] { Properties.Resources.err_message_search_from_year, "4" });
                    return(false);
                }

                // 検索From月を取得
                string fromMonth = combFromMonth.Text;
                // 未入力の場合
                if (CheckUtil.IsNullOrEmpty(fromMonth))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { Properties.Resources.err_message_search_from_month });
                    return(false);
                }

                // 半角数値かチェック
                if (!CheckUtil.IsHankakuNum(fromMonth))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                 new string[] { Properties.Resources.err_message_search_from_month, "1", "12" });
                    return(false);
                }

                // 月入力が正しいかチェック
                if (!CheckUtil.IsMonth(Convert.ToInt16(fromMonth)))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                 new string[] { Properties.Resources.err_message_search_from_month, "1", "12" });
                    return(false);
                }

                // 検索From日を取得
                string fromDay = combFromDay.Text;
                // 未入力の場合
                if (CheckUtil.IsNullOrEmpty(fromDay))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { Properties.Resources.err_message_search_from_day });
                    return(false);
                }

                // 半角数値かチェック
                if (!CheckUtil.IsHankakuNum(fromDay))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                 new string[] { Properties.Resources.err_message_search_from_day, "1", "31" });
                    return(false);
                }

                // 日入力が正しいかチェック
                if (!CheckUtil.IsDay(Convert.ToInt16(fromDay)))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                 new string[] { Properties.Resources.err_message_search_from_day, "1", "31" });
                    return(false);
                }

                // 検索From時を取得
                string fromHour = combFromHour.Text;
                // 検索From分を取得
                string fromMin = combFromMin.Text;
                if (CheckUtil.IsNullOrEmpty(fromHour) != CheckUtil.IsNullOrEmpty(fromMin))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_026,
                                                 new string[] { Properties.Resources.err_message_search_from_time });
                    return(false);
                }
                // 入力の場合
                if (!CheckUtil.IsNullOrEmpty(fromHour))
                {
                    // 半角数値かチェック
                    if (!CheckUtil.IsHankakuNum(fromHour))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_from_hour, "0", "23" });
                        return(false);
                    }

                    // 時入力が正しいかチェック
                    if (!CheckUtil.IsHour(Convert.ToInt16(fromHour)))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_from_hour, "0", "23" });
                        return(false);
                    }
                }


                // 入力の場合
                if (!CheckUtil.IsNullOrEmpty(fromMin))
                {
                    // 半角数値かチェック
                    if (!CheckUtil.IsHankakuNum(fromMin))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_from_min, "0", "59" });
                        return(false);
                    }
                    // 分入力が正しいかチェック
                    if (!CheckUtil.IsMin(Convert.ToInt16(fromMin)))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_from_min, "0", "59" });
                        return(false);
                    }
                }
                //日付チェック
                if (Convert.ToInt16(fromDay) > DateTime.DaysInMonth(Convert.ToInt16(fromYear), Convert.ToInt16(fromMonth)))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_018,
                                                 new string[] { Properties.Resources.err_message_search_from_date });
                    return(false);
                }
                // 検索To年、月、日、時、分を取得
                string toYear  = tbxToYear.Text;
                string toMonth = combToMonth.Text;
                string toDay   = combToDay.Text;
                string toHour  = combToHour.Text;
                string toMin   = combToMin.Text;
                if (!(CheckUtil.IsNullOrEmpty(toYear) &&
                      CheckUtil.IsNullOrEmpty(toMonth) &&
                      CheckUtil.IsNullOrEmpty(toDay) &&
                      CheckUtil.IsNullOrEmpty(toHour) &&
                      CheckUtil.IsNullOrEmpty(toMin)))
                {
                    // 未入力の場合
                    if (CheckUtil.IsNullOrEmpty(toYear))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                     new string[] { Properties.Resources.err_message_search_to_year });
                        return(false);
                    }

                    // 半角数値かチェック
                    if (!CheckUtil.IsHankakuNum(toYear))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_007,
                                                     new string[] { Properties.Resources.err_message_search_to_year });
                        return(false);
                    }

                    // 4桁かチェック
                    if (!CheckUtil.IsLen(toYear, 4))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_012,
                                                     new string[] { Properties.Resources.err_message_search_to_year, "4" });
                        return(false);
                    }

                    // 未入力の場合
                    if (CheckUtil.IsNullOrEmpty(toMonth))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                     new string[] { Properties.Resources.err_message_search_to_month });
                        return(false);
                    }

                    // 半角数値かチェック
                    if (!CheckUtil.IsHankakuNum(toMonth))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_to_month, "1", "12" });
                        return(false);
                    }
                    // 月入力が正しいかチェック
                    if (!CheckUtil.IsMonth(Convert.ToInt16(toMonth)))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_to_month, "1", "12" });
                        return(false);
                    }

                    // 未入力の場合
                    if (CheckUtil.IsNullOrEmpty(toDay))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                     new string[] { Properties.Resources.err_message_search_to_day });
                        return(false);
                    }

                    // 半角数値かチェック
                    if (!CheckUtil.IsHankakuNum(toDay))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_to_day, "1", "31" });
                        return(false);
                    }
                    // 日入力が正しいかチェック
                    if (!CheckUtil.IsDay(Convert.ToInt16(toDay)))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                     new string[] { Properties.Resources.err_message_search_to_day, "1", "31" });
                        return(false);
                    }

                    if (CheckUtil.IsNullOrEmpty(toHour) != CheckUtil.IsNullOrEmpty(toMin))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_026,
                                                     new string[] { Properties.Resources.err_message_search_to_time });
                        return(false);
                    }

                    // 入力の場合
                    if (!CheckUtil.IsNullOrEmpty(toHour))
                    {
                        // 半角数値かチェック
                        if (!CheckUtil.IsHankakuNum(toHour))
                        {
                            CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                         new string[] { Properties.Resources.err_message_search_to_hour, "0", "23" });
                            return(false);
                        }

                        // 時入力が正しいかチェック
                        if (!CheckUtil.IsHour(Convert.ToInt16(toHour)))
                        {
                            CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                         new string[] { Properties.Resources.err_message_search_to_hour, "0", "23" });
                            return(false);
                        }
                    }

                    // 入力の場合
                    if (!CheckUtil.IsNullOrEmpty(toMin))
                    {
                        // 半角数値かチェック
                        if (!CheckUtil.IsHankakuNum(toMin))
                        {
                            CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                         new string[] { Properties.Resources.err_message_search_to_min, "0", "59" });
                            return(false);
                        }
                        // 分入力が正しいかチェック
                        if (!CheckUtil.IsMin(Convert.ToInt16(toMin)))
                        {
                            CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_017,
                                                         new string[] { Properties.Resources.err_message_search_to_min, "0", "59" });
                            return(false);
                        }
                    }
                    //日付チェック
                    if (Convert.ToInt16(toDay) > DateTime.DaysInMonth(Convert.ToInt16(toYear), Convert.ToInt16(toMonth)))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_018,
                                                     new string[] { Properties.Resources.err_message_search_to_date });
                        return(false);
                    }
                }
            }

            try
            {
                if (CheckUtil.IsNullOrEmpty(tbxJobnetId.Text))
                {
                    regexJobnetId = null;
                }
                else
                {
                    regexJobnetId = new Regex("^" + tbxJobnetId.Text + "$");
                }

                if (CheckUtil.IsNullOrEmpty(tbxJobId.Text))
                {
                    regexJobId = null;
                }
                else
                {
                    regexJobId = new Regex("^" + tbxJobId.Text + "$");
                }

                if (CheckUtil.IsNullOrEmpty(combUserName.Text))
                {
                    regexUserName = null;
                }
                else
                {
                    regexUserName = new Regex("^" + combUserName.Text + "$");
                }
            }
            catch (Exception ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_020);
                return(false);
            }
            return(true);
        }