/// <summary> /// This is a function that collects all applications /// </summary> private void LoadApplicationsList() { try { DataLayer.App apps = new DataLayer.App(); List <DataLayer.Apps> appsList = apps.GetList(); List <DataLayer.Apps> appsListForBugs = apps.GetList(); appsList.Insert(0, new DataLayer.Apps() { AppName = "<Add New>" }); appsListForBugs.Insert(0, new DataLayer.Apps() { AppName = "<Select A App>" }); listBoxApps.DataSource = appsList; // apps.GetList(); listBoxApps.DisplayMember = "AppName"; appsComboBox.DataSource = appsListForBugs; appsComboBox.DisplayMember = "AppName"; } catch (SqlException sqlex) { //connection error... DisplayErrorMessage(sqlex.Message); } }
/// <summary> /// This function will handle what to do when the app delete button is clicked /// </summary> /// <param name="sender">This is the paramater for sender</param> /// <param name="e">This is the paramater for EventAtgs</param> private void appDeleteButton_Click(object sender, EventArgs e) { DataLayer.Apps selectedApp = (DataLayer.Apps)listBoxApps.SelectedValue; DataLayer.App apps = new DataLayer.App(); int getAppID = selectedApp.AppID; int checkedAppForBug = apps.CheckAppsForBugs(getAppID); DialogResult result = MessageBox.Show("Are You Sure You Want To Delete Application?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { if (checkedAppForBug == 0) { try { apps.DeleteApplication(getAppID); //reload the log table to display new log data List <DataLayer.Apps> appsList = apps.GetList(); appsList.Insert(0, new DataLayer.Apps() { AppName = "<Add New>" }); listBoxApps.DataSource = appsList; // apps.GetList(); listBoxApps.DisplayMember = "AppName"; appsComboBox.DataSource = appsList; // apps.GetList(); appsComboBox.DisplayMember = "AppName"; } catch (SqlException sqlex) { DisplayErrorMessage(sqlex.Message); } } else { MessageBox.Show("You Can Not Delete Apps With Bugs"); } } else if (result == DialogResult.No) { //code for No } else if (result == DialogResult.Cancel) { //code for Cancel } }
/// <summary> /// This was a test function to make sure that the application lists will always update on the bug page /// Even if a new app is added or an app is deleted /// </summary> /// <param name="sender">This is the paramater for sender</param> /// <param name="e">This is the paramater for EventAtgs</param> private void bugsTab_Click(object sender, EventArgs e) { DataLayer.Apps selectedApp = (DataLayer.Apps)listBoxApps.SelectedValue; DataLayer.App apps = new DataLayer.App(); List <DataLayer.Apps> appsList = apps.GetList(); appsList.Insert(0, new DataLayer.Apps() { AppName = "<Add New>" }); appsComboBox.DataSource = appsList; // apps.GetList(); appsComboBox.DisplayMember = "AppName"; }
/// <summary> /// This is the function that will handle the event when the save button is clicked for save application /// </summary> /// <param name="sender">This is the paramater for sender</param> /// <param name="e">This is the paramater for EventAtgs</param> private void appSaveButton_Click(object sender, EventArgs e) { try { // A search must first be performed if (appNameTextBox.Text.Length > 0 && appVersionTextBox.Text.Length > 0 && appDescTextBox.Text.Length > 0 && appIdTextBox.Text.Length > 0) { DataLayer.App apps = new DataLayer.App(); int AppID = int.Parse(appIdTextBox.Text); apps.UpdateApplications(appNameTextBox.Text, appVersionTextBox.Text, appDescTextBox.Text, AppID); //reload the data to refresh the hidden fields //buttonGetEmployee_Click(sender, null); List <DataLayer.Apps> appsList = apps.GetList(); appsList.Insert(0, new DataLayer.Apps() { AppName = "<Add New>" }); listBoxApps.DataSource = appsList; // apps.GetList(); listBoxApps.DisplayMember = "AppName"; appsComboBox.DataSource = appsList; // apps.GetList(); appsComboBox.DisplayMember = "AppName"; } else if (appNameTextBox.Text.Length > 0 && appVersionTextBox.Text.Length > 0 && appDescTextBox.Text.Length > 0 && appIdTextBox.Text.Length == 0) { DataLayer.App apps = new DataLayer.App(); apps.AddApplication(appNameTextBox.Text, appVersionTextBox.Text, appDescTextBox.Text); List <DataLayer.Apps> appsList = apps.GetList(); appsList.Insert(0, new DataLayer.Apps() { AppName = "<Add New>" }); listBoxApps.DataSource = appsList; // apps.GetList(); listBoxApps.DisplayMember = "AppName"; appsComboBox.DataSource = appsList; // apps.GetList(); appsComboBox.DisplayMember = "AppName"; } else { MessageBox.Show("Please Fill In All Fields"); } } catch (SqlException sqlex) { DisplayErrorMessage(sqlex.Message); } }