Exemplo n.º 1
0
        private void Runner_Shown(object sender, EventArgs e)
        {
            using (JobManager jobManager = new JobManager())
            {
                jobManager.ConnectionString = _connectionString;
                jobManager.Initialize();

                DataTable jobs = jobManager.GetAllJobs();

                foreach (DataRow job in jobs.Rows)
                    jobsComboBox.Items.Add(job["name"].ToString().Trim());

                jobsComboBox.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        private void saveJobButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text.Trim().Length == 0)
            {
                MessageBox.Show("Name can't empty", "Error with input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_jobDetails.Rows.Count == 0)
            {
                MessageBox.Show("No items to add into job", "Error with input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (JobManager jobManager = new JobManager())
            {
                jobManager.ConnectionString = _connectionString;
                jobManager.Initialize();

                string jobName = nameTextBox.Text.Trim();

                try
                {
                    string msg = "";
                    if (_currentMode == Modes.Add)
                    {
                        jobManager.AddJob(jobName, _jobDetails);
                        msg = "Job created!";
                    }
                    else if (_currentMode == Modes.Edit)
                    {
                        int id = jobManager.GetJob(jobsComboBox.SelectedItem.ToString().Trim()).Id;
                        jobManager.ModifyJob(id, jobName, _jobDetails);
                        _currentMode = Modes.EditInit;
                        msg = "Job modified!";
                    }

                    MessageBox.Show(msg, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    InitializeForm();
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Error with input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Fatal, Contact admin", "Error with input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 3
0
        private void InitializeForm()
        {
            if (_currentMode == Modes.Add)
            {
                jobSelectPanel.Visible = false;
                _jobDetails.Rows.Clear();
                nameTextBox.Text = "";
                InitializeAddSections();
                nameTextBox.Focus();
                this.Text = "Create a Job";
            }
            else if (_currentMode == Modes.EditInit)
            {
                jobSelectPanel.Enabled = true;
                _jobDetails.Rows.Clear();
                jobsComboBox.Items.Clear();

                using (JobManager jobManager = new JobManager())
                {
                    jobManager.ConnectionString = _connectionString;
                    jobManager.Initialize();

                    DataTable jobs = jobManager.GetAllJobs();

                    foreach (DataRow job in jobs.Rows)
                        jobsComboBox.Items.Add(job["name"].ToString().Trim());

                    jobsComboBox.SelectedIndex = 0;
                }

                detailsPanel.Enabled = false;
                this.Text = "Edit a Job";

                jobsComboBox.Focus();
            }
            else if (_currentMode == Modes.Edit)
            {
                jobSelectPanel.Enabled = false;
                detailsPanel.Enabled = true;
                nameTextBox.Focus();
            }
        }
Exemplo n.º 4
0
        private void editButton_Click(object sender, EventArgs e)
        {
            string jobName = jobsComboBox.SelectedItem.ToString();

            using (JobManager jobManager = new JobManager())
            {
                jobManager.ConnectionString = _connectionString;
                jobManager.Initialize();

                _jobDetails.Rows.Clear();
                _jobDetails.Merge(jobManager.GetJobDetails(jobName));

                nameTextBox.Text = jobName.Trim();

                _currentMode = Modes.Edit;
                InitializeForm();
            }
        }