DataTable CreateVehiclesInfoSource(List<int> dataBlocksIds, DataBlock dataBlock) { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("#", typeof(int))); dt.Columns.Add(new DataColumn("Имя файла", typeof(string))); dt.Columns.Add(new DataColumn("Тип карты", typeof(string))); dt.Columns.Add(new DataColumn("Период С", typeof(string))); dt.Columns.Add(new DataColumn("По", typeof(string))); dt.Columns.Add(new DataColumn("Кол-во записей", typeof(int))); dt.Columns.Add(new DataColumn("Дата разбора", typeof(string))); int i = 1; List<DateTime> startEnd = new List<DateTime>(); foreach (int id in dataBlocksIds) { dr = dt.NewRow(); dr["#"] = i++; dr["имя файла"] = dataBlock.GetDataBlock_FileName(id); dr["Тип карты"] = dataBlock.GetCardTypeName(id); startEnd = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(id); dr["Период С"] = startEnd[0].ToLongDateString(); dr["По"] = startEnd[1].ToLongDateString(); dr["Кол-во записей"] = dataBlock.GetDataBlock_RecorsCount(id); dr["Дата разбора"] = dataBlock.GetDataBlock_EDate(id); dt.Rows.Add(dr); } return dt; }
private List<DeleteStructure> LoadAllDeleteLists() { try { int userId = 0; List<DeleteStructure> deleteStructureList = new List<DeleteStructure>(); int i = 0; string connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); DeleteStructure deleteStructureTemp; List<int> dataBlockIds = new List<int>(); dataBlock.OpenConnection(); dataBlockIds = dataBlock.GetAllParsedDataBlockIDs(userId); foreach (int dataBlockId in dataBlockIds) { i++; deleteStructureTemp = new DeleteStructure(); deleteStructureTemp.dataBlockId = dataBlockId; deleteStructureTemp.number = i; deleteStructureTemp.name = dataBlock.GetDriversNameOrVehiclesNumberByBlockId(dataBlockId); deleteStructureTemp.cardTypeName = dataBlock.GetCardTypeName(dataBlockId); deleteStructureTemp.recordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId); deleteStructureTemp.createTime = dataBlock.GetDataBlock_EDate(dataBlockId); deleteStructureTemp.dataBlockState = dataBlock.GetDataBlockState(dataBlockId); deleteStructureList.Add(deleteStructureTemp); } if (dataBlockIds.Count == 0) Status.Text = "Нет записей для отображения"; AddGrid.DataSource = CreateDeleteDataSource(deleteStructureList); AddGrid.DataBind(); dataBlock.CloseConnection(); return deleteStructureList; } catch (Exception ex) { Status.Text = "Произошла ошибка: " + ex.Message + " Возможо просто нету данных в БД. Исправление в след. версии"; return null; } finally { } }
private static List<Driver> LoadAllDriversLists(int cardId) { List<Driver> driversStructureList = new List<Driver>(); int number = 0; string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); Driver driversStructureTemp; List<int> dataBlockIds = new List<int>(); try { dataBlock.OpenConnection(); dataBlockIds = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId); int cardType; List<DateTime> startEnd = new List<DateTime>(); foreach (int dataBlockId in dataBlockIds) { number++; driversStructureTemp = new Driver(); driversStructureTemp.DataBlockId = dataBlockId; driversStructureTemp.Number = number; driversStructureTemp.Name = dataBlock.GetDataBlock_FileName(dataBlockId); driversStructureTemp.RecordsCount = dataBlock.GetDataBlock_RecorsCount(dataBlockId); driversStructureTemp.CreationTime = dataBlock.GetDataBlock_EDate(dataBlockId); cardType = dataBlock.GetDataBlock_CardType(dataBlockId); driversStructureTemp.CardTypeName = dataBlock.GetCardTypeName(dataBlockId); if (cardType == 0) { startEnd = dataBlock.cardUnitInfo.Get_StartEndPeriod(dataBlockId); driversStructureTemp.setFromDate(startEnd[0]); driversStructureTemp.setToDate(startEnd[1]); } else if (cardType == 2) { driversStructureTemp.setFromDate(dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId)); driversStructureTemp.setToDate(dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId)); } else { driversStructureTemp.setFromDate(new DateTime()); driversStructureTemp.setToDate(new DateTime()); } driversStructureList.Add(driversStructureTemp); } dataBlock.CloseConnection(); return driversStructureList; } catch (Exception ex) { dataBlock.CloseConnection(); return null; } }