private void btnAddProduct_Click(object sender, EventArgs e) { InvestigationClass InvestigationToDelete = (InvestigationClass)InvestigationChooser.SelectedItem; if (InvestigationToDelete.ID == 0) { MessageBox.Show("Choose investigation to add product to it"); } else { AddProductView newWin = new AddProductView(InvestigationToDelete.ID); newWin.ShowDialog(); LoadOrRefresh(); } }
private void InvestigationChooser_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cmb = (ComboBox)sender; InvestigationClass SelectedInvestigation = (InvestigationClass)cmb.SelectedItem; SQLRequests SQLReq = new SQLRequests(); DisplayProductTable.Clear(); DisplayProductTable = SQLReq.GetProducts(SelectedInvestigation.ID); ProductList.DataSource = new BindingSource { DataSource = DisplayProductTable }; ProductList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; ProductList.Columns[1].Visible = false; ProductList.Columns[2].HeaderText = "Type"; ProductList.Columns[3].HeaderText = "Creation Date"; ProductList.Columns[6].Visible = false; }
private void btnDelInvestigation_Click(object sender, EventArgs e) { InvestigationClass InvestigationToDelete = (InvestigationClass)InvestigationChooser.SelectedItem; if (InvestigationToDelete.ID == 0) { MessageBox.Show("Choose investigation to delete"); } else { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this investigation?\nThis will delete all the products related to it.", "", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Thread thread = new Thread(() => DelItemThread(ItemToDelete.Investigation, InvestigationToDelete.ID, -1)); thread.Start(); } } }
public ObservableCollection <InvestigationClass> GetInvestigations() { ObservableCollection <InvestigationClass> ReturnList = new ObservableCollection <InvestigationClass>(); string connectionString = ConfigurationManager.ConnectionStrings["LEABrowser.Properties.Settings.LEADBConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection((connectionString))) { using (SqlCommand cmd = new SqlCommand("SELECT * FROM InvestigationTable", con)) { try { con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { InvestigationClass itemToAdd = new InvestigationClass(); itemToAdd.ID = int.Parse(reader["ID"].ToString()); itemToAdd.Name = reader["Name"].ToString(); itemToAdd.CreationDate = DateTime.Parse(reader["CreationDate"].ToString()); ReturnList.Add(itemToAdd); } reader.Close(); } } catch (Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } finally { if ((con != null) && (con.State == ConnectionState.Open)) { con.Close(); } } } } return(ReturnList); }