private void jobNameComboBox_SelectedIndexChanged(object sender, EventArgs e) { jobNumberComboBox.SelectedIndex = jobNameComboBox.SelectedIndex; if (jobNameComboBox.SelectedIndex != -1 || jobNumberComboBox.SelectedIndex != -1) { jobControls loadSelectedJob = new jobControls(Username); loadSelectedJob.loadJob(jobNumberComboBox.Text); if (loadSelectedJob.JobCode != null) { if (jobCodesComboBox.Items.Contains(loadSelectedJob.JobCode)) { jobCodesComboBox.SelectedItem = loadSelectedJob.JobCode; } jobStartDateTimePicker.Value = loadSelectedJob.StartDate; jobEndDateTimePicker.Value = loadSelectedJob.EndDate; jobEstimateTextBox.Text = Convert.ToString(loadSelectedJob.JobEstimateCost); JobStatus = loadSelectedJob.JobStatus; jobNotesTextBox.Text = loadSelectedJob.JobNotes; string[] jobEmployList = loadSelectedJob.jobEmployees; employeeListBox.Items.Clear(); if (jobEmployList != null) { for (int i = 0; i < jobEmployList.Length; i++) { employeeListBox.Items.Add(jobEmployList[i]); } } } lastTimeUpdateLabel.Text = "Last Time Updated: \n" + File.GetLastWriteTime(DirectoryName + jobNumberComboBox.Text + JOBFILEEXTENSHION).ToShortDateString() + "\n" + File.GetLastWriteTime(DirectoryName + jobNumberComboBox.Text + JOBFILEEXTENSHION).ToShortTimeString(); jobNameComboBox.Enabled = false; jobNumberComboBox.Enabled = false; jobControlPanel.Visible = true; saveJobButton.Visible = true; saveJobToolStripMenuItem.Visible = true; deleteJobBtn.Visible = true; deleteJobToolStripMenuItem.Visible = true; editJobToolStripMenuItem.Visible = true; editJobNameButton.Visible = true; loadSelectedJob = null; } else { jobNameComboBox.Enabled = true; jobNumberComboBox.Enabled = true; jobControlPanel.Visible = false; deleteJobBtn.Visible = false; saveJobButton.Visible = false; saveJobToolStripMenuItem.Visible = false; deleteJobToolStripMenuItem.Visible = false; editJobToolStripMenuItem.Visible = false; editJobNameButton.Visible = false; } }
public editJob(string recivedUsername, string selectedJobNumber) { InitializeComponent(); fillJobCodesList(); int cutAt = selectedJobNumber.IndexOf(" "); selectedJobNumber = selectedJobNumber.Remove(cutAt); jobNumberLabel.Text = selectedJobNumber; jobNumber = selectedJobNumber; currentUsername = recivedUsername; userNameLabel.Text = currentUsername; this.Text = String.Format("Edit Job For {0}", currentUsername); jobControls loadSelectedJob = new jobControls(currentUsername); loadSelectedJob.loadJob(selectedJobNumber); if (!String.IsNullOrWhiteSpace(loadSelectedJob.JobCode)) { if (jobCodesComboBox.Items.Contains(loadSelectedJob.JobCode)) { jobCodesComboBox.SelectedItem = loadSelectedJob.JobCode; } jobName = loadSelectedJob.JobName; jobStartDateTimePicker.Value = loadSelectedJob.StartDate; jobEndDateTimePicker.Value = loadSelectedJob.EndDate; jobEstimateTextBox.Text = Convert.ToString(loadSelectedJob.JobEstimateCost); JobStatus = loadSelectedJob.JobStatus; jobNotesTextBox.Text = loadSelectedJob.JobNotes; string[] jobEmployList = loadSelectedJob.jobEmployees; employeeListBox.Items.Clear(); if (jobEmployList != null) { for (int i = 0; i < jobEmployList.Length; i++) { employeeListBox.Items.Add(jobEmployList[i]); } } } DateTime lastWriteTime = File.GetLastWriteTime(REQUIREDFOLDER + currentUsername + "\\" + selectedJobNumber + JOBFILEEXTENSHION); lastTimeUpdateLabel.Text = String.Format("Last Time Updated: {0}{1}{2}{3}", Environment.NewLine, lastWriteTime.ToShortDateString(), Environment.NewLine, lastWriteTime.ToShortDateString()); jobNameLabel.Text = JobName; }