Beispiel #1
0
        // TODO:リストビューのインデックス直指定の変更。
        private void List_Task_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TaskData taskData = new Data.TaskData();

            // 更新タスクの取得 LoadForm_Task_Select(タスクNo, ユーザーNo)
            Task task_Update = taskData.LoadForm_Task_Select(ListView_Task.SelectedItems[0].SubItems[9].Text, TextBox_UserNo.Text);

            // タスク更新画面
            Form_TaskUpdate f_TaskUpdate = new Form_TaskUpdate(task_Update);

            f_TaskUpdate.ShowDialog(this);
            f_TaskUpdate.Dispose();

            // タスク一覧の再検索および表示
            this.TaskListSelectForListView();
        }
Beispiel #2
0
        private void ButtonTaskAddClick(object sender, EventArgs e)
        {
            #region エラー制御
            // 期限日が空の場合はエラー
            if (TextBox_TodoDay_Add.Text == "")
            {
                MessageBox.Show("期限日を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 期限日が日付型に変換できない場合はエラー
            if (!DateTime.TryParse(TextBox_TodoDay_Add.Text, out DateTime dt))
            {
                MessageBox.Show("期限日には日付を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                TextBox_TodoDay_Add.Clear();

                return;
            }

            // 予定時間が空の場合はエラー
            if (TextBox_PlanTime_Add.Text == "")
            {
                MessageBox.Show("予定時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 予定時間が時間型に変換できない場合はエラー
            if (!TimeSpan.TryParse(TextBox_PlanTime_Add.Text, out TimeSpan ts))
            {
                MessageBox.Show("予定時間には時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                TextBox_PlanTime_Add.Clear();

                return;
            }

            // 種別が空の場合はエラー
            if (ComboBox_KindName_Add.Text == "")
            {
                MessageBox.Show("種別を選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が空の場合はエラー
            if (TextBox_TaskName_Add.Text == "")
            {
                MessageBox.Show("タスク内容を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が50バイトを超える場合はエラー
            if (Encoding.GetEncoding("Shift_JIS").GetByteCount(TextBox_TaskName_Add.Text) > 100)
            {
                MessageBox.Show("タスク内容は最大全角50文字です。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }
            #endregion

            // 追加タスクのステータスは、「未」(01)で固定。
            Code taskStatusCodeForAdd = new Code(Constants.TaskStatus.UNCOMPLETED_01);
            Code taskKindCodeForAdd   = new Code(TextBox_KindCode_Add.Text);
            Code taskGroupCodeForAdd  = new Code(TextBox_GroupCode_Add.Text);

            TaskData taskData = new Data.TaskData();

            Task taskAdd = new Task(
                // 追加タスクのタスクNoを取得する。ユーザ毎(最大タスクNo+1)
                taskData.Get_TaskNo_Max(TextBox_UserNo.Text),
                TextBox_UserNo.Text,
                taskStatusCodeForAdd,
                taskKindCodeForAdd,
                taskGroupCodeForAdd,
                TextBox_TaskName_Add.Text,
                planTime: TimeSpan.Parse(TextBox_PlanTime_Add.Text),
                // 追加タスクに実績時間はゼロ分
                resultTime: new TimeSpan(0),
                memo: "",
                createYmd: DateTime.Today,
                updateYmd: DateTime.Parse("1900/01/01"),
                todoYmd: DateTime.Parse(TextBox_TodoDay_Add.Text),
                finishedYmd: DateTime.Parse("1900/01/01")
                );

            // タスクの追加処理
            taskData.Task_Insert(taskAdd);

            // タスク一覧の再検索および表示
            this.TaskListSelectForListView();

            // 画面のタスク追加設定の初期化
            TextBox_PlanTime_Add.Text = "";
            TextBox_TaskName_Add.Text = "";
        }
Beispiel #3
0
        private void Button_End_Update_Click(object sender, EventArgs e)
        {
            #region エラー制御
            // 期限日が空の場合、エラー
            if (TextBox_TodoDay_Update.Text == "")
            {
                MessageBox.Show("期限日を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 期限日が日付型に変換できない場合はエラー
            if (!DateTime.TryParse(TextBox_TodoDay_Update.Text, out DateTime dt))
            {
                MessageBox.Show("期限日には日付を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 予定時間が空の場合、エラー
            if (TextBox_PlanTime_Update.Text == "")
            {
                MessageBox.Show("予定時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 予定時間が時間型に変換できない場合はエラー
            if (!TimeSpan.TryParse(TextBox_PlanTime_Update.Text, out TimeSpan ts))
            {
                MessageBox.Show("予定時間には時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 実績時間が時間型に変換できない場合はエラー
            if (TextBox_ResultTime_Update.Text != "" && TextBox_ResultTime_Update.Text != null && !TimeSpan.TryParse(TextBox_ResultTime_Update.Text, out TimeSpan ts_Result))
            {
                MessageBox.Show("実績時間には時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 状況が空の場合、エラー
            if (ComboBox_StatusName_Update.Text == "")
            {
                MessageBox.Show("種別を選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 種別が空の場合、エラー
            if (ComboBox_KindName_Update.Text == "")
            {
                MessageBox.Show("種別を選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が空の場合、エラー
            if (TextBox_TaskName_Update.Text == "")
            {
                MessageBox.Show("タスク内容を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が50バイトを超える場合はエラー
            if (Encoding.GetEncoding("Shift_JIS").GetByteCount(TextBox_TaskName_Update.Text) > 100)
            {
                MessageBox.Show("タスク内容は最大50文字です。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }
            #endregion

            #region 更新確認処理
            DialogResult dr_YESNO = MessageBox.Show("タスクを完了しますか?",
                                                    "完了",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Information);

            // 「いいえ」を選択した場合、画面戻る。
            if (dr_YESNO == DialogResult.No)
            {
                return;
            }
            #endregion

            // 完了処理時は、ステータスは"10"(完了)固定
            Code taskStatusCodeForCompleted = new Code(Constants.TaskStatus.COMPLETED_10);
            Code taskKindCodeForCompleted   = new Code(TextBox_KindCode_Update.Text);
            Code taskGroupCodeForCompleted  = new Code(TextBox_GroupCode_Update.Text);

            Task taskUpdate = new Task(
                TextBox_TaskNo_Update.Text,
                TextBox_UserNo_Update.Text,
                taskStatusCodeForCompleted,
                taskKindCodeForCompleted,
                taskGroupCodeForCompleted,
                TextBox_TaskName_Update.Text,
                TimeSpan.Parse(TextBox_PlanTime_Update.Text),
                // 実績テキストボックスが空文字かNULLの場合はラベルを採用
                TimeSpan.Parse(TextBox_ResultTime_Update.Text == ""
                  ? Label_ResultTime_Update.Text
                  : TextBox_ResultTime_Update.Text ?? Label_ResultTime_Update.Text),
                TextBox_Memo_Update.Text,
                DateTime.Parse(TextBox_PlanTime_Update.Text),
                DateTime.Today,
                DateTime.Parse(TextBox_TodoDay_Update.Text),
                DateTime.Today
                );

            // タスクデータインスタンス生成
            TaskData taskData = new Data.TaskData();

            // タスク更新
            taskData.Task_Update(taskUpdate);

            #region 更新通知処理
            DialogResult dr_OK = MessageBox.Show("更新が完了しました。",
                                                 "完了",
                                                 MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information);
            #endregion

            // 更新画面をクローズ
            this.Close();
            return;
        }
Beispiel #4
0
        private void Button_Delete_Update_Click(object sender, EventArgs e)
        {
            #region エラー制御
            // 期限日が空の場合、エラー
            if (TextBox_TodoDay_Update.Text == "")
            {
                MessageBox.Show("期限日を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 期限日が日付型に変換できない場合はエラー
            if (!DateTime.TryParse(TextBox_TodoDay_Update.Text, out DateTime dt))
            {
                MessageBox.Show("期限日には日付を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 予定時間が空の場合、エラー
            if (TextBox_PlanTime_Update.Text == "")
            {
                MessageBox.Show("予定時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 予定時間が時間型に変換できない場合はエラー
            if (!TimeSpan.TryParse(TextBox_PlanTime_Update.Text, out TimeSpan ts))
            {
                MessageBox.Show("予定時間には時間を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 状況が空の場合、エラー
            if (ComboBox_StatusName_Update.Text == "")
            {
                MessageBox.Show("種別を選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // 種別が空の場合、エラー
            if (ComboBox_KindName_Update.Text == "")
            {
                MessageBox.Show("種別を選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が空の場合、エラー
            if (TextBox_TaskName_Update.Text == "")
            {
                MessageBox.Show("タスク内容を入力してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }

            // タスク内容が50バイトを超える場合はエラー
            if (Encoding.GetEncoding("Shift_JIS").GetByteCount(TextBox_TaskName_Update.Text) > 100)
            {
                MessageBox.Show("タスク内容は最大50文字です。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return;
            }
            #endregion

            #region 削除確認処理
            DialogResult dr_YESNO = MessageBox.Show("タスクを削除しますか?",
                                                    "削除",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Information);

            // 「いいえ」を選択した場合、画面戻る。
            if (dr_YESNO == DialogResult.No)
            {
                return;
            }
            #endregion

            // 削除処理時は、ステータスは"20"(削除)固定
            Code taskStatusCodeForDelete = new Code(Constants.TaskStatus.DELETE_20);

            Task TaskDelete = new Task(
                TextBox_TaskNo_Update.Text,
                TextBox_UserNo_Update.Text,
                taskStatusCodeForDelete,
                memo: TextBox_Memo_Update.Text,
                updateYmd: DateTime.Today
                );

            // タスクデータインスタンス生成
            TaskData taskData = new Data.TaskData();

            // タスク更新
            taskData.Task_Delete(TaskDelete);

            #region 更新通知処理
            DialogResult dr_OK = MessageBox.Show("削除が完了しました。",
                                                 "削除",
                                                 MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information);
            #endregion

            // 更新画面をクローズ
            this.Close();
            return;
        }
Beispiel #5
0
        /*★★TODO 重複記述のリファクタリング ストップウォッチ開始/終了処理★★*/
        #region 開始/中断ボタン押下処理
        private void Button_Start_Update_Click(object sender, EventArgs e)
        {
            #region 開始ボタン押下処理
            if (sw_Switch == false)
            {
                // 計測開始
                myStopWatch.Start();

                // 表示更新タイマー開始
                Timer_ResultTime_Update.Start();

                // スイッチON
                sw_Switch = true;

                // ボタンの表示テキストを変更
                Button_Start_Update.Text = "中断";

                // 時間計測の初期値
                start_ResultTime = TimeSpan.Parse(TextBox_ResultTimeReadOnly_Update.Text);

                #region ボタンの状態設定
                TextBox_TodoDay_Update.Enabled      = false;
                TextBox_PlanTime_Update.Enabled     = false;
                ComboBox_KindName_Update.Enabled    = false;
                ComboBox_GroupName_Update.Enabled   = false;
                TextBox_TaskName_Update.Enabled     = false;
                TextBox_ResultTime_Update.Enabled   = false;
                ComboBox_StatusName_Update.Enabled  = false;
                Button_Update_Update.Enabled        = false;
                Button_Delete_Update.Enabled        = false;
                Button_Return_Update.Enabled        = false;
                TextBox_UserNo_Update.BackColor     = Color.White;
                TextBox_UserNo_Update.ForeColor     = Color.Black;
                TextBox_TodoDay_Update.BackColor    = Color.White;
                TextBox_TodoDay_Update.ForeColor    = Color.Black;
                TextBox_PlanTime_Update.BackColor   = Color.White;
                TextBox_PlanTime_Update.ForeColor   = Color.Black;
                TextBox_TaskName_Update.BackColor   = Color.White;
                TextBox_TaskName_Update.ForeColor   = Color.Black;
                TextBox_ResultTime_Update.BackColor = Color.White;
                TextBox_ResultTime_Update.ForeColor = Color.Black;
                #endregion
            }
            #endregion

            #region 中断ボタン押下処理
            else if (sw_Switch == true)
            {
                //計測終了
                myStopWatch.Stop();

                //表示固定
                Timer_ResultTime_Update.Stop();

                //スイッチOFF
                sw_Switch = false;

                // ボタンの表示テキストを変更
                Button_Start_Update.Text = "開始";

                #region 中断状態のタスクを更新
                Task taskStop = new Task(
                    TextBox_TaskNo_Update.Text,
                    TextBox_UserNo_Update.Text,
                    resultTime: TimeSpan.Parse(Label_ResultTime_Update.Text),
                    memo: TextBox_Memo_Update.Text
                    );

                // タスクデータインスタンス生成
                TaskData taskData = new Data.TaskData();

                // タスク更新
                taskData.Task_Stop(taskStop);
                #endregion

                #region インスタンス状態設定
                TextBox_TodoDay_Update.Enabled      = true;
                TextBox_PlanTime_Update.Enabled     = true;
                ComboBox_KindName_Update.Enabled    = true;
                ComboBox_GroupName_Update.Enabled   = true;
                TextBox_TaskName_Update.Enabled     = true;
                ComboBox_StatusName_Update.Enabled  = true;
                TextBox_ResultTime_Update.Enabled   = true;
                Button_Update_Update.Enabled        = true;
                Button_Delete_Update.Enabled        = true;
                Button_Return_Update.Enabled        = true;
                TextBox_UserNo_Update.BackColor     = Color.White;
                TextBox_UserNo_Update.ForeColor     = Color.Black;
                TextBox_TodoDay_Update.BackColor    = Color.White;
                TextBox_TodoDay_Update.ForeColor    = Color.Black;
                TextBox_PlanTime_Update.BackColor   = Color.White;
                TextBox_PlanTime_Update.ForeColor   = Color.Black;
                TextBox_TaskName_Update.BackColor   = Color.White;
                TextBox_TaskName_Update.ForeColor   = Color.Black;
                TextBox_ResultTime_Update.BackColor = Color.White;
                TextBox_ResultTime_Update.ForeColor = Color.Black;
                #endregion
            }
            #endregion
        }