private void FormPCIBulkLoad_Load(object sender, EventArgs e) { if (dataAdapter != null) { dataAdapter.Dispose(); // Free up the resources } if (binding != null) { binding.Dispose(); } if (table != null) { table.Dispose(); } try { string strQuery; if (m_bIsLinear) { strQuery = "SELECT * FROM PCI_VALIDATION_LINEAR ORDER BY ROUTES, DIRECTION, BEGIN_STATION, END_STATION, DATE_"; } else { strQuery = "SELECT * FROM PCI_VALIDATION ORDER BY FACILITY, SECTION, DATE_, SAMPLE_"; } dataAdapter = new DataAdapter(strQuery); // Populate a new data table and bind it to the BindingSource. table = new DataTable(); table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); binding = new BindingSource(); binding.DataSource = table; dgvPCIBulkLoad.DataSource = binding; bindingNavigatorPCIValidation.BindingSource = binding; dgvPCIBulkLoad.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; if (m_bIsLinear) { Validation.LoadLRS(); } else { Validation.LoadSRS(); } } catch (Exception exception) { Global.WriteOutput("Error: Building current attribute view. SQL message is " + exception.Message); } foreach (DataGridViewColumn column in dgvPCIBulkLoad.Columns) { column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } }
private void Form1_Disposed(object sender, EventArgs e) { if (m_dataSet != null) { m_dataSet.Dispose(); } if (m_bindingSource != null) { m_bindingSource.Dispose(); } }
private void tbSearch_TextChanged(object sender, EventArgs e) { var list = eBin.List; var result = list.OfType <GED_PROC_CodigosBarras_Result>().Where(bc => bc.TPD_DESCRICAO.ToUpper().Contains((sender as TextBox).Text.ToUpper()) || bc.TPD_CODIGOBARRA.Contains((sender as TextBox).Text.ToUpper())); //bs.Filter = string.Format("TPD_DESCRICAO LIKE '%{0}%' OR TPD_CODIGOBARRA LIKE '%{1}%'", (sender as TextBox).Text, (sender as TextBox).Text); if (SearchBarCode != null) { SearchBarCode.Dispose(); } SearchBarCode = new BindingSource(result, ""); if ((sender as TextBox).Text.Equals("")) { this.dgvBarCodes.DataSource = eBin; if (SearchBarCode != null) { SearchBarCode.Dispose(); } } else { this.dgvBarCodes.DataSource = SearchBarCode; } this.dgvBarCodes.Refresh(); }
private void dgvMalade_DoubleClick(object sender, EventArgs e) { #region Chargement Data try { clsDoTraitement.Identifiant_Personne = Convert.ToInt32(dgvMalade["colid", dgvMalade.CurrentRow.Index].Value); clsDoTraitement.IdMalade = Convert.ToInt32(dgvMalade["colidMal", dgvMalade.CurrentRow.Index].Value); clsDoTraitement.idMaladeDossierPre = clsDoTraitement.IdMalade; clsDoTraitement.doubleclic_categorie_malade = clsMetier.GetInstance().getClscategoriemalade1(clsDoTraitement.IdMalade).Designation; clsDoTraitement.doubleclic_nom_malade = dgvMalade["colNom_complet", dgvMalade.CurrentRow.Index].Value.ToString(); clsDoTraitement.doubleclic_entreprise = clsMetier.GetInstance().getClsetablissementpriseencharge(clsDoTraitement.IdMalade).Denomination; clsDoTraitement.doubleclic_taux = clsMetier.GetInstance().getClscategoriemalade1(clsDoTraitement.IdMalade).Taux; clsDoTraitement.doubleclicRecherchePersonneMaladeDg = true; } catch (Exception ex) { MessageBox.Show(ex.Message + " >>>> Erreur lors de la récupération des informations", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } #endregion Fin Chargement Data //Déchargement du BindingSource et DataGrid bsrc_mal.Dispose(); dgvMalade.Dispose(); this.Dispose(); }
public void BindingNavigator_BindingSource_IsActual_AfterOldOneIsDisposed() { using BindingNavigator control = new BindingNavigator(true); int rowsCount1 = 3; BindingSource bindingSource1 = GetTestBindingSource(rowsCount1); int rowsCount2 = 5; BindingSource bindingSource2 = GetTestBindingSource(rowsCount2); control.BindingSource = bindingSource1; Assert.Equal(bindingSource1, control.BindingSource); Assert.Equal("1", control.PositionItem.Text); Assert.Equal($"of {rowsCount1}", control.CountItem.Text); control.BindingSource = bindingSource2; Assert.Equal(bindingSource2, control.BindingSource); Assert.Equal("1", control.PositionItem.Text); Assert.Equal($"of {rowsCount2}", control.CountItem.Text); bindingSource1.Dispose(); // bindingSource2 is actual for the BindingNavigator // so it will contain correct PositionItem and CountItem values // even after bindingSource1 is disposed. // This test checks that Disposed events unsubscribed correctly Assert.Equal(bindingSource2, control.BindingSource); Assert.Equal("1", control.PositionItem.Text); Assert.Equal($"of {rowsCount2}", control.CountItem.Text); }
private void dgvPersonne_DoubleClick(object sender, EventArgs e) { #region Chargement Data try { clsDoTraitement.Identifiant_Personne = Convert.ToInt32(dgvPersonne["colid", dgvPersonne.CurrentRow.Index].Value); clsDoTraitement.Identifiant_Fournisseur = Convert.ToInt32(dgvPersonne["colidFour", dgvPersonne.CurrentRow.Index].Value); clsDoTraitement.Numero_du_fournisseur = dgvPersonne["colnumero", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.FullNamePersonne = dgvPersonne["colNom_complet", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.NomPersonne = dgvPersonne["colNom", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.PostnomPersonne = dgvPersonne["colPostnom", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.PrenomPersonne = dgvPersonne["colPrenom", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.SexePersonne = dgvPersonne["colsexe", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.TelPersonne = dgvPersonne["coltelephone", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.EtatCivPersonne = dgvPersonne["coletatcivil", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.AdressePersonne = dgvPersonne["coladresse", dgvPersonne.CurrentRow.Index].Value.ToString(); clsDoTraitement.DatenaissancePersonne = (dgvPersonne["coldatenaissance", dgvPersonne.CurrentRow.Index].Value == DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(dgvPersonne["coldatenaissance", dgvPersonne.CurrentRow.Index].Value); clsDoTraitement.doubleclicRecherchePersonneFournisseurDg = true; } catch (Exception ex) { MessageBox.Show(ex.Message + " >>>> Erreur lors de la récupération des informations", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } #endregion Fin Chargement Data //Déchargement du BindingSource et DataGrid bsrc_pers.Dispose(); dgvPersonne.Dispose(); this.Dispose(); }
private void frmFormulaList_FormClosed(object sender, FormClosedEventArgs e) { dtMostly.Dispose(); //dtTempDel.Dispose(); dtFind_Date.Dispose(); myBds.Dispose(); }
private void cmdExit_Click(object sender, EventArgs e) { try { m_DataTable.Dispose(); } catch (Exception) { } try { m_DataTable2.Dispose(); } catch (Exception) { } try { m_BindingSource.Dispose(); } catch (Exception) { } try { m_DBCon.Dispose(); } catch (Exception) { } this.Close(); }
private void LoadDistressMapping() { string query = "SELECT * FROM PCI_DISTRESS"; if (pciDistressMapAdapter != null) { pciDistressMapAdapter.Dispose(); // Free up the resources } if (binding != null) { binding.Dispose(); } if (table != null) { table.Dispose(); } pciDistressMapAdapter = new DataAdapter(query); // Populate a new data table and bind it to the BindingSource. table = new DataTable(); table.Locale = System.Globalization.CultureInfo.InvariantCulture; pciDistressMapAdapter.Fill(table); binding = new BindingSource(); binding.DataSource = table; dgvDistressMapping.DataSource = binding; }
public void Dispose() { if (!Util.ObjectIsNull(cda)) { cda.Dispose(); } if (!Util.ObjectIsNull(ds)) { ds.Dispose(); } if (!Util.ObjectIsNull(bs)) { bs.CancelEdit(); bs.Dispose(); } if (!Util.ObjectIsNull(epda)) { epda.Connection.Close(); epda.Dispose(); } if (!Util.ObjectIsNull(eda)) { eda.Connection.Close(); eda.Dispose(); } if (!Util.ObjectIsNull(pda)) { pda.Connection.Close(); pda.Dispose(); } }
/// <summary> /// Releases the resources used by the control. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { _bindingSource?.Dispose(); _internalSource?.Dispose(); base.Dispose(disposing); }
/// <summary> /// Detaches this instance from its associated binding. /// </summary> protected override void OnDetached() { if (BindingSource != null) { BindingSource.Dispose(); } }
private void PackageSourcesOptionsControl_Disposed(object sender, EventArgs e) { Disposed -= PackageSourcesOptionsControl_Disposed; _nugetSourcesService?.Dispose(); _nugetSourcesService = null; _packageSources?.Dispose(); _machineWidepackageSources?.Dispose(); }
protected override void Dispose(bool disposing) { if (recordBindingSource != null) { recordBindingSource.Dispose(); } base.Dispose(disposing); }
private void unloadData() { bsrc.Dispose(); dgvAgent.Dispose(); cboCategorieAgent.Dispose(); cboFonction.Dispose(); cboQualification.Dispose(); cboService.Dispose(); }
private void frmDeliveryTest_FormClosed(object sender, FormClosedEventArgs e) { dtMostly.Dispose(); dtDetails.Dispose(); dtTempDel.Dispose(); dtFind_Date.Dispose(); myBDS1.Dispose(); myBDS2.Dispose(); //System.GC.Collect(); }
// Populate view of character sets. private void PopulateCharacterSetView(IEnumerable <CharacterSet> characterSets) { // Add character sets to control. bool exceptionThrown = true; BindingSource newBinding = new BindingSource(); try { foreach (CharacterSet characterSet in characterSets) { newBinding.Add(characterSet); } this.dgvCharacterSets.DataSource = newBinding; exceptionThrown = false; } finally { // Just in case the .Add throws an exception. if (exceptionThrown) { newBinding.Dispose(); } } // Add extra column to control. exceptionThrown = true; var columnCheck = new DataGridViewCheckBoxColumn(); try { columnCheck.Name = COLUMN_NAME_ALLOWED; columnCheck.HeaderText = COLUMN_NAME_ALLOWED + "?"; this.dgvCharacterSets.Columns.Add(columnCheck); exceptionThrown = false; } finally { // Just in case the .Add throws an exception. if (exceptionThrown) { columnCheck.Dispose(); } } // Set flag for every allowed character set. foreach (DataGridViewRow row in this.dgvCharacterSets.Rows) { row.Cells[COLUMN_NAME_ALLOWED].Value = true; } // If only one allowed character set, make sure it isn't removed! this.AtLeastOneCharacterSetAllowed(); this.dgvCharacterSets.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dgvCharacterSets.AutoResizeColumns(); }
/// <summary> /// Releases the resources used by the control. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (_bindingSource != null) { _bindingSource.Dispose(); } if (_internalSource != null) { _internalSource.Dispose(); } base.Dispose(disposing); }
public void BindingNavigator_BindingSource_IsNull_AfterDisposing() { using BindingNavigator control = new BindingNavigator(); BindingSource bindingSource = GetTestBindingSource(5); control.BindingSource = bindingSource; Assert.Equal(bindingSource, control.BindingSource); bindingSource.Dispose(); Assert.Null(control.BindingSource); }
//private string titletext = "title"; public override void CloseTabPage() { base.CloseTabPage(); _dataTable.Clear(); _dataSet.Clear(); advancedDataGridView_main.Dispose(); bindingSource_main.Dispose(); components.Dispose(); //public DrawArea drawarea; panelTabPage.Dispose(); }
private void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Dispose managed resources. _bindingSource.Dispose(); BadFiles.Clear(); BadVariables.Clear(); } } _disposed = true; }
private void UpdateSectionGrid() { bool IsLinear = false; if (checkMilepost.Checked) { IsLinear = true; } string strSelect = DBOp.GetAdvancedFilterSelectStatement(IsLinear, m_strNetworkID, comboBoxRouteFacilty.Text, textBoxAdvanceSearch.Text, comboBoxFilterAttribute.Text, comboBoxAttributeValue.Text); if (dataAdapter != null) { dataAdapter.Dispose(); // Free up the resources } if (binding != null) { binding.Dispose(); } if (table != null) { table.Dispose(); } try { binding = new BindingSource(); dataAdapter = new DataAdapter(strSelect); // Populate a new data table and bind it to the BindingSource. table = new DataTable(); table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); binding.DataSource = table; dgvSection.DataSource = binding; bindingNavigatorSectionView.BindingSource = binding; dgvSection.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; for (int i = 0; i < dgvSection.ColumnCount; i++) { dgvSection.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } dgvSection.Columns["SECTIONID"].Visible = false; } catch (Exception exc) { Global.WriteOutput("Error: Filling Section View. Check advanced search. " + exc.Message); } }
protected override void Dispose(bool disposing) { if (disposing) { if (_BS_trees != null) { _BS_trees.Dispose(); _BS_trees = null; } AppSettings = null; DataService = null; } base.Dispose(disposing); }
/// <summary> /// Local dispose method /// </summary> /// <param name="bDisposing">if disposing is required</param> protected virtual void Dispose(bool bDisposing) { if (!m_bDisposed) { if (bDisposing) { if (_bindingSource != null) { _bindingSource.Dispose(); _bindingSource = null; } } m_bDisposed = true; } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } if (disposing && (!alreadyDisposed)) { alreadyDisposed = true; bindingSource.Dispose(); insertRow.Dispose(); insertTenRows.Dispose(); deleteSelectedRows.Dispose(); } base.Dispose(disposing); }
public void BindingNavigator_UpdatesItsItems_AfterDataSourceDisposing() { using BindingNavigator control = new BindingNavigator(true); int rowsCount = 5; BindingSource bindingSource = GetTestBindingSource(rowsCount); control.BindingSource = bindingSource; Assert.Equal("1", control.PositionItem.Text); Assert.Equal($"of {rowsCount}", control.CountItem.Text); bindingSource.Dispose(); // The BindingNavigator updates its PositionItem and CountItem values // after its BindingSource is disposed Assert.Equal("0", control.PositionItem.Text); Assert.Equal("of 0", control.CountItem.Text); }
private void UpdateAssetGrid() { if (dataAdapter != null) { dataAdapter.Dispose(); // Free up the resources } if (binding != null) { binding.Dispose(); } if (table != null) { table.Dispose(); } try { String strQuery = "Select * From " + m_strAsset; if (tbAdvancedSearch.Text != "") { strQuery += " WHERE " + tbAdvancedSearch.Text; } binding = new BindingSource(); dataAdapter = new DataAdapter(strQuery, m_assetCP); // Populate a new data table and bind it to the BindingSource. table = new DataTable(); table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); binding.DataSource = table; dgvAssets.DataSource = binding; bindingNavigatorAsset.BindingSource = binding; dgvAssets.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; dgvAssets.Columns["GEOMETRY"].Visible = false; dgvAssets.Columns["EnvelopeMinX"].Visible = false; dgvAssets.Columns["EnvelopeMaxX"].Visible = false; dgvAssets.Columns["EnvelopeMinY"].Visible = false; dgvAssets.Columns["EnvelopeMaxY"].Visible = false; } catch (Exception exception) { Global.WriteOutput("Error: Building current attribute view. SQL message is " + exception.Message); } }
private void dgvAgent_DoubleClick(object sender, EventArgs e) { #region Chargement Data try { clsDoTraitement.Identifiant_Personne = Convert.ToInt32(dgvAgent["colid", dgvAgent.CurrentRow.Index].Value); clsDoTraitement.Identifiant_Agent = Convert.ToInt32(dgvAgent["colidAg", dgvAgent.CurrentRow.Index].Value); clsDoTraitement.doubleclicRecherchePersonneAgentDg = true; } catch (Exception ex) { MessageBox.Show(ex.Message + " >>>> Erreur lors de la récupération des informations", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } #endregion Fin Chargement Data //Déchargement du BindingSource et DataGrid bsrc_mal.Dispose(); dgvAgent.Dispose(); this.Dispose(); }
async void FillDataGrid() { kdgvData.EndEdit(); var newSrc = new BindingSource(); var curSrc = (BindingSource)kdgvData.DataSource; kdgvData.DataSource = newSrc; if (!ReferenceEquals(curSrc.DataSource, null)) { var v = (BindingListView <DrivingLicense>)curSrc.DataSource; v.DataSource = new List <DrivingLicense>(); } //curSrc.Clear(); var wait = new WaitForm { Status = TextUI.RetrievingData, OwnerForm = this }; wait.Show(); var data = await DrivingLicense.GetDrivingLicenses((int)pcPage.CurrentPage, (int)pcPage.PageSize); wait.Close(); wait.Dispose(); if (ReferenceEquals(data, null)) { MessageBox.Show(ErrorTexts.FailedToGetDataFromServer); } else { pcPage.TotalRecords = data.TotalNumber; var view = new BindingListView <DrivingLicense>(data.Items); curSrc.DataSource = view; //data.Items; } kdgvData.DataSource = curSrc; newSrc.Dispose(); kdgvData.Invalidate(); }
private void cmbGroup_SelectedIndexChanged(object sender, EventArgs e) { if (cmbGroup.SelectedIndex == -1) { return; } string sq = ""; if (cmbGroup.SelectedIndex == cmbGroup.Items.Count - 1) { sq = "SELECT * FROM employees ORDER BY CAST(SUBSTRING(eid , 4 , 9999) AS INT)"; } else { sq = "SELECT * FROM employees WHERE groop='" + cmbGroup.Text + "' ORDER BY CAST(SUBSTRING(eid , 4 , 9999) AS INT)"; } SqlConnection cn = new SqlConnection(st.ConStr); cn.Open(); SqlDataReader rd = new SqlCommand(sq, cn).ExecuteReader(); int c = 0; while (rd.Read()) { c++; } rd.Close(); rd.Dispose(); lblTot.Text = c + ""; if (c == 0) { if (src != null) { src.Dispose(); src = null; } foreach (Control x in Controls) { if (x.Name == "lblTot") { x.Text = "No Members"; ml.Message = "0 / 0 "; continue; } if (x.Name.StartsWith("lbl")) { x.Text = ""; } if (x is PictureBox) { ((PictureBox)x).BackgroundImage = null; } } return; } ds = new DataSet(); SqlDataAdapter adp = new SqlDataAdapter(sq, cn); adp.Fill(ds, "employees"); if (src != null) { src.Dispose(); } src = new BindingSource() { DataSource = ds, DataMember = "employees" }; lblEid.DataBindings.Clear(); lblEname.DataBindings.Clear(); lblPh.DataBindings.Clear(); lblIkey.DataBindings.Clear(); lblGroup.DataBindings.Clear(); lblEid.DataBindings.Add("Text", src, "eid"); lblEname.DataBindings.Add("Text", src, "ename"); lblPh.DataBindings.Add("Text", src, "phone"); lblIkey.DataBindings.Add("Text", src, "imgkey"); lblGroup.DataBindings.Add("Text", src, "groop"); ml.Message = (src.Position + 1) + " / " + src.Count + " "; //picIris.DataBindings.Add("BackgroundImage", src, "img"); src.MoveFirst(); setImage(); }