void PopulateForm() { dtpCompletedDateTime.Format = dtpStartedDateTime.Format = dtpStatusDateTime.Format = dtpWaitForDateTime.Format = DateTimePickerFormat.Time; if (_taskQueueItem == null) // add new item { btnSave.Text = "Add"; tbTaskQueueCode.Text = _daMgr.GetNextUniqueId(TaskProcessing.Constants.TaskQueueCode, 1, Int32.MaxValue, 1).ToString(); dtpCompletedDateTime.Enabled = dtpStartedDateTime.Enabled = dtpWaitForDateTime.Enabled = false; cbCompletedDtNull.Checked = cbStartedDtNull.Checked = cbWaitedDtNull.Checked = true; dtpStatusDateTime.Visible = lblStatusDateTime.Visible = false; cbWaitForTasks.Enabled = btnDelDepTask.Enabled = btnAddDepTask.Enabled = btnChangeDepTask.Enabled = false; } else // change item { TaskProcessing.TaskProcessingQueue.StatusCodeEnum status = (TaskProcessing.TaskProcessingQueue.StatusCodeEnum) Convert.ToByte(_taskQueueItem[TaskProcessing.Constants.StatusCode]); rbTPQFailed.Enabled = rbTPQInProcess.Enabled = rbTPQSucceeded.Enabled = false; if (status == TaskProcessing.TaskProcessingQueue.StatusCodeEnum.InProcess) { btnSave.Enabled = false; } else { btnSave.Enabled = true; } btnSave.Text = "Change"; tbTaskQueueCode.Text = _taskQueueItem[TaskProcessing.Constants.TaskQueueCode].ToString(); LoadTaskIds(); cmbTaskId.SelectedItem = _taskQueueItem[TaskProcessing.Constants.TaskId].ToString(); nudPriority.Value = Convert.ToByte(_taskQueueItem[TaskProcessing.Constants.PriorityCode]); if (_taskQueueItem[TaskProcessing.Constants.CompletedDateTime] != DBNull.Value) { dtpCompletedDateTime.Value = Convert.ToDateTime(_taskQueueItem[TaskProcessing.Constants.CompletedDateTime]); } else { cbCompletedDtNull.Checked = true; dtpCompletedDateTime.Enabled = false; } dtpStatusDateTime.Value = Convert.ToDateTime(_taskQueueItem[TaskProcessing.Constants.StatusDateTime]); if (_taskQueueItem[TaskProcessing.Constants.StartedDateTime] != DBNull.Value) { dtpStartedDateTime.Value = Convert.ToDateTime(_taskQueueItem[TaskProcessing.Constants.StartedDateTime]); } else { cbStartedDtNull.Checked = true; dtpStartedDateTime.Enabled = false; } if (_taskQueueItem[TaskProcessing.Constants.WaitForDateTime] != DBNull.Value) { dtpWaitForDateTime.Value = Convert.ToDateTime(_taskQueueItem[TaskProcessing.Constants.WaitForDateTime]); } else { cbWaitedDtNull.Checked = true; dtpWaitForDateTime.Enabled = false; } tbTaskParams.Text = _taskQueueItem[TaskProcessing.Constants.TaskParameters].ToString(); tbTaskRemarks.Text = _taskQueueItem[TaskProcessing.Constants.TaskRemark].ToString(); tbWaitForEngine.Text = _taskQueueItem[TaskProcessing.Constants.WaitForEngineId].ToString(); tbWaitForConfig.Text = _taskQueueItem[TaskProcessing.Constants.WaitForConfigId].ToString(); if (_taskQueueItem[TaskProcessing.Constants.WaitForNoUsers] != DBNull.Value) { cbWaitNoUsers.Checked = Convert.ToBoolean(_taskQueueItem[TaskProcessing.Constants.WaitForNoUsers]); } cbWaitForTasks.Checked = Convert.ToBoolean(_taskQueueItem[TaskProcessing.Constants.WaitForTasks]); btnAddDepTask.Enabled = btnChangeDepTask.Enabled = btnDelDepTask.Enabled = cbWaitForTasks.Checked; tbIntervalCount.Text = _taskQueueItem[TaskProcessing.Constants.IntervalCount].ToString(); if (_taskQueueItem[TaskProcessing.Constants.IntervalSecondsRequeue] != DBNull.Value) { nudIntervalRequeueSec.Value = Convert.ToInt32(_taskQueueItem[TaskProcessing.Constants.IntervalSecondsRequeue]); } } }