//*******************************************************************
        /// <summary> DAOの初期化処理</summary>
        //*******************************************************************
        private void InitialDAO()
        {
            // フィルター管理テーブル
            _filterControlDAO = new FilterControlDAO(dbAccess);

            // カレンダー管理テーブル
            _calendarControlDAO = new CalendarControlDAO(dbAccess);
        }
Example #2
0
        //*******************************************************************
        /// <summary>登録ボタンをクリック</summary>
        /// <param name="sender">源</param>
        /// <param name="e">イベント</param>
        //*******************************************************************
        private void regist_Click(object sender, RoutedEventArgs e)
        {
            int interval = 0;

            int[] stHM = new int[2];
            int[] edHM = new int[2];

            string bootTime  = "";
            string startTime = "";

            string CycleInterval = "";

            string[] TmData = new string[4];


            // 開始ログ
            base.WriteStartLog("regist_Click", Consts.PROCESS_001);

            // 起動方法の判別
            if (container.rbStartTime.IsChecked == true)
            {
                // 起動時刻ラジオボタンを選択

                // 入力チェック
                if (!InputCheck(0, ref TmData))
                {
                    return;
                }
                // TmDataには時分に分解された起動時刻が格納されている

                // 起動時刻を取得
                bootTime = TmData[0] + TmData[1];

                if (bootTime.Length == 3)
                {
                    bootTime = "0" + bootTime;
                }
                DataRow[] rows = ParentContainer.ScheduleDetailTable.Select("calendar_id='" + _objectId + "' and boot_time='" + bootTime + "'");

                if (rows.Length < 1)
                {
                    DataRow row = ParentContainer.ScheduleDetailTable.NewRow();
                    row["calendar_id"] = _objectId;
                    row["boot_time"]   = bootTime;
                    row["schedule_id"] = ParentContainer.ScheduleId;
                    if (Consts.ObjectEnum.FILTER == _objectType)
                    {
                        row["object_flag"] = "1";
                        FilterControlDAO filterControlDAO = new FilterControlDAO(dbAccess);
                        DataTable        dt = filterControlDAO.GetValidORMaxUpdateDateEntityById(_objectId);
                        row["object_name"] = dt.Rows[0]["filter_name"];
                    }
                    else if (Consts.ObjectEnum.CALENDAR == _objectType)
                    {
                        row["object_flag"] = "0";
                        CalendarControlDAO calendarControlDAO = new CalendarControlDAO(dbAccess);
                        DataTable          dt = calendarControlDAO.GetValidORMaxUpdateDateEntityById(_objectId);
                        row["object_name"] = dt.Rows[0]["calendar_name"];
                    }
                    ParentContainer.ScheduleDetailTable.Rows.Add(row);
                }
            }
            else
            {
                // サイクル起動ラジオボタンを選択

                // 入力チェック
                if (!InputCheck(1, ref TmData))
                {
                    return;
                }
                // TmDataには時分に分解された開始時刻と終了時刻が格納されている

                // 開始時刻を取得
                stHM[0] = int.Parse(TmData[0]);
                stHM[1] = int.Parse(TmData[1]);

                // 終了時刻を取得
                edHM[0] = int.Parse(TmData[2]);
                edHM[1] = int.Parse(TmData[3]);

                // 間隔時間(分)を取得
                CycleInterval = container.textBox_CycleInterval.Text.Trim();

                interval = int.Parse(CycleInterval);

                TimeSpan t1 = new TimeSpan(stHM[0], stHM[1], 0);
                TimeSpan t2 = new TimeSpan(0, 0, 0);
                TimeSpan t3 = new TimeSpan(edHM[0], edHM[1], 0);

                // 開始時刻を取得
                startTime = TmData[0] + TmData[1];

                DataRow[] rows = ParentContainer.ScheduleDetailTable.Select("calendar_id='" + _objectId + "' and boot_time='" + startTime + "'");

                if (rows.Length < 1)
                {
                    for (; t1 <= t3; t1 = t1 + t2)
                    {
                        t2 = new TimeSpan(0, interval, 0);
                        DataRow row = ParentContainer.ScheduleDetailTable.NewRow();
                        row["calendar_id"] = _objectId;
                        row["boot_time"]   = t1.ToString("hhmm");
                        row["schedule_id"] = ParentContainer.ScheduleId;
                        if (Consts.ObjectEnum.FILTER == _objectType)
                        {
                            row["object_flag"] = "1";
                            FilterControlDAO filterControlDAO = new FilterControlDAO(dbAccess);
                            DataTable        dt = filterControlDAO.GetValidORMaxUpdateDateEntityById(_objectId);
                            row["object_name"] = dt.Rows[0]["filter_name"];
                        }
                        else if (Consts.ObjectEnum.CALENDAR == _objectType)
                        {
                            row["object_flag"] = "0";
                            CalendarControlDAO calendarControlDAO = new CalendarControlDAO(dbAccess);
                            DataTable          dt = calendarControlDAO.GetValidORMaxUpdateDateEntityById(_objectId);
                            row["object_name"] = dt.Rows[0]["calendar_name"];
                        }
                        ParentContainer.ScheduleDetailTable.Rows.Add(row);
                    }
                }
            }

            this.Close();
            // 終了ログ
            base.WriteEndLog("regist_Click", Consts.PROCESS_001);
        }