Exemple #1
0
        private void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            _openJob = new Job();

            if (!CheckFields())
            {
                MessageBox.Show("Something is missing. Enter as much detail as possible.", "Can't save!",
                    MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            // Update the job object
            _openJob.SqlOnly = SqlOnlyCheckBox.IsChecked ?? false;
            _openJob.IsOffshore = OffshoreCheckBox.IsChecked ?? false;
            _openJob.JobNumber = int.Parse(JobNumberTextBox.Text);
            _openJob.Comment = CommentTextBox.Text;
            _openJob.HasDepend = HasDependCheckBox.IsChecked ?? false;
            _openJob.DependNote = DependNoteTextBox.Text;

            // Things that are for non-SQL only jobs go in here
            if (_openJob.SqlOnly)
            {
                _openJob.JobRevision = 0;
                _openJob.AppBuild = 0;
                _openJob.CvsBranch = string.Empty;
                _openJob.FilesList = null;
            }
            else
            {
                _openJob.JobRevision = int.Parse(JobRevisionTextBox.Text);
                _openJob.AppBuild = int.Parse(AppBuildTextBox.Text);
                _openJob.CvsBranch = CvsBranchTextBox.Text;
                _openJob.FilesList = new List<string>();
                foreach (string item in FilesChangedListBox.Items)
                    _openJob.FilesList.Add(item);
            }

            if (!string.IsNullOrEmpty(_jobPath))
            {
                _openJob.Save(_jobPath);
                return;
            }

            var saveDialog = new SaveFileDialog
            {
                FileName = _openJob.JobNumber.ToString(),
                DefaultExt = ".yml",
                Filter = "YAML Files (*.yml)|*.yml"
            };
            var result = saveDialog.ShowDialog();

            if (result == true)
            {
                _openJob.Save(saveDialog.FileName);
                _jobPath = saveDialog.FileName;
            }
        }