/// <summary> /// Updates or inserts an Application. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1Save_Click(object sender, EventArgs e) { // all boxes must be filled in if (!textBox1ApplicationName.Text.Equals("") && !textBox1CurrentVersion.Text.Equals("") && !textBox1Description.Text.Equals("")) { dataLayer.Application curApp = (dataLayer.Application)listBox1Applications.SelectedItem; curApp.AppName = textBox1ApplicationName.Text; curApp.AppVersion = textBox1CurrentVersion.Text; curApp.AppDesc = textBox1Description.Text; curApp.Save(); PopulateApplicationPage(); // update the list UpdateAppComboBox(); // udpate combo box on bug page MessageBox.Show(this, "App saved.", "Success"); } // else pop up else { MessageBox.Show(this, "No field Can be left blank.", "Form Error"); } }
/// <summary> /// Fills the application page/tab with data /// </summary> private void PopulateApplicationPage() { // get all apps List <dataLayer.Application> apps = dataLayer.Applications.GetAllApplications(); dataLayer.Application newApp = new dataLayer.Application(); newApp.AppName = " < Add New > "; apps.Insert(0, newApp); listBox1Applications.DataSource = apps; listBox1Applications.DisplayMember = "AppName"; }
public void UpdateAppComboBox() { // get all apps List <dataLayer.Application> apps = dataLayer.Applications.GetAllApplications(); dataLayer.Application newApp = new dataLayer.Application(); newApp.AppName = "<Select Application>"; apps.Insert(0, newApp); comboBox2SelectApplication.DataSource = apps; comboBox2SelectApplication.DisplayMember = "AppName"; }
/// <summary> /// Deletes an app from the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1Delete_Click(object sender, EventArgs e) { if (listBox1Applications.SelectedIndex > 0) { dataLayer.Application app = (dataLayer.Application)listBox1Applications.SelectedItem; if (app.Delete()) { MessageBox.Show(this, "App Deleted.", "Success"); PopulateApplicationPage(); // clear controls labelVal1ApplicationId.Text = ""; textBox1ApplicationName.Text = ""; textBox1CurrentVersion.Text = ""; textBox1Description.Text = ""; UpdateBugList(); // update bug list to not show this app } else { MessageBox.Show(this, "Cannot delete app, bug data exists.", "Error"); } } }