public static IEnumerable <FactoryColors> RequestColors() { PlannerDataSet ds = new PlannerDataSet(); ds.EnforceConstraints = false; PlannerDataSetTableAdapters.FactoriesColorsTableAdapter adapt = new PlannerDataSetTableAdapters.FactoriesColorsTableAdapter(); adapt.Fill(ds.FactoriesColors); var table = ds.FactoriesColors; foreach (DataRow row in table.Rows) { FactoryColors color = new FactoryColors { FactoryId = Convert.ToInt32(row[table.IdColumn.ColumnName]), FactoryColor = GetColor(row[table.FactoryColorColumn.ColumnName].ToString()), ClientColor = GetColor(row[table.ClientColorColumn.ColumnName].ToString()), UrgentColor = GetColor(row[table.UrgentColorColumn.ColumnName].ToString()), FinalDayColor = GetColor(row[table.FinalDayColorColumn.ColumnName].ToString()), PreferenceColor = GetColor(row[table.PreferenceColorColumn.ColumnName].ToString()) }; yield return(color); } }
public static string GetColorFactory(int idFactory) { string color = Colors.Gray.ToString(); PlannerDataSet ds = new PlannerDataSet(); ds.EnforceConstraints = false; DataTable Colour = new DataTable(); PlannerDataSetTableAdapters.FactoriesColorsTableAdapter adapter = new PlannerDataSetTableAdapters.FactoriesColorsTableAdapter(); adapter.FillBy(ds.FactoriesColors, idFactory); var table = ds.FactoriesColors; if (table.Rows.Count > 0) { color = table.Rows[0]["FactoryColor"].ToString().Trim(); } return(color); }