public static bool ValidName(string name, DataGridViewColumnCollection columns, IContainer container, INameCreationService nameCreationService, DataGridViewColumnCollection liveColumns, bool allowDuplicateNameInLiveColumnCollection) { if (columns.Contains(name)) { return(false); } if (((container != null) && (container.Components[name] != null)) && ((!allowDuplicateNameInLiveColumnCollection || (liveColumns == null)) || !liveColumns.Contains(name))) { return(false); } return(((nameCreationService == null) || nameCreationService.IsValidName(name)) || ((allowDuplicateNameInLiveColumnCollection && (liveColumns != null)) && liveColumns.Contains(name))); }
//--------------------------------------------------------------------- public void AddColumn(DataGridViewColumn column, Func <TModel, TValue> predicate = null) { if (column == null) { throw new ArgumentNullException(nameof(column)); } if (_columns.Contains(column)) { throw new ArgumentException(string.Empty, nameof(column)); } _columns.Add(column); if (predicate != null) { _cacheColumnIndexes.Add(column.Index, predicate); } }
public static bool ValidName(string name, DataGridViewColumnCollection columns, IContainer container, INameCreationService nameCreationService, DataGridViewColumnCollection liveColumns, bool allowDuplicateNameInLiveColumnCollection, out string errorString) { if (columns.Contains(name)) { errorString = System.Design.SR.GetString("DataGridViewDuplicateColumnName", new object[] { name }); return(false); } if (((container != null) && (container.Components[name] != null)) && ((!allowDuplicateNameInLiveColumnCollection || (liveColumns == null)) || !liveColumns.Contains(name))) { errorString = System.Design.SR.GetString("DesignerHostDuplicateName", new object[] { name }); return(false); } if (((nameCreationService != null) && !nameCreationService.IsValidName(name)) && ((!allowDuplicateNameInLiveColumnCollection || (liveColumns == null)) || !liveColumns.Contains(name))) { errorString = System.Design.SR.GetString("CodeDomDesignerLoaderInvalidIdentifier", new object[] { name }); return(false); } errorString = string.Empty; return(true); }
//Funkcje pomocnicze //Ładowanie używanych STK do Słownika plus Ładowanie IDCO do słownika private void LoadSTK(decimal Year) { //Deklaracja zmiennych DataTable STK = new DataTable(); DataRow FoundRow; string LinkSTK; string[] ANC = new string[3]; string[] ANCSpec = new string[2]; string STKYear; decimal STKValue; bool STKCheck; bool Zero = false; // LinkSTK = ImportData.Load_Link("STK"); ImportData.Load_TxtToDataTable(ref STK, LinkSTK); //Sprawdzenie czy STK na dany rok jest już w bazie czy nie ma - jak nie ma daje wybrór użytkowanikowi aby użył z poprzedniego roku do { DataColumnCollection Columns = STK.Columns; if (!Columns.Contains(Year.ToString())) { STKCheck = true; DialogResult dialogResult = MessageBox.Show("STK for this Year not exist, Do you want to take for calculation STK from Year Before?", "STK Issue", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Zero = false; Year = Year - 1; } else if (dialogResult == DialogResult.No) { Zero = true; STKCheck = false; } } else { STKCheck = false; } } while (STKCheck); STKYear = "STK/" + Year.ToString(); //Dodanie do słownika ANC z Old/New for (int counter = 1; counter <= ANCChangeNumber; counter++) { ANC[0] = ((TextBox)mainProgram.TabControl.Controls.Find("TB_OldANC" + counter.ToString(), true).First()).Text; ANC[1] = ((TextBox)mainProgram.TabControl.Controls.Find("TB_NewANC" + counter.ToString(), true).First()).Text; ANC[2] = ((TextBox)mainProgram.TabControl.Controls.Find("TB_NextANC" + counter.ToString(), true).First()).Text; for (int counter2 = 0; counter2 < 3; counter2++) { if (ANC[counter2].ToString() != "") { if (!STKDictionary.ContainsKey(ANC[counter2])) { if (!Zero) { FoundRow = STK.Select(string.Format("ANC LIKE '%{0}%'", ANC[counter2])).FirstOrDefault(); if (FoundRow != null) { if (FoundRow[STKYear].ToString() != "") { STKValue = decimal.Parse(FoundRow[STKYear].ToString()); STKDictionary.Add(ANC[counter2], STKValue); IDCODictionary.Add(ANC[counter2], FoundRow["IDCO"].ToString()); } else { STKDictionary.Add(ANC[counter2], 0); IDCODictionary.Add(ANC[counter2], ""); } } else { STKDictionary.Add(ANC[counter2], 0); IDCODictionary.Add(ANC[counter2], ""); } } else { STKDictionary.Add(ANC[counter2], 0); IDCODictionary.Add(ANC[counter2], ""); } } } } } //Jeśli jest PNCSpec to musi przelecieć kolejną tabele aby dodać brakujące ANC if (((CheckBox)mainProgram.TabControl.Controls.Find("cb_CalcPNCSpec", true).First()).Checked) { DataGridView PNC = (DataGridView)mainProgram.TabControl.Controls.Find("dg_PNC", true).First(); DataGridViewColumnCollection Columns = PNC.Columns; if (Columns.Contains("OLD ANC")) { foreach (DataGridViewRow Row in PNC.Rows) { if (Row.Cells["PNC"].Value == null || Row.Cells["PNC"].Value.ToString() == "") { ANCSpec[0] = Row.Cells["OLD ANC"].Value.ToString(); ANCSpec[1] = Row.Cells["NEW ANC"].Value.ToString(); for (int counter = 0; counter < 2; counter++) { if (ANCSpec[counter] != "") { if (!STKDictionary.ContainsKey(ANCSpec[counter])) { if (!Zero) { FoundRow = STK.Select(string.Format("ANC LIKE '%{0}%'", ANCSpec[counter])).FirstOrDefault(); if (FoundRow != null && FoundRow[STKYear].ToString() != "") { STKValue = decimal.Parse(FoundRow[STKYear].ToString()); STKDictionary.Add(ANCSpec[counter], STKValue); IDCODictionary.Add(ANCSpec[counter], FoundRow["IDCO"].ToString()); } else { STKDictionary.Add(ANCSpec[counter], 0); IDCODictionary.Add(ANCSpec[counter], ""); } } else { STKDictionary.Add(ANCSpec[counter], 0); IDCODictionary.Add(ANCSpec[counter], ""); } } } } } } } } }
/// <summary>Determines whether the collection contains the column referred to by the given name. </summary> /// <returns>true if the column is contained in the collection; otherwise, false.</returns> /// <param name="columnName">The name of the column to look for.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="columnName"/> is null.</exception> public bool Contains(string columnName) { return(_columns.Contains(columnName)); }